本文整理匯總了C++中EXTRACT_U_1函數的典型用法代碼示例。如果您正苦於以下問題:C++ EXTRACT_U_1函數的具體用法?C++ EXTRACT_U_1怎麽用?C++ EXTRACT_U_1使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EXTRACT_U_1函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: print_attr_netmask6
static void
print_attr_netmask6(netdissect_options *ndo,
const u_char *data, u_int length, u_short attr_code _U_)
{
u_char data2[16];
if (length < 2 || length > 18)
{
ND_PRINT("ERROR: length %u not in range (2..18)", length);
return;
}
ND_TCHECK_LEN(data, length);
if (EXTRACT_U_1(data + 1) > 128)
{
ND_PRINT("ERROR: netmask %u not in range (0..128)", EXTRACT_U_1(data + 1));
return;
}
memset(data2, 0, sizeof(data2));
if (length > 2)
memcpy(data2, data+2, length-2);
ND_PRINT("%s/%u", ip6addr_string(ndo, data2), EXTRACT_U_1(data + 1));
if (EXTRACT_U_1(data + 1) > 8 * (length - 2))
ND_PRINT(" (inconsistent prefix length)");
return;
trunc:
nd_print_trunc(ndo);
}
示例2: ipnet_hdr_print
static inline void
ipnet_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const ipnet_hdr_t *hdr;
hdr = (const ipnet_hdr_t *)bp;
ND_TCHECK_SIZE(hdr);
ND_PRINT("%u > %u", EXTRACT_BE_U_4(hdr->iph_zsrc),
EXTRACT_BE_U_4(hdr->iph_zdst));
if (!ndo->ndo_qflag) {
ND_PRINT(", family %s (%u)",
tok2str(ipnet_values, "Unknown",
EXTRACT_U_1(hdr->iph_family)),
EXTRACT_U_1(hdr->iph_family));
} else {
ND_PRINT(", %s",
tok2str(ipnet_values,
"Unknown Ethertype (0x%04x)",
EXTRACT_U_1(hdr->iph_family)));
}
ND_PRINT(", length %u: ", length);
return;
trunc:
ND_PRINT(" %s", tstr);
}
示例3: igrp_entry_print
static void
igrp_entry_print(netdissect_options *ndo, const struct igrprte *igr,
int is_interior, int is_exterior)
{
u_int delay, bandwidth;
u_int metric, mtu;
if (is_interior)
ND_PRINT(" *.%u.%u.%u", igr->igr_net[0],
igr->igr_net[1], igr->igr_net[2]);
else if (is_exterior)
ND_PRINT(" X%u.%u.%u.0", igr->igr_net[0],
igr->igr_net[1], igr->igr_net[2]);
else
ND_PRINT(" %u.%u.%u.0", igr->igr_net[0],
igr->igr_net[1], igr->igr_net[2]);
delay = EXTRACT_BE_U_3(igr->igr_dly);
bandwidth = EXTRACT_BE_U_3(igr->igr_bw);
metric = bandwidth + delay;
if (metric > 0xffffff)
metric = 0xffffff;
mtu = EXTRACT_BE_U_2(igr->igr_mtu);
ND_PRINT(" d=%u b=%u r=%u l=%u M=%u mtu=%u in %u hops",
10 * delay, bandwidth == 0 ? 0 : 10000000 / bandwidth,
EXTRACT_U_1(igr->igr_rel), EXTRACT_U_1(igr->igr_ld), metric,
mtu, EXTRACT_U_1(igr->igr_hct));
}
示例4: ppp_if_print
/* PPP I/F printer */
u_int
ppp_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
if (caplen < PPP_HDRLEN) {
ND_PRINT("[|ppp]");
return (caplen);
}
#if 0
/*
* XXX: seems to assume that there are 2 octets prepended to an
* actual PPP frame. The 1st octet looks like Input/Output flag
* while 2nd octet is unknown, at least to me
* ([email protected]).
*
* That was what the original tcpdump code did.
*
* FreeBSD's "if_ppp.c" *does* set the first octet to 1 for outbound
* packets and 0 for inbound packets - but only if the
* protocol field has the 0x8000 bit set (i.e., it's a network
* control protocol); it does so before running the packet through
* "bpf_filter" to see if it should be discarded, and to see
* if we should update the time we sent the most recent packet...
*
* ...but it puts the original address field back after doing
* so.
*
* NetBSD's "if_ppp.c" doesn't set the first octet in that fashion.
*
* I don't know if any PPP implementation handed up to a BPF
* device packets with the first octet being 1 for outbound and
* 0 for inbound packets, so I ([email protected]) don't know
* whether that ever needs to be checked or not.
*
* Note that NetBSD has a DLT_PPP_SERIAL, which it uses for PPP,
* and its tcpdump appears to assume that the frame always
* begins with an address field and a control field, and that
* the address field might be 0x0f or 0x8f, for Cisco
* point-to-point with HDLC framing as per section 4.3.1 of RFC
* 1547, as well as 0xff, for PPP in HDLC-like framing as per
* RFC 1662.
*
* (Is the Cisco framing in question what DLT_C_HDLC, in
* BSD/OS, is?)
*/
if (ndo->ndo_eflag)
ND_PRINT("%c %4d %02x ", EXTRACT_U_1(p) ? 'O' : 'I',
length, EXTRACT_U_1(p + 1));
#endif
ppp_print(ndo, p, length);
return (0);
}
示例5: timed_print
void
timed_print(netdissect_options *ndo,
const u_char *bp)
{
const struct tsp *tsp = (const struct tsp *)bp;
uint8_t tsp_type;
int sec, usec;
ndo->ndo_protocol = "timed";
ND_TCHECK_1(tsp->tsp_type);
tsp_type = EXTRACT_U_1(tsp->tsp_type);
if (tsp_type < TSPTYPENUMBER)
ND_PRINT("TSP_%s", tsptype[tsp_type]);
else
ND_PRINT("(tsp_type %#x)", tsp_type);
ND_TCHECK_1(tsp->tsp_vers);
ND_PRINT(" vers %u", EXTRACT_U_1(tsp->tsp_vers));
ND_TCHECK_2(tsp->tsp_seq);
ND_PRINT(" seq %u", EXTRACT_BE_U_2(tsp->tsp_seq));
switch (tsp_type) {
case TSP_LOOP:
ND_TCHECK_1(tsp->tsp_hopcnt);
ND_PRINT(" hopcnt %u", EXTRACT_U_1(tsp->tsp_hopcnt));
break;
case TSP_SETTIME:
case TSP_ADJTIME:
case TSP_SETDATE:
case TSP_SETDATEREQ:
ND_TCHECK_8(&tsp->tsp_time);
sec = EXTRACT_BE_S_4(tsp->tsp_time.tv_sec);
usec = EXTRACT_BE_S_4(tsp->tsp_time.tv_usec);
/* XXX The comparison below is always false? */
if (usec < 0)
/* invalid, skip the rest of the packet */
return;
ND_PRINT(" time ");
if (sec < 0 && usec != 0) {
sec++;
if (sec == 0)
ND_PRINT("-");
usec = 1000000 - usec;
}
ND_PRINT("%d.%06d", sec, usec);
break;
}
ND_PRINT(" name ");
if (nd_printzp(ndo, tsp->tsp_name, sizeof(tsp->tsp_name),
ndo->ndo_snapend))
goto trunc;
return;
trunc:
nd_print_trunc(ndo);
}
示例6: print_ip6cp_config_options
/* IP6CP config options */
static u_int
print_ip6cp_config_options(netdissect_options *ndo,
const u_char *p, u_int length)
{
u_int opt, len;
if (length < 2)
return 0;
ND_TCHECK_2(p);
opt = EXTRACT_U_1(p);
len = EXTRACT_U_1(p + 1);
if (length < len)
return 0;
if (len < 2) {
ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
tok2str(ip6cpopt_values,"unknown",opt),
opt,
len);
return 0;
}
ND_PRINT("\n\t %s Option (0x%02x), length %u",
tok2str(ip6cpopt_values,"unknown",opt),
opt,
len);
switch (opt) {
case IP6CP_IFID:
if (len != 10) {
ND_PRINT(" (length bogus, should be = 10)");
return len;
}
ND_TCHECK_8(p + 2);
ND_PRINT(": %04x:%04x:%04x:%04x",
EXTRACT_BE_U_2(p + 2),
EXTRACT_BE_U_2(p + 4),
EXTRACT_BE_U_2(p + 6),
EXTRACT_BE_U_2(p + 8));
break;
default:
/*
* Unknown option; dump it as raw bytes now if we're
* not going to do so below.
*/
if (ndo->ndo_vflag < 2)
print_unknown_data(ndo, p + 2, "\n\t ", len - 2);
break;
}
if (ndo->ndo_vflag > 1)
print_unknown_data(ndo, p + 2, "\n\t ", len - 2); /* exclude TLV header */
return len;
trunc:
ND_PRINT("[|ip6cp]");
return 0;
}
示例7: print_vendor_attr
/*
* print vendor specific attributes
*/
static void
print_vendor_attr(netdissect_options *ndo,
const u_char *data, u_int length, u_short attr_code _U_)
{
u_int idx;
u_int vendor_id;
u_int vendor_type;
u_int vendor_length;
if (length < 4)
goto trunc;
ND_TCHECK_4(data);
vendor_id = EXTRACT_BE_U_4(data);
data+=4;
length-=4;
ND_PRINT("Vendor: %s (%u)",
tok2str(smi_values,"Unknown",vendor_id),
vendor_id);
while (length >= 2) {
ND_TCHECK_2(data);
vendor_type = EXTRACT_U_1(data);
vendor_length = EXTRACT_U_1(data + 1);
if (vendor_length < 2)
{
ND_PRINT("\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
vendor_type,
vendor_length);
return;
}
if (vendor_length > length)
{
ND_PRINT("\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
vendor_type,
vendor_length);
return;
}
data+=2;
vendor_length-=2;
length-=2;
ND_TCHECK_LEN(data, vendor_length);
ND_PRINT("\n\t Vendor Attribute: %u, Length: %u, Value: ",
vendor_type,
vendor_length);
for (idx = 0; idx < vendor_length ; idx++, data++)
ND_PRINT("%c", ND_ISPRINT(EXTRACT_U_1(data)) ? EXTRACT_U_1(data) : '.');
length-=vendor_length;
}
return;
trunc:
nd_print_trunc(ndo);
}
示例8: pptp_err_code_print
static void
pptp_err_code_print(netdissect_options *ndo,
const nd_uint8_t *err_code)
{
ND_PRINT(" ERR_CODE(%u", EXTRACT_U_1(*err_code));
if (ndo->ndo_vflag) {
ND_PRINT(":%s", tok2str(pptp_errcode_str, "?", EXTRACT_U_1(*err_code)));
}
ND_PRINT(")");
}
示例9: print_bacp_config_options
/* BACP config options */
static u_int
print_bacp_config_options(netdissect_options *ndo,
const u_char *p, u_int length)
{
u_int opt, len;
if (length < 2)
return 0;
ND_TCHECK_2(p);
opt = EXTRACT_U_1(p);
len = EXTRACT_U_1(p + 1);
if (length < len)
return 0;
if (len < 2) {
ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
tok2str(bacconfopts_values, "Unknown", opt),
opt,
len);
return 0;
}
ND_PRINT("\n\t %s Option (0x%02x), length %u",
tok2str(bacconfopts_values, "Unknown", opt),
opt,
len);
switch (opt) {
case BACPOPT_FPEER:
if (len != 6) {
ND_PRINT(" (length bogus, should be = 6)");
return len;
}
ND_TCHECK_4(p + 2);
ND_PRINT(": Magic-Num 0x%08x", EXTRACT_BE_U_4(p + 2));
break;
default:
/*
* Unknown option; dump it as raw bytes now if we're
* not going to do so below.
*/
if (ndo->ndo_vflag < 2)
print_unknown_data(ndo, p + 2, "\n\t ", len - 2);
break;
}
if (ndo->ndo_vflag > 1)
print_unknown_data(ndo, p + 2, "\n\t ", len - 2); /* exclude TLV header */
return len;
trunc:
ND_PRINT("[|bacp]");
return 0;
}
示例10: of_header_body_print
/* Print a single OpenFlow message. */
static const u_char *
of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
{
uint8_t version, type;
uint16_t length;
uint32_t xid;
if (ep < cp + OF_HEADER_LEN)
goto invalid;
/* version */
ND_TCHECK_1(cp);
version = EXTRACT_U_1(cp);
cp += 1;
/* type */
ND_TCHECK_1(cp);
type = EXTRACT_U_1(cp);
cp += 1;
/* length */
ND_TCHECK_2(cp);
length = EXTRACT_BE_U_2(cp);
cp += 2;
/* xid */
ND_TCHECK_4(cp);
xid = EXTRACT_BE_U_4(cp);
cp += 4;
/* Message length includes the header length and a message always includes
* the basic header. A message length underrun fails decoding of the rest of
* the current packet. At the same time, try decoding as much of the current
* message as possible even when it does not end within the current TCP
* segment. */
if (length < OF_HEADER_LEN) {
of_header_print(ndo, version, type, length, xid);
goto invalid;
}
/* Decode known protocol versions further without printing the header (the
* type decoding is version-specific. */
switch (version) {
case OF_VER_1_0:
return of10_header_body_print(ndo, cp, ep, type, length, xid);
default:
of_header_print(ndo, version, type, length, xid);
ND_TCHECK_LEN(cp, length - OF_HEADER_LEN);
return cp + length - OF_HEADER_LEN; /* done with current message */
}
invalid: /* fail current packet */
ND_PRINT("%s", istr);
ND_TCHECK_LEN(cp, ep - cp);
return ep;
trunc:
ND_PRINT("%s", tstr);
return ep;
}
示例11: igrp_print
void
igrp_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const struct igrphdr *hdr;
const u_char *cp;
u_int nint, nsys, next;
hdr = (const struct igrphdr *)bp;
cp = (const u_char *)(hdr + 1);
ND_PRINT("igrp:");
/* Header */
ND_TCHECK_SIZE(hdr);
nint = EXTRACT_BE_U_2(hdr->ig_ni);
nsys = EXTRACT_BE_U_2(hdr->ig_ns);
next = EXTRACT_BE_U_2(hdr->ig_nx);
ND_PRINT(" %s V%u edit=%u AS=%u (%u/%u/%u)",
tok2str(op2str, "op-#%u", IGRP_OP(EXTRACT_U_1(hdr->ig_vop))),
IGRP_V(EXTRACT_U_1(hdr->ig_vop)),
EXTRACT_U_1(hdr->ig_ed),
EXTRACT_BE_U_2(hdr->ig_as),
nint,
nsys,
next);
length -= sizeof(*hdr);
while (length >= IGRP_RTE_SIZE) {
if (nint > 0) {
ND_TCHECK_LEN(cp, IGRP_RTE_SIZE);
igrp_entry_print(ndo, (const struct igrprte *)cp, 1, 0);
--nint;
} else if (nsys > 0) {
ND_TCHECK_LEN(cp, IGRP_RTE_SIZE);
igrp_entry_print(ndo, (const struct igrprte *)cp, 0, 0);
--nsys;
} else if (next > 0) {
ND_TCHECK_LEN(cp, IGRP_RTE_SIZE);
igrp_entry_print(ndo, (const struct igrprte *)cp, 0, 1);
--next;
} else {
ND_PRINT(" [extra bytes %u]", length);
break;
}
cp += IGRP_RTE_SIZE;
length -= IGRP_RTE_SIZE;
}
if (nint == 0 && nsys == 0 && next == 0)
return;
trunc:
ND_PRINT(" [|igrp]");
}
示例12: cmu_print
static void
cmu_print(netdissect_options *ndo,
const u_char *bp)
{
const struct cmu_vend *cmu;
uint8_t v_flags;
ND_PRINT(" vend-cmu");
cmu = (const struct cmu_vend *)bp;
/* Only print if there are unknown bits */
ND_TCHECK_4(cmu->v_flags);
v_flags = EXTRACT_U_1(cmu->v_flags);
if ((v_flags & ~(VF_SMASK)) != 0)
ND_PRINT(" F:0x%x", v_flags);
PRINTCMUADDR(v_dgate, "DG");
PRINTCMUADDR(v_smask, v_flags & VF_SMASK ? "SM" : "SM*");
PRINTCMUADDR(v_dns1, "NS1");
PRINTCMUADDR(v_dns2, "NS2");
PRINTCMUADDR(v_ins1, "IEN1");
PRINTCMUADDR(v_ins2, "IEN2");
PRINTCMUADDR(v_ts1, "TS1");
PRINTCMUADDR(v_ts2, "TS2");
return;
trunc:
nd_print_trunc(ndo);
}
示例13: vxlan_print
void
vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
uint8_t flags;
uint32_t vni;
ndo->ndo_protocol = "vxlan";
if (len < VXLAN_HDR_LEN)
goto trunc;
ND_TCHECK_LEN(bp, VXLAN_HDR_LEN);
flags = EXTRACT_U_1(bp);
bp += 4;
vni = EXTRACT_BE_U_3(bp);
bp += 4;
ND_PRINT("VXLAN, ");
ND_PRINT("flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags);
ND_PRINT("vni %u\n", vni);
ether_print(ndo, bp, len - VXLAN_HDR_LEN, ndo->ndo_snapend - bp, NULL, NULL);
return;
trunc:
nd_print_trunc(ndo);
}
示例14: atalk_print
/*
* Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called
* when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk
* packets in them).
*/
void
atalk_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
const struct atDDP *dp;
u_short snet;
ndo->ndo_protocol = "atalk";
if(!ndo->ndo_eflag)
ND_PRINT("AT ");
if (length < ddpSize) {
ND_PRINT(" [|ddp %u]", length);
return;
}
if (!ND_TTEST_LEN(bp, ddpSize)) {
ND_PRINT(" [|ddp]");
return;
}
dp = (const struct atDDP *)bp;
snet = EXTRACT_BE_U_2(dp->srcNet);
ND_PRINT("%s.%s", ataddr_string(ndo, snet, EXTRACT_U_1(dp->srcNode)),
ddpskt_string(ndo, EXTRACT_U_1(dp->srcSkt)));
ND_PRINT(" > %s.%s: ",
ataddr_string(ndo, EXTRACT_BE_U_2(dp->dstNet), EXTRACT_U_1(dp->dstNode)),
ddpskt_string(ndo, EXTRACT_U_1(dp->dstSkt)));
bp += ddpSize;
length -= ddpSize;
ddp_print(ndo, bp, length, EXTRACT_U_1(dp->type), snet, EXTRACT_U_1(dp->srcNode), EXTRACT_U_1(dp->srcSkt));
}
示例15: token_hdr_print
/*
* Print the TR MAC header
*/
static void
token_hdr_print(netdissect_options *ndo,
const struct token_header *trp, u_int length,
const u_char *fsrc, const u_char *fdst)
{
const char *srcname, *dstname;
srcname = etheraddr_string(ndo, fsrc);
dstname = etheraddr_string(ndo, fdst);
if (!ndo->ndo_qflag)
ND_PRINT("%02x %02x ",
EXTRACT_U_1(trp->token_ac),
EXTRACT_U_1(trp->token_fc));
ND_PRINT("%s > %s, length %u: ",
srcname, dstname,
length);
}