]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip-demux.c
CHANGES: Add/move change(s) backported to 4.99
[tcpdump] / print-ip-demux.c
index 2dae30d25f7200c562e55d82b1ec1418feaa71af..c347b8d230da5238bd2050630413195226705904 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"
 #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, u_int nh,
-              const u_char *iph)
+              u_int length, u_int ver, int fragmented, u_int ttl_hl,
+              uint8_t nh, const u_char *iph)
 {
        int advance;
        const char *p_name;
@@ -105,11 +101,23 @@ again:
                break;
 
        case IPPROTO_ICMP:
-               icmp_print(ndo, bp, length, iph, fragmented);
+               if (ver == 4)
+                       icmp_print(ndo, bp, length, iph, 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:
@@ -149,14 +157,18 @@ 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:
                /* ipv4-in-ip encapsulation */
                ip_print(ndo, bp, length);
-               if (! ndo->ndo_vflag)
-                       ND_PRINT(" (ipip-proto-4)");
                break;
 
        case IPPROTO_IPV6:
@@ -184,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;
 
@@ -192,6 +204,16 @@ 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_NONE:
                ND_PRINT("no next header");
                break;