#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
#include <stdio.h>
#include <string.h>
-#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"
{ 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"},
{ 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 }
{
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;
nh = ip6->ip6_nxt;
hlen = sizeof(struct ip6_hdr);
- while (bp < snapend) {
+ while (bp < ep) {
bp += hlen;
switch(nh) {
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;
}
/* 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("]");
}
}
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) {
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
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;
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);