[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.9 and 1.10

version 1.9, 2007/09/11 18:16:48 version 1.10, 2007/12/14 18:35:46
Line 69 
Line 69 
 #include <sys/socket.h>  #include <sys/socket.h>
 #include <sys/socketvar.h>  #include <sys/socketvar.h>
 #include <sys/protosw.h>  #include <sys/protosw.h>
   #include <sys/sysctl.h>
   
 #include <net/if.h>  #include <net/if.h>
   
Line 79 
Line 80 
 #undef _KERNEL  #undef _KERNEL
   
 #include <stdio.h>  #include <stdio.h>
   #include <errno.h>
 #include "netstat.h"  #include "netstat.h"
   
 #ifdef INET6  
   
 #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 mrpaddr, u_long mfcaddr, u_long mifaddr)  mroute6pr(u_long mfcaddr, u_long mifaddr)
 {  {
         int banner_printed, saved_nflag, waitings, i;          int banner_printed, saved_nflag, waitings, i;
         struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp;          struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp;
Line 96 
Line 96 
         mifi_t maxmif = 0, mifi;          mifi_t maxmif = 0, mifi;
         struct mf6c mfc;          struct mf6c mfc;
         u_int mrtproto;          u_int mrtproto;
           int mib[] = { CTL_NET, AF_INET6, IPPROTO_IPV6, IPV6CTL_MRTPROTO };
           size_t len = sizeof(int);
   
         if (mrpaddr == 0) {          if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
                 printf("mroute6pr: symbol not in namelist\n");              &mrtproto, &len, NULL, 0) == -1) {
                   if (errno != ENOPROTOOPT)
                           warn("mroute");
                 return;                  return;
         }          }
   
         kread(mrpaddr, &mrtproto, sizeof(mrtproto));  
         switch (mrtproto) {          switch (mrtproto) {
   
         case 0:          case 0:
                 printf("no IPv6 multicast routing compiled into this system\n");                  printf("no IPv6 multicast routing compiled into this system\n");
                 return;                  return;
   
         case IPPROTO_PIM:          case IPPROTO_PIM:
                 break;                  break;
   
         default:          default:
                 printf("IPv6 multicast routing protocol %u, unknown\n",                  printf("IPv6 multicast routing protocol %u, unknown\n",
                     mrtproto);                      mrtproto);
Line 156 
Line 155 
                 printf(" %9llu  %9llu\n", mifp->m6_pkt_in, mifp->m6_pkt_out);                  printf(" %9llu  %9llu\n", mifp->m6_pkt_in, mifp->m6_pkt_out);
         }          }
         if (!banner_printed)          if (!banner_printed)
                 printf("\nIPv6 Multicast Interface Table is empty\n");                  printf("IPv6 Multicast Interface Table is empty\n");
   
         kread(mfcaddr, &mf6ctable, sizeof(mf6ctable));          kread(mfcaddr, &mf6ctable, sizeof(mf6ctable));
         banner_printed = 0;          banner_printed = 0;
Line 165 
Line 164 
                 while (mfcp) {                  while (mfcp) {
                         kread((u_long)mfcp, &mfc, sizeof(mfc));                          kread((u_long)mfcp, &mfc, sizeof(mfc));
                         if (!banner_printed) {                          if (!banner_printed) {
                                 printf ("\nIPv6 Multicast Forwarding Cache\n");                                  printf("\nIPv6 Multicast Forwarding Cache\n");
                                 printf(" %-*.*s %-*.*s %s",                                  printf(" %-*.*s %-*.*s %s",
                                     WID_ORG, WID_ORG, "Origin",                                      WID_ORG, WID_ORG, "Origin",
                                     WID_GRP, WID_GRP, "Group",                                      WID_GRP, WID_GRP, "Group",
Line 200 
Line 199 
                 }                  }
         }          }
         if (!banner_printed)          if (!banner_printed)
                 printf("\nIPv6 Multicast Routing Table is empty\n");                  printf("IPv6 Multicast Routing Table is empty");
   
         printf("\n");          printf("\n");
         nflag = saved_nflag;          nflag = saved_nflag;
 }  }
   
 void  void
 mrt6_stats(u_long mrpaddr, u_long mstaddr)  mrt6_stats(void)
 {  {
         struct mrt6stat mrtstat;          struct mrt6stat mrt6stat;
         u_int mrtproto;          u_int mrt6proto;
           int mib[] = { CTL_NET, AF_INET6, IPPROTO_IPV6, IPV6CTL_MRTPROTO };
           int mib2[] = { CTL_NET, AF_INET6, IPPROTO_IPV6, IPV6CTL_MRTSTATS };
           size_t len = sizeof(int);
   
         if (mrpaddr == 0) {          if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
                 printf("mrt6_stats: symbol not in namelist\n");              &mrt6proto, &len, NULL, 0) == -1) {
                   if (errno != ENOPROTOOPT)
                           warn("mroute");
                 return;                  return;
         }          }
           switch (mrt6proto) {
         kread(mrpaddr, &mrtproto, sizeof(mrtproto));  
         switch (mrtproto) {  
         case 0:          case 0:
                  printf("no IPv6 multicast routing compiled into this system\n");                  printf("no IPv6 multicast routing compiled into this system\n");
                  return;                  return;
   
         case IPPROTO_PIM:          case IPPROTO_PIM:
                  break;                  break;
   
         default:          default:
                 printf("IPv6 multicast routing protocol %u, unknown\n",                  printf("IPv6 multicast routing protocol %u, unknown\n",
                     mrtproto);                      mrt6proto);
                 return;                  return;
         }          }
   
         if (mstaddr == 0) {          len = sizeof(mrt6stat);
                 printf("mrt6_stats: symbol not in namelist\n");          if (sysctl(mib2, sizeof(mib2) / sizeof(mib2[0]),
               &mrt6stat, &len, NULL, 0) == -1) {
                   if (errno != ENOPROTOOPT)
                           warn("mroute");
                 return;                  return;
         }          }
   
         kread(mstaddr, &mrtstat, sizeof(mrtstat));  
         printf("multicast forwarding:\n");          printf("multicast forwarding:\n");
         printf(" %10llu multicast forwarding cache lookup%s\n",          printf("\t%llu multicast forwarding cache lookup%s\n",
             mrtstat.mrt6s_mfc_lookups, plural(mrtstat.mrt6s_mfc_lookups));              mrt6stat.mrt6s_mfc_lookups, plural(mrt6stat.mrt6s_mfc_lookups));
         printf(" %10llu multicast forwarding cache miss%s\n",          printf("\t%llu multicast forwarding cache miss%s\n",
             mrtstat.mrt6s_mfc_misses, plurales(mrtstat.mrt6s_mfc_misses));              mrt6stat.mrt6s_mfc_misses, plurales(mrt6stat.mrt6s_mfc_misses));
         printf(" %10llu upcall%s to mrouted\n",          printf("\t%llu upcall%s to mrouted\n",
             mrtstat.mrt6s_upcalls, plural(mrtstat.mrt6s_upcalls));              mrt6stat.mrt6s_upcalls, plural(mrt6stat.mrt6s_upcalls));
         printf(" %10llu upcall queue overflow%s\n",          printf("\t%llu upcall queue overflow%s\n",
             mrtstat.mrt6s_upq_ovflw, plural(mrtstat.mrt6s_upq_ovflw));              mrt6stat.mrt6s_upq_ovflw, plural(mrt6stat.mrt6s_upq_ovflw));
         printf(" %10llu upcall%s dropped due to full socket buffer\n",          printf("\t%llu upcall%s dropped due to full socket buffer\n",
             mrtstat.mrt6s_upq_sockfull, plural(mrtstat.mrt6s_upq_sockfull));              mrt6stat.mrt6s_upq_sockfull, plural(mrt6stat.mrt6s_upq_sockfull));
         printf(" %10llu cache cleanup%s\n",          printf("\t%llu cache cleanup%s\n",
             mrtstat.mrt6s_cache_cleanups, plural(mrtstat.mrt6s_cache_cleanups));              mrt6stat.mrt6s_cache_cleanups, plural(mrt6stat.mrt6s_cache_cleanups));
         printf(" %10llu datagram%s with no route for origin\n",          printf("\t%llu datagram%s with no route for origin\n",
             mrtstat.mrt6s_no_route, plural(mrtstat.mrt6s_no_route));              mrt6stat.mrt6s_no_route, plural(mrt6stat.mrt6s_no_route));
         printf(" %10llu datagram%s arrived with bad tunneling\n",          printf("\t%llu datagram%s arrived with bad tunneling\n",
             mrtstat.mrt6s_bad_tunnel, plural(mrtstat.mrt6s_bad_tunnel));              mrt6stat.mrt6s_bad_tunnel, plural(mrt6stat.mrt6s_bad_tunnel));
         printf(" %10llu datagram%s could not be tunneled\n",          printf("\t%llu datagram%s could not be tunneled\n",
             mrtstat.mrt6s_cant_tunnel, plural(mrtstat.mrt6s_cant_tunnel));              mrt6stat.mrt6s_cant_tunnel, plural(mrt6stat.mrt6s_cant_tunnel));
         printf(" %10llu datagram%s arrived on wrong interface\n",          printf("\t%llu datagram%s arrived on wrong interface\n",
             mrtstat.mrt6s_wrong_if, plural(mrtstat.mrt6s_wrong_if));              mrt6stat.mrt6s_wrong_if, plural(mrt6stat.mrt6s_wrong_if));
         printf(" %10llu datagram%s selectively dropped\n",          printf("\t%llu datagram%s selectively dropped\n",
             mrtstat.mrt6s_drop_sel, plural(mrtstat.mrt6s_drop_sel));              mrt6stat.mrt6s_drop_sel, plural(mrt6stat.mrt6s_drop_sel));
         printf(" %10llu datagram%s dropped due to queue overflow\n",          printf("\t%llu datagram%s dropped due to queue overflow\n",
             mrtstat.mrt6s_q_overflow, plural(mrtstat.mrt6s_q_overflow));              mrt6stat.mrt6s_q_overflow, plural(mrt6stat.mrt6s_q_overflow));
         printf(" %10llu datagram%s dropped for being too large\n",          printf("\t%llu datagram%s dropped for being too large\n",
             mrtstat.mrt6s_pkt2large, plural(mrtstat.mrt6s_pkt2large));              mrt6stat.mrt6s_pkt2large, plural(mrt6stat.mrt6s_pkt2large));
 }  }
 #endif /*INET6*/  

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10