本文整理汇总了C++中EXTRACT_24BITS函数的典型用法代码示例。如果您正苦于以下问题:C++ EXTRACT_24BITS函数的具体用法?C++ EXTRACT_24BITS怎么用?C++ EXTRACT_24BITS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EXTRACT_24BITS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: otv_print
void
otv_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
uint8_t flags;
ND_PRINT((ndo, "OTV, "));
if (len < 8)
goto trunc;
ND_TCHECK(*bp);
flags = *bp;
ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
bp += 1;
ND_TCHECK2(*bp, 3);
ND_PRINT((ndo, "overlay %u, ", EXTRACT_24BITS(bp)));
bp += 3;
ND_TCHECK2(*bp, 3);
ND_PRINT((ndo, "instance %u\n", EXTRACT_24BITS(bp)));
bp += 3;
/* Reserved */
ND_TCHECK(*bp);
bp += 1;
ether_print(ndo, bp, len - 8, ndo->ndo_snapend - bp, NULL, NULL);
return;
trunc:
ND_PRINT((ndo, " [|OTV]"));
}
示例2: igrp_entry_print
static void
igrp_entry_print(register struct igrprte *igr, register int is_interior,
register int is_exterior)
{
register u_int delay, bandwidth;
u_int metric, mtu;
if (is_interior)
printf(" *.%d.%d.%d", igr->igr_net[0],
igr->igr_net[1], igr->igr_net[2]);
else if (is_exterior)
printf(" X%d.%d.%d.0", igr->igr_net[0],
igr->igr_net[1], igr->igr_net[2]);
else
printf(" %d.%d.%d.0", igr->igr_net[0],
igr->igr_net[1], igr->igr_net[2]);
delay = EXTRACT_24BITS(igr->igr_dly);
bandwidth = EXTRACT_24BITS(igr->igr_bw);
metric = bandwidth + delay;
if (metric > 0xffffff)
metric = 0xffffff;
mtu = EXTRACT_16BITS(igr->igr_mtu);
printf(" d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops",
10 * delay, bandwidth == 0 ? 0 : 10000000 / bandwidth,
igr->igr_rel, igr->igr_ld, metric,
mtu, igr->igr_hct);
}
示例3: juniper_services_print
u_int
juniper_services_print(const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_services_header {
u_int8_t svc_id;
u_int8_t flags_len;
u_int8_t svc_set_id[2];
u_int8_t dir_iif[4];
};
const struct juniper_services_header *sh;
l2info.pictype = DLT_JUNIPER_SERVICES;
if(juniper_parse_header(p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
sh = (struct juniper_services_header *)p;
if (eflag)
printf("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
sh->svc_id,
sh->flags_len,
EXTRACT_16BITS(&sh->svc_set_id),
EXTRACT_24BITS(&sh->dir_iif[1]));
ip_heuristic_guess(p, l2info.length);
return l2info.header_len;
}
示例4: juniper_services_print
u_int
juniper_services_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_services_header {
uint8_t svc_id;
uint8_t flags_len;
uint8_t svc_set_id[2];
uint8_t dir_iif[4];
};
const struct juniper_services_header *sh;
l2info.pictype = DLT_JUNIPER_SERVICES;
if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
sh = (struct juniper_services_header *)p;
if (ndo->ndo_eflag)
ND_PRINT((ndo, "service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
sh->svc_id,
sh->flags_len,
EXTRACT_16BITS(&sh->svc_set_id),
EXTRACT_24BITS(&sh->dir_iif[1])));
/* no proto field - lets guess by first byte of IP header*/
ip_heuristic_guess (ndo, p, l2info.length);
return l2info.header_len;
}
示例5: dccp_print_ack_no
static void dccp_print_ack_no(const u_char *bp)
{
const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
const struct dccp_hdr_ack_bits *dh_ack =
(struct dccp_hdr_ack_bits *)(bp + dccp_basic_hdr_len(dh));
u_int32_t ack_high;
u_int64_t ackno;
TCHECK2(*dh_ack,4);
ack_high = DCCPH_ACK(dh_ack);
ackno = EXTRACT_24BITS(&ack_high) & 0xFFFFFF;
if (DCCPH_X(dh) != 0) {
u_int32_t ack_low;
TCHECK2(*dh_ack,8);
ack_low = dh_ack->dccph_ack_nr_low;
ackno &= 0x00FFFF; /* clear reserved field */
ackno = (ackno << 32) + EXTRACT_32BITS(&ack_low);
}
(void)printf("(ack=%" PRIu64 ") ", ackno);
trunc:
return;
}
示例6: sig_print
static void
sig_print(const u_char *p, int caplen)
{
bpf_u_int32 call_ref;
if (caplen < PROTO_POS) {
printf("[|atm]");
return;
}
if (p[PROTO_POS] == Q2931) {
/*
* protocol:Q.2931 for User to Network Interface
* (UNI 3.1) signalling
*/
printf("Q.2931");
if (caplen < MSG_TYPE_POS) {
printf(" [|atm]");
return;
}
printf(":%s ",
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
/*
* The call reference comes before the message type,
* so if we know we have the message type, which we
* do from the caplen test above, we also know we have
* the call reference.
*/
call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
printf("CALL_REF:0x%06x", call_ref);
} else {
/* SCCOP with some unknown protocol atop it */
printf("SSCOP, proto %d ", p[PROTO_POS]);
}
}
示例7: vxlan_print
void
vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
uint8_t flags;
uint32_t vni;
if (len < VXLAN_HDR_LEN)
goto trunc;
ND_TCHECK2(*bp, VXLAN_HDR_LEN);
flags = *bp;
bp += 4;
vni = EXTRACT_24BITS(bp);
bp += 4;
ND_PRINT((ndo, "VXLAN, "));
ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
ND_PRINT((ndo, "vni %u\n", vni));
ether_print(ndo, bp, len - VXLAN_HDR_LEN, len - VXLAN_HDR_LEN, NULL, NULL);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
}
示例8: sig_print
static void
sig_print(const u_char *p, int caplen)
{
bpf_u_int32 call_ref;
if (caplen < PROTO_POS) {
printf("[|atm]");
return;
}
if (p[PROTO_POS] == Q2931) {
/*
* protocol:Q.2931 for User to Network Interface
* (UNI 3.1) signalling
*/
printf("Q.2931");
if (caplen < MSG_TYPE_POS) {
printf(" [|atm]");
return;
}
printf(":%s ",
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
if (caplen < CALL_REF_POS+3) {
printf("[|atm]");
return;
}
call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
printf("CALL_REF:0x%06x", call_ref);
} else {
/* SCCOP with some unknown protocol atop it */
printf("SSCOP, proto %d ", p[PROTO_POS]);
}
}
示例9: handle_llc_packet
static void handle_llc_packet(const struct llc* llc, int dir) {
struct ip* ip = (struct ip*)((void*)llc + sizeof(struct llc));
/* Taken from tcpdump/print-llc.c */
if(llc->ssap == LLCSAP_SNAP && llc->dsap == LLCSAP_SNAP
&& llc->llcui == LLC_UI) {
u_int32_t orgcode;
register u_short et;
orgcode = EXTRACT_24BITS(&llc->llc_orgcode[0]);
et = EXTRACT_16BITS(&llc->llc_ethertype[0]);
switch(orgcode) {
case OUI_ENCAP_ETHER:
case OUI_CISCO_90:
handle_ip_packet(ip, dir);
break;
case OUI_APPLETALK:
if(et == ETHERTYPE_ATALK) {
handle_ip_packet(ip, dir);
}
break;
default:;
/* Not a lot we can do */
}
}
}
示例10: juniper_atm2_print
u_int
juniper_atm2_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, register const u_char *p)
{
uint16_t extracted_ethertype;
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM2;
if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */
oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
return l2info.header_len;
}
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL,
&extracted_ethertype) != 0)
return l2info.header_len;
}
if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
(EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
}
if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) /* PPPoA vcmux encaps ? */
return l2info.header_len;
if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */
return l2info.header_len;
return l2info.header_len;
}
示例11: juniper_atm2_print
u_int
juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
{
u_int16_t extracted_ethertype;
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM2;
if(juniper_parse_header(p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) {
oam_print(p,l2info.length,ATM_OAM_NOHEC);
return l2info.header_len;
}
if (EXTRACT_24BITS(p) == 0xfefe03 ||
EXTRACT_24BITS(p) == 0xaaaa03) {
if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL,
&extracted_ethertype) != 0)
return l2info.header_len;
}
if (l2info.direction != JUNIPER_BPF_PKT_IN &&
(EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
ether_print(p, l2info.length, l2info.caplen);
return l2info.header_len;
}
if (p[0] == 0x03) {
isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1);
return l2info.header_len;
}
if(juniper_ppp_heuristic_guess(p, l2info.length) != 0)
return l2info.header_len;
if(ip_heuristic_guess(p, l2info.length) != 0)
return l2info.header_len;
return l2info.header_len;
}
示例12: ospf_print_lshdr
static int
ospf_print_lshdr(register const struct lsa_hdr *lshp)
{
u_int ls_length;
TCHECK(lshp->ls_length);
ls_length = EXTRACT_16BITS(&lshp->ls_length);
if (ls_length < sizeof(struct lsa_hdr)) {
printf("\n\t Bogus length %u < %lu", ls_length,
(unsigned long)sizeof(struct lsa_hdr));
return(-1);
}
TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */
printf("\n\t Advertising Router: %s, seq 0x%08x, age %us, length: %u",
ipaddr_string(&lshp->ls_router),
EXTRACT_32BITS(&lshp->ls_seq),
EXTRACT_16BITS(&lshp->ls_age),
ls_length-(u_int)sizeof(struct lsa_hdr));
TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */
switch (lshp->ls_type) {
/* the LSA header for opaque LSAs was slightly changed */
case LS_TYPE_OPAQUE_LL:
case LS_TYPE_OPAQUE_AL:
case LS_TYPE_OPAQUE_DW:
printf("\n\t %s LSA (%d), Opaque-Type: %s LSA (%u), Opaque-ID: %u",
tok2str(lsa_values,"unknown",lshp->ls_type),
lshp->ls_type,
tok2str(lsa_opaque_values,
"unknown",
*(&lshp->un_lsa_id.opaque_field.opaque_type)),
*(&lshp->un_lsa_id.opaque_field.opaque_type),
EXTRACT_24BITS(&lshp->un_lsa_id.opaque_field.opaque_id)
);
break;
/* all other LSA types use regular style LSA headers */
default:
printf("\n\t %s LSA (%d), LSA-ID: %s",
tok2str(lsa_values,"unknown",lshp->ls_type),
lshp->ls_type,
ipaddr_string(&lshp->un_lsa_id.lsa_id));
break;
}
TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
printf("\n\t Options: [%s]", bittok2str(ospf_option_values,"none",lshp->ls_options));
return (ls_length);
trunc:
return (-1);
}
示例13: vxlan_gpe_print
void
vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
uint8_t flags;
uint8_t next_protocol;
uint32_t vni;
if (len < VXLAN_GPE_HDR_LEN)
goto trunc;
ND_TCHECK2(*bp, VXLAN_GPE_HDR_LEN);
flags = *bp;
bp += 3;
next_protocol = *bp;
bp += 1;
vni = EXTRACT_24BITS(bp);
bp += 4;
ND_PRINT((ndo, "VXLAN-GPE, "));
ND_PRINT((ndo, "flags [%s], ",
bittok2str_nosep(vxlan_gpe_flags, "none", flags)));
ND_PRINT((ndo, "vni %u", vni));
ND_PRINT((ndo, ndo->ndo_vflag ? "\n " : ": "));
switch (next_protocol) {
case 0x1:
ip_print(ndo, bp, len - 8);
break;
case 0x2:
ip6_print(ndo, bp, len - 8);
break;
case 0x3:
ether_print(ndo, bp, len - 8, len - 8, NULL, NULL);
break;
case 0x4:
nsh_print(ndo, bp, len - 8);
break;
case 0x5:
mpls_print(ndo, bp, len - 8);
break;
default:
ND_PRINT((ndo, "ERROR: unknown-next-protocol"));
return;
}
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
}
示例14: dccp_seqno
static u_int64_t dccp_seqno(const struct dccp_hdr *dh)
{
u_int32_t seq_high = DCCPH_SEQ(dh);
u_int64_t seqno = EXTRACT_24BITS(&seq_high) & 0xFFFFFF;
if (DCCPH_X(dh) != 0) {
const struct dccp_hdr_ext *dhx = (void *)(dh + 1);
u_int32_t seq_low = dhx->dccph_seq_low;
seqno &= 0x00FFFF; /* clear reserved field */
seqno = (seqno << 32) + EXTRACT_32BITS(&seq_low);
}
return seqno;
}
示例15: dccp_seqno
static u_int64_t dccp_seqno(const u_char *bp)
{
const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
u_int64_t seqno;
if (DCCPH_X(dh) != 0) {
const struct dccp_hdr_ext *dhx = (const struct dccp_hdr_ext *)bp;
seqno = EXTRACT_48BITS(dhx->dccph_seq);
} else {
seqno = EXTRACT_24BITS(dh->dccph_seq);
}
return seqno;
}