本文整理汇总了C++中ND_PRINT函数的典型用法代码示例。如果您正苦于以下问题:C++ ND_PRINT函数的具体用法?C++ ND_PRINT怎么用?C++ ND_PRINT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ND_PRINT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: bootp_print
/*
* Print bootp requests
*/
void
bootp_print(netdissect_options *ndo,
register const u_char *cp, u_int length)
{
register const struct bootp *bp;
static const u_char vm_cmu[4] = VM_CMU;
static const u_char vm_rfc1048[4] = VM_RFC1048;
bp = (const struct bootp *)cp;
ND_TCHECK(bp->bp_op);
ND_PRINT((ndo, "BOOTP/DHCP, %s",
tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)));
if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
ND_TCHECK2(bp->bp_chaddr[0], 6);
ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr)));
}
ND_PRINT((ndo, ", length %u", length));
if (!ndo->ndo_vflag)
return;
ND_TCHECK(bp->bp_secs);
/* The usual hardware address type is 1 (10Mb Ethernet) */
if (bp->bp_htype != 1)
ND_PRINT((ndo, ", htype %d", bp->bp_htype));
/* The usual length for 10Mb Ethernet address is 6 bytes */
if (bp->bp_htype != 1 || bp->bp_hlen != 6)
ND_PRINT((ndo, ", hlen %d", bp->bp_hlen));
/* Only print interesting fields */
if (bp->bp_hops)
ND_PRINT((ndo, ", hops %d", bp->bp_hops));
if (EXTRACT_32BITS(&bp->bp_xid))
ND_PRINT((ndo, ", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)));
if (EXTRACT_16BITS(&bp->bp_secs))
ND_PRINT((ndo, ", secs %d", EXTRACT_16BITS(&bp->bp_secs)));
ND_PRINT((ndo, ", Flags [%s]",
bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))));
if (ndo->ndo_vflag > 1)
ND_PRINT((ndo, " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)));
/* Client's ip address */
ND_TCHECK(bp->bp_ciaddr);
if (EXTRACT_32BITS(&bp->bp_ciaddr.s_addr))
ND_PRINT((ndo, "\n\t Client-IP %s", ipaddr_string(ndo, &bp->bp_ciaddr)));
/* 'your' ip address (bootp client) */
ND_TCHECK(bp->bp_yiaddr);
if (EXTRACT_32BITS(&bp->bp_yiaddr.s_addr))
ND_PRINT((ndo, "\n\t Your-IP %s", ipaddr_string(ndo, &bp->bp_yiaddr)));
/* Server's ip address */
ND_TCHECK(bp->bp_siaddr);
if (EXTRACT_32BITS(&bp->bp_siaddr.s_addr))
ND_PRINT((ndo, "\n\t Server-IP %s", ipaddr_string(ndo, &bp->bp_siaddr)));
/* Gateway's ip address */
ND_TCHECK(bp->bp_giaddr);
if (EXTRACT_32BITS(&bp->bp_giaddr.s_addr))
ND_PRINT((ndo, "\n\t Gateway-IP %s", ipaddr_string(ndo, &bp->bp_giaddr)));
/* Client's Ethernet address */
if (bp->bp_htype == 1 && bp->bp_hlen == 6) {
ND_TCHECK2(bp->bp_chaddr[0], 6);
ND_PRINT((ndo, "\n\t Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr)));
}
ND_TCHECK2(bp->bp_sname[0], 1); /* check first char only */
if (*bp->bp_sname) {
ND_PRINT((ndo, "\n\t sname \""));
if (fn_print(ndo, bp->bp_sname, ndo->ndo_snapend)) {
ND_PRINT((ndo, "\""));
ND_PRINT((ndo, "%s", tstr + 1));
return;
}
ND_PRINT((ndo, "\""));
}
ND_TCHECK2(bp->bp_file[0], 1); /* check first char only */
if (*bp->bp_file) {
ND_PRINT((ndo, "\n\t file \""));
if (fn_print(ndo, bp->bp_file, ndo->ndo_snapend)) {
ND_PRINT((ndo, "\""));
ND_PRINT((ndo, "%s", tstr + 1));
return;
}
ND_PRINT((ndo, "\""));
}
/* Decode the vendor buffer */
ND_TCHECK(bp->bp_vend[0]);
if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:freebsd,代码行数:101,代码来源:print-bootp.c
示例2: pptp_hostname_print
static void
pptp_hostname_print(netdissect_options *ndo,
const u_char *hostname)
{
ND_PRINT(" HOSTNAME(%.64s)", hostname);
}
开发者ID:MisterDA,项目名称:tcpdump,代码行数:6,代码来源:print-pptp.c
示例3: pptp_max_channel_print
static void
pptp_max_channel_print(netdissect_options *ndo,
const nd_uint16_t *max_channel)
{
ND_PRINT(" MAX_CHAN(%u)", EXTRACT_BE_U_2(*max_channel));
}
开发者ID:MisterDA,项目名称:tcpdump,代码行数:6,代码来源:print-pptp.c
示例4: pptp_call_ser_print
static void
pptp_call_ser_print(netdissect_options *ndo,
const nd_uint16_t *call_ser)
{
ND_PRINT(" CALL_SER_NUM(%u)", EXTRACT_BE_U_2(*call_ser));
}
开发者ID:MisterDA,项目名称:tcpdump,代码行数:6,代码来源:print-pptp.c
示例5: pptp_conn_speed_print
static void
pptp_conn_speed_print(netdissect_options *ndo,
const nd_uint32_t *conn_speed)
{
ND_PRINT(" CONN_SPEED(%u)", EXTRACT_BE_U_4(*conn_speed));
}
开发者ID:MisterDA,项目名称:tcpdump,代码行数:6,代码来源:print-pptp.c
示例6: print_trans2
static void
print_trans2(netdissect_options *ndo,
const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
{
u_int bcc;
static const struct smbfnsint *fn = &trans2_fns[0];
const u_char *data, *param;
const u_char *w = words + 1;
const char *f1 = NULL, *f2 = NULL;
int pcnt, dcnt;
ND_TCHECK(words[0]);
if (request) {
ND_TCHECK2(w[14 * 2], 2);
pcnt = EXTRACT_LE_16BITS(w + 9 * 2);
param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
dcnt = EXTRACT_LE_16BITS(w + 11 * 2);
data = buf + EXTRACT_LE_16BITS(w + 12 * 2);
fn = smbfindint(EXTRACT_LE_16BITS(w + 14 * 2), trans2_fns);
} else {
if (words[0] == 0) {
ND_PRINT((ndo, "%s\n", fn->name));
ND_PRINT((ndo, "Trans2Interim\n"));
return;
}
ND_TCHECK2(w[7 * 2], 2);
pcnt = EXTRACT_LE_16BITS(w + 3 * 2);
param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
dcnt = EXTRACT_LE_16BITS(w + 6 * 2);
data = buf + EXTRACT_LE_16BITS(w + 7 * 2);
}
ND_PRINT((ndo, "%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt));
if (request) {
if (words[0] == 8) {
smb_fdata(ndo, words + 1,
"Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",
maxbuf, unicodestr);
return;
} else {
smb_fdata(ndo, words + 1,
"TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[b][P1]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[b][P1]\n",
words + 1 + 14 * 2, unicodestr);
}
f1 = fn->descript.req_f1;
f2 = fn->descript.req_f2;
} else {
smb_fdata(ndo, words + 1,
"TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[b][P1]\n",
words + 1 + 10 * 2, unicodestr);
f1 = fn->descript.rep_f1;
f2 = fn->descript.rep_f2;
}
ND_TCHECK2(*dat, 2);
bcc = EXTRACT_LE_16BITS(dat);
ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (fn->descript.fn)
(*fn->descript.fn)(ndo, param, data, pcnt, dcnt);
else {
smb_fdata(ndo, param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr);
smb_fdata(ndo, data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr);
}
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:68,代码来源:print-smb.c
示例7: chdlc_slarp_print
static void
chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
{
const struct cisco_slarp *slarp;
u_int sec,min,hrs,days;
ND_PRINT((ndo, "SLARP (length: %u), ",length));
if (length < SLARP_MIN_LEN)
goto trunc;
slarp = (const struct cisco_slarp *)cp;
ND_TCHECK2(*slarp, SLARP_MIN_LEN);
switch (EXTRACT_32BITS(&slarp->code)) {
case SLARP_REQUEST:
ND_PRINT((ndo, "request"));
/*
* At least according to William "Chops" Westfield's
* message in
*
* http://www.nethelp.no/net/cisco-hdlc.txt
*
* the address and mask aren't used in requests -
* they're just zero.
*/
break;
case SLARP_REPLY:
ND_PRINT((ndo, "reply %s/%s",
ipaddr_string(ndo, &slarp->un.addr.addr),
ipaddr_string(ndo, &slarp->un.addr.mask)));
break;
case SLARP_KEEPALIVE:
ND_PRINT((ndo, "keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
EXTRACT_32BITS(&slarp->un.keep.myseq),
EXTRACT_32BITS(&slarp->un.keep.yourseq),
EXTRACT_16BITS(&slarp->un.keep.rel)));
if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */
cp += SLARP_MIN_LEN;
ND_TCHECK2(*cp, 4);
sec = EXTRACT_32BITS(cp) / 1000;
min = sec / 60; sec -= min * 60;
hrs = min / 60; min -= hrs * 60;
days = hrs / 24; hrs -= days * 24;
ND_PRINT((ndo, ", link uptime=%ud%uh%um%us",days,hrs,min,sec));
}
break;
default:
ND_PRINT((ndo, "0x%02x unknown", EXTRACT_32BITS(&slarp->code)));
if (ndo->ndo_vflag <= 1)
print_unknown_data(ndo,cp+4,"\n\t",length-4);
break;
}
if (SLARP_MAX_LEN < length && ndo->ndo_vflag)
ND_PRINT((ndo, ", (trailing junk: %d bytes)", length - SLARP_MAX_LEN));
if (ndo->ndo_vflag > 1)
print_unknown_data(ndo,cp+4,"\n\t",length-4);
return;
trunc:
ND_PRINT((ndo, "[|slarp]"));
}
开发者ID:RichardsonAlex,项目名称:cheribsd,代码行数:62,代码来源:print-chdlc.c
示例8: slow_oam_print
static void
slow_oam_print(netdissect_options *ndo,
const u_char *tptr, u_int tlen)
{
uint8_t code;
uint8_t type, length;
uint8_t state;
uint8_t command;
u_int hexdump;
struct slow_oam_common_header_t {
nd_uint16_t flags;
nd_uint8_t code;
};
struct slow_oam_tlv_header_t {
nd_uint8_t type;
nd_uint8_t length;
};
union {
const struct slow_oam_common_header_t *slow_oam_common_header;
const struct slow_oam_tlv_header_t *slow_oam_tlv_header;
} ptr;
union {
const struct slow_oam_info_t *slow_oam_info;
const struct slow_oam_link_event_t *slow_oam_link_event;
const struct slow_oam_variablerequest_t *slow_oam_variablerequest;
const struct slow_oam_variableresponse_t *slow_oam_variableresponse;
const struct slow_oam_loopbackctrl_t *slow_oam_loopbackctrl;
} tlv;
ptr.slow_oam_common_header = (const struct slow_oam_common_header_t *)tptr;
if (tlen < sizeof(*ptr.slow_oam_common_header))
goto tooshort;
ND_TCHECK_SIZE(ptr.slow_oam_common_header);
tptr += sizeof(struct slow_oam_common_header_t);
tlen -= sizeof(struct slow_oam_common_header_t);
code = EXTRACT_U_1(ptr.slow_oam_common_header->code);
ND_PRINT("\n\tCode %s OAM PDU, Flags [%s]",
tok2str(slow_oam_code_values, "Unknown (%u)", code),
bittok2str(slow_oam_flag_values,
"none",
EXTRACT_BE_U_2(ptr.slow_oam_common_header->flags)));
switch (code) {
case SLOW_OAM_CODE_INFO:
while (tlen > 0) {
ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
if (tlen < sizeof(*ptr.slow_oam_tlv_header))
goto tooshort;
ND_TCHECK_SIZE(ptr.slow_oam_tlv_header);
type = EXTRACT_U_1(ptr.slow_oam_tlv_header->type);
length = EXTRACT_U_1(ptr.slow_oam_tlv_header->length);
ND_PRINT("\n\t %s Information Type (%u), length %u",
tok2str(slow_oam_info_type_values, "Reserved", type),
type,
length);
if (type == SLOW_OAM_INFO_TYPE_END_OF_TLV) {
/*
* As IEEE Std 802.3-2015 says for the End of TLV Marker,
* "(the length and value of the Type 0x00 TLV can be ignored)".
*/
return;
}
/* length includes the type and length fields */
if (length < sizeof(struct slow_oam_tlv_header_t)) {
ND_PRINT("\n\t ERROR: illegal length - should be >= %u",
(u_int)sizeof(struct slow_oam_tlv_header_t));
return;
}
if (tlen < length)
goto tooshort;
ND_TCHECK_LEN(tptr, length);
hexdump = FALSE;
switch (type) {
case SLOW_OAM_INFO_TYPE_LOCAL: /* identical format - fall through */
case SLOW_OAM_INFO_TYPE_REMOTE:
tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr;
if (EXTRACT_U_1(tlv.slow_oam_info->info_length) !=
sizeof(struct slow_oam_info_t)) {
ND_PRINT("\n\t ERROR: illegal length - should be %lu",
(unsigned long) sizeof(struct slow_oam_info_t));
hexdump = TRUE;
goto badlength_code_info;
}
ND_PRINT("\n\t OAM-Version %u, Revision %u",
EXTRACT_U_1(tlv.slow_oam_info->oam_version),
EXTRACT_BE_U_2(tlv.slow_oam_info->revision));
state = EXTRACT_U_1(tlv.slow_oam_info->state);
ND_PRINT("\n\t State-Parser-Action %s, State-MUX-Action %s",
//.........这里部分代码省略.........
开发者ID:Wilm0r,项目名称:tcpdump,代码行数:101,代码来源:print-slow.c
示例9: mpls_print
/*
* RFC3032: MPLS label stack encoding
*/
void
mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const u_char *p;
uint32_t label_entry;
uint16_t label_stack_depth = 0;
enum mpls_packet_type pt = PT_UNKNOWN;
p = bp;
ND_PRINT((ndo, "MPLS"));
do {
ND_TCHECK2(*p, sizeof(label_entry));
label_entry = EXTRACT_32BITS(p);
ND_PRINT((ndo, "%s(label %u",
(label_stack_depth && ndo->ndo_vflag) ? "\n\t" : " ",
MPLS_LABEL(label_entry)));
label_stack_depth++;
if (ndo->ndo_vflag &&
MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
ND_PRINT((ndo, " (%s)", mpls_labelname[MPLS_LABEL(label_entry)]));
ND_PRINT((ndo, ", exp %u", MPLS_EXP(label_entry)));
if (MPLS_STACK(label_entry))
ND_PRINT((ndo, ", [S]"));
ND_PRINT((ndo, ", ttl %u)", MPLS_TTL(label_entry)));
p += sizeof(label_entry);
} while (!MPLS_STACK(label_entry));
/*
* Try to figure out the packet type.
*/
switch (MPLS_LABEL(label_entry)) {
case 0: /* IPv4 explicit NULL label */
case 3: /* IPv4 implicit NULL label */
pt = PT_IPV4;
break;
case 2: /* IPv6 explicit NULL label */
pt = PT_IPV6;
break;
default:
/*
* Generally there's no indication of protocol in MPLS label
* encoding.
*
* However, draft-hsmit-isis-aal5mux-00.txt describes a
* technique for encapsulating IS-IS and IP traffic on the
* same ATM virtual circuit; you look at the first payload
* byte to determine the network layer protocol, based on
* the fact that
*
* 1) the first byte of an IP header is 0x45-0x4f
* for IPv4 and 0x60-0x6f for IPv6;
*
* 2) the first byte of an OSI CLNP packet is 0x81,
* the first byte of an OSI ES-IS packet is 0x82,
* and the first byte of an OSI IS-IS packet is
* 0x83;
*
* so the network layer protocol can be inferred from the
* first byte of the packet, if the protocol is one of the
* ones listed above.
*
* Cisco sends control-plane traffic MPLS-encapsulated in
* this fashion.
*/
switch(*p) {
case 0x45:
case 0x46:
case 0x47:
case 0x48:
case 0x49:
case 0x4a:
case 0x4b:
case 0x4c:
case 0x4d:
case 0x4e:
case 0x4f:
pt = PT_IPV4;
break;
case 0x60:
case 0x61:
case 0x62:
case 0x63:
case 0x64:
case 0x65:
case 0x66:
case 0x67:
case 0x68:
case 0x69:
case 0x6a:
case 0x6b:
case 0x6c:
//.........这里部分代码省略.........
开发者ID:0-kaladin,项目名称:ad-away,代码行数:101,代码来源:print-mpls.c
示例10: slow_print
void
slow_print(netdissect_options *ndo,
const u_char *pptr, u_int len)
{
int print_version;
u_int subtype;
ndo->ndo_protocol = "slow";
if (len < 1)
goto tooshort;
ND_TCHECK_1(pptr);
subtype = EXTRACT_U_1(pptr);
/*
* Sanity checking of the header.
*/
switch (subtype) {
case SLOW_PROTO_LACP:
if (len < 2)
goto tooshort;
ND_TCHECK_1(pptr + 1);
if (EXTRACT_U_1(pptr + 1) != LACP_VERSION) {
ND_PRINT("LACP version %u packet not supported", EXTRACT_U_1(pptr + 1));
return;
}
print_version = 1;
break;
case SLOW_PROTO_MARKER:
if (len < 2)
goto tooshort;
ND_TCHECK_1(pptr + 1);
if (EXTRACT_U_1(pptr + 1) != MARKER_VERSION) {
ND_PRINT("MARKER version %u packet not supported", EXTRACT_U_1(pptr + 1));
return;
}
print_version = 1;
break;
case SLOW_PROTO_OAM: /* fall through */
print_version = 0;
break;
default:
/* print basic information and exit */
print_version = -1;
break;
}
if (print_version == 1) {
ND_PRINT("%sv%u, length %u",
tok2str(slow_proto_values, "unknown (%u)", subtype),
EXTRACT_U_1((pptr + 1)),
len);
} else {
/* some slow protos don't have a version number in the header */
ND_PRINT("%s, length %u",
tok2str(slow_proto_values, "unknown (%u)", subtype),
len);
}
/* unrecognized subtype */
if (print_version == -1) {
print_unknown_data(ndo, pptr, "\n\t", len);
return;
}
if (!ndo->ndo_vflag)
return;
switch (subtype) {
default: /* should not happen */
break;
case SLOW_PROTO_OAM:
/* skip subtype */
len -= 1;
pptr += 1;
slow_oam_print(ndo, pptr, len);
break;
case SLOW_PROTO_LACP: /* LACP and MARKER share the same semantics */
case SLOW_PROTO_MARKER:
/* skip subtype and version */
len -= 2;
pptr += 2;
slow_marker_lacp_print(ndo, pptr, len, subtype);
break;
}
return;
tooshort:
if (!ndo->ndo_vflag)
ND_PRINT(" (packet is too short)");
else
ND_PRINT("\n\t\t packet is too short");
return;
trunc:
ND_PRINT("%s", tstr);
//.........这里部分代码省略.........
开发者ID:Wilm0r,项目名称:tcpdump,代码行数:101,代码来源:print-slow.c
示例11: slow_marker_lacp_print
static void
slow_marker_lacp_print(netdissect_options *ndo,
const u_char *tptr, u_int tlen,
u_int proto_subtype)
{
const struct tlv_header_t *tlv_header;
const u_char *tlv_tptr;
u_int tlv_type, tlv_len, tlv_tlen;
union {
const struct lacp_marker_tlv_terminator_t *lacp_marker_tlv_terminator;
const struct lacp_tlv_actor_partner_info_t *lacp_tlv_actor_partner_info;
const struct lacp_tlv_collector_info_t *lacp_tlv_collector_info;
const struct marker_tlv_marker_info_t *marker_tlv_marker_info;
} tlv_ptr;
while(tlen>0) {
/* is the packet big enough to include the tlv header ? */
if (tlen < sizeof(struct tlv_header_t))
goto tooshort;
/* did we capture enough for fully decoding the tlv header ? */
ND_TCHECK_LEN(tptr, sizeof(struct tlv_header_t));
tlv_header = (const struct tlv_header_t *)tptr;
tlv_type = EXTRACT_U_1(tlv_header->type);
tlv_len = EXTRACT_U_1(tlv_header->length);
ND_PRINT("\n\t%s TLV (0x%02x), length %u",
tok2str(slow_tlv_values,
"Unknown",
(proto_subtype << 8) + tlv_type),
tlv_type,
tlv_len);
if (tlv_type == LACP_MARKER_TLV_TERMINATOR) {
/*
* This TLV has a length of zero, and means there are no
* more TLVs to process.
*/
return;
}
/* length includes the type and length fields */
if (tlv_len < sizeof(struct tlv_header_t)) {
ND_PRINT("\n\t ERROR: illegal length - should be >= %lu",
(unsigned long) sizeof(struct tlv_header_t));
return;
}
/* is the packet big enough to include the tlv ? */
if (tlen < tlv_len)
goto tooshort;
/* did we capture enough for fully decoding the tlv ? */
ND_TCHECK_LEN(tptr, tlv_len);
tlv_tptr=tptr+sizeof(struct tlv_header_t);
tlv_tlen=tlv_len-sizeof(struct tlv_header_t);
switch((proto_subtype << 8) + tlv_type) {
/* those two TLVs have the same structure -> fall through */
case ((SLOW_PROTO_LACP << 8) + LACP_TLV_ACTOR_INFO):
case ((SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO):
if (tlv_tlen !=
sizeof(struct lacp_tlv_actor_partner_info_t)) {
ND_PRINT("\n\t ERROR: illegal length - should be %lu",
(unsigned long) (sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_actor_partner_info_t)));
goto badlength;
}
tlv_ptr.lacp_tlv_actor_partner_info = (const struct lacp_tlv_actor_partner_info_t *)tlv_tptr;
ND_PRINT("\n\t System %s, System Priority %u, Key %u"
", Port %u, Port Priority %u\n\t State Flags [%s]",
etheraddr_string(ndo, tlv_ptr.lacp_tlv_actor_partner_info->sys),
EXTRACT_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->sys_pri),
EXTRACT_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->key),
EXTRACT_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->port),
EXTRACT_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->port_pri),
bittok2str(lacp_tlv_actor_partner_info_state_values,
"none",
EXTRACT_U_1(tlv_ptr.lacp_tlv_actor_partner_info->state)));
break;
case ((SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO):
if (tlv_tlen !=
sizeof(struct lacp_tlv_collector_info_t)) {
ND_PRINT("\n\t ERROR: illegal length - should be %lu",
(unsigned long) (sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_collector_info_t)));
goto badlength;
}
tlv_ptr.lacp_tlv_collector_info = (const struct lacp_tlv_collector_info_t *)tlv_tptr;
ND_PRINT("\n\t Max Delay %u",
EXTRACT_BE_U_2(tlv_ptr.lacp_tlv_collector_info->max_delay));
break;
case ((SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO):
//.........这里部分代码省略.........
开发者ID:Wilm0r,项目名称:tcpdump,代码行数:101,代码来源:print-slow.c
示例12: print_internal
static void
print_internal(netdissect_options *ndo, const struct internal_tipc_pkthdr *ap)
{
u_int32_t w0, w1, w2, w4, w5, w9;
u_int user;
u_int hsize;
u_int msize;
u_int mtype;
u_int seq_gap;
u_int broadcast_ack;
u_int bc_gap_after;
u_int bc_gap_to;
u_int prev_node;
u_int last_sent_frag;
u_int next_sent_frag;
u_int sess_no;
u_int orig_node;
u_int dest_node;
u_int trans_seq;
u_int msg_cnt;
u_int link_tol;
ND_TCHECK(ap->dest_node);
w0 = EXTRACT_32BITS(&ap->w0);
user = TIPC_USER(w0);
hsize = TIPC_HSIZE(w0);
msize = TIPC_MSIZE(w0);
w1 = EXTRACT_32BITS(&ap->w1);
mtype = TIPC_MTYPE(w1);
orig_node = EXTRACT_32BITS(&ap->orig_node);
dest_node = EXTRACT_32BITS(&ap->dest_node);
ND_PRINT((ndo, "TIPC v%u.0 %u.%u.%u > %u.%u.%u, headerlength %u bytes, MessageSize %u bytes, %s, messageType %s (0x%08x)",
TIPC_VER(w0),
TIPC_ZONE(orig_node), TIPC_CLUSTER(orig_node), TIPC_NODE(orig_node),
TIPC_ZONE(dest_node), TIPC_CLUSTER(dest_node), TIPC_NODE(dest_node),
hsize*4, msize,
tok2str(tipcuser_values, "unknown", user),
tok2str(tipcmtype_values, "Unknown", mtype), w1));
if (ndo->ndo_vflag) {
ND_TCHECK(*ap);
seq_gap = TIPC_SEQ_GAP(w1);
broadcast_ack = TIPC_BROADCAST_ACK(w1);
w2 = EXTRACT_32BITS(&ap->w2);
bc_gap_after = TIPC_BC_GAP_AFTER(w2);
bc_gap_to = TIPC_BC_GAP_TO(w2);
prev_node = EXTRACT_32BITS(&ap->prev_node);
w4 = EXTRACT_32BITS(&ap->w4);
last_sent_frag = TIPC_LAST_SENT_FRAG(w4);
next_sent_frag = TIPC_NEXT_SENT_FRAG(w4);
w5 = EXTRACT_32BITS(&ap->w5);
sess_no = TIPC_SESS_NO(w5);
trans_seq = EXTRACT_32BITS(&ap->trans_seq);
w9 = EXTRACT_32BITS(&ap->w9);
msg_cnt = TIPC_MSG_CNT(w9);
link_tol = TIPC_LINK_TOL(w9);
ND_PRINT((ndo, "\n\tPrevious Node %u.%u.%u, Session No. %u, Broadcast Ack %u, Sequence Gap %u, Broadcast Gap After %u, Broadcast Gap To %u, Last Sent Packet No. %u, Next sent Packet No. %u, Transport Sequence %u, msg_count %u, Link Tolerance %u",
TIPC_ZONE(prev_node), TIPC_CLUSTER(prev_node), TIPC_NODE(prev_node),
sess_no, broadcast_ack, seq_gap, bc_gap_after, bc_gap_to,
last_sent_frag, next_sent_frag, trans_seq, msg_cnt,
link_tol));
}
return;
trunc:
ND_PRINT((ndo, "[|TIPC]"));
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:67,代码来源:print-tipc.c
示例13: print_payload
static void
print_payload(netdissect_options *ndo, const struct payload_tipc_pkthdr *ap)
{
u_int32_t w0, w1, w2;
u_int user;
u_int hsize;
u_int msize;
u_int mtype;
u_int broadcast_ack;
u_int link_ack;
u_int link_seq;
u_int prev_node;
u_int orig_port;
u_int dest_port;
u_int orig_node;
u_int dest_node;
ND_TCHECK(ap->dest_port);
w0 = EXTRACT_32BITS(&ap->w0);
user = TIPC_USER(w0);
hsize = TIPC_HSIZE(w0);
msize = TIPC_MSIZE(w0);
w1 = EXTRACT_32BITS(&ap->w1);
mtype = TIPC_MTYPE(w1);
prev_node = EXTRACT_32BITS(&ap->prev_node);
orig_port = EXTRACT_32BITS(&ap->orig_port);
dest_port = EXTRACT_32BITS(&ap->dest_port);
if (hsize <= 6) {
ND_PRINT((ndo, "TIPC v%u.0 %u.%u.%u:%u > %u, headerlength %u bytes, MessageSize %u bytes, %s, messageType %s",
TIPC_VER(w0),
TIPC_ZONE(prev_node), TIPC_CLUSTER(prev_node), TIPC_NODE(prev_node),
orig_port, dest_port,
hsize*4, msize,
tok2str(tipcuser_values, "unknown", user),
tok2str(tipcmtype_values, "Unknown", mtype)));
} else {
ND_TCHECK(ap->dest_node);
orig_node = EXTRACT_32BITS(&ap->orig_node);
dest_node = EXTRACT_32BITS(&ap->dest_node);
ND_PRINT((ndo, "TIPC v%u.0 %u.%u.%u:%u > %u.%u.%u:%u, headerlength %u bytes, MessageSize %u bytes, %s, messageType %s",
TIPC_VER(w0),
TIPC_ZONE(orig_node), TIPC_CLUSTER(orig_node), TIPC_NODE(orig_node),
orig_port,
TIPC_ZONE(dest_node), TIPC_CLUSTER(dest_node), TIPC_NODE(dest_node),
dest_port,
hsize*4, msize,
tok2str(tipcuser_values, "unknown", user),
tok2str(tipcmtype_values, "Unknown", mtype)));
if (ndo->ndo_vflag) {
broadcast_ack = TIPC_BROADCAST_ACK(w1);
w2 = EXTRACT_32BITS(&ap->w2);
link_ack = TIPC_LINK_ACK(w2);
link_seq = TIPC_LINK_SEQ(w2);
ND_PRINT((ndo, "\n\tPrevious Node %u.%u.%u, Broadcast Ack %u, Link Ack %u, Link Sequence %u",
TIPC_ZONE(prev_node), TIPC_CLUSTER(prev_node), TIPC_NODE(prev_node),
broadcast_ack, link_ack, link_seq));
}
}
return;
trunc:
ND_PRINT((ndo, "[|TIPC]"));
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:64,代码来源:print-tipc.c
示例14: rfc1048_print
static void
rfc1048_print(netdissect_options *ndo,
register const u_char *bp)
{
register uint16_t tag;
register u_int len;
register const char *cp;
register char c;
int first, idx;
uint32_t ul;
uint16_t us;
uint8_t uc, subopt, suboptlen;
ND_PRINT((ndo, "\n\t Vendor-rfc1048 Extensions"));
/* Step over magic cookie */
ND_PRINT((ndo, "\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp)));
bp += sizeof(int32_t);
/* Loop while we there is a tag left in the buffer */
while (ND_TTEST2(*bp, 1)) {
tag = *bp++;
if (tag == TAG_PAD && ndo->ndo_vflag < 3)
continue;
if (tag == TAG_END && ndo->ndo_vflag < 3)
return;
if (tag == TAG_EXTENDED_OPTION) {
ND_TCHECK2(*(bp + 1), 2);
tag = EXTRACT_16BITS(bp + 1);
/* XXX we don't know yet if the IANA will
* preclude overlap of 1-byte and 2-byte spaces.
* If not, we need to offset tag after this step.
*/
cp = tok2str(xtag2str, "?xT%u", tag);
} else
cp = tok2str(tag2str, "?T%u", tag);
c = *cp++;
if (tag == TAG_PAD || tag == TAG_END)
len = 0;
else {
/* Get the length; check for truncation */
ND_TCHECK2(*bp, 1);
len = *bp++;
}
ND_PRINT((ndo, "\n\t %s Option %u, length %u%s", cp, tag, len,
len > 0 ? ": " : ""));
if (tag == TAG_PAD && ndo->ndo_vflag > 2) {
u_int ntag = 1;
while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) {
bp++;
ntag++;
}
if (ntag > 1)
ND_PRINT((ndo, ", occurs %u", ntag));
}
if (!ND_TTEST2(*bp, len)) {
ND_PRINT((ndo, "[|rfc1048 %u]", len));
return;
}
if (tag == TAG_DHCP_MESSAGE && len == 1) {
uc = *bp++;
ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)));
continue;
}
if (tag == TAG_PARM_REQUEST) {
idx = 0;
while (len-- > 0) {
uc = *bp++;
cp = tok2str(tag2str, "?Option %u", uc);
if (idx % 4 == 0)
ND_PRINT((ndo, "\n\t "));
else
ND_PRINT((ndo, ", "));
ND_PRINT((ndo, "%s", cp + 1));
idx++;
}
continue;
}
if (tag == TAG_EXTENDED_REQUEST) {
first = 1;
while (len > 1) {
len -= 2;
us = EXTRACT_16BITS(bp);
bp += 2;
cp = tok2str(xtag2str, "?xT%u", us);
if (!first)
ND_PRINT((ndo, "+"));
ND_PRINT((ndo, "%s", cp + 1));
first = 0;
}
continue;
}
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:freebsd,代码行数:101,代码来源:print-bootp.c
示例15: lmp_print_data_link_subobjs
static int
lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr,
int total_subobj_len, int offset)
{
int hexdump = FALSE;
int subobj_type, subobj_len;
union { /* int to float conversion buffer */
float f;
uint32_t i;
} bw;
while (total_subobj_len > 0 && hexdump == FALSE ) {
subobj_type = EXTRACT_U_1(obj_tptr + offset);
subobj_len = EXTRACT_U_1(obj_tptr + offset + 1);
ND_PRINT("\n\t Subobject, Type: %s (%u), Length: %u",
tok2str(lmp_data_link_subobj,
"Unknown",
subobj_type),
subobj_type,
subobj_len);
if (subobj_len < 4) {
ND_PRINT(" (too short)");
break;
}
if ((subobj_len % 4) != 0) {
ND_PRINT(" (not a multiple of 4)");
break;
}
if (total_subobj_len < subobj_len) {
ND_PRINT(" (goes past the end of the object)");
break;
}
switch(subobj_type) {
case INT_SWITCHING_TYPE_SUBOBJ:
ND_PRINT("\n\t Switching Type: %s (%u)",
tok2str(gmpls_switch_cap_values,
"Unknown",
EXTRACT_U_1(obj_tptr + offset + 2)),
EXTRACT_U_1(obj_tptr + offset + 2));
ND_PRINT("\n\t Encoding Type: %s (%u)",
tok2str(gmpls_encoding_values,
"Unknown",
EXTRACT_U_1(obj_tptr + offset + 3)),
EXTRACT_U_1(obj_tptr + offset + 3));
bw.i = EXTRACT_BE_U_4(obj_tptr + offset + 4);
ND_PRINT("\n\t Min Reservable Bandwidth: %.3f Mbps",
bw.f*8/1000000);
bw.i = EXTRACT_BE_U_4(obj_tptr + offset + 8);
ND_PRINT("\n\t Max Reservable Bandwidth: %.3f Mbps",
bw.f*8/1000000);
break;
case WAVELENGTH_SUBOBJ:
ND_PRINT("\n\t Wavelength: %u",
EXTRACT_BE_U_4(obj_tptr + offset + 4));
break;
default:
/* Any Unknown Subobject ==> Exit loop */
hexdump=TRUE;
break;
}
total_subobj_len-=subobj_len;
offset+=subobj_len;
}
return (hexdump);
}
开发者ID:biot,项目名称:tcpdump,代码行数:66,代码来源:print-lmp.c
示例16: _geneve_print
void
_geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
uint8_t ver_opt;
uint version;
uint8_t flags;
uint16_t prot;
uint32_t vni;
uint8_t reserved;
u_int opts_len;
ND_PRINT((ndo, "Geneve"));
ND_TCHECK2(*bp, 8);
ver_opt = *bp;
bp += 1;
len -= 1;
version = ver_opt >> VER_SHIFT;
if (version != 0) {
ND_PRINT((ndo, " ERROR: unknown-version %u", version));
return;
}
flags = *bp;
bp += 1;
len -= 1;
prot = EXTRACT_16BITS(bp);
bp += 2;
len -= 2;
vni = EXTRACT_24BITS(bp);
bp += 3;
len -= 3;
reserved = *bp;
bp += 1;
len -= 1;
ND_PRINT((ndo, ", Flags [%s]",
bittok2str_nosep(geneve_flag_values, "none", flags)));
ND_PRINT((ndo, ", vni 0x%x", vni));
if (reserved)
ND_PRINT((ndo, ", rsvd 0x%x", reserved));
if (ndo->ndo_eflag)
ND_PRINT((ndo, ", proto %s (0x%04x)",
tok2str(ethertype_values, "unknown", prot), prot));
opts_len = (ver_opt & HDR_OPTS_LEN_MASK) * 4;
if (len < opts_len) {
ND_PRINT((ndo, " truncated-geneve - %u bytes missing",
len - opts_len));
return;
}
ND_TCHECK2(*bp, opts_len);
if (opts_len > 0) {
ND_PRINT((ndo, ", options ["));
if (ndo->ndo_vflag)
geneve_opts_print(ndo, bp, opts_len);
else
ND_PRINT((ndo, "%u bytes", opts_len));
ND_PRINT((ndo, "]"));
}
bp += opts_len;
len -= opts_len;
if (ndo->ndo_vflag < 1)
ND_PRINT((ndo, ": "));
else
ND_PRINT((ndo, "\n\t"));
if (ethertype_print(ndo, prot, bp, len, len) == 0) {
if (prot == ETHERTYPE_TEB)
ether_print(ndo, bp, len, len, NULL, NULL);
else
ND_PRINT((ndo, "geneve-proto-0x%x", prot));
}
return;
trunc:
ND_PRINT((ndo, " [|geneve]"));
}
开发者ID:RichardsonAlex,项目名称:cheribsd,代码行数:93,代码来源:print-geneve.c
示例17: lmp_print
void
lmp_print(netdissect_options *ndo,
const u_char *pptr, u_int len)
{
const struct lmp_common_header *lmp_com_header;
const struct lmp_object_header *lmp_obj_header;
const u_char *tptr,*obj_tptr;
u_int version_res, tlen, lmp_obj_len, lmp_obj_ctype, obj_tlen;
int hexdump;
u_int offset;
u_int link_type;
union { /* int to float conversion buffer */
float f;
uint32_t i;
} bw;
ndo->ndo_protocol = "lmp";
tptr=pptr;
lmp_com_header = (const struct lmp_common_header *)pptr;
ND_TCHECK_SIZE(lmp_com_header);
version_res = EXTRACT_BE_U_2(lmp_com_header->version_res);
/*
* Sanity checking of the header.
*/
if (LMP_EXTRACT_VERSION(version_res) != LMP_VERSION) {
ND_PRINT("LMP version %u packet not supported",
LMP_EXTRACT_VERSION(version_res));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
if (ndo->ndo_vflag < 1) {
ND_PRINT("LMPv%u %s Message, length: %u",
LMP_EXTRACT_VERSION(version_res),
tok2str(lmp_msg_type_values, "unknown (%u)",EXTRACT_U_1(lmp_com_header->msg_type)),
len);
return;
}
/* ok they seem to want to know everything - lets fully decode it */
tlen=EXTRACT_BE_U_2(lmp_com_header->length);
ND_PRINT("\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u",
LMP_EXTRACT_VERSION(version_res),
tok2str(lmp_msg_type_values, "unknown, type: %u",EXTRACT_U_1(lmp_com_header->msg_type)),
bittok2str(lmp_header_flag_values,"none",EXTRACT_U_1(lmp_com_header->flags)),
tlen);
if (tlen < sizeof(struct lmp_common_header)) {
ND_PRINT(" (too short)");
return;
}
if (tlen > len) {
ND_PRINT(" (too long)");
tlen = len;
}
tptr+=sizeof(struct lmp_common_header);
tlen-=sizeof(struct lmp_common_header);
while(tlen>0) {
/* did we capture enough for fully decoding the object header ? */
ND_TCHECK_LEN(tptr, sizeof(struct lmp_object_header));
lmp_obj_header = (const struct lmp_object_header *)tptr;
lmp_obj_len=EXTRACT_BE_U_2(lmp_obj_header->length);
lmp_obj_ctype=EXTRACT_U_1(lmp_obj_header->ctype)&0x7f;
ND_PRINT("\n\t %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u",
tok2str(lmp_obj_values,
"Unknown",
EXTRACT_U_1(lmp_obj_header->class_num)),
EXTRACT_U_1(lmp_obj_header->class_num),
tok2str(lmp_ctype_values,
"Unknown",
(EXTRACT_U_1(lmp_obj_header->class_num)<<8)+lmp_obj_ctype),
lmp_obj_ctype,
EXTRACT_U_1(lmp_obj_header->ctype)&0x80 ? "" : "non-",
lmp_obj_len);
if (lmp_obj_len < 4) {
ND_PRINT(" (too short)");
return;
}
if ((lmp_obj_len % 4) != 0) {
ND_PRINT(" (not a multiple of 4)");
return;
}
obj_tptr=tptr+sizeof(struct lmp_object_header);
obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header);
/* did we capture enough for fully decoding the object ? */
ND_TCHECK_LEN(tptr, lmp_obj_len);
hexdump=FALSE;
switch(EXTRACT_U_1(lmp_obj_header->class_num)) {
//.........这里部分代码省略.........
开发者ID:biot,项目名称:tcpdump,代码行数:101,代码来源:print-lmp.c
示例18: ip6_opt_print
static void
ip6_opt_print(netdissect_options *ndo, const u_char *bp, int len)
{
int i;
int optlen = 0;
if (len == 0)
return;
for (i = 0; i < len; i += optlen) {
if (bp[i] == IP6OPT_PAD1)
optlen = 1;
else {
if (i + 1 < len)
optlen = bp[i + 1] + 2;
else
goto trunc;
}
if (i + optlen > len)
goto trunc;
switch (bp[i]) {
case IP6OPT_PAD1:
ND_PRINT((ndo, "(pad1)"));
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
ND_PRINT((ndo, "(padn: trunc)"));
goto trunc;
}
ND_PRINT((ndo, "(padn)"));
break;
case IP6OPT_ROUTER_ALERT:
if (len - i < IP6OPT_RTALERT_LEN) {
ND_PRINT((ndo, "(rtalert: trunc)"));
goto trunc;
}
if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) {
ND_PRINT((ndo, "(rtalert: invalid len %d)", bp[i + 1]));
goto trunc;
}
ND_PRINT((ndo, "(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2])));
break;
case IP6OPT_JUMBO:
if (len - i < IP6OPT_JUMBO_LEN) {
ND_PRINT((ndo, "(jumbo: trunc)"));
goto trunc;
}
if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) {
ND_PRINT((ndo, "(jumbo: invalid len %d)", bp[i + 1]));
goto trunc;
}
ND_PRINT((ndo, "(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2])));
break;
case IP6OPT_HOME_ADDRESS:
if (len - i < IP6OPT_HOMEADDR_MINLEN) {
ND_PRINT((ndo, "(homeaddr: trunc)"));
goto trunc;
}
if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) {
ND_PRINT((ndo, "(homeaddr: invalid len %d)", bp[i + 1]));
goto trunc;
}
ND_PRINT((ndo, "(homeaddr: %s", ip6addr_string(ndo, &bp[i + 2])));
if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) {
ip6_sopt_print(ndo, &bp[i + IP6OPT_HOMEADDR_MINLEN],
(optlen - IP6OPT_HOMEADDR_MINLEN));
}
|
请发表评论