From: hannes Date: Thu, 3 Oct 2002 16:00:32 +0000 (+0000) Subject: hide multiline output using vflag plus enhanced, ES-IS decoder X-Git-Tag: tcpdump-3.8-bp~337 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/f60a1bd8cb38cbd37ee6d4f4bb00618af69846d5 hide multiline output using vflag plus enhanced, ES-IS decoder --- diff --git a/FILES b/FILES index 52625772..ba5ce531 100644 --- a/FILES +++ b/FILES @@ -140,6 +140,7 @@ print-radius.c print-raw.c print-rip.c print-ripng.c +print-rsvp.c print-rt6.c print-rx.c print-sctp.c diff --git a/INSTALL b/INSTALL index 66942699..f3e60a29 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -@(#) $Header: /tcpdump/master/tcpdump/Attic/INSTALL,v 1.50 2002-09-05 21:25:35 guy Exp $ (LBL) +@(#) $Header: /tcpdump/master/tcpdump/Attic/INSTALL,v 1.51 2002-10-03 16:00:33 hannes Exp $ (LBL) If you have not built libpcap, do so first. See the README file in this directory for the ftp location. @@ -166,6 +166,7 @@ print-radius.c - Radius protocol printer routines print-raw.c - Raw IP printer routines print-rip.c - Routing Information Protocol printer routines print-ripng.c - IPv6 Routing Information Protocol printer routines +print-rsvp.c - Resource reSerVation Protocol (RSVP) printer routines print-rt6.c - IPv6 routing header printer routines print-rx.c - AFS RX printer routines print-sctp.c - Stream Control Transmission Protocol printer routines diff --git a/Makefile.in b/Makefile.in index 95634766..9db5c300 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,7 +17,7 @@ # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # -# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.266 2002-09-05 21:25:35 guy Exp $ (LBL) +# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.267 2002-10-03 16:00:33 hannes Exp $ (LBL) # # Various configurable paths (remember to edit Makefile.in, not Makefile) @@ -78,7 +78,7 @@ CSRC = addrtoname.c gmt2local.c machdep.c parsenfsfh.c \ print-lwres.c print-msdp.c print-mobile.c print-mpls.c \ print-nfs.c print-ntp.c print-null.c print-ospf.c \ print-pflog.c print-pim.c print-ppp.c print-pppoe.c \ - print-pptp.c print-radius.c print-raw.c print-rip.c \ + print-pptp.c print-radius.c print-raw.c print-rip.c print-rsvp.c \ print-rx.c print-sctp.c print-sl.c print-sll.c \ print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \ print-tcp.c print-telnet.c print-tftp.c print-timed.c \ diff --git a/ethertype.h b/ethertype.h index f8deb31a..d3c9a53f 100644 --- a/ethertype.h +++ b/ethertype.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.17 2002-09-11 22:15:16 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.18 2002-10-03 16:00:33 hannes Exp $ (LBL) */ /* @@ -123,3 +123,12 @@ #ifndef ETHERTYPE_ISO #define ETHERTYPE_ISO 0xfefe /* nonstandard - used in Cisco HDLC encapsulation */ #endif + +/* FIXME complete the proto-id to string mapping */ +static const struct tok ethertype_values[] = { + { ETHERTYPE_IP, "IPv4" }, + { ETHERTYPE_MPLS, "MPLS unicast" }, + { ETHERTYPE_MPLS_MULTI, "MPLS multicast" }, + { ETHERTYPE_IPV6, "IPv6" }, + { 0, NULL} +}; diff --git a/interface.h b/interface.h index ea7c5593..8d01dfb5 100644 --- a/interface.h +++ b/interface.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.194 2002-09-05 21:25:36 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.195 2002-10-03 16:00:33 hannes Exp $ (LBL) */ #ifndef tcpdump_interface_h @@ -253,6 +253,7 @@ extern void null_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void ospf_print(const u_char *, u_int, const u_char *); extern void pimv1_print(const u_char *, u_int); extern void cisco_autorp_print(const u_char *, u_int); +extern void rsvp_print(const u_char *, u_int); extern void mobile_print(const u_char *, u_int); extern void pim_print(const u_char *, u_int); extern u_int pppoe_print(const u_char *, u_int); diff --git a/print-ip.c b/print-ip.c index a94ae30e..c88a2076 100644 --- a/print-ip.c +++ b/print-ip.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.113 2002-09-05 21:25:41 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.114 2002-10-03 16:00:34 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -549,6 +549,12 @@ again: break; #endif /*INET6*/ +#ifndef IPPROTO_RSVP +#define IPPROTO_RSVP 46 +#endif + case IPPROTO_RSVP: + rsvp_print(cp, len); + break; #ifndef IPPROTO_GRE #define IPPROTO_GRE 47 @@ -676,3 +682,4 @@ ipN_print(register const u_char *bp, register u_int length) } + diff --git a/print-isoclns.c b/print-isoclns.c index 6405a661..96dcf927 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.62 2002-09-15 00:58:43 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.63 2002-10-03 16:00:34 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -122,6 +122,7 @@ static struct tok isis_pdu_values[] = { #define TLV_SHARED_RISK_GROUP 138 #define TLV_NORTEL_PRIVATE1 176 #define TLV_NORTEL_PRIVATE2 177 +#define TLV_HOLDTIME 198 /* ES-IS */ #define TLV_RESTART_SIGNALING 211 #define TLV_MT_IS_REACH 222 #define TLV_MT_SUPPORTED 229 @@ -161,6 +162,7 @@ static struct tok isis_tlv_values[] = { { TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"}, { TLV_NORTEL_PRIVATE1, "Nortel Proprietary"}, { TLV_NORTEL_PRIVATE2, "Nortel Proprietary"}, + { TLV_HOLDTIME, "Holdtime"}, { TLV_RESTART_SIGNALING, "Restart Signaling"}, { TLV_MT_IS_REACH, "Multi Topology IS Reachability"}, { TLV_MT_SUPPORTED, "Multi Topology"}, @@ -310,7 +312,7 @@ static struct tok isis_lsp_istype_values[] = { { 0, NULL } }; -static struct tok isis_nlpid_values[] = { +static struct tok osi_nlpid_values[] = { { NLPID_CLNS, "CLNS"}, { NLPID_IP, "IPv4"}, { NLPID_IP6, "IPv6"}, @@ -496,18 +498,16 @@ void isoclns_print(const u_char *p, u_int length, u_int caplen, break; case NLPID_ESIS: - (void)printf("ESIS, length: %u", length); if (!eflag && esrc != NULL && edst != NULL) - (void)printf(", %s > %s", + (void)printf("%s > %s, ", etheraddr_string(esrc), etheraddr_string(edst)); esis_print(p, length); return; case NLPID_ISIS: - (void)printf("ISIS, length: %u", length); if (!eflag && esrc != NULL && edst != NULL) - (void)printf(", %s > %s", + (void)printf("%s > %s, ", etheraddr_string(esrc), etheraddr_string(edst)); if (!isis_print(p, length)) @@ -538,6 +538,13 @@ void isoclns_print(const u_char *p, u_int length, u_int caplen, #define ESIS_ESH 2 #define ESIS_ISH 4 +static struct tok esis_values[] = { + { ESIS_REDIRECT, "redirect"}, + { ESIS_ESH, "ESH"}, + { ESIS_ISH, "ISH"}, + { 0, NULL } +}; + struct esis_hdr { u_char version; u_char reserved; @@ -580,24 +587,14 @@ esis_print(const u_char *p, u_int length) } return; } - switch (eh->type & 0x1f) { - case ESIS_REDIRECT: - printf(" redirect"); - break; + printf("ES-IS, %s, length: %u", + tok2str(esis_values,"unknown type: %u",eh->type & 0x1f), + length); - case ESIS_ESH: - printf(" ESH"); - break; + if(vflag < 1) + return; - case ESIS_ISH: - printf(" ISH"); - break; - - default: - printf(" type %d", eh->type & 0x1f); - break; - } if (vflag && osi_cksum(p, li)) { printf(" bad cksum (got 0x%02x%02x)", eh->cksum[1], eh->cksum[0]); @@ -634,11 +631,10 @@ esis_print(const u_char *p, u_int length) li = ep - p; break; } -#if 0 + case ESIS_ESH: - printf(" ESH"); break; -#endif + case ESIS_ISH: { const u_char *is; @@ -656,13 +652,18 @@ esis_print(const u_char *p, u_int length) } default: - (void)printf(" len=%d", length); - if (length && p < snapend) { - length = snapend - p; - default_print(p, length); - } - return; + if (vflag <= 1) { + if (p < snapend) + print_unknown_data(p,"\n\t ",snapend-p); + } + return; } + + /* hexdump - FIXME ? */ + if (vflag > 1) { + if (p < snapend) + print_unknown_data(p,"\n\t ",snapend-p); + } if (vflag) while (p < ep && li) { u_int op, opli; @@ -671,29 +672,37 @@ esis_print(const u_char *p, u_int length) if (snapend - p < 2) return; if (li < 2) { - printf(" bad opts/li"); + printf(", bad opts/li"); return; } op = *p++; opli = *p++; li -= 2; if (opli > li) { - printf(" opt (%d) too long", op); + printf(", opt (%d) too long", op); return; } li -= opli; q = p; p += opli; + if (snapend < p) return; - if (op == 198 && opli == 2) { - printf(" tmo=%d", q[0] * 256 + q[1]); + + if (op == TLV_HOLDTIME && opli == 2) { + printf("\n\tholdtime: %us", EXTRACT_16BITS(q)); continue; } - printf (" %d:<", op); - while (opli-- > 0) - printf("%02x", *q++); - printf (">"); + + if (op == TLV_PROTOCOLS && opli >= 1) { + printf("\n\t%s (length: %u): %s", + tok2str(isis_tlv_values, "unknown", op), + opli, + tok2str(osi_nlpid_values,"Unknown 0x%02x",*q)); + continue; + } + + print_unknown_data(q,"\n\t ",opli); } } @@ -1180,6 +1189,19 @@ static int isis_print (const u_char *p, u_int length) break; } + pdu_type=header->pdu_type; + + /* in non-verbose mode just lets print the basic PDU Type*/ + if (vflag < 1) { + printf("IS-IS, %s, length: %u", + tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type), + length); + return(1); + } + + /* ok they seem to want to know everything - lets fully decode it */ + printf("IS-IS, length: %u",length); + printf("\n\thlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)", header->fixed_len, header->version, @@ -1189,12 +1211,10 @@ static int isis_print (const u_char *p, u_int length) max_area, header->max_area); - pdu_type=header->pdu_type; - /* first lets see if we know the PDU name*/ printf(", pdu-type: %s", tok2str(isis_pdu_values, - "unknown, type %d", + "unknown, type %u", pdu_type)); if (vflag) { @@ -1846,7 +1866,7 @@ static int isis_print (const u_char *p, u_int length) if (!TTEST2(*(tptr), 1)) goto trunctlv; printf("%s", - tok2str(isis_nlpid_values, + tok2str(osi_nlpid_values, "Unknown 0x%02x", *tptr++)); if (tmp>1) /* further NPLIDs ? - put comma */ @@ -2061,13 +2081,14 @@ static int isis_print (const u_char *p, u_int length) case TLV_MT_IP6_REACH: default: - if (!vflag) { + if (vflag <= 1) { if(!print_unknown_data(pptr,"\n\t\t",len)) return(0); } break; } - if (vflag) { + /* do we want to see an additionally hexdump ? */ + if (vflag> 1) { if(!print_unknown_data(pptr,"\n\t\t",len)) return(0); }