X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/9d046ee0503d4c8cbfcb200c88986de876f6cae7..b51a0dafc7861eb31d21524ec067d7c529a664b8:/print-ip-demux.c diff --git a/print-ip-demux.c b/print-ip-demux.c index f18055d6..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,7 +35,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 +103,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,7 +159,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 +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; @@ -190,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;