#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.52 2001-06-01 04:08:57 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.60 2002-05-30 22:01:34 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include <arpa/inet.h>
#include <stdio.h>
+#include <string.h>
#include <netdb.h>
#include "ip6.h"
#define abs(a) ((0 < (a)) ? (a) : -(a))
#endif
-#ifndef ND_RA_FLAG_RTPREF_MASK
-#define ND_RA_FLAG_RTPREF_MASK 0x18
-#endif
-
static const char *
get_rtpref(u_int v)
{
char buf[256];
int icmp6len, prot;
-#if 0
-#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
-#endif
-
dp = (struct icmp6_hdr *)bp;
ip = (struct ip6_hdr *)bp2;
oip = (struct ip6_hdr *)(dp + 1);
else /* XXX: jumbo payload case... */
icmp6len = snapend - bp;
-#if 0
- (void)printf("%s > %s: ",
- ip6addr_string(&ip->ip6_src),
- ip6addr_string(&ip->ip6_dst));
-#endif
-
TCHECK(dp->icmp6_code);
switch (dp->icmp6_type) {
case ICMP6_DST_UNREACH:
printf("M");
if (p->nd_ra_flags_reserved & ND_RA_FLAG_OTHER)
printf("O");
-#ifndef ND_RA_FLAG_HA
-#define ND_RA_FLAG_HA 0x20
-#endif
- if (p->nd_ra_flags_reserved & ND_RA_FLAG_HA)
+ if (p->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT)
printf("H");
if ((p->nd_ra_flags_reserved & ~ND_RA_FLAG_RTPREF_MASK)
case ICMP6_NI_REPLY:
icmp6_nodeinfo_print(icmp6len, bp, ep);
break;
+ case ICMP6_HADISCOV_REQUEST:
+ case ICMP6_HADISCOV_REPLY:
+ {
+ struct in6_addr *in6;
+ u_int32_t *res;
+ u_char *cp;
+ printf("icmp6: ha discovery %s: ",
+ dp->icmp6_type == ICMP6_HADISCOV_REQUEST ?
+ "request" : "reply");
+ TCHECK(dp->icmp6_data16[0]);
+ printf("id=%d", ntohs(dp->icmp6_data16[0]));
+ cp = (u_char *)dp + icmp6len;
+ res = (u_int32_t *)(dp + 1);
+ in6 = (struct in6_addr *)(res + 2);
+ for (; (u_char *)in6 < cp; in6++) {
+ TCHECK(*in6);
+ printf(", %s", ip6addr_string(in6));
+ }
+ break;
+ }
+ case ICMP6_MOBILEPREFIX_SOLICIT:
+ case ICMP6_MOBILEPREFIX_ADVERT:
default:
printf("icmp6: type-#%d", dp->icmp6_type);
break;
return;
trunc:
fputs("[|icmp6]", stdout);
-#if 0
-#undef TCHECK
-#endif
}
static struct udphdr *
const struct icmp6_opts_redirect *opr;
const struct nd_opt_mtu *opm;
const struct nd_opt_advinterval *opa;
+ const struct nd_opt_homeagent_info *oph;
const struct nd_opt_route_info *opri;
const u_char *cp, *ep;
struct in6_addr in6, *in6p;
/*(*/
printf(")");
break;
+ case ND_OPT_HOMEAGENT_INFO:
+ oph = (struct nd_opt_homeagent_info *)op;
+ TCHECK(oph->nd_opt_hai_lifetime);
+ printf("(ha info:"); /*)*/
+ printf(" pref=%d", ntohs(oph->nd_opt_hai_preference));
+ printf(", lifetime=%u", ntohs(oph->nd_opt_hai_lifetime));
+ printf(")");
+ break;
case ND_OPT_ROUTE_INFO:
opri = (struct nd_opt_route_info *)op;
TCHECK(opri->nd_opt_rti_lifetime);
printf(")");
break;
default:
- printf("(unknwon opt_type=%d, opt_len=%d)",
+ printf("(unknown opt_type=%d, opt_len=%d)",
op->nd_opt_type, op->nd_opt_len);
break;
}