X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/9358ac260ebddc23441f11a97a46bd17f296616a..2cfe2bf4a5bdba199215e4c92129a36271b10a64:/print-ip.c diff --git a/print-ip.c b/print-ip.c index d37c47ea..3cc07768 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.93 2001-01-28 08:18:27 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.98 2001-06-15 22:17:33 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -301,7 +301,7 @@ ip_print(register const u_char *bp, register u_int length) len = ntohs(ip->ip_len); if (length < len) - (void)printf("truncated-ip - %d bytes missing!", + (void)printf("truncated-ip - %d bytes missing! ", len - length); len -= hlen; len0 = len; @@ -315,7 +315,11 @@ ip_print(register const u_char *bp, register u_int length) cp = (const u_char *)ip + hlen; nh = ip->ip_p; - if (nh != IPPROTO_TCP && nh != IPPROTO_UDP) { +#ifndef IPPROTO_SCTP +#define IPPROTO_SCTP 132 +#endif + if (nh != IPPROTO_TCP && nh != IPPROTO_UDP && + nh != IPPROTO_SCTP) { (void)printf("%s > %s: ", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); } @@ -362,6 +366,10 @@ again: goto again; } + case IPPROTO_SCTP: + sctp_print(cp, (const u_char *)ip, len); + break; + case IPPROTO_TCP: tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000)); break; @@ -382,10 +390,6 @@ again: break; case IPPROTO_ND: -#if 0 - (void)printf("%s > %s:", ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); -#endif (void)printf(" nd %d", len); break; @@ -409,15 +413,9 @@ again: case 4: /* DVMRP multicast tunnel (ip-in-ip encapsulation) */ -#if 0 - if (vflag) - (void)printf("%s > %s: ", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); -#endif ip_print(cp, len); if (! vflag) { - printf(" (ipip)"); + printf(" (ipip-proto-4)"); return; } break; @@ -428,17 +426,7 @@ again: #endif case IP6PROTO_ENCAP: /* ip6-in-ip encapsulation */ -#if 0 - if (vflag) - (void)printf("%s > %s: ", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); -#endif ip6_print(cp, len); - if (! vflag) { - printf(" (encap)"); - return; - } break; #endif /*INET6*/ @@ -447,31 +435,15 @@ again: #define IPPROTO_GRE 47 #endif case IPPROTO_GRE: - if (vflag) - (void)printf("gre %s > %s: ", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); /* do it */ gre_print(cp, len); - if (! vflag) { - printf(" (gre encap)"); - return; - } break; #ifndef IPPROTO_MOBILE #define IPPROTO_MOBILE 55 #endif case IPPROTO_MOBILE: - if (vflag) - (void)printf("mobile %s > %s: ", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); mobile_print(cp, len); - if (! vflag) { - printf(" (mobile encap)"); - return; - } break; #ifndef IPPROTO_PIM @@ -485,18 +457,10 @@ again: #define IPPROTO_VRRP 112 #endif case IPPROTO_VRRP: - if (vflag) - (void)printf("vrrp %s > %s: ", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); vrrp_print(cp, len, ip->ip_ttl); break; default: -#if 0 - (void)printf("%s > %s:", ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); -#endif (void)printf(" ip-proto-%d %d", nh, len); break; } @@ -537,10 +501,17 @@ again: if (ip->ip_tos) { (void)printf(" [tos 0x%x", (int)ip->ip_tos); /* ECN bits */ - if (ip->ip_tos&0x02) { - (void)printf(",ECT"); - if (ip->ip_tos&0x01) + if (ip->ip_tos & 0x03) { + switch (ip->ip_tos & 0x03) { + case 1: + (void)printf(",ECT(1)"); + break; + case 2: + (void)printf(",ECT(0)"); + break; + case 3: (void)printf(",CE"); + } } (void)printf("] "); }