diff options
Diffstat (limited to 'contrib/tcpdump')
-rw-r--r-- | contrib/tcpdump/addrtoname.c | 90 | ||||
-rw-r--r-- | contrib/tcpdump/ethertype.h | 5 | ||||
-rw-r--r-- | contrib/tcpdump/interface.h | 20 | ||||
-rw-r--r-- | contrib/tcpdump/ppp.h | 6 | ||||
-rw-r--r-- | contrib/tcpdump/print-atm.c | 4 | ||||
-rw-r--r-- | contrib/tcpdump/print-ether.c | 15 | ||||
-rw-r--r-- | contrib/tcpdump/print-fddi.c | 6 | ||||
-rw-r--r-- | contrib/tcpdump/print-fr.c | 276 | ||||
-rw-r--r-- | contrib/tcpdump/print-ip.c | 8 | ||||
-rw-r--r-- | contrib/tcpdump/print-ip6.c | 7 | ||||
-rw-r--r-- | contrib/tcpdump/print-ipx.c | 4 | ||||
-rw-r--r-- | contrib/tcpdump/print-isoclns.c | 139 | ||||
-rw-r--r-- | contrib/tcpdump/print-llc.c | 109 | ||||
-rw-r--r-- | contrib/tcpdump/print-null.c | 4 | ||||
-rw-r--r-- | contrib/tcpdump/print-pim.c | 20 | ||||
-rw-r--r-- | contrib/tcpdump/print-token.c | 6 | ||||
-rw-r--r-- | contrib/tcpdump/tcpdump-stdinc.h | 4 | ||||
-rw-r--r-- | contrib/tcpdump/tcpdump.1 | 70 | ||||
-rw-r--r-- | contrib/tcpdump/tcpdump.c | 57 |
19 files changed, 557 insertions, 293 deletions
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c index bb0f2f5..d2e7b48 100644 --- a/contrib/tcpdump/addrtoname.c +++ b/contrib/tcpdump/addrtoname.c @@ -25,7 +25,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.5 2005/04/25 08:43:05 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.7 2005/09/29 07:46:45 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -90,7 +90,6 @@ struct hnamemem tporttable[HASHNAMESIZE]; struct hnamemem uporttable[HASHNAMESIZE]; struct hnamemem eprototable[HASHNAMESIZE]; struct hnamemem dnaddrtable[HASHNAMESIZE]; -struct hnamemem llcsaptable[HASHNAMESIZE]; struct hnamemem ipxsaptable[HASHNAMESIZE]; #if defined(INET6) && defined(WIN32) @@ -463,9 +462,10 @@ lookup_protoid(const u_char *pi) const char * etheraddr_string(register const u_char *ep) { - register u_int i, oui; + register int i; register char *cp; register struct enamemem *tp; + int oui; char buf[BUFSIZE]; tp = lookup_emem(ep); @@ -477,9 +477,9 @@ etheraddr_string(register const u_char *ep) /* * We don't cast it to "const struct ether_addr *" - * because some systems don't modify the Ethernet - * address but fail to declare the second argument - * as a "const" pointer. + * because some systems fail to declare the second + * argument as a "const" pointer, even though they + * don't modify what it points to. */ if (ether_ntohost(buf2, (struct ether_addr *)ep) == 0) { tp->e_name = strdup(buf2); @@ -488,20 +488,20 @@ etheraddr_string(register const u_char *ep) } #endif cp = buf; - oui=EXTRACT_24BITS(ep); + oui = EXTRACT_24BITS(ep); *cp++ = hex[*ep >> 4 ]; *cp++ = hex[*ep++ & 0xf]; - for (i = 5; (int)--i >= 0;) { - *cp++ = ':'; - *cp++ = hex[*ep >> 4 ]; - *cp++ = hex[*ep++ & 0xf]; - } - - if (!nflag) { - snprintf(cp,BUFSIZE," (oui %s)", - tok2str(oui_values,"Unknown",oui)); - } else - *cp = '\0'; + for (i = 5; --i >= 0;) { + *cp++ = ':'; + *cp++ = hex[*ep >> 4 ]; + *cp++ = hex[*ep++ & 0xf]; + } + + if (!nflag) { + snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)", + tok2str(oui_values, "Unknown", oui)); + } else + *cp = '\0'; tp->e_name = strdup(buf); return (tp->e_name); } @@ -587,25 +587,6 @@ protoid_string(register const u_char *pi) return (tp->p_name); } -const char * -llcsap_string(u_char sap) -{ - register struct hnamemem *tp; - register u_int32_t i = sap; - char buf[sizeof("sap 00")]; - - for (tp = &llcsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) - if (tp->addr == i) - return (tp->name); - - tp->addr = i; - tp->nxt = newhnamemem(); - - snprintf(buf, sizeof(buf), "sap %02x", sap & 0xff); - tp->name = strdup(buf); - return (tp->name); -} - #define ISONSAP_MAX_LENGTH 20 const char * isonsap_string(const u_char *nsap, register u_int nsap_length) @@ -874,40 +855,6 @@ init_etherarray(void) } } -static struct tok llcsap_db[] = { - { LLCSAP_NULL, "null" }, - { LLCSAP_8021B_I, "802.1b-gsap" }, - { LLCSAP_8021B_G, "802.1b-isap" }, - { LLCSAP_IP, "ip-sap" }, - { LLCSAP_PROWAYNM, "proway-nm" }, - { LLCSAP_8021D, "802.1d" }, - { LLCSAP_RS511, "eia-rs511" }, - { LLCSAP_ISO8208, "x.25/llc2" }, - { LLCSAP_PROWAY, "proway" }, - { LLCSAP_SNAP, "snap" }, - { LLCSAP_IPX, "IPX" }, - { LLCSAP_NETBEUI, "netbeui" }, - { LLCSAP_ISONS, "iso-clns" }, - { LLCSAP_GLOBAL, "global" }, - { 0, NULL } -}; - -static void -init_llcsaparray(void) -{ - register int i; - register struct hnamemem *table; - - for (i = 0; llcsap_db[i].s != NULL; i++) { - table = &llcsaptable[llcsap_db[i].v]; - while (table->name) - table = table->nxt; - table->name = llcsap_db[i].s; - table->addr = llcsap_db[i].v; - table->nxt = newhnamemem(); - } -} - static struct tok ipxsap_db[] = { { 0x0000, "Unknown" }, { 0x0001, "User" }, @@ -1164,7 +1111,6 @@ init_addrtoname(u_int32_t localnet, u_int32_t mask) init_etherarray(); init_servarray(); init_eprotoarray(); - init_llcsaparray(); init_protoidarray(); init_ipxsaparray(); } diff --git a/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h index 808cdcf..1555b4d 100644 --- a/contrib/tcpdump/ethertype.h +++ b/contrib/tcpdump/ethertype.h @@ -19,7 +19,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * - * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.24 2004/10/07 16:04:07 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.24.2.1 2005/07/10 14:51:10 hannes Exp $ (LBL) * $FreeBSD$ */ @@ -111,6 +111,9 @@ #ifndef ETHERTYPE_PPP #define ETHERTYPE_PPP 0x880b #endif +#ifndef ETHERTYPE_SLOW +#define ETHERTYPE_SLOW 0x8809 +#endif #ifndef ETHERTYPE_MPLS #define ETHERTYPE_MPLS 0x8847 #endif diff --git a/contrib/tcpdump/interface.h b/contrib/tcpdump/interface.h index 3fb09b4..d26eb1c 100644 --- a/contrib/tcpdump/interface.h +++ b/contrib/tcpdump/interface.h @@ -19,7 +19,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * - * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244 2005/04/06 21:33:27 mcr Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.18 2005/09/29 07:46:45 hannes Exp $ (LBL) * $FreeBSD$ */ @@ -157,7 +157,6 @@ extern void safeputchar(int); extern void safeputs(const char *); extern const char *isonsap_string(const u_char *, register u_int); -extern const char *llcsap_string(u_char); extern const char *protoid_string(const u_char *); extern const char *ipxsap_string(u_short); extern const char *dnname_string(u_short); @@ -168,11 +167,13 @@ extern const char *dnnum_string(u_short); #include <pcap.h> extern int print_unknown_data(const u_char *, const char *,int); -extern void ascii_print_with_offset(const char *, const u_char *, u_int, u_int); -extern void ascii_print(const char *, const u_char *, u_int); +extern void ascii_print(const u_char *, u_int); +extern void hex_and_ascii_print_with_offset(const char *, const u_char *, + u_int, u_int); +extern void hex_and_ascii_print(const char *, const u_char *, u_int); extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int); -extern void telnet_print(const u_char *, u_int); extern void hex_print(const char *, const u_char *, u_int); +extern void telnet_print(const u_char *, u_int); extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *); extern int llc_print(const u_char *, u_int, u_int, const u_char *, const u_char *, u_short *); @@ -204,6 +205,7 @@ extern void fddi_print(const u_char *, u_int, u_int); extern u_int fddi_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int fr_print(register const u_char *, u_int); +extern u_int mfr_print(register const u_char *, u_int); extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *, const u_char *); @@ -252,6 +254,7 @@ extern u_int lane_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int cip_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int chdlc_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int chdlc_print(register const u_char *, u_int); extern u_int juniper_atm1_print(const struct pcap_pkthdr *, const u_char *); extern u_int juniper_atm2_print(const struct pcap_pkthdr *, const u_char *); extern u_int juniper_mfr_print(const struct pcap_pkthdr *, register const u_char *); @@ -263,6 +266,10 @@ extern u_int juniper_ggsn_print(const struct pcap_pkthdr *, const u_char *); extern u_int juniper_es_print(const struct pcap_pkthdr *, const u_char *); extern u_int juniper_monitor_print(const struct pcap_pkthdr *, const u_char *); extern u_int juniper_services_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_ether_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_ppp_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_frelay_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_chdlc_print(const struct pcap_pkthdr *, const u_char *); extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *); extern void snmp_print(const u_char *, u_int); extern void sunrpcrequest_print(const u_char *, u_int, const u_char *); @@ -285,12 +292,14 @@ extern const char *nt_errstr(u_int32_t); extern void print_data(const unsigned char *, int); extern void l2tp_print(const u_char *, u_int); extern void vrrp_print(const u_char *, u_int, int); +extern void slow_print(const u_char *, u_int); extern void pgm_print(const u_char *, u_int, const u_char *); extern void cdp_print(const u_char *, u_int, u_int); extern void stp_print(const u_char *, u_int); extern void radius_print(const u_char *, u_int); extern void lwres_print(const u_char *, u_int); extern void pptp_print(const u_char *); +extern void dccp_print(const u_char *, const u_char *, u_int); extern void sctp_print(const u_char *, const u_char *, u_int); extern void mpls_print(const u_char *, u_int); extern void mpls_lsp_ping_print(const u_char *, u_int); @@ -347,6 +356,7 @@ extern netdissect_options *gndo; #define Xflag gndo->ndo_Xflag #define Cflag gndo->ndo_Cflag #define Aflag gndo->ndo_Aflag +#define suppress_default_print gndo->ndo_suppress_default_print #define packettype gndo->ndo_packettype #define tcpmd5secret gndo->ndo_tcpmd5secret #define Wflag gndo->ndo_Wflag diff --git a/contrib/tcpdump/ppp.h b/contrib/tcpdump/ppp.h index 484ea46..9c4b473 100644 --- a/contrib/tcpdump/ppp.h +++ b/contrib/tcpdump/ppp.h @@ -19,25 +19,19 @@ */ #define PPP_HDRLEN 4 /* length of PPP header */ -#undef PPP_ADDRESS #define PPP_ADDRESS 0xff /* The address byte value */ -#undef PPP_CONTROL #define PPP_CONTROL 0x03 /* The control byte value */ #define PPP_WITHDIRECTION_IN 0x00 /* non-standard for DLT_PPP_WITHDIRECTION */ #define PPP_WITHDIRECTION_OUT 0x01 /* non-standard for DLT_PPP_WITHDIRECTION */ /* Protocol numbers */ -#ifndef PPP_IP #define PPP_IP 0x0021 /* Raw IP */ -#endif #define PPP_OSI 0x0023 /* OSI Network Layer */ #define PPP_NS 0x0025 /* Xerox NS IDP */ #define PPP_DECNET 0x0027 /* DECnet Phase IV */ #define PPP_APPLE 0x0029 /* Appletalk */ -#ifndef PPP_IPX #define PPP_IPX 0x002b /* Novell IPX */ -#endif #define PPP_VJC 0x002d /* Van Jacobson Compressed TCP/IP */ #define PPP_VJNC 0x002f /* Van Jacobson Uncompressed TCP/IP */ #define PPP_BRPDU 0x0031 /* Bridging PDU */ diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c index 4e061b0..1fdae6e 100644 --- a/contrib/tcpdump/print-atm.c +++ b/contrib/tcpdump/print-atm.c @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.2 2005/06/20 07:45:06 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.3 2005/07/07 01:24:34 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -108,7 +108,7 @@ atm_llc_print(const u_char *p, int length, int caplen) printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); } } diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c index a82fc93..57a3d8e 100644 --- a/contrib/tcpdump/print-ether.c +++ b/contrib/tcpdump/print-ether.c @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.2 2005/07/01 16:16:30 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.4 2005/07/10 14:47:57 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -67,6 +67,7 @@ const struct tok ethertype_values[] = { { ETHERTYPE_AARP, "Appletalk ARP" }, { ETHERTYPE_IPX, "IPX" }, { ETHERTYPE_PPP, "PPP" }, + { ETHERTYPE_SLOW, "Slow Protocols" }, { ETHERTYPE_PPPOED, "PPPoE D" }, { ETHERTYPE_PPPOES, "PPPoE S" }, { ETHERTYPE_EAPOL, "EAPOL" }, @@ -138,7 +139,7 @@ ether_print(const u_char *p, u_int length, u_int caplen) if (!eflag) ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN); - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); } } else if (ether_encap_print(ether_type, p, length, caplen, @@ -147,7 +148,7 @@ ether_print(const u_char *p, u_int length, u_int caplen) if (!eflag) ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN); - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); } } @@ -247,7 +248,7 @@ ether_encap_print(u_short ether_type, const u_char *p, ether_hdr_print(p - 18, length + 4); } - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p - 18, caplen + 4); return (1); @@ -272,7 +273,7 @@ ether_encap_print(u_short ether_type, const u_char *p, ether_hdr_print(p - 16, length + 2); } - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p - 16, caplen + 2); return (1); @@ -299,6 +300,10 @@ ether_encap_print(u_short ether_type, const u_char *p, } return (1); + case ETHERTYPE_SLOW: + slow_print(p, length); + return (1); + case ETHERTYPE_LOOPBACK: return (1); diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c index acb68a9..9166735 100644 --- a/contrib/tcpdump/print-fddi.c +++ b/contrib/tcpdump/print-fddi.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.64 2004/03/17 23:24:37 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.64.2.1 2005/07/07 01:24:35 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -282,7 +282,7 @@ fddi_print(const u_char *p, u_int length, u_int caplen) printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); } } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) @@ -292,7 +292,7 @@ fddi_print(const u_char *p, u_int length, u_int caplen) if (!eflag) fddi_hdr_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr), EDST(&ehdr)); - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); } } diff --git a/contrib/tcpdump/print-fr.c b/contrib/tcpdump/print-fr.c index 6e5798f..e1f9686 100644 --- a/contrib/tcpdump/print-fr.c +++ b/contrib/tcpdump/print-fr.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.4 2005/05/27 14:56:52 hannes Exp $ (LBL)"; + "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.12 2005/08/23 03:15:51 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -84,6 +84,20 @@ struct tok fr_header_flag_values[] = { { 0, NULL } }; +/* FRF.15 / FRF.16 */ +#define MFR_B_BIT 0x80 +#define MFR_E_BIT 0x40 +#define MFR_C_BIT 0x20 +#define MFR_BEC_MASK (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT) +#define MFR_CTRL_FRAME (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT) +#define MFR_FRAG_FRAME (MFR_B_BIT | MFR_E_BIT ) + +struct tok frf_flag_values[] = { + { MFR_B_BIT, "Begin" }, + { MFR_E_BIT, "End" }, + { MFR_C_BIT, "Control" }, + { 0, NULL } +}; /* Finds out Q.922 address length, DLCI and flags. Returns 0 on success * save the flags dep. on address length @@ -252,7 +266,6 @@ fr_print(register const u_char *p, u_int length) if (eflag) fr_hdr_print(length, addr_len, dlci, flags, nlpid); - p += hdr_len; length -= hdr_len; @@ -278,7 +291,7 @@ fr_print(register const u_char *p, u_int length) if (!eflag) fr_hdr_print(length + hdr_len, hdr_len, dlci, flags, nlpid); - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p - hdr_len, length + hdr_len); } break; @@ -307,6 +320,191 @@ fr_print(register const u_char *p, u_int length) } +#define MFR_CTRL_MSG_ADD_LINK 1 +#define MFR_CTRL_MSG_ADD_LINK_ACK 2 +#define MFR_CTRL_MSG_ADD_LINK_REJ 3 +#define MFR_CTRL_MSG_HELLO 4 +#define MFR_CTRL_MSG_HELLO_ACK 5 +#define MFR_CTRL_MSG_REMOVE_LINK 6 +#define MFR_CTRL_MSG_REMOVE_LINK_ACK 7 + +struct tok mfr_ctrl_msg_values[] = { + { MFR_CTRL_MSG_ADD_LINK, "Add Link" }, + { MFR_CTRL_MSG_ADD_LINK_ACK, "Add Link ACK" }, + { MFR_CTRL_MSG_ADD_LINK_REJ, "Add Link Reject" }, + { MFR_CTRL_MSG_HELLO, "Hello" }, + { MFR_CTRL_MSG_HELLO_ACK, "Hello ACK" }, + { MFR_CTRL_MSG_REMOVE_LINK, "Remove Link" }, + { MFR_CTRL_MSG_REMOVE_LINK_ACK, "Remove Link ACK" }, + { 0, NULL } +}; + +#define MFR_CTRL_IE_BUNDLE_ID 1 +#define MFR_CTRL_IE_LINK_ID 2 +#define MFR_CTRL_IE_MAGIC_NUM 3 +#define MFR_CTRL_IE_TIMESTAMP 5 +#define MFR_CTRL_IE_VENDOR_EXT 6 +#define MFR_CTRL_IE_CAUSE 7 + +struct tok mfr_ctrl_ie_values[] = { + { MFR_CTRL_IE_BUNDLE_ID, "Bundle ID"}, + { MFR_CTRL_IE_LINK_ID, "Link ID"}, + { MFR_CTRL_IE_MAGIC_NUM, "Magic Number"}, + { MFR_CTRL_IE_TIMESTAMP, "Timestamp"}, + { MFR_CTRL_IE_VENDOR_EXT, "Vendor Extension"}, + { MFR_CTRL_IE_CAUSE, "Cause"}, + { 0, NULL } +}; + +#define MFR_ID_STRING_MAXLEN 50 + +struct ie_tlv_header_t { + u_int8_t ie_type; + u_int8_t ie_len; +}; + +u_int +mfr_print(register const u_char *p, u_int length) +{ + u_int tlen,idx,hdr_len = 0; + u_int16_t sequence_num; + u_int8_t ie_type,ie_len; + const u_int8_t *tptr; + + +/* + * FRF.16 Link Integrity Control Frame + * + * 7 6 5 4 3 2 1 0 + * +----+----+----+----+----+----+----+----+ + * | B | E | C=1| 0 0 0 0 | EA | + * +----+----+----+----+----+----+----+----+ + * | 0 0 0 0 0 0 0 0 | + * +----+----+----+----+----+----+----+----+ + * | message type | + * +----+----+----+----+----+----+----+----+ + */ + + TCHECK2(*p, 4); /* minimum frame header length */ + + if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) { + printf("FRF.16 Control, Flags [%s], %s, length %u", + bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)), + tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]), + length); + tptr = p + 3; + tlen = length -3; + hdr_len = 3; + + if (!vflag) + return hdr_len; + + while (tlen>sizeof(struct ie_tlv_header_t)) { + TCHECK2(*tptr, sizeof(struct ie_tlv_header_t)); + ie_type=tptr[0]; + ie_len=tptr[1]; + + printf("\n\tIE %s (%u), length %u: ", + tok2str(mfr_ctrl_ie_values,"Unknown",ie_type), + ie_type, + ie_len); + + /* infinite loop check */ + if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t)) + return hdr_len; + + TCHECK2(*tptr,ie_len); + tptr+=sizeof(struct ie_tlv_header_t); + /* tlv len includes header */ + ie_len-=sizeof(struct ie_tlv_header_t); + tlen-=sizeof(struct ie_tlv_header_t); + + switch (ie_type) { + + case MFR_CTRL_IE_MAGIC_NUM: + printf("0x%08x",EXTRACT_32BITS(tptr)); + break; + + case MFR_CTRL_IE_BUNDLE_ID: /* same message format */ + case MFR_CTRL_IE_LINK_ID: + for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) { + if (*(tptr+idx) != 0) /* don't print null termination */ + safeputchar(*(tptr+idx)); + else + break; + } + break; + + case MFR_CTRL_IE_TIMESTAMP: + if (ie_len == sizeof(struct timeval)) { + ts_print((const struct timeval *)tptr); + break; + } + /* fall through and hexdump if no unix timestamp */ + + /* + * FIXME those are the defined IEs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case MFR_CTRL_IE_VENDOR_EXT: + case MFR_CTRL_IE_CAUSE: + + default: + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",ie_len); + break; + } + + /* do we want to see a hexdump of the IE ? */ + if (vflag > 1 ) + print_unknown_data(tptr,"\n\t ",ie_len); + + tlen-=ie_len; + tptr+=ie_len; + } + return hdr_len; + } +/* + * FRF.16 Fragmentation Frame + * + * 7 6 5 4 3 2 1 0 + * +----+----+----+----+----+----+----+----+ + * | B | E | C=0|seq. (high 4 bits) | EA | + * +----+----+----+----+----+----+----+----+ + * | sequence (low 8 bits) | + * +----+----+----+----+----+----+----+----+ + * | DLCI (6 bits) | CR | EA | + * +----+----+----+----+----+----+----+----+ + * | DLCI (4 bits) |FECN|BECN| DE | EA | + * +----+----+----+----+----+----+----+----+ + */ + + sequence_num = (p[0]&0x1e)<<7 | p[1]; + /* whole packet or first fragment ? */ + if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME || + (p[0] & MFR_BEC_MASK) == MFR_B_BIT) { + printf("FRF.16 Frag, seq %u, Flags [%s], ", + sequence_num, + bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))); + hdr_len = 2; + fr_print(p+hdr_len,length-hdr_len); + return hdr_len; + } + + /* must be a middle or the last fragment */ + printf("FRF.16 Frag, seq %u, Flags [%s]", + sequence_num, + bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))); + print_unknown_data(p,"\n\t",length); + + return hdr_len; + + trunc: + printf("[|mfr]"); + return length; +} + /* an NLPID of 0xb1 indicates a 2-byte * FRF.15 header * @@ -322,13 +520,6 @@ fr_print(register const u_char *p, u_int length) * +----+----+----+----+----+----+----+----+ */ -struct tok frf15_flag_values[] = { - { 0x80, "Begin" }, - { 0x40, "End" }, - { 0x20, "Control" }, - { 0, NULL } -}; - #define FR_FRF15_FRAGTYPE 0x01 static void @@ -336,13 +527,13 @@ frf15_print (const u_char *p, u_int length) { u_int16_t sequence_num, flags; - flags = p[0]&0xe0; + flags = p[0]&MFR_BEC_MASK; sequence_num = (p[0]&0x1e)<<7 | p[1]; printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u", sequence_num, - bittok2str(frf15_flag_values,"none",flags), - flags&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End", + bittok2str(frf_flag_values,"none",flags), + p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End", length); /* TODO: @@ -454,10 +645,10 @@ struct tok fr_lmi_report_type_ie_values[] = { { 0, NULL } }; -/* array of 16 codepages - currently we only support codepage 5 */ +/* array of 16 codepages - currently we only support codepage 1,5 */ static struct tok *fr_q933_ie_codesets[] = { NULL, - NULL, + fr_q933_ie_values_codeset5, NULL, NULL, NULL, @@ -474,22 +665,16 @@ static struct tok *fr_q933_ie_codesets[] = { NULL }; - -struct common_ie_header { - u_int8_t ie_id; - u_int8_t ie_len; -}; - -static int fr_q933_print_ie_codeset5(const struct common_ie_header *ie_p, +static int fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p); -typedef int (*codeset_pr_func_t)(const struct common_ie_header *ie_p, +typedef int (*codeset_pr_func_t)(const struct ie_tlv_header_t *ie_p, const u_char *p); -/* array of 16 codepages - currently we only support codepage 5 */ +/* array of 16 codepages - currently we only support codepage 1,5 */ static codeset_pr_func_t fr_q933_print_ie_codeset[] = { NULL, - NULL, + fr_q933_print_ie_codeset5, NULL, NULL, NULL, @@ -510,10 +695,11 @@ void q933_print(const u_char *p, u_int length) { const u_char *ptemp = p; - struct common_ie_header *ie_p; + struct ie_tlv_header_t *ie_p; int olen; int is_ansi = 0; u_int codeset; + u_int ie_is_known = 0; if (length < 9) { /* shortest: Q.933a LINK VERIFY */ printf("[|q.933]"); @@ -528,7 +714,7 @@ q933_print(const u_char *p, u_int length) printf("%s", eflag ? "" : "Q.933, "); /* printing out header part */ - printf(is_ansi ? "ANSI" : "CCITT"); + printf("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset); if (p[0]) printf(", Call Ref: 0x%02x", p[0]); @@ -552,10 +738,10 @@ q933_print(const u_char *p, u_int length) ptemp += 2 + is_ansi; /* Loop through the rest of IE */ - while (length > sizeof(struct common_ie_header)) { - ie_p = (struct common_ie_header *)ptemp; - if (length < sizeof(struct common_ie_header) || - length < sizeof(struct common_ie_header) + ie_p->ie_len) { + while (length > sizeof(struct ie_tlv_header_t )) { + ie_p = (struct ie_tlv_header_t *)ptemp; + if (length < sizeof(struct ie_tlv_header_t ) || + length < sizeof(struct ie_tlv_header_t ) + ie_p->ie_len) { if (vflag) /* not bark if there is just a trailer */ printf("\n[|q.933]"); else @@ -567,19 +753,23 @@ q933_print(const u_char *p, u_int length) * however some IEs (DLCI Status, Link Verify) * are also intereststing in non-verbose mode */ if (vflag) - printf("\n\t%s IE (%u), length %u: ", - tok2str(fr_q933_ie_codesets[codeset],"unknown",ie_p->ie_id), - ie_p->ie_id, + printf("\n\t%s IE (0x%02x), length %u: ", + tok2str(fr_q933_ie_codesets[codeset],"unknown",ie_p->ie_type), + ie_p->ie_type, ie_p->ie_len); - - if (!fr_q933_print_ie_codeset[codeset] || - (*fr_q933_print_ie_codeset[codeset])(ie_p, ptemp)) { - if (vflag <= 1) - print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len); - } + + /* sanity check */ + if (ie_p->ie_type == 0 || ie_p->ie_len == 0) + return; + + if (fr_q933_print_ie_codeset[codeset] != NULL) + ie_is_known = fr_q933_print_ie_codeset[codeset](ie_p, ptemp); + + if (vflag >= 1 && !ie_is_known) + print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len); /* do we want to see a hexdump of the IE ? */ - if (vflag> 1) + if (vflag> 1 && ie_is_known) print_unknown_data(ptemp+2,"\n\t ",ie_p->ie_len); length = length - ie_p->ie_len - 2; @@ -590,11 +780,11 @@ q933_print(const u_char *p, u_int length) } static int -fr_q933_print_ie_codeset5(const struct common_ie_header *ie_p, const u_char *p) +fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p) { u_int dlci; - switch (ie_p->ie_id) { + switch (ie_p->ie_type) { case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */ case FR_LMI_CCITT_REPORT_TYPE_IE: diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c index 9773c29..9ea7141 100644 --- a/contrib/tcpdump/print-ip.c +++ b/contrib/tcpdump/print-ip.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149.2.1 2005/05/20 21:15:46 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149.2.2 2005/09/20 06:05:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -413,6 +413,10 @@ again: case IPPROTO_SCTP: sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len); break; + + case IPPROTO_DCCP: + dccp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len); + break; case IPPROTO_TCP: tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, @@ -667,7 +671,7 @@ ip_print(netdissect_options *ndo, ipds->nh = ipds->ip->ip_p; if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP && - ipds->nh != IPPROTO_SCTP) { + ipds->nh != IPPROTO_SCTP && ipds->nh != IPPROTO_DCCP) { (void)printf("%s > %s: ", ipaddr_string(&ipds->ip->ip_src), ipaddr_string(&ipds->ip->ip_dst)); diff --git a/contrib/tcpdump/print-ip6.c b/contrib/tcpdump/print-ip6.c index cdf2f2a..5e6902d 100644 --- a/contrib/tcpdump/print-ip6.c +++ b/contrib/tcpdump/print-ip6.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47.2.2 2005/07/03 20:36:33 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47.2.3 2005/09/20 06:05:38 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -118,7 +118,7 @@ ip6_print(register const u_char *bp, register u_int length) if (cp == (const u_char *)(ip6 + 1) && nh != IPPROTO_TCP && nh != IPPROTO_UDP && - nh != IPPROTO_SCTP) { + nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) { (void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src), ip6addr_string(&ip6->ip6_dst)); } @@ -162,6 +162,9 @@ ip6_print(register const u_char *bp, register u_int length) case IPPROTO_SCTP: sctp_print(cp, (const u_char *)ip6, len); return; + case IPPROTO_DCCP: + dccp_print(cp, (const u_char *)ip6, len); + return; case IPPROTO_TCP: tcp_print(cp, len, (const u_char *)ip6, fragmented); return; diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c index 4afc4b3..6459b31 100644 --- a/contrib/tcpdump/print-ipx.c +++ b/contrib/tcpdump/print-ipx.c @@ -198,7 +198,7 @@ ipx_rip_print(const u_short *ipx, u_int length) (void)printf("ipx-rip-req"); if (length > 0) { TCHECK(ipx[3]); - (void)printf(" %x/%d.%d", EXTRACT_32BITS(&ipx[0]), + (void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]), EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])); } break; @@ -206,7 +206,7 @@ ipx_rip_print(const u_short *ipx, u_int length) (void)printf("ipx-rip-resp"); for (i = 0; i < 50 && length > 0; i++) { TCHECK(ipx[3]); - (void)printf(" %x/%d.%d", EXTRACT_32BITS(&ipx[0]), + (void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]), EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])); ipx += 4; diff --git a/contrib/tcpdump/print-isoclns.c b/contrib/tcpdump/print-isoclns.c index ccfabc7..7092ef2 100644 --- a/contrib/tcpdump/print-isoclns.c +++ b/contrib/tcpdump/print-isoclns.c @@ -28,7 +28,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.12 2005/06/16 01:14:52 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.19 2005/09/20 10:15:22 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -112,7 +112,9 @@ static struct tok isis_pdu_values[] = { #define ISIS_TLV_LSP 9 /* iso10589 */ #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */ #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */ +#define ISIS_TLV_CHECKSUM_MINLEN 2 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */ +#define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */ #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */ #define ISIS_TLV_DECNET_PHASE4 42 @@ -121,6 +123,7 @@ static struct tok isis_pdu_values[] = { #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */ #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */ #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */ +#define ISIS_TLV_IDRP_INFO_MINLEN 1 #define ISIS_TLV_IPADDR 132 /* rfc1195 */ #define ISIS_TLV_IPAUTH 133 /* rfc1195 */ #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */ @@ -130,15 +133,20 @@ static struct tok isis_pdu_values[] = { #define ISIS_TLV_NORTEL_PRIVATE1 176 #define ISIS_TLV_NORTEL_PRIVATE2 177 #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */ +#define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1 +#define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */ #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */ +#define ISIS_TLV_MT_SUPPORTED_MINLEN 2 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */ #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */ #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */ #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */ #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */ #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */ +#define ISIS_TLV_IIH_SEQNR_MINLEN 4 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */ +#define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3 static struct tok isis_tlv_values[] = { { ISIS_TLV_AREA_ADDR, "Area address(es)"}, @@ -338,11 +346,12 @@ static struct tok clnp_option_qos_global_values[] = { #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */ #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */ #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */ -#define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */ -#define ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE 12 /* draft-ietf-tewg-diff-te-proto-06 */ +#define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */ +#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */ #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */ #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */ #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */ +#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */ static struct tok isis_ext_is_reach_subtlv_values[] = { { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" }, @@ -353,10 +362,11 @@ static struct tok isis_ext_is_reach_subtlv_values[] = { { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" }, { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" }, { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" }, - { ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE, "Diffserv TE" }, { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" }, { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" }, { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" }, + { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD, "Bandwidth Constraints (old)" }, + { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS, "Bandwidth Constraints" }, { 250, "Reserved for cisco specific extensions" }, { 251, "Reserved for cisco specific extensions" }, { 252, "Reserved for cisco specific extensions" }, @@ -782,6 +792,7 @@ static int clnp_print (const u_int8_t *pptr, u_int length) if (clnp_flags & CLNP_SEGMENT_PART) { clnp_segment_header = (const struct clnp_segment_header_t *) pptr; + TCHECK(*clnp_segment_header); printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u", EXTRACT_16BITS(clnp_segment_header->data_unit_id), EXTRACT_16BITS(clnp_segment_header->segment_offset), @@ -842,7 +853,7 @@ static int clnp_print (const u_int8_t *pptr, u_int length) if (tlen < source_address_length+1) { printf("\n\t NSAP address goes past end of option"); break; - } + } if (source_address_length > 0) { source_address=(tptr+1); TCHECK2(*source_address, source_address_length); @@ -1400,9 +1411,9 @@ trunctlv: */ static int -isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) { +isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const char *ident) { - int priority_level,bandwidth_constraint; + u_int te_class,priority_level; union { /* int to float conversion buffer for several subTLVs */ float f; u_int32_t i; @@ -1432,7 +1443,7 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i break; case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR: case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR: - if (subl >= 4) + if (subl >= sizeof(struct in_addr)) printf(", %s", ipaddr_string(tptr)); break; case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW : @@ -1444,28 +1455,29 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i break; case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW : if (subl >= 32) { - for (priority_level = 0; priority_level < 8; priority_level++) { + for (te_class = 0; te_class < 8; te_class++) { bw.i = EXTRACT_32BITS(tptr); - printf("%s priority level %d: %.3f Mbps", + printf("%s TE-Class %u: %.3f Mbps", ident, - priority_level, + te_class, bw.f*8/1000000 ); tptr+=4; } } break; - case ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE: + case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */ + case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD: printf("%sBandwidth Constraints Model ID: %s (%u)", ident, tok2str(diffserv_te_bc_values, "unknown", *tptr), *tptr); tptr++; /* decode BCs until the subTLV ends */ - for (bandwidth_constraint = 0; bandwidth_constraint < (subl-1)/4; bandwidth_constraint++) { + for (te_class = 0; te_class < (subl-1)/4; te_class++) { bw.i = EXTRACT_32BITS(tptr); - printf("%s Bandwidth constraint %d: %.3f Mbps", + printf("%s Bandwidth constraint CT%u: %.3f Mbps", ident, - bandwidth_constraint, + te_class, bw.f*8/1000000 ); tptr+=4; } @@ -1606,7 +1618,7 @@ static int isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) { char ident_buffer[20]; - u_int8_t prefix[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */ + u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */ u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen; if (!TTEST2(*tptr, 4)) @@ -1636,7 +1648,7 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi if (!TTEST2(*tptr, byte_length)) return (0); - memset(prefix, 0, 16); /* clear the copy buffer */ + memset(prefix, 0, sizeof(struct in6_addr)); /* clear the copy buffer */ memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ tptr+=byte_length; processed+=byte_length; @@ -2264,15 +2276,15 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_IP6ADDR: - while (tmp>=16) { - if (!TTEST2(*tptr, 16)) + while (tmp>=sizeof(struct in6_addr)) { + if (!TTEST2(*tptr, sizeof(struct in6_addr))) goto trunctlv; printf("\n\t IPv6 interface address: %s", ip6addr_string(tptr)); - tptr += 16; - tmp -= 16; + tptr += sizeof(struct in6_addr); + tmp -= sizeof(struct in6_addr); } break; #endif @@ -2362,18 +2374,18 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_TE_ROUTER_ID: - if (!TTEST2(*pptr, 4)) + if (!TTEST2(*pptr, sizeof(struct in_addr))) goto trunctlv; printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr)); break; case ISIS_TLV_IPADDR: - while (tmp>=4) { - if (!TTEST2(*tptr, 4)) + while (tmp>=sizeof(struct in_addr)) { + if (!TTEST2(*tptr, sizeof(struct in_addr))) goto trunctlv; printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr)); - tptr += 4; - tmp -= 4; + tptr += sizeof(struct in_addr); + tmp -= sizeof(struct in_addr); } break; @@ -2403,21 +2415,21 @@ static int isis_print (const u_int8_t *p, u_int length) printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"); tmp--; - if (tmp < 4) + if (tmp < sizeof(struct in_addr)) break; - if (!TTEST2(*tptr,4)) + if (!TTEST2(*tptr,sizeof(struct in_addr))) goto trunctlv; printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr)); - tptr+=4; - tmp-=4; + tptr+=sizeof(struct in_addr); + tmp-=sizeof(struct in_addr); - if (tmp < 4) + if (tmp < sizeof(struct in_addr)) break; - if (!TTEST2(*tptr,4)) + if (!TTEST2(*tptr,sizeof(struct in_addr))) goto trunctlv; printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr)); - tptr+=4; - tmp-=4; + tptr+=sizeof(struct in_addr); + tmp-=sizeof(struct in_addr); while (tmp>=4) { if (!TTEST2(*tptr, 4)) @@ -2450,9 +2462,9 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_CHECKSUM: - if (tmp < 2) + if (tmp < ISIS_TLV_CHECKSUM_MINLEN) break; - if (!TTEST2(*tptr, 2)) + if (!TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN)) goto trunctlv; printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)); /* do not attempt to verify the checksum if it is zero @@ -2466,6 +2478,8 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_MT_SUPPORTED: + if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN) + break; while (tmp>1) { /* length can only be a multiple of 2, otherwise there is something broken -> so decode down until length is 1 */ @@ -2483,30 +2497,41 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_RESTART_SIGNALING: - if (tmp < 3) - break; - if (!TTEST2(*tptr, 3)) + /* first attempt to decode the flags */ + if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN)) goto trunctlv; - printf("\n\t Flags [%s], Remaining holding time %us", - bittok2str(isis_restart_flag_values, "none", *tptr), - EXTRACT_16BITS(tptr+1)); - tptr+=3; - tmp-=3; + printf("\n\t Flags [%s]", + bittok2str(isis_restart_flag_values, "none", *tptr)); + tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; + tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; + + /* is there anything other than the flags field? */ + if (tmp == 0) + break; + + if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)) + goto trunctlv; + + printf(", Remaining holding time %us", EXTRACT_16BITS(tptr+1)); + tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; + tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; + + /* is there an additional sysid field present ?*/ if (tmp == SYSTEM_ID_LEN) { if (!TTEST2(*tptr, SYSTEM_ID_LEN)) goto trunctlv; printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN)); - } else if (tmp == NODE_ID_LEN) { - if (!TTEST2(*tptr, NODE_ID_LEN)) - goto trunctlv; - printf(", for %s",isis_print_id(tptr,NODE_ID_LEN)); - } + } break; case ISIS_TLV_IDRP_INFO: - if (tmp < 1) + if (tmp < ISIS_TLV_IDRP_INFO_MINLEN) break; - if (!TTEST2(*tptr, 1)) + if (!TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN)) goto trunctlv; printf("\n\t Inter-Domain Information Type: %s", tok2str(isis_subtlv_idrp_values, @@ -2528,9 +2553,9 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_LSP_BUFFERSIZE: - if (tmp < 2) + if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN) break; - if (!TTEST2(*tptr, 2)) + if (!TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN)) goto trunctlv; printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr)); break; @@ -2577,17 +2602,17 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_IIH_SEQNR: - if (tmp < 4) + if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN) break; - if (!TTEST2(*tptr, 4)) /* check if four bytes are on the wire */ + if (!TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */ goto trunctlv; printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) ); break; case ISIS_TLV_VENDOR_PRIVATE: - if (tmp < 3) + if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN) break; - if (!TTEST2(*tptr, 3)) /* check if enough byte for a full oui */ + if (!TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */ goto trunctlv; vendor_id = EXTRACT_24BITS(tptr); printf("\n\t Vendor: %s (%u)", diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c index cc665f5..3820f32 100644 --- a/contrib/tcpdump/print-llc.c +++ b/contrib/tcpdump/print-llc.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61.2.4 2005/04/26 07:27:16 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61.2.5 2005/09/29 07:40:13 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -52,6 +52,7 @@ static struct tok llc_values[] = { { LLCSAP_8021B_I, "802.1B I" }, { LLCSAP_8021B_G, "802.1B G" }, { LLCSAP_IP, "IP" }, + { LLCSAP_SNA, "SNA" }, { LLCSAP_PROWAYNM, "ProWay NM" }, { LLCSAP_8021D, "STP" }, { LLCSAP_RS511, "RS511" }, @@ -64,7 +65,7 @@ static struct tok llc_values[] = { { 0, NULL }, }; -static struct tok cmd2str[] = { +static struct tok llc_cmd_values[] = { { LLC_UI, "ui" }, { LLC_TEST, "test" }, { LLC_XID, "xid" }, @@ -76,6 +77,23 @@ static struct tok cmd2str[] = { { 0, NULL } }; +static const struct tok llc_flag_values[] = { + { 0, "Command" }, + { LLC_GSAP, "Response" }, + { LLC_U_POLL, "Poll" }, + { LLC_GSAP|LLC_U_POLL, "Final" }, + { LLC_GSAP|LLC_IS_POLL, "Final" }, + { 0, NULL } +}; + +static const struct tok llc_supervisory_values[] = { + { 0, "Receiver Ready" }, + { 1, "Reject" }, + { 2, "Receiver not Ready" }, + { 0, NULL } +}; + + static const struct tok cisco_values[] = { { PID_CISCO_CDP, "CDP" }, { 0, NULL } @@ -117,7 +135,7 @@ int llc_print(const u_char *p, u_int length, u_int caplen, const u_char *esrc, const u_char *edst, u_short *extracted_ethertype) { - u_int8_t dsap, ssap; + u_int8_t dsap_field, dsap, ssap_field, ssap; u_int16_t control; int is_u; register int ret; @@ -128,8 +146,10 @@ llc_print(const u_char *p, u_int length, u_int caplen, return(0); } - dsap = *p; - ssap = *(p + 1); + dsap_field = *p; + dsap = dsap_field & ~LLC_IG; + ssap_field = *(p + 1); + ssap = ssap_field & ~LLC_GSAP; /* * OK, what type of LLC frame is this? The length @@ -178,27 +198,23 @@ llc_print(const u_char *p, u_int length, u_int caplen, */ if (eflag) - printf("IPX-802.3: "); + printf("IPX 802.3: "); ipx_print(p, length); return (1); } if (eflag) { + printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x)", + tok2str(llc_values, "Unknown", dsap), + dsap, + tok2str(llc_values, "Unknown", ssap), + ssap); + if (is_u) { - printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x), cmd 0x%02x: ", - tok2str(llc_values, "Unknown", dsap), - dsap, - tok2str(llc_values, "Unknown", ssap), - ssap, - control); + printf(", cmd 0x%02x: ", control); } else { - printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x), cmd 0x%04x: ", - tok2str(llc_values, "Unknown", dsap), - dsap, - tok2str(llc_values, "Unknown", ssap), - ssap, - control); + printf(", cmd 0x%04x: ", control); } } @@ -223,7 +239,9 @@ llc_print(const u_char *p, u_int length, u_int caplen, * * Skip DSAP, LSAP, and control field. */ - printf("(NOV-802.2) "); + if (eflag) + printf("IPX 802.2: "); + ipx_print(p+3, length-3); return (1); } @@ -278,42 +296,33 @@ llc_print(const u_char *p, u_int length, u_int caplen, } if (!eflag) { - if ((ssap & ~LLC_GSAP) == dsap) { + if (ssap == dsap) { if (esrc == NULL || edst == NULL) - (void)printf("%s ", llcsap_string(dsap)); + (void)printf("%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)); else (void)printf("%s > %s %s ", etheraddr_string(esrc), etheraddr_string(edst), - llcsap_string(dsap)); + tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)); } else { if (esrc == NULL || edst == NULL) (void)printf("%s > %s ", - llcsap_string(ssap & ~LLC_GSAP), - llcsap_string(dsap)); + tok2str(llc_values, "Unknown SSAP 0x%02x", ssap), + tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)); else (void)printf("%s %s > %s %s ", etheraddr_string(esrc), - llcsap_string(ssap & ~LLC_GSAP), + tok2str(llc_values, "Unknown SSAP 0x%02x", ssap), etheraddr_string(edst), - llcsap_string(dsap)); + tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)); } } if (is_u) { - const char *m; - char f; - - m = tok2str(cmd2str, "%02x", LLC_U_CMD(control)); - switch ((ssap & LLC_GSAP) | (control & LLC_U_POLL)) { - case 0: f = 'C'; break; - case LLC_GSAP: f = 'R'; break; - case LLC_U_POLL: f = 'P'; break; - case LLC_GSAP|LLC_U_POLL: f = 'F'; break; - default: f = '?'; break; - } - - printf("%s/%c", m, f); + printf("Unnumbered, %s, Flags [%s], length %u", + tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)), + bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_U_POLL)), + length); p += 3; length -= 3; @@ -328,27 +337,19 @@ llc_print(const u_char *p, u_int length, u_int caplen, } } } else { - char f; - - switch ((ssap & LLC_GSAP) | (control & LLC_IS_POLL)) { - case 0: f = 'C'; break; - case LLC_GSAP: f = 'R'; break; - case LLC_IS_POLL: f = 'P'; break; - case LLC_GSAP|LLC_IS_POLL: f = 'F'; break; - default: f = '?'; break; - } if ((control & LLC_S_FMT) == LLC_S_FMT) { - static const char *llc_s[] = { "rr", "rej", "rnr", "03" }; - (void)printf("%s (r=%d,%c)", - llc_s[LLC_S_CMD(control)], + (void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u", + tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)), LLC_IS_NR(control), - f); + bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)), + length); } else { - (void)printf("I (s=%d,r=%d,%c)", + (void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u", LLC_I_NS(control), LLC_IS_NR(control), - f); + bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)), + length); } p += 4; length -= 4; diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c index 04254d2..bb6ab3c 100644 --- a/contrib/tcpdump/print-null.c +++ b/contrib/tcpdump/print-null.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.2 2005/05/19 07:26:18 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.3 2005/07/07 01:24:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -175,7 +175,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p) /* unknown AF_ value */ if (!eflag) null_hdr_print(family, length + NULL_HDRLEN); - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); } diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c index d4bafe4..a99d060 100644 --- a/contrib/tcpdump/print-pim.c +++ b/contrib/tcpdump/print-pim.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45.2.2 2005/04/20 22:08:44 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45.2.3 2005/07/11 20:24:34 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -142,7 +142,7 @@ pimv1_join_prune_print(register const u_char *bp, register u_int len) return; } - TCHECK2(bp[0], 4); + TCHECK2(bp[0], sizeof(struct in_addr)); if (vflag > 1) (void)printf("\n"); (void)printf(" Upstream Nbr: %s", ipaddr_string(bp)); @@ -167,9 +167,9 @@ pimv1_join_prune_print(register const u_char *bp, register u_int len) * XXX - does the address have length "addrlen" and the * mask length "maddrlen"? */ - TCHECK2(bp[0], 4); + TCHECK2(bp[0], sizeof(struct in_addr)); (void)printf("\n\tGroup: %s", ipaddr_string(bp)); - TCHECK2(bp[4], 4); + TCHECK2(bp[4], sizeof(struct in_addr)); if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) (void)printf("/%s", ipaddr_string(&bp[4])); TCHECK2(bp[8], 4); @@ -249,7 +249,7 @@ pimv1_print(register const u_char *bp, register u_int len) break; case 2: (void)printf(" Register-Stop"); - TCHECK2(bp[12], 4); + TCHECK2(bp[12], sizeof(struct in_addr)); (void)printf(" for %s > %s", ipaddr_string(&bp[8]), ipaddr_string(&bp[12])); break; @@ -272,7 +272,7 @@ pimv1_print(register const u_char *bp, register u_int len) break; case 5: (void)printf(" Assert"); - TCHECK2(bp[16], 4); + TCHECK2(bp[16], sizeof(struct in_addr)); (void)printf(" for %s > %s", ipaddr_string(&bp[16]), ipaddr_string(&bp[8])); if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) @@ -522,12 +522,12 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) switch (bp[0]) { case 1: af = AF_INET; - len = 4; + len = sizeof(struct in_addr); break; #ifdef INET6 case 2: af = AF_INET6; - len = 16; + len = sizeof(struct in6_addr); break; #endif default: @@ -538,11 +538,11 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) hdrlen = 2; } else { switch (pimv2_addr_len) { - case 4: + case sizeof(struct in_addr): af = AF_INET; break; #ifdef INET6 - case 16: + case sizeof(struct in6_addr): af = AF_INET6; break; #endif diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c index 3f8e215..0a80fb6 100644 --- a/contrib/tcpdump/print-token.c +++ b/contrib/tcpdump/print-token.c @@ -27,7 +27,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25 2004/03/17 23:24:38 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25.2.1 2005/07/07 01:24:40 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -169,7 +169,7 @@ token_print(const u_char *p, u_int length, u_int caplen) printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); } } else { @@ -178,7 +178,7 @@ token_print(const u_char *p, u_int length, u_int caplen) if (!eflag) token_hdr_print(trp, length + TOKEN_HDRLEN + route_len, ESRC(&ehdr), EDST(&ehdr)); - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); } return (hdr_len); diff --git a/contrib/tcpdump/tcpdump-stdinc.h b/contrib/tcpdump/tcpdump-stdinc.h index 6591183..337d45e 100644 --- a/contrib/tcpdump/tcpdump-stdinc.h +++ b/contrib/tcpdump/tcpdump-stdinc.h @@ -29,7 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * - * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12 2005/03/27 01:35:45 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12.2.4 2005/07/09 21:19:45 risso Exp $ (LBL) * * $FreeBSD$ */ @@ -48,11 +48,11 @@ #include <stdio.h> #include <winsock2.h> +#include <Ws2tcpip.h> #include "bittypes.h" #include <ctype.h> #include <time.h> #include <io.h> -#include "IP6_misc.h" #include <fcntl.h> #include <sys/types.h> #include <net/netdb.h> /* in wpcap's Win32/include */ diff --git a/contrib/tcpdump/tcpdump.1 b/contrib/tcpdump/tcpdump.1 index 3d5bdbd..1dc0340f 100644 --- a/contrib/tcpdump/tcpdump.1 +++ b/contrib/tcpdump/tcpdump.1 @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167.2.4 2005/05/02 21:27:34 guy Exp $ (LBL) +.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167.2.6 2005/09/05 09:14:37 guy Exp $ (LBL) .\" .\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $ .\" @@ -1029,20 +1029,72 @@ Note that \fItcpdump\fP does not currently know how to parse these protocols. .IP "\fBvlan \fI[vlan_id]\fR" True if the packet is an IEEE 802.1Q VLAN packet. -If \fI[vlan_id]\fR is specified, only true is the packet has the specified +If \fI[vlan_id]\fR is specified, only true if the packet has the specified \fIvlan_id\fR. Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR -changes the decoding offsets for the remainder of \fIexpression\fR -on the assumption that the packet is a VLAN packet. -the \fI[vlan_id]\fR statement may be used more than once, to filter on vlan hierarchies. -each use of the \fI[vlan_id]\fR \fIexpression\fR increments the filter offsets by 4. +changes the decoding offsets for the remainder of \fIexpression\fR on +the assumption that the packet is a VLAN packet. The \fBvlan +\fI[vlan_id]\fR expression may be used more than once, to filter on VLAN +hierarchies. Each use of that expression increments the filter offsets +by 4. +.IP +For example: +.in +.5i +.nf +\fBvlan 100 && vlan 200\fR .fi -example(s): +.in -.5i +filters on VLAN 200 encapsulated within VLAN 100, and +.in +.5i +.nf +\fBvlan && vlan 300 && ip\fR +.fi +.in -.5i +filters IPv4 protocols encapsulated in VLAN 300 encapsulated within any +higher order VLAN. +.IP "\fBmpls \fI[label_num]\fR" +True if the packet is an MPLS packet. +If \fI[label_num]\fR is specified, only true is the packet has the specified +\fIlabel_num\fR. +Note that the first \fBmpls\fR keyword encountered in \fIexpression\fR +changes the decoding offsets for the remainder of \fIexpression\fR on +the assumption that the packet is a MPLS-encapsulated IP packet. The +\fBmpls \fI[label_num]\fR expression may be used more than once, to +filter on MPLS hierarchies. Each use of that expression increments the +filter offsets by 4. +.IP +For example: +.in +.5i +.nf +\fBmpls 100000 && mpls 1024\fR .fi -"vlan 100 && vlan 200" filters on vlan 200 encapsulated within vlan 100 +.in -.5i +filters packets with an outer label of 100000 and an inner label of +1024, and +.in +.5i +.nf +\fBmpls && mpls 1024 && host 192.9.200.1\fR .fi -"vlan && vlan 300 && ip" filters IPv4 protocols encapsulated in vlan 300 encapsulated within any higher order vlan +.in -.5i +filters packets to or from 192.9.200.1 with an inner label of 1024 and +any outer label. +.IP \fBpppoed\fP +True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet +type 0x8863). +.IP \fBpppoes\fP +True if the packet is a PPP-over-Ethernet Session packet (Ethernet +type 0x8864). +Note that the first \fBpppoes\fR keyword encountered in \fIexpression\fR +changes the decoding offsets for the remainder of \fIexpression\fR on +the assumption that the packet is a PPPoE session packet. +.IP +For example: +.in +.5i +.nf +\fBpppoes && ip\fR .fi +.in -.5i +filters IPv4 protocols encapsulated in PPPoE. .IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR" Abbreviations for: .in +.5i diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c index 3263824..1730463 100644 --- a/contrib/tcpdump/tcpdump.c +++ b/contrib/tcpdump/tcpdump.c @@ -30,7 +30,7 @@ static const char copyright[] _U_ = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ The Regents of the University of California. All rights reserved.\n"; static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.8 2005/07/05 21:09:05 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.11 2005/08/23 10:29:41 hannes Exp $ (LBL)"; #endif /* $FreeBSD$ */ @@ -255,6 +255,18 @@ static struct printer printers[] = { #ifdef DLT_JUNIPER_SERVICES { juniper_services_print, DLT_JUNIPER_SERVICES }, #endif +#ifdef DLT_JUNIPER_ETHER + { juniper_ether_print, DLT_JUNIPER_ETHER }, +#endif +#ifdef DLT_JUNIPER_PPP + { juniper_ppp_print, DLT_JUNIPER_PPP }, +#endif +#ifdef DLT_JUNIPER_FRELAY + { juniper_frelay_print, DLT_JUNIPER_FRELAY }, +#endif +#ifdef DLT_JUNIPER_CHDLC + { juniper_chdlc_print, DLT_JUNIPER_CHDLC }, +#endif { NULL, 0 }, }; @@ -494,8 +506,6 @@ main(int argc, char **argv) break; case 'A': - ++xflag; - ++Xflag; ++Aflag; break; @@ -657,6 +667,7 @@ main(int argc, char **argv) case 'q': ++qflag; + ++suppress_default_print; break; case 'r': @@ -737,10 +748,12 @@ main(int argc, char **argv) case 'x': ++xflag; + ++suppress_default_print; break; case 'X': ++Xflag; + ++suppress_default_print; break; case 'y': @@ -1226,9 +1239,28 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) snapend = sp + h->caplen; hdrlen = (*print_info->printer)(h, sp); - if (xflag) { + if (Xflag) { /* - * Print the raw packet data. + * Print the raw packet data in hex and ASCII. + */ + if (Xflag > 1) { + /* + * Include the link-layer header. + */ + hex_and_ascii_print("\n\t", sp, h->caplen); + } else { + /* + * Don't include the link-layer header - and if + * we have nothing past the link-layer header, + * print nothing. + */ + if (h->caplen > hdrlen) + hex_and_ascii_print("\n\t", sp + hdrlen, + h->caplen - hdrlen); + } + } else if (xflag) { + /* + * Print the raw packet data in hex. */ if (xflag > 1) { /* @@ -1245,15 +1277,15 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) hex_print("\n\t", sp + hdrlen, h->caplen - hdrlen); } - } else if (Xflag) { + } else if (Aflag) { /* - * Print the raw packet data. + * Print the raw packet data in ASCII. */ - if (Xflag > 1) { + if (Aflag > 1) { /* * Include the link-layer header. */ - ascii_print("\n\t", sp, h->caplen); + ascii_print(sp, h->caplen); } else { /* * Don't include the link-layer header - and if @@ -1261,8 +1293,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) * print nothing. */ if (h->caplen > hdrlen) - ascii_print("\n\t", sp + hdrlen, - h->caplen - hdrlen); + ascii_print(sp + hdrlen, h->caplen - hdrlen); } } @@ -1301,12 +1332,12 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) #endif /* - * By default, print the specified data out in hex. + * By default, print the specified data out in hex and ASCII. */ static void ndo_default_print(netdissect_options *ndo _U_, const u_char *bp, u_int length) { - ascii_print("\n\t", bp, length); /* pass on lf and identation string */ + hex_and_ascii_print("\n\t", bp, length); /* pass on lf and identation string */ } void |