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

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

version 1.16, 2006/05/27 19:16:37 version 1.17, 2007/12/14 18:35:46
Line 46 
Line 46 
 #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>
 #include <net/route.h>  #include <net/route.h>
Line 58 
Line 59 
 #include <limits.h>  #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
   #include <errno.h>
 #include "netstat.h"  #include "netstat.h"
   
 static void print_bw_meter(struct bw_meter *bw_meter, int *banner_printed);  static void print_bw_meter(struct bw_meter *bw_meter, int *banner_printed);
Line 83 
Line 85 
 }  }
   
 void  void
 mroutepr(u_long mrpaddr, u_long mfchashtbladdr, u_long mfchashaddr, u_long vifaddr)  mroutepr(u_long mfchashtbladdr, u_long mfchashaddr, u_long vifaddr)
 {  {
         u_int mrtproto;          u_int mrtproto;
         LIST_HEAD(, mfc) *mfchashtbl;          LIST_HEAD(, mfc) *mfchashtbl;
         u_long mfchash;          u_long mfchash;
         struct vif viftable[MAXVIFS];          struct vif viftable[MAXVIFS], *v;
         struct mfc *mfcp, mfc;          struct mfc *mfcp, mfc;
         struct vif *v;  
         vifi_t vifi;          vifi_t vifi;
         int i;          int mib[] = { CTL_NET, AF_INET, IPPROTO_IP, IPCTL_MRTPROTO };
         int banner_printed;          size_t len = sizeof(int);
         int saved_nflag;          int i, banner_printed = 0, saved_nflag, numvifs = 0;
         int numvifs;  
         int nmfc;               /* No. of cache entries */          int nmfc;               /* No. of cache entries */
   
         if (mrpaddr == 0) {          if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
                 printf("ip_mrtproto: 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 multicast routing compiled into this system\n");                  printf("no multicast routing compiled into this system\n");
                 return;                  return;
   
         case IGMP_DVMRP:          case IGMP_DVMRP:
                 break;                  break;
   
         default:          default:
                 printf("multicast routing protocol %u, unknown\n", mrtproto);                  printf("multicast routing protocol %u, unknown\n", mrtproto);
                 return;                  return;
Line 134 
Line 132 
         nflag = 1;          nflag = 1;
   
         kread(vifaddr, &viftable, sizeof(viftable));          kread(vifaddr, &viftable, sizeof(viftable));
         banner_printed = 0;  
         numvifs = 0;  
   
         for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {          for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {
                 if (v->v_lcl_addr.s_addr == 0)                  if (v->v_lcl_addr.s_addr == 0)
Line 157 
Line 153 
                     v->v_pkt_in, v->v_pkt_out);                      v->v_pkt_in, v->v_pkt_out);
         }          }
         if (!banner_printed)          if (!banner_printed)
                 printf("\nVirtual Interface Table is empty\n");                  printf("Virtual Interface Table is empty\n");
   
         kread(mfchashtbladdr, &mfchashtbl, sizeof(mfchashtbl));          kread(mfchashtbladdr, &mfchashtbl, sizeof(mfchashtbl));
         kread(mfchashaddr, &mfchash, sizeof(mfchash));          kread(mfchashaddr, &mfchash, sizeof(mfchash));
Line 213 
Line 209 
                         }                          }
                 }                  }
         if (!banner_printed)          if (!banner_printed)
                 printf("\nMulticast Forwarding Cache is empty\n");                  printf("Multicast Forwarding Cache is empty\n");
         else          else
                 printf("\nTotal no. of entries in cache: %d\n", nmfc);                  printf("\nTotal no. of entries in cache: %d\n", nmfc);
   
Line 299 
Line 295 
 }  }
   
 void  void
 mrt_stats(u_long mrpaddr, u_long mstaddr)  mrt_stats(void)
 {  {
         u_int mrtproto;          u_int mrtproto;
         struct mrtstat mrtstat;          struct mrtstat mrtstat;
           int mib[] = { CTL_NET, AF_INET, IPPROTO_IP, IPCTL_MRTPROTO };
           int mib2[] = { CTL_NET, AF_INET, IPPROTO_IP, IPCTL_MRTSTATS };
           size_t len = sizeof(int);
   
         if (mrpaddr == 0) {          if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
                 printf("ip_mrtproto: 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 multicast routing compiled into this system\n");                  printf("no multicast routing compiled into this system\n");
Line 323 
Line 322 
                 return;                  return;
         }          }
   
         if (mstaddr == 0) {          len = sizeof(mrtstat);
                 printf("mrtstat: symbol not in namelist\n");          if (sysctl(mib2, sizeof(mib2) / sizeof(mib2[0]),
               &mrtstat, &len, NULL, 0) == -1) {
                   if (errno != ENOPROTOOPT)
                           warn("mroute");
                 return;                  return;
         }          }
   
         kread(mstaddr, &mrtstat, sizeof(mrtstat));  
         printf("multicast routing:\n");          printf("multicast routing:\n");
         printf("\t%lu datagram%s with no route for origin\n",          printf("\t%lu datagram%s with no route for origin\n",
             mrtstat.mrts_no_route, plural(mrtstat.mrts_no_route));              mrtstat.mrts_no_route, plural(mrtstat.mrts_no_route));

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