]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-icmp6.c
Get rid of unneeded includes of <netinet/in_systm.h> and <netinet/ip.h>.
[tcpdump] / print-icmp6.c
index 1b47c89c6f9663c0351f53fe5ccac8f2a74e6666..71323c7dcd895098be86fd971e2c98edaa29cc78 100644 (file)
@@ -21,7 +21,7 @@
 
 #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
@@ -43,6 +43,7 @@ static const char rcsid[] =
 #include <arpa/inet.h>
 
 #include <stdio.h>
+#include <string.h>
 #include <netdb.h>
 
 #include "ip6.h"
@@ -68,10 +69,6 @@ void icmp6_rrenum_print(int, const u_char *, const u_char *);
 #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)
 {
@@ -126,10 +123,6 @@ icmp6_print(const u_char *bp, const u_char *bp2)
        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);
@@ -142,12 +135,6 @@ icmp6_print(const u_char *bp, const u_char *bp2)
        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:
@@ -280,10 +267,7 @@ icmp6_print(const u_char *bp, const u_char *bp2)
                                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)
@@ -372,6 +356,28 @@ icmp6_print(const u_char *bp, const u_char *bp2)
        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;
@@ -379,9 +385,6 @@ icmp6_print(const u_char *bp, const u_char *bp2)
        return;
 trunc:
        fputs("[|icmp6]", stdout);
-#if 0
-#undef TCHECK
-#endif
 }
 
 static struct udphdr *
@@ -466,6 +469,7 @@ icmp6_opt_print(const u_char *bp, int resid)
        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;
@@ -564,6 +568,14 @@ icmp6_opt_print(const u_char *bp, int resid)
                        /*(*/
                        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);
@@ -593,7 +605,7 @@ icmp6_opt_print(const u_char *bp, int resid)
                        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;
                }