X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/49b23c5a9b0198bb382dcf43c458d46fcf2fa809..1bf91b1413a6d0eefb4c49bafdb612befa838556:/print-ip.c diff --git a/print-ip.c b/print-ip.c index 69e621d2..bb1554f9 100644 --- a/print-ip.c +++ b/print-ip.c @@ -330,6 +330,10 @@ again: switch (ipds->nh) { case IPPROTO_AH: + if (!ND_TTEST(*ipds->cp)) { + ND_PRINT((ndo, "[|AH]")); + break; + } ipds->nh = *ipds->cp; ipds->advance = ah_print(ndo, ipds->cp); if (ipds->advance <= 0) @@ -354,14 +358,14 @@ again: case IPPROTO_IPCOMP: { - int enh; - ipds->advance = ipcomp_print(ndo, ipds->cp, &enh); - if (ipds->advance <= 0) - break; - ipds->cp += ipds->advance; - ipds->len -= ipds->advance; - ipds->nh = enh & 0xff; - goto again; + ipcomp_print(ndo, ipds->cp); + /* + * Either this has decompressed 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_SCTP: @@ -526,13 +530,14 @@ ip_print(netdissect_options *ndo, ipds->ip = (const struct ip *)bp; ND_TCHECK(ipds->ip->ip_vhl); - if (IP_V(ipds->ip) != 4) { /* print version if != 4 */ + if (IP_V(ipds->ip) != 4) { /* print version and fail if != 4 */ if (IP_V(ipds->ip) == 6) ND_PRINT((ndo, "IP6, wrong link-layer encapsulation ")); else ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip))); + return; } - else if (!ndo->ndo_eflag) + if (!ndo->ndo_eflag) ND_PRINT((ndo, "IP ")); ND_TCHECK(*ipds->ip); @@ -681,24 +686,28 @@ trunc: void ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length) { - struct ip hdr; - - if (length < 4) { + if (length < 1) { ND_PRINT((ndo, "truncated-ip %d", length)); return; } - memcpy (&hdr, bp, 4); - switch (IP_V(&hdr)) { - case 4: + + ND_TCHECK(*bp); + switch (*bp & 0xF0) { + case 0x40: ip_print (ndo, bp, length); - return; - case 6: + break; + case 0x60: ip6_print (ndo, bp, length); - return; + break; default: - ND_PRINT((ndo, "unknown ip %d", IP_V(&hdr))); - return; + ND_PRINT((ndo, "unknown ip %d", (*bp & 0xF0) >> 4)); + break; } + return; + +trunc: + ND_PRINT((ndo, "%s", tstr)); + return; } /*