]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip6.c
Add printing support for vsockmon devices.
[tcpdump] / print-ip6.c
index 9802ce04cffc12c2bab2b6f5f356aba9a9a44ab1..9f8b4dbf63734ed7cf5f7fc3dd53eaf43723f36e 100644 (file)
@@ -53,6 +53,7 @@ ip6_finddst(netdissect_options *ndo, struct in6_addr *dst,
        const void *dst_addr;
        const struct ip6_rthdr *dp;
        const struct ip6_rthdr0 *dp0;
+       const struct ip6_srh *srh;
        const u_char *p;
        int i, len;
 
@@ -114,6 +115,19 @@ ip6_finddst(netdissect_options *ndo, struct in6_addr *dst,
                                        p += 16;
                                }
                                break;
+                       case IPV6_RTHDR_TYPE_4:
+                               /* IPv6 Segment Routing Header (SRH) */
+                               srh = (const struct ip6_srh *)dp;
+                               if (len % 2 == 1)
+                                       goto trunc;
+                               p = (const u_char *) srh->srh_segments;
+                               /*
+                                * The list of segments are encoded in the reverse order.
+                                * Accordingly, the final DA is encoded in srh_segments[0]
+                                */
+                               ND_TCHECK_16(p);
+                               dst_addr = (const void *)p;
+                               break;
 
                        default:
                                break;
@@ -281,6 +295,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
 
        cp = (const u_char *)ip6;
        advance = sizeof(struct ip6_hdr);
+       /* Process extension headers */
        while (cp < ndo->ndo_snapend && advance > 0) {
                if (len < (u_int)advance)
                        goto trunc;
@@ -295,18 +310,21 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
                }
 
                switch (nh) {
+
                case IPPROTO_HOPOPTS:
                        advance = hbhopt_print(ndo, cp);
                        if (advance < 0)
                                return;
                        nh = GET_U_1(cp);
                        break;
+
                case IPPROTO_DSTOPTS:
                        advance = dstopt_print(ndo, cp);
                        if (advance < 0)
                                return;
                        nh = GET_U_1(cp);
                        break;
+
                case IPPROTO_FRAGMENT:
                        advance = frag6_print(ndo, cp, (const u_char *)ip6);
                        if (advance < 0 || ndo->ndo_snapend <= cp + advance)
@@ -330,6 +348,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
                                return;
                        nh = GET_U_1(cp);
                        return;
+
                case IPPROTO_ROUTING:
                        ND_TCHECK_1(cp);
                        advance = rt6_print(ndo, cp, (const u_char *)ip6);
@@ -337,88 +356,14 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
                                return;
                        nh = GET_U_1(cp);
                        break;
-               case IPPROTO_SCTP:
-                       sctp_print(ndo, cp, (const u_char *)ip6, len);
-                       return;
-               case IPPROTO_DCCP:
-                       dccp_print(ndo, cp, (const u_char *)ip6, len);
-                       return;
-               case IPPROTO_TCP:
-                       tcp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
-                       return;
-               case IPPROTO_UDP:
-                       udp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
-                       return;
-               case IPPROTO_ICMPV6:
-                       icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
-                       return;
-               case IPPROTO_AH:
-                       advance = ah_print(ndo, cp);
-                       if (advance < 0)
-                               return;
-                       nh = GET_U_1(cp);
-                       break;
-               case IPPROTO_ESP:
-                   {
-                       u_int enh, padlen;
-                       advance = esp_print(ndo, cp, len, (const u_char *)ip6, &enh, &padlen);
-                       if (advance < 0)
-                               return;
-                       nh = enh & 0xff;
-                       len -= padlen;
-                       break;
-                   }
-               case IPPROTO_IPCOMP:
-                   {
-                       ipcomp_print(ndo, 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.
-                        */
-                       advance = -1;
-                       break;
-                   }
-
-               case IPPROTO_PIM:
-                       pim_print(ndo, cp, len, (const u_char *)ip6);
-                       return;
-
-               case IPPROTO_OSPF:
-                       ospf6_print(ndo, cp, len);
-                       return;
-
-               case IPPROTO_IPV6:
-                       ip6_print(ndo, cp, len);
-                       return;
-
-               case IPPROTO_IPV4:
-                       ip_print(ndo, cp, len);
-                       return;
-
-                case IPPROTO_PGM:
-                        pgm_print(ndo, cp, len, (const u_char *)ip6);
-                        return;
-
-               case IPPROTO_GRE:
-                       gre_print(ndo, cp, len);
-                       return;
-
-               case IPPROTO_RSVP:
-                       rsvp_print(ndo, cp, len);
-                       return;
-
-               case IPPROTO_EIGRP:
-                       eigrp_print(ndo, cp, len);
-                       return;
-
-               case IPPROTO_NONE:
-                       ND_PRINT("no next header");
-                       return;
 
                default:
-                       ND_PRINT("ip-proto-%u %u", nh, len);
+                       /*
+                        * Not an extension header; hand off to the
+                        * IP protocol demuxer.
+                        */
+                       ip_print_demux(ndo, cp, len, 6, fragmented,
+                           GET_U_1(ip6->ip6_hlim), nh, bp);
                        return;
                }