X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/202051bb55f5e99fb304c4b68cfb2a729fe2d55e..a10ab62bf4f611c63b479df48ab8c9192fa0b281:/print-ip-demux.c diff --git a/print-ip-demux.c b/print-ip-demux.c index 265658e7..a0a6fbd1 100644 --- a/print-ip-demux.c +++ b/print-ip-demux.c @@ -27,8 +27,6 @@ #include "netdissect-stdinc.h" -#include - #include "netdissect.h" #include "addrtoname.h" #include "extract.h" @@ -37,10 +35,10 @@ #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; @@ -66,15 +64,14 @@ again: case IPPROTO_ESP: { - u_int enh, padlen; - advance = esp_print(ndo, bp, length, - iph, &enh, &padlen); - if (advance <= 0) - break; - bp += advance; - length -= advance + padlen; - nh = enh & 0xff; - goto again; + esp_print(ndo, bp, length, iph, ver, fragmented, ttl_hl); + /* + * Either this has decrypted the payload and + * printed it, in which case there's nothing more + * to do, or it hasn't, in which case there's + * nothing more to do. + */ + break; } case IPPROTO_IPCOMP: @@ -106,12 +103,24 @@ 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); - return; + 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: /* @@ -150,16 +159,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)"); - return; - } break; case IPPROTO_IPV6: @@ -187,7 +198,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; @@ -195,6 +206,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;