]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip.c
Patch sent to Debian by Roderick Schertler <[email protected]> to print
[tcpdump] / print-ip.c
index 0d86de55da82816093768cb2f3444968524dd445..505cf847b665b9f5b9c6969aa44357ef7cf93dc2 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.82 2000-05-10 05:11:27 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.89 2000-10-03 02:54:58 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -33,16 +33,7 @@ static const char rcsid[] =
 #include <sys/socket.h>
 
 #include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
-
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -52,6 +43,8 @@ static const char rcsid[] =
 #include "interface.h"
 #include "extract.h"                   /* must come after interface.h */
 
+#include "ip.h"
+
 /* Compatibility */
 #ifndef        IPPROTO_ND
 #define        IPPROTO_ND      77
@@ -450,7 +443,7 @@ ip_print(register const u_char *bp, register u_int length)
                (void)printf("truncated-ip %d", length);
                return;
        }
-       hlen = ip->ip_hl * 4;
+       hlen = IP_HL(ip) * 4;
        if (hlen < sizeof (struct ip)) {
                (void)printf("bad-hlen %d", hlen);
                return;
@@ -714,6 +707,8 @@ again:
                        (void)printf("%sid %d", sep, (int)ntohs(ip->ip_id));
                        sep = ", ";
                }
+               (void)printf("%slen %d", sep, (int)ntohs(ip->ip_len));
+               sep = ", ";
                if ((u_char *)ip + hlen <= snapend) {
                        sum = in_cksum((const u_short *)ip, hlen, 0);
                        if (sum != 0) {
@@ -729,3 +724,29 @@ again:
                printf(")");
        }
 }
+
+void
+ipN_print(register const u_char *bp, register u_int length)
+{
+       struct ip *ip, hdr;
+
+       ip = (struct ip *)bp;
+       if (length < 4) {
+               (void)printf("truncated-ip %d", length);
+               return;
+       }
+       memcpy (&hdr, (char *)ip, 4);
+       switch (IP_V(&hdr)) {
+       case 4:
+           ip_print (bp, length);
+           return;
+#ifdef INET6
+       case 6:
+           ip6_print (bp, length);
+           return;
+#endif
+       default:
+           (void)printf("unknown ip %d", IP_V(&hdr));
+           return;
+       }
+}