[BACK]Return to mroute6.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / netstat

Diff for /src/usr.bin/netstat/mroute6.c between version 1.16 and 1.17

version 1.16, 2015/01/17 07:09:50 version 1.17, 2015/02/09 12:25:03
Line 65 
Line 65 
  */   */
   
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/queue.h>  
 #include <sys/socket.h>  #include <sys/socket.h>
 #include <sys/protosw.h>  
 #include <sys/sysctl.h>  #include <sys/sysctl.h>
   
 #include <net/if.h>  #include <net/if.h>
 #include <net/if_var.h>  
   
 #include <netinet/in.h>  #include <netinet/in.h>
   
 #define _KERNEL  
 #include <netinet6/ip6_mroute.h>  #include <netinet6/ip6_mroute.h>
 #undef _KERNEL  
   
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <stdio.h>  #include <stdio.h>
   #include <util.h>
 #include "netstat.h"  #include "netstat.h"
   
 #define WID_ORG (lflag ? 39 : (nflag ? 29 : 18)) /* width of origin column */  #define WID_ORG (lflag ? 39 : (nflag ? 29 : 18)) /* width of origin column */
 #define WID_GRP (lflag ? 18 : (nflag ? 16 : 18)) /* width of group column */  #define WID_GRP (lflag ? 18 : (nflag ? 16 : 18)) /* width of group column */
   
 void  void
 mroute6pr(u_long mfcaddr, u_long mifaddr)  mroute6pr(void)
 {  {
         int banner_printed, saved_nflag, waitings, i;          char *buf;
         struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp;          char fmtbuf[FMT_SCALED_STRSIZE];
         struct mif6 mif6table[MAXMIFS], *mifp;          struct mf6cinfo *mfc;
         struct rtdetq rte, *rtep;          struct mif6info *mif;
         mifi_t maxmif = 0, mifi;          size_t needed, mifi, nummifs, mfci, nummfcs;
         struct mf6c mfc;          int banner_printed, saved_nflag;
           mifi_t maxmif = 0;
         u_int mrtproto;          u_int mrtproto;
         int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_MRTPROTO };          int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_MRTPROTO };
         size_t len = sizeof(int);          size_t len = sizeof(int);
Line 118 
Line 113 
                 return;                  return;
         }          }
   
         if (mfcaddr == 0) {  
                 printf("mf6ctable: symbol not in namelist\n");  
                 return;  
         }  
         if (mifaddr == 0) {  
                 printf("miftable: symbol not in namelist\n");  
                 return;  
         }  
   
         saved_nflag = nflag;          saved_nflag = nflag;
         nflag = 1;          nflag = 1;
   
         kread(mifaddr, &mif6table, sizeof(mif6table));          mib[3] = IPV6CTL_MRTMIF;
           needed = get_sysctl(mib, sizeof(mib) / sizeof(mib[0]), &buf);
           nummifs = needed / sizeof(*mif);
           mif = (struct mif6info *)buf;
           if (nummifs)
                   maxmif = mif[nummifs - 1].m6_mifi;
   
         banner_printed = 0;          banner_printed = 0;
         for (mifi = 0, mifp = mif6table; mifi < MAXMIFS; ++mifi, ++mifp) {          for (mifi = 0; mifi < nummifs; ++mifi, ++mif) {
                 struct ifnet ifnet;  
                 char ifname[IFNAMSIZ];                  char ifname[IFNAMSIZ];
   
                 if (mifp->m6_ifp == NULL)                  if (mif->m6_ifindex == 0)
                         continue;                          continue;
   
                 kread((u_long)mifp->m6_ifp, &ifnet, sizeof(ifnet));  
                 maxmif = mifi;  
                 if (!banner_printed) {                  if (!banner_printed) {
                         printf("\nIPv6 Multicast Interface Table\n"                          printf("\nIPv6 Multicast Interface Table\n"
                             " Mif   Rate   PhyIF   "                              " Mif   Rate   PhyIF   "
Line 149 
Line 138 
                 }                  }
   
                 printf("  %2u   %4d",                  printf("  %2u   %4d",
                     mifi, mifp->m6_rate_limit);                      mif->m6_mifi, mif->m6_rate_limit);
                 printf("   %5s", (mifp->m6_flags & MIFF_REGISTER) ?                  printf("   %5s", (mif->m6_flags & MIFF_REGISTER) ?
                     "reg0" : if_indextoname(ifnet.if_index, ifname));                      "reg0" : if_indextoname(mif->m6_ifindex, ifname));
   
                 printf(" %9llu  %9llu\n", mifp->m6_pkt_in, mifp->m6_pkt_out);                  printf(" %9llu  %9llu\n", mif->m6_pkt_in, mif->m6_pkt_out);
         }          }
         if (!banner_printed)          if (!banner_printed)
                 printf("IPv6 Multicast Interface Table is empty\n");                  printf("IPv6 Multicast Interface Table is empty\n");
   
         kread(mfcaddr, &mf6ctable, sizeof(mf6ctable));          mib[3] = IPV6CTL_MRTMFC;
           needed = get_sysctl(mib, sizeof(mib) / sizeof(mib[0]), &buf);
           nummfcs = needed / sizeof(*mfc);
           mfc = (struct mf6cinfo *)buf;
   
         banner_printed = 0;          banner_printed = 0;
         for (i = 0; i < MF6CTBLSIZ; ++i) {          for (mfci = 0; mfci < nummfcs; ++mfci, ++mfc) {
                 mfcp = mf6ctable[i];                  if (!banner_printed) {
                 while (mfcp) {                          printf("\nIPv6 Multicast Forwarding Cache\n");
                         kread((u_long)mfcp, &mfc, sizeof(mfc));                          printf(" %-*.*s %-*.*s %s",
                         if (!banner_printed) {                              WID_ORG, WID_ORG, "Origin",
                                 printf("\nIPv6 Multicast Forwarding Cache\n");                              WID_GRP, WID_GRP, "Group",
                                 printf(" %-*.*s %-*.*s %s",                              "  Packets Waits In-Mif  Out-Mifs\n");
                                     WID_ORG, WID_ORG, "Origin",                          banner_printed = 1;
                                     WID_GRP, WID_GRP, "Group",                  }
                                     "  Packets Waits In-Mif  Out-Mifs\n");  
                                 banner_printed = 1;  
                         }  
   
                         printf(" %-*.*s", WID_ORG, WID_ORG,                  printf(" %-*.*s", WID_ORG, WID_ORG,
                             routename6(&mfc.mf6c_origin));                      routename6(&mfc->mf6c_origin));
                         printf(" %-*.*s", WID_GRP, WID_GRP,                  printf(" %-*.*s", WID_GRP, WID_GRP,
                             routename6(&mfc.mf6c_mcastgrp));                      routename6(&mfc->mf6c_mcastgrp));
                         printf(" %9llu", mfc.mf6c_pkt_cnt);                  fmt_scaled(mfc->mf6c_pkt_cnt, fmtbuf);
                   printf(" %9s", fmtbuf);
   
                         for (waitings = 0, rtep = mfc.mf6c_stall; rtep; ) {                  printf("   %3llu", mfc->mf6c_stall_cnt);
                                 waitings++;  
                                 kread((u_long)rtep, &rte, sizeof(rte));  
                                 rtep = rte.next;  
                         }  
                         printf("   %3d", waitings);  
   
                         if (mfc.mf6c_parent == MF6C_INCOMPLETE_PARENT)                  if (mfc->mf6c_parent == MF6C_INCOMPLETE_PARENT)
                                 printf("  ---   ");                          printf("  ---   ");
                         else                  else
                                 printf("  %3d   ", mfc.mf6c_parent);                          printf("  %3d   ", mfc->mf6c_parent);
                         for (mifi = 0; mifi <= MAXMIFS; mifi++) {                  for (mifi = 0; mifi <= MAXMIFS; mifi++) {
                                 if (IF_ISSET(mifi, &mfc.mf6c_ifset))                          if (IF_ISSET(mifi, &mfc->mf6c_ifset))
                                         printf(" %u", mifi);                                  printf(" %zu", mifi);
                         }  
                         printf("\n");  
   
                         mfcp = mfc.mf6c_next;  
                 }                  }
                   printf("\n");
         }          }
         if (!banner_printed)          if (!banner_printed)
                 printf("IPv6 Multicast Routing Table is empty");                  printf("IPv6 Multicast Routing Table is empty");

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17