rt_metrics: Add rmx_iw* to record user-set IW parameters
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 12 Apr 2012 08:55:25 +0000 (16:55 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 12 Apr 2012 08:55:25 +0000 (16:55 +0800)
sbin/route/keywords
sbin/route/route.c
sys/net/route.h
sys/net/rtsock.c
usr.bin/netstat/route.c

index d0875df..75ad048 100644 (file)
@@ -55,3 +55,5 @@ x25
 xns
 xresolve
 msl
+iwmax
+iw
index 6297257..ee4cc88 100644 (file)
@@ -563,6 +563,8 @@ set_metric(char *value, int key)
        caseof(K_RTT, RTV_RTT, rmx_rtt);
        caseof(K_RTTVAR, RTV_RTTVAR, rmx_rttvar);
        caseof(K_MSL, RTV_MSL, rmx_msl);
+       caseof(K_IWMAX, RTV_IWMAXSEGS, rmx_iwmaxsegs);
+       caseof(K_IW, RTV_IWCAPSEGS, rmx_iwcapsegs);
        }
        rtm_inits |= flag;
        if (lockrest || locking)
@@ -763,6 +765,8 @@ newroute(int argc, char **argv)
                        case K_RTT:
                        case K_RTTVAR:
                        case K_MSL:
+                       case K_IWMAX:
+                       case K_IW:
                                if (--argc == 0)
                                        usage(NULL);
                                set_metric(*++argv, key);
@@ -1376,8 +1380,8 @@ const char *msgtypes[] = {
 };
 
 char metricnames[] =
-"\011msl\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount"
-"\1mtu";
+"\013iw\012iwmax\011msl\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire"
+"\2hopcount\1mtu";
 char routeflags[] =
 "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT"
 "\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016"
@@ -1529,7 +1533,7 @@ print_getmsg(struct rt_msghdr *rtm, int msglen)
 #define msec(u)        (((u) + 500) / 1000)            /* usec to msec */
 
        printf("\n%s\n", "\
- recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire  msl,msec");
+ recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire  msl,msec iwmax iw");
        printf("%8ld%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE));
        printf("%8ld%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE));
        printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH));
@@ -1540,7 +1544,9 @@ print_getmsg(struct rt_msghdr *rtm, int msglen)
        if (rtm->rtm_rmx.rmx_expire != 0)
                rtm->rtm_rmx.rmx_expire -= time(0);
        printf("%8ld%c ", rtm->rtm_rmx.rmx_expire, lock(EXPIRE));
-       printf("%8ld\n", rtm->rtm_rmx.rmx_msl);
+       printf("%8ld ", rtm->rtm_rmx.rmx_msl);
+       printf("%5ld ", rtm->rtm_rmx.rmx_iwmaxsegs);
+       printf("%3ld\n", rtm->rtm_rmx.rmx_iwcapsegs);
 #undef lock
 #undef msec
 #define        RTA_IGN (RTA_DST|RTA_GATEWAY|RTA_NETMASK|RTA_IFP|RTA_IFA|RTA_BRD)
index f778712..a530099 100644 (file)
@@ -117,7 +117,8 @@ struct rt_metrics { /* grouped for locality of reference */
        u_short rmx_mssopt;     /* peer's cached MSS */
        u_short rmx_pad;        /* explicit pad */
        u_long  rmx_msl;        /* maximum segment lifetime, unit: ms */
-       u_long  rmx_filler[2];  /* for future expansion */
+       u_long  rmx_iwmaxsegs;  /* IW segments max */
+       u_long  rmx_iwcapsegs;  /* IW segments */
 };
 
 /*
@@ -273,6 +274,8 @@ struct rt_msghdr {
 #define RTV_RTT                0x40    /* init or lock _rtt */
 #define RTV_RTTVAR     0x80    /* init or lock _rttvar */
 #define RTV_MSL                0x100   /* init or lock _msl */
+#define RTV_IWMAXSEGS  0x200   /* init or lock _iwmaxsegs */
+#define RTV_IWCAPSEGS  0x400   /* init or lock _iwcapsegs */
 
 /*
  * Bitmask values for rtm_addrs.
index c187292..56792c5 100644 (file)
@@ -789,6 +789,8 @@ rt_setmetrics(u_long which, struct rt_metrics *in, struct rt_metrics *out)
        setmetric(RTV_MTU, rmx_mtu);
        setmetric(RTV_EXPIRE, rmx_expire);
        setmetric(RTV_MSL, rmx_msl);
+       setmetric(RTV_IWMAXSEGS, rmx_iwmaxsegs);
+       setmetric(RTV_IWCAPSEGS, rmx_iwcapsegs);
 #undef setmetric
 }
 
index fe37512..818b81d 100644 (file)
@@ -247,6 +247,8 @@ static int wid_if;
 static int wid_expire;
 static int wid_mplslops;
 static int wid_msl;
+static int wid_iwmax;
+static int wid_iw;
 
 static void
 size_cols(int ef, struct radix_node *rn)
@@ -261,6 +263,8 @@ size_cols(int ef, struct radix_node *rn)
        wid_expire = 6;
        wid_mplslops = 7;
        wid_msl = 7;
+       wid_iwmax = 5;
+       wid_iw = 2;
 
        if (Wflag)
                size_cols_tree(rn);
@@ -363,6 +367,16 @@ size_cols_rtentry(struct rtentry *rt)
                                       "%lu", rt->rt_rmx.rmx_msl);
                        wid_msl = MAX(len, wid_msl);
                }
+               if (rt->rt_rmx.rmx_iwmaxsegs) {
+                       len = snprintf(buffer, sizeof(buffer),
+                                      "%lu", rt->rt_rmx.rmx_iwmaxsegs);
+                       wid_iwmax = MAX(len, wid_iwmax);
+               }
+               if (rt->rt_rmx.rmx_iwcapsegs) {
+                       len = snprintf(buffer, sizeof(buffer),
+                                      "%lu", rt->rt_rmx.rmx_iwcapsegs);
+                       wid_iw = MAX(len, wid_iw);
+               }
        }
 }
 
@@ -378,7 +392,8 @@ pr_rthdr(int af1)
                printf("%-8.8s ","Address");
        if (af1 == AF_INET || Wflag) {
                if (Wflag) {
-                       printf("%-*.*s %-*.*s %-*.*s %*.*s %*.*s %*.*s %*.*s %*s %-*s %*s\n",
+                       printf("%-*.*s %-*.*s %-*.*s %*.*s %*.*s %*.*s %*.*s "
+                              "%*s %-*s%*s %*s %*s\n",
                                wid_dst,        wid_dst,        "Destination",
                                wid_gw,         wid_gw,         "Gateway",
                                wid_flags,      wid_flags,      "Flags",
@@ -388,7 +403,9 @@ pr_rthdr(int af1)
                                wid_if,         wid_if,         "Netif",
                                wid_expire,                     "Expire",
                                wid_mplslops,                   "Labelops",
-                               wid_msl,                        "Msl");
+                               wid_msl,                        "Msl",
+                               wid_iwmax,                      "IWmax",
+                               wid_iw,                         "IW");
                } else {
                        printf("%-*.*s %-*.*s %-*.*s %*.*s %*.*s %*.*s %*s\n",
                                wid_dst,        wid_dst,        "Destination",
@@ -801,7 +818,15 @@ p_rtentry(struct rtentry *rt)
                if (rt->rt_rmx.rmx_msl != 0)
                        printf(" %*lu", wid_msl, rt->rt_rmx.rmx_msl);
                else
-                       printf(" %*s", wid_msl, "");
+                       printf("%*s ", wid_msl, "");
+               if (rt->rt_rmx.rmx_iwmaxsegs != 0)
+                       printf(" %*lu", wid_iwmax, rt->rt_rmx.rmx_iwmaxsegs);
+               else
+                       printf("%*s ", wid_iwmax, "");
+               if (rt->rt_rmx.rmx_iwcapsegs != 0)
+                       printf(" %*lu", wid_iw, rt->rt_rmx.rmx_iwcapsegs);
+               else
+                       printf("%*s ", wid_iw, "");
        }
        putchar('\n');
 }