X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/932c88e77273a35731ec8598b1e101583d5e9e2e..ffa1470e5c7ff0e50028d085a481dc797b0b51ed:/print-icmp6.c?ds=sidebyside diff --git a/print-icmp6.c b/print-icmp6.c index a9f53cfe..5bf0f7e1 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.79 2005-01-14 10:41:50 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.79.2.6 2005-09-05 09:29:28 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -35,14 +35,14 @@ static const char rcsid[] _U_ = #include #include -#include "ip6.h" -#include "icmp6.h" -#include "ipproto.h" - #include "interface.h" #include "addrtoname.h" #include "extract.h" +#include "ip6.h" +#include "icmp6.h" +#include "ipproto.h" + #include "udp.h" #include "ah.h" @@ -69,18 +69,18 @@ static struct tok icmp6_type_values[] = { { ICMP6_PARAM_PROB, "parameter problem"}, { ICMP6_ECHO_REQUEST, "echo request"}, { ICMP6_ECHO_REPLY, "echo reply"}, - { MLD6_LISTENER_QUERY, "multicast listener query "}, - { MLD6_LISTENER_REPORT, "multicast listener report "}, - { MLD6_LISTENER_DONE, "multicast listener done "}, - { ND_ROUTER_SOLICIT, "router solicitation "}, + { MLD6_LISTENER_QUERY, "multicast listener query"}, + { MLD6_LISTENER_REPORT, "multicast listener report"}, + { MLD6_LISTENER_DONE, "multicast listener done"}, + { ND_ROUTER_SOLICIT, "router solicitation"}, { ND_ROUTER_ADVERT, "router advertisement"}, { ND_NEIGHBOR_SOLICIT, "neighbor solicitation"}, - { ND_NEIGHBOR_ADVERT, "neighbor advertisment"}, + { ND_NEIGHBOR_ADVERT, "neighbor advertisement"}, { ND_REDIRECT, "redirect"}, { ICMP6_ROUTER_RENUMBERING, "router renumbering"}, { IND_SOLICIT, "inverse neighbor solicitation"}, { IND_ADVERT, "inverse neighbor advertisement"}, - { MLDV2_LISTENER_REPORT, "multicast listener report v2 "}, + { MLDV2_LISTENER_REPORT, "multicast listener report v2"}, { ICMP6_HADISCOV_REQUEST, "ha discovery request"}, { ICMP6_HADISCOV_REPLY, "ha discovery reply"}, { ICMP6_MOBILEPREFIX_SOLICIT, "mobile router solicitation"}, @@ -131,7 +131,7 @@ static struct tok icmp6_opt_values[] = { { ND_OPT_PREFIX_INFORMATION, "prefix info"}, { ND_OPT_REDIRECTED_HEADER, "redirected header"}, { ND_OPT_MTU, "mtu"}, - { ND_OPT_ADVINTERVAL, "advertisment interval"}, + { ND_OPT_ADVINTERVAL, "advertisement interval"}, { ND_OPT_HOMEAGENT_INFO, "homeagent information"}, { ND_OPT_ROUTE_INFO, "route info"}, { 0, NULL } @@ -237,18 +237,15 @@ icmp6_print(const u_char *bp, u_int length, const u_char *bp2, int fragmented) { const struct icmp6_hdr *dp; const struct ip6_hdr *ip; - const char *str; const struct ip6_hdr *oip; const struct udphdr *ouh; int dport; const u_char *ep; - char buf[256]; u_int prot; dp = (struct icmp6_hdr *)bp; ip = (struct ip6_hdr *)bp2; oip = (struct ip6_hdr *)(dp + 1); - str = buf; /* 'ep' points to the end of available data. */ ep = snapend; @@ -542,7 +539,7 @@ get_upperlayer(u_char *bp, u_int *prot) nh = ip6->ip6_nxt; hlen = sizeof(struct ip6_hdr); - while (bp < snapend) { + while (bp < ep) { bp += hlen; switch(nh) { @@ -767,13 +764,13 @@ mldv2_report_print(const u_char *bp, u_int len) printf(" [invalid number of groups]"); return; } - TCHECK2(bp[group + 4], 16); + TCHECK2(bp[group + 4], sizeof(struct in6_addr)); printf(" [gaddr %s", ip6addr_string(&bp[group + 4])); printf(" %s", tok2str(mldv2report2str, " [v2-report-#%d]", bp[group])); nsrcs = (bp[group + 2] << 8) + bp[group + 3]; /* Check the number of sources and print them */ - if (len < group + 20 + (nsrcs * 16)) { + if (len < group + 20 + (nsrcs * sizeof(struct in6_addr))) { printf(" [invalid number of sources %d]", nsrcs); return; } @@ -783,13 +780,14 @@ mldv2_report_print(const u_char *bp, u_int len) /* Print the sources */ (void)printf(" {"); for (j = 0; j < nsrcs; j++) { - TCHECK2(bp[group + 20 + j * 16], 16); - printf(" %s", ip6addr_string(&bp[group + 20 + j * 16])); + TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)], + sizeof(struct in6_addr)); + printf(" %s", ip6addr_string(&bp[group + 20 + j * sizeof(struct in6_addr)])); } (void)printf(" }"); } /* Next group record */ - group += 20 + nsrcs * 16; + group += 20 + nsrcs * sizeof(struct in6_addr); printf("]"); } } @@ -823,7 +821,7 @@ mldv2_query_print(const u_char *bp, u_int len) if (vflag) { (void)printf(" [max resp delay=%d]", mrt); } - TCHECK2(bp[8], 16); + TCHECK2(bp[8], sizeof(struct in6_addr)); printf(" [gaddr %s", ip6addr_string(&bp[8])); if (vflag) { @@ -845,13 +843,14 @@ mldv2_query_print(const u_char *bp, u_int len) TCHECK2(bp[26], 2); nsrcs = ntohs(*(u_short *)&bp[26]); if (nsrcs > 0) { - if (len < 28 + nsrcs * 16) + if (len < 28 + nsrcs * sizeof(struct in6_addr)) printf(" [invalid number of sources]"); else if (vflag > 1) { printf(" {"); for (i = 0; i < nsrcs; i++) { - TCHECK2(bp[28 + i * 16], 16); - printf(" %s", ip6addr_string(&bp[28 + i * 16])); + TCHECK2(bp[28 + i * sizeof(struct in6_addr)], + sizeof(struct in6_addr)); + printf(" %s", ip6addr_string(&bp[28 + i * sizeof(struct in6_addr)])); } printf(" }"); } else @@ -1153,8 +1152,6 @@ static void icmp6_rrenum_print(const u_char *bp, const u_char *ep) { struct icmp6_router_renum *rr6; - struct icmp6_hdr *dp; - size_t siz; const char *cp; struct rr_pco_match *match; struct rr_pco_use *use; @@ -1163,9 +1160,7 @@ icmp6_rrenum_print(const u_char *bp, const u_char *ep) if (ep < bp) return; - dp = (struct icmp6_hdr *)bp; rr6 = (struct icmp6_router_renum *)bp; - siz = ep - bp; cp = (const char *)(rr6 + 1); TCHECK(rr6->rr_reserved);