示例#1
0
bool get_ai_string(struct addrinfo * ai, char* addrstr, size_t addrstr_length)
{
    size_t cur_len = 0;
    while(ai)
    {
        sockaddr * addr = ai->ai_addr;
        uint16_t port = 0;
        get_addr_string(addr, addrstr + cur_len, addrstr_length - cur_len, port);
        cur_len = strnlen(addrstr, addrstr_length);
        //cur_len += snprintf(addrstr + cur_len, addrstr_length - cur_len,":%hu ", port);
        cur_len += snprintf(addrstr + cur_len, addrstr_length - cur_len," ");
        ai = ai->ai_next;
    }
    return cur_len != 0;
} 
示例#2
0
void dt_single_instr(uint32_t op)
{
    char addr[32], offset[16], *cond, tsize;

    get_offset_string(op, offset, sizeof(offset), 0);
    get_addr_string(op, ADIS_RN(op), offset, addr, sizeof(addr));
    // byte / word
    tsize = ADIS_BYTE_BIT(op) ? 'B' : 0;
    cond = get_condition_string(op);

    // load / store
    if (ADIS_LOAD_BIT(op)) {
        printf("LDR%s%c R%d,%s\n", cond, tsize, ADIS_RD(op), addr);
    } else {
        printf("STR%s%c R%d,%s\n", cond, tsize, ADIS_RD(op), addr);
    }
}
示例#3
0
文件: dt_extra.c 项目: whirleyes/adis
void dt_extra_instr(uint32_t op)
{
    char addr[32], offset[8], *subinstr, *cond, unpriv;

    // Special bit combination for dual instructions,
    // other instructions are either signed, halfword,
    // both, or neither (regular data swap)
    if (is_dt_dual(op)) {
        subinstr = "D";
        unpriv = 0;
        goto have_subinstr;
    }

    if (!ADIS_HW_BIT(op) && !ADIS_SIGNED_BIT(op)) {
        // Regular SWP instruction, handled by sync_instr
        sync_instr(op);
        return;
    }

    if (ADIS_HW_BIT(op) && ADIS_SIGNED_BIT(op)) {
        subinstr = "SH";
    } else if (!ADIS_HW_BIT(op) && ADIS_SIGNED_BIT(op)) {
        subinstr = "SB";
    } else {
        subinstr = "H";
    }

    unpriv = ADIS_UNPRIV_BIT(op) ? 'T' : 0;

have_subinstr:
    cond = get_condition_string(op);
    dtex_get_offset_string(op, offset, sizeof(offset));
    get_addr_string(op, ADIS_RN(op), offset, addr, sizeof(addr));

    if (ADIS_LOAD_BIT(op)) {
        printf("LDR%s%c%s R%d,%s\n", subinstr, unpriv, cond, ADIS_RD(op), addr);
    } else {
        printf("STR%s%c%s R%d,%s\n", subinstr, unpriv, cond, ADIS_RD(op), addr);
    }
}
示例#4
0
void dt_coproc_instr(uint32_t op) {

    char addr[32], offset[16], *long_bit, *cond;

    cond = get_condition_string(op);
    get_offset_string(op, offset, sizeof(offset), 0);
    get_addr_string(op, ADIS_RN(op), offset, addr, sizeof(addr));

    // long bit set?
    if (ADIS_LONG_BIT(op)) {
        long_bit = 'L';
    } else {
        long_bit = 0;
    }

    // load / store
    if (ADIS_LOAD_BIT(op)) {
        printf("LDC%s%c p%d,c%d,%s\n", cond, long_bit,
            ADIS_CPNUM(op), ADIS_RD(op), addr);
    } else {
        printf("STC%s%c p%d,c%d,%s\n", cond, long_bit,
            ADIS_CPNUM(op), ADIS_RD(op), addr);
    }
}
/* Get the local bind address string. */
char *get_localaddr_string(const msiod *iod) {
  return get_addr_string(&iod->local, iod->locallen);
}
/* Get the peer/host address string.
 * In case we have support for UNIX domain sockets, function returns
 * string containing path to UNIX socket if the address family is AF_UNIX,
 * otherwise it returns string containing "<address>:<port>". */
char *get_peeraddr_string(const msiod *iod) {
  if (iod->peerlen > 0)
    return get_addr_string(&iod->peer, iod->peerlen);
  else
    return "peer unspecified";
}