本文整理匯總了C++中EXTRACT_LE_16BITS函數的典型用法代碼示例。如果您正苦於以下問題:C++ EXTRACT_LE_16BITS函數的具體用法?C++ EXTRACT_LE_16BITS怎麽用?C++ EXTRACT_LE_16BITS使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EXTRACT_LE_16BITS函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: handle_probe_response
static int
handle_probe_response(const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN);
offset += IEEE802_11_TSTAMP_LEN;
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_BCNINT_LEN;
pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_CAPINFO_LEN;
parse_elements(&pbody, p, offset);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
PRINT_DS_CHANNEL(pbody);
return 1;
}
示例2: handle_assoc_response
static int
handle_assoc_response(const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
IEEE802_11_AID_LEN))
return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_CAPINFO_LEN;
pbody.status_code = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_STATUS_LEN;
pbody.aid = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_AID_LEN;
parse_elements(&pbody, p, offset);
printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 ,
CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "",
(pbody.status_code < NUM_STATUSES
? status_text[pbody.status_code]
: "n/a"));
return 1;
}
示例3: handle_reassoc_request
static int
handle_reassoc_request(const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
IEEE802_11_AP_LEN))
return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_CAPINFO_LEN;
pbody.listen_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_LISTENINT_LEN;
memcpy(&pbody.ap, p+offset, IEEE802_11_AP_LEN);
offset += IEEE802_11_AP_LEN;
parse_elements(&pbody, p, offset);
PRINT_SSID(pbody);
printf(" AP : %s", etheraddr_string( pbody.ap ));
return 1;
}
示例4: handle_probe_response
static int
handle_probe_response(const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN);
offset += IEEE802_11_TSTAMP_LEN;
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_BCNINT_LEN;
pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_CAPINFO_LEN;
if (!parse_elements(&pbody, p, offset))
return 0;
printf(" (");
fn_print(pbody.ssid.ssid, NULL);
printf(") ");
PRINT_RATES(pbody);
printf(" CH: %u%s", pbody.ds.channel,
CAPABILITY_PRIVACY(pbody.capability_info) ? ", PRIVACY" : "" );
return 1;
}
示例5: handle_assoc_request
static int
handle_assoc_request(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN))
return 0;
if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN)
return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_CAPINFO_LEN;
length -= IEEE802_11_CAPINFO_LEN;
pbody.listen_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_LISTENINT_LEN;
length -= IEEE802_11_LISTENINT_LEN;
ret = parse_elements(&pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
return ret;
}
示例6: print_l2_routes
static int
print_l2_routes(const char *rp, u_int len)
{
int count;
int area;
int info;
/* The last short is a checksum */
while (len > (3 * sizeof(short))) {
TCHECK2(*rp, 3 * sizeof(short));
count = EXTRACT_LE_16BITS(rp);
if (count > 1024)
return (1); /* seems to be bogus from here on */
rp += sizeof(short);
len -= sizeof(short);
area = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
info = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
(void)printf("{areas %d-%d cost %d hops %d} ", area, area + count,
RI_COST(info), RI_HOPS(info));
}
return (1);
trunc:
return (0);
}
示例7: handle_beacon
static int
handle_beacon(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN)
return 0;
memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN);
offset += IEEE802_11_TSTAMP_LEN;
length -= IEEE802_11_TSTAMP_LEN;
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_BCNINT_LEN;
length -= IEEE802_11_BCNINT_LEN;
pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_CAPINFO_LEN;
length -= IEEE802_11_CAPINFO_LEN;
ret = parse_elements(&pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
printf(" %s",
CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS");
PRINT_DS_CHANNEL(pbody);
return ret;
}
示例8: print_l1_routes
static int
print_l1_routes(netdissect_options *ndo,
const char *rp, u_int len)
{
int count;
int id;
int info;
/* The last short is a checksum */
while (len > (3 * sizeof(short))) {
ND_TCHECK2(*rp, 3 * sizeof(short));
count = EXTRACT_LE_16BITS(rp);
if (count > 1024)
return (1); /* seems to be bogus from here on */
rp += sizeof(short);
len -= sizeof(short);
id = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
info = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
ND_PRINT((ndo, "{ids %d-%d cost %d hops %d} ", id, id + count,
RI_COST(info), RI_HOPS(info)));
}
return (1);
trunc:
return (0);
}
示例9: ctrl_header_print
static void
ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
const u_int8_t **dstp)
{
if (srcp != NULL)
*srcp = NULL;
if (dstp != NULL)
*dstp = NULL;
if (!eflag)
return;
switch (FC_SUBTYPE(fc)) {
case CTRL_BAR:
printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
break;
case CTRL_BA:
printf("RA:%s ",
etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
break;
case CTRL_PS_POLL:
printf("BSSID:%s TA:%s ",
etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid),
etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta));
break;
case CTRL_RTS:
printf("RA:%s TA:%s ",
etheraddr_string(((const struct ctrl_rts_t *)p)->ra),
etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
break;
case CTRL_CTS:
printf("RA:%s ",
etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
break;
case CTRL_ACK:
printf("RA:%s ",
etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
break;
case CTRL_CF_END:
printf("RA:%s BSSID:%s ",
etheraddr_string(((const struct ctrl_end_t *)p)->ra),
etheraddr_string(((const struct ctrl_end_t *)p)->bssid));
break;
case CTRL_END_ACK:
printf("RA:%s BSSID:%s ",
etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra),
etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid));
break;
default:
printf("(H) Unknown Ctrl Subtype");
break;
}
}
示例10: handle_auth
static int
handle_auth(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 6))
return 0;
if (length < 6)
return 0;
pbody.auth_alg = EXTRACT_LE_16BITS(p);
offset += 2;
length -= 2;
pbody.auth_trans_seq_num = EXTRACT_LE_16BITS(p + offset);
offset += 2;
length -= 2;
pbody.status_code = EXTRACT_LE_16BITS(p + offset);
offset += 2;
length -= 2;
ret = parse_elements(&pbody, p, offset, length);
if ((pbody.auth_alg == 1) &&
((pbody.auth_trans_seq_num == 2) ||
(pbody.auth_trans_seq_num == 3))) {
printf(" (%s)-%x [Challenge Text] %s",
(pbody.auth_alg < NUM_AUTH_ALGS)
? auth_alg_text[pbody.auth_alg]
: "Reserved",
pbody.auth_trans_seq_num,
((pbody.auth_trans_seq_num % 2)
? ((pbody.status_code < NUM_STATUSES)
? status_text[pbody.status_code]
: "n/a") : ""));
return ret;
}
printf(" (%s)-%x: %s",
(pbody.auth_alg < NUM_AUTH_ALGS)
? auth_alg_text[pbody.auth_alg]
: "Reserved",
pbody.auth_trans_seq_num,
(pbody.auth_trans_seq_num % 2)
? ((pbody.status_code < NUM_STATUSES)
? status_text[pbody.status_code]
: "n/a")
: "");
return ret;
}
示例11: loopback_message_print
static void
loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int len)
{
const u_char *ep = cp + len;
uint16_t function;
if (len < 2)
goto corrupt;
/* function */
ND_TCHECK2(*cp, 2);
function = EXTRACT_LE_16BITS(cp);
cp += 2;
ND_PRINT((ndo, ", %s", tok2str(fcode_str, " invalid (%u)", function)));
switch (function) {
case LOOPBACK_REPLY:
if (len < 4)
goto corrupt;
/* receipt number */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, ", receipt number %u", EXTRACT_LE_16BITS(cp)));
cp += 2;
/* data */
ND_PRINT((ndo, ", data (%u octets)", len - 4));
ND_TCHECK2(*cp, len - 4);
break;
case LOOPBACK_FWDDATA:
if (len < 8)
goto corrupt;
/* forwarding address */
ND_TCHECK2(*cp, ETHER_ADDR_LEN);
ND_PRINT((ndo, ", forwarding address %s", etheraddr_string(cp)));
cp += ETHER_ADDR_LEN;
/* data */
ND_PRINT((ndo, ", data (%u octets)", len - 8));
ND_TCHECK2(*cp, len - 8);
break;
default:
ND_TCHECK2(*cp, len - 2);
break;
}
return;
corrupt:
ND_PRINT((ndo, "%s", cstr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
}
示例12: loopback_print
void
loopback_print(netdissect_options *ndo, const u_char *cp, const u_int len)
{
const u_char *ep = cp + len;
uint16_t skipCount;
ND_PRINT((ndo, "Loopback"));
if (len < 2)
goto corrupt;
/* skipCount */
ND_TCHECK2(*cp, 2);
skipCount = EXTRACT_LE_16BITS(cp);
cp += 2;
ND_PRINT((ndo, ", skipCount %u", skipCount));
if (skipCount % 8)
ND_PRINT((ndo, " (bogus)"));
if (skipCount > len - 2)
goto corrupt;
loopback_message_print(ndo, cp + skipCount, len - 2 - skipCount);
return;
corrupt:
ND_PRINT((ndo, "%s", cstr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
}
示例13: handle_deauth
static int
handle_deauth(const struct mgmt_header_t *pmh, const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
const char *reason = NULL;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_REASON_LEN))
return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_REASON_LEN;
reason = (pbody.reason_code < NUM_REASONS)
? reason_text[pbody.reason_code]
: "Reserved";
if (eflag) {
printf(": %s", reason);
} else {
printf(" (%s): %s", etheraddr_string(pmh->sa), reason);
}
return 1;
}
示例14: rrcp_print
/*
* Print RRCP requests
*/
void
rrcp_print(netdissect_options *ndo,
register const u_char *cp,
u_int length _U_)
{
const u_char *rrcp;
uint8_t rrcp_proto;
uint8_t rrcp_opcode;
register const struct ether_header *ep;
char proto_str[16];
char opcode_str[32];
ep = (const struct ether_header *)cp;
rrcp = cp + ETHER_HDRLEN;
ND_TCHECK(*(rrcp + RRCP_PROTO_OFFSET));
rrcp_proto = *(rrcp + RRCP_PROTO_OFFSET);
ND_TCHECK(*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET));
rrcp_opcode = (*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK;
ND_PRINT((ndo, "%s > %s, %s %s",
etheraddr_string(ndo, ESRC(ep)),
etheraddr_string(ndo, EDST(ep)),
tok2strbuf(proto_values,"RRCP-0x%02x",rrcp_proto,proto_str,sizeof(proto_str)),
((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"));
if (rrcp_proto==1){
ND_PRINT((ndo, ": %s",
tok2strbuf(opcode_values,"unknown opcode (0x%02x)",rrcp_opcode,opcode_str,sizeof(opcode_str))));
}
if (rrcp_opcode==1 || rrcp_opcode==2){
ND_TCHECK2(*(rrcp + RRCP_REG_ADDR_OFFSET), 6);
ND_PRINT((ndo, " addr=0x%04x, data=0x%08x",
EXTRACT_LE_16BITS(rrcp + RRCP_REG_ADDR_OFFSET),
EXTRACT_LE_32BITS(rrcp + RRCP_REG_DATA_OFFSET)));
}
if (rrcp_proto==1){
ND_TCHECK2(*(rrcp + RRCP_AUTHKEY_OFFSET), 2);
ND_PRINT((ndo, ", auth=0x%04x",
EXTRACT_16BITS(rrcp + RRCP_AUTHKEY_OFFSET)));
}
if (rrcp_proto==1 && rrcp_opcode==0 &&
((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY)){
ND_TCHECK2(*(rrcp + RRCP_VENDOR_ID_OFFSET), 4);
ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ",
*(rrcp + RRCP_DOWNLINK_PORT_OFFSET),
*(rrcp + RRCP_UPLINK_PORT_OFFSET),
etheraddr_string(ndo, rrcp + RRCP_UPLINK_MAC_OFFSET),
EXTRACT_32BITS(rrcp + RRCP_VENDOR_ID_OFFSET),
EXTRACT_16BITS(rrcp + RRCP_CHIP_ID_OFFSET)));
}else if (rrcp_opcode==1 || rrcp_opcode==2 || rrcp_proto==2){
ND_TCHECK2(*(rrcp + RRCP_COOKIE2_OFFSET), 4);
ND_PRINT((ndo, ", cookie=0x%08x%08x ",
EXTRACT_32BITS(rrcp + RRCP_COOKIE2_OFFSET),
EXTRACT_32BITS(rrcp + RRCP_COOKIE1_OFFSET)));
}
return;
trunc:
ND_PRINT((ndo, "[|rrcp]"));
}
示例15: rrcp_print
/*
* Print RRCP requests
*/
void
rrcp_print(netdissect_options *ndo,
register const u_char *cp,
u_int length _U_,
const struct lladdr_info *src,
const struct lladdr_info *dst)
{
uint8_t rrcp_proto;
uint8_t rrcp_opcode;
ND_TCHECK(*(cp + RRCP_PROTO_OFFSET));
rrcp_proto = *(cp + RRCP_PROTO_OFFSET);
ND_TCHECK(*(cp + RRCP_OPCODE_ISREPLY_OFFSET));
rrcp_opcode = (*(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK;
if (src != NULL && dst != NULL) {
ND_PRINT((ndo, "%s > %s, ",
(src->addr_string)(ndo, src->addr),
(dst->addr_string)(ndo, dst->addr)));
}
ND_PRINT((ndo, "%s %s",
tok2str(proto_values,"RRCP-0x%02x",rrcp_proto),
((*(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"));
if (rrcp_proto==1){
ND_PRINT((ndo, ": %s",
tok2str(opcode_values,"unknown opcode (0x%02x)",rrcp_opcode)));
}
if (rrcp_opcode==1 || rrcp_opcode==2){
ND_TCHECK2(*(cp + RRCP_REG_ADDR_OFFSET), 6);
ND_PRINT((ndo, " addr=0x%04x, data=0x%08x",
EXTRACT_LE_16BITS(cp + RRCP_REG_ADDR_OFFSET),
EXTRACT_LE_32BITS(cp + RRCP_REG_DATA_OFFSET)));
}
if (rrcp_proto==1){
ND_TCHECK2(*(cp + RRCP_AUTHKEY_OFFSET), 2);
ND_PRINT((ndo, ", auth=0x%04x",
EXTRACT_16BITS(cp + RRCP_AUTHKEY_OFFSET)));
}
if (rrcp_proto==1 && rrcp_opcode==0 &&
((*(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY)){
ND_TCHECK2(*(cp + RRCP_VENDOR_ID_OFFSET), 4);
ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ",
*(cp + RRCP_DOWNLINK_PORT_OFFSET),
*(cp + RRCP_UPLINK_PORT_OFFSET),
etheraddr_string(ndo, cp + RRCP_UPLINK_MAC_OFFSET),
EXTRACT_32BITS(cp + RRCP_VENDOR_ID_OFFSET),
EXTRACT_16BITS(cp + RRCP_CHIP_ID_OFFSET)));
}else if (rrcp_opcode==1 || rrcp_opcode==2 || rrcp_proto==2){
ND_TCHECK2(*(cp + RRCP_COOKIE2_OFFSET), 4);
ND_PRINT((ndo, ", cookie=0x%08x%08x ",
EXTRACT_32BITS(cp + RRCP_COOKIE2_OFFSET),
EXTRACT_32BITS(cp + RRCP_COOKIE1_OFFSET)));
}
return;
trunc:
ND_PRINT((ndo, "[|rrcp]"));
}