[email protected] (Jeremie Courreges-Anglas) writes:

> As defined by https://tools.ietf.org/html/rfc4191, prompted by
> http://marc.info/?l=openbsd-misc&m=146239072929264&w=2
>
> "pref" is inspired by upstream tcpdump format.
>
> Thoughts / ok?

Committed, thanks for the reviews.

What about the same thing for route info options?

Index: print-icmp6.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/print-icmp6.c,v
retrieving revision 1.19
diff -u -p -p -u -r1.19 print-icmp6.c
--- print-icmp6.c       6 May 2016 17:16:24 -0000       1.19
+++ print-icmp6.c       6 May 2016 18:54:31 -0000
@@ -526,7 +526,10 @@ icmp6_opt_print(const u_char *bp, int re
        const struct icmp6_opts_redirect *opr;
        const struct nd_opt_mtu *opm;
        const struct nd_opt_rdnss *oprd;
+       const struct nd_opt_route_info *opri;
        const u_char *ep;
+       const struct in6_addr *in6p;
+       struct in6_addr in6;
        int     i, opts_len;
 #if 0
        const struct ip6_hdr *ip;
@@ -642,7 +645,43 @@ icmp6_opt_print(const u_char *bp, int re
                                resid - (op->nd_opt_len << 3));
                break;
        case ND_OPT_ROUTE_INFO:
-               printf("(route-info: opt_len=%d)", op->nd_opt_len);
+               opri = (struct nd_opt_route_info *)op;
+               TCHECK(opri->nd_opt_rti_lifetime);
+               printf("(route-info: ");
+               memset(&in6, 0, sizeof(in6));
+               in6p = (const struct in6_addr *)(opri + 1);
+               switch (op->nd_opt_len) {
+               case 1:
+                       break;
+               case 2:
+                       TCHECK2(*in6p, 8);
+                       memcpy(&in6, opri + 1, 8);
+                       break;
+               case 3:
+                       TCHECK(*in6p);
+                       memcpy(&in6, opri + 1, sizeof(in6));
+                       break;
+               default:
+                       goto trunc;
+               }
+               printf("%s/%u, ", ip6addr_string(&in6),
+                   opri->nd_opt_rti_prefixlen);
+               switch (opri->nd_opt_rti_flags & ND_RA_FLAG_RTPREF_MASK) {
+               case ND_RA_FLAG_RTPREF_HIGH:
+                       printf("pref=high, ");
+                       break;
+               case ND_RA_FLAG_RTPREF_MEDIUM:
+                       printf("pref=medium, ");
+                       break;
+               case ND_RA_FLAG_RTPREF_LOW:
+                       printf("pref=low, ");
+                       break;
+               case ND_RA_FLAG_RTPREF_RSV:
+                       printf("pref=rsv, ");
+                       break;
+               }
+               printf("lifetime=%us)",
+                   (u_int32_t)ntohl(opri->nd_opt_rti_lifetime));
                icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
                                resid - (op->nd_opt_len << 3));
                break;

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to