]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip.c
Add SIGINFO handler from LBL
[tcpdump] / print-ip.c
index 6d9c861d310aa154ca653e0022d47737c7310574..3cc07768b1cd6537671264ed52aeed5a9eeb8b5a 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.92 2001-01-02 23:00:01 guy 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
@@ -203,7 +203,7 @@ ip_optprint(register const u_char *cp, u_int length)
                                printf("{%d}", len);
                        else if (cp[2] || cp[3])
                                printf("%d.%d", cp[2], cp[3]);
-                       break;
+                       break;
 
                default:
                        printf(" IPOPT-%d{%d}", cp[0], len);
@@ -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;
+                       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("] ");
        }
@@ -592,15 +563,15 @@ ipN_print(register const u_char *bp, register u_int length)
        memcpy (&hdr, (char *)ip, 4);
        switch (IP_V(&hdr)) {
        case 4:
-           ip_print (bp, length);
-           return;
+               ip_print (bp, length);
+               return;
 #ifdef INET6
        case 6:
-           ip6_print (bp, length);
-           return;
+               ip6_print (bp, length);
+               return;
 #endif
        default:
-           (void)printf("unknown ip %d", IP_V(&hdr));
-           return;
+               (void)printf("unknown ip %d", IP_V(&hdr));
+               return;
        }
 }