]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip-demux.c
CI: Add warning exemptions for Sun C (suncc-5.15) on Solaris 10
[tcpdump] / print-ip-demux.c
index f18055d6a13fd5706d2d7836f48d00fa4d117203..b5282761ccd86e430cd26f7097c2f1cef2ce8322 100644 (file)
 
 /* \summary: IPv4/IPv6 payload printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
-#include <string.h>
-
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
@@ -37,7 +33,7 @@
 #include "ipproto.h"
 
 void
-ip_print_demux(netdissect_options *ndo,
+ip_demux_print(netdissect_options *ndo,
               const u_char *bp,
               u_int length, u_int ver, int fragmented, u_int ttl_hl,
               uint8_t nh, const u_char *iph)
@@ -105,11 +101,23 @@ again:
                break;
 
        case IPPROTO_ICMP:
-               icmp_print(ndo, bp, length, iph, fragmented);
+               if (ver == 4)
+                       icmp_print(ndo, bp, length, fragmented);
+               else {
+                       ND_PRINT("[%s requires IPv4]",
+                                tok2str(ipproto_values,"unknown",nh));
+                       nd_print_invalid(ndo);
+               }
                break;
 
        case IPPROTO_ICMPV6:
-               icmp6_print(ndo, bp, length, iph, fragmented);
+               if (ver == 6)
+                       icmp6_print(ndo, bp, length, iph, fragmented);
+               else {
+                       ND_PRINT("[%s requires IPv6]",
+                                tok2str(ipproto_values,"unknown",nh));
+                       nd_print_invalid(ndo);
+               }
                break;
 
        case IPPROTO_PIGP:
@@ -119,12 +127,12 @@ again:
                 * (used by Cisco for their IGRP)" and 88 as
                 * "EIGRP" from Cisco.
                 *
-                * Recent BSD <netinet/in.h> headers define
-                * IP_PROTO_PIGP as 9 and IP_PROTO_IGRP as 88.
-                * We define IP_PROTO_PIGP as 9 and
-                * IP_PROTO_EIGRP as 88; those names better
-                * match was the current protocol number
-                * assignments say.
+                * Recent FreeBSD, DragonFly BSD, and macOS <netinet/in.h>
+                * headers define IPPROTO_PIGP as 9 and IPPROTO_IGRP
+                * as 88.  We define IPPROTO_PIGP ("private interior
+                * gateway protocol") as 9 and IPPROTO_EIGRP as 88;
+                * those names better match what the current protocol
+                * number assignments say.
                 */
                igrp_print(ndo, bp, length);
                break;
@@ -149,7 +157,13 @@ again:
                break;
 
        case IPPROTO_IGMP:
-               igmp_print(ndo, bp, length);
+               if (ver == 4)
+                       igmp_print(ndo, bp, length);
+               else {
+                       ND_PRINT("[%s requires IPv4]",
+                                tok2str(ipproto_values,"unknown",nh));
+                       nd_print_invalid(ndo);
+               }
                break;
 
        case IPPROTO_IPV4:
@@ -182,7 +196,7 @@ again:
                if (ndo->ndo_packettype == PT_CARP) {
                        carp_print(ndo, bp, length, ttl_hl);
                } else {
-                       vrrp_print(ndo, bp, length, iph, ttl_hl);
+                       vrrp_print(ndo, bp, length, iph, ttl_hl, ver);
                }
                break;
 
@@ -190,6 +204,20 @@ again:
                pgm_print(ndo, bp, length, iph);
                break;
 
+       case IPPROTO_ETHERNET:
+               if (ver == 6)
+                       ether_print(ndo, bp, length, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
+               else {
+                       ND_PRINT("[%s requires IPv6]",
+                                tok2str(ipproto_values,"unknown",nh));
+                       nd_print_invalid(ndo);
+               }
+               break;
+
+       case IPPROTO_NHRP:
+               nhrp_print(ndo, bp, length);
+               break;
+
        case IPPROTO_NONE:
                ND_PRINT("no next header");
                break;