[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.11 and 1.12

version 1.11, 2003/07/07 21:36:52 version 1.12, 2005/01/14 15:00:44
Line 37 
Line 37 
  */   */
   
 /*  /*
  * Print DVMRP multicast routing structures and statistics.   * Print multicast routing structures and statistics.
  *   *
  * MROUTING 1.0   * MROUTING 1.0
  */   */
Line 60 
Line 60 
 #include <stdlib.h>  #include <stdlib.h>
 #include "netstat.h"  #include "netstat.h"
   
   static void print_bw_meter(struct bw_meter *bw_meter, int *banner_printed);
   
 static char *  static char *
 pktscale(u_long n)  pktscale(u_long n)
 {  {
Line 186 
Line 188 
                                                     mfc.mfc_ttls[vifi]);                                                      mfc.mfc_ttls[vifi]);
   
                                 printf("\n");                                  printf("\n");
   
                                   /* Print the bw meter information */
                                   {
                                           struct bw_meter bw_meter, *bwm;
                                           int banner_printed2 = 0;
   
                                           bwm = mfc.mfc_bw_meter;
                                           while (bwm) {
                                                   kread((u_long)bwm,
                                                         (char *)&bw_meter,
                                                         sizeof bw_meter);
                                                   print_bw_meter(&bw_meter,
                                                                  &banner_printed2);
                                                   bwm = bw_meter.bm_mfc_next;
                                           }
   #if 0   /* Don't ever print it? */
                                           if (! banner_printed2)
                                                   printf("\n  No Bandwidth Meters\n");
   #endif
                                   }
   
                                 nmfc++;                                  nmfc++;
                         }                          }
                 }                  }
Line 198 
Line 221 
         nflag = saved_nflag;          nflag = saved_nflag;
 }  }
   
   static void
   print_bw_meter(struct bw_meter *bw_meter, int *banner_printed)
   {
           char s0[256], s1[256], s2[256], s3[256];
           struct timeval now, end, delta;
   
           gettimeofday(&now, NULL);
   
           if (! *banner_printed) {
                   printf(" Bandwidth Meters\n");
                   printf("  %-30s", "Measured(Start|Packets|Bytes)");
                   printf(" %s", "Type");
                   printf("  %-30s", "Thresh(Interval|Packets|Bytes)");
                   printf(" Remain");
                   printf("\n");
                   *banner_printed = 1;
           }
   
           /* The measured values */
           if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS)
                   snprintf(s1, sizeof s1, "%llu",
                            bw_meter->bm_measured.b_packets);
           else
                   snprintf(s1, sizeof s1, "?");
           if (bw_meter->bm_flags & BW_METER_UNIT_BYTES)
                   snprintf(s2, sizeof s2, "%llu", bw_meter->bm_measured.b_bytes);
           else
                   snprintf(s2, sizeof s2, "?");
           snprintf(s0, sizeof s0, "%lu.%lu|%s|%s",
                    bw_meter->bm_start_time.tv_sec,
                    bw_meter->bm_start_time.tv_usec,
                    s1, s2);
           printf("  %-30s", s0);
   
           /* The type of entry */
           snprintf(s0, sizeof s0, "%s", "?");
           if (bw_meter->bm_flags & BW_METER_GEQ)
                   snprintf(s0, sizeof s0, "%s", ">=");
           else if (bw_meter->bm_flags & BW_METER_LEQ)
                   snprintf(s0, sizeof s0, "%s", "<=");
           printf("  %-3s", s0);
   
           /* The threshold values */
           if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS)
                   snprintf(s1, sizeof s1, "%llu",
                            bw_meter->bm_threshold.b_packets);
           else
                   snprintf(s1, sizeof s1, "?");
           if (bw_meter->bm_flags & BW_METER_UNIT_BYTES)
                   snprintf(s2, sizeof s2, "%llu",
                            bw_meter->bm_threshold.b_bytes);
           else
                   snprintf(s2, sizeof s2, "?");
           snprintf(s0, sizeof s0, "%lu.%lu|%s|%s",
                    bw_meter->bm_threshold.b_time.tv_sec,
                    bw_meter->bm_threshold.b_time.tv_usec,
                    s1, s2);
           printf("  %-30s", s0);
   
           /* Remaining time */
           timeradd(&bw_meter->bm_start_time,
                    &bw_meter->bm_threshold.b_time, &end);
           if (timercmp(&now, &end, <=)) {
                   timersub(&end, &now, &delta);
                   snprintf(s3, sizeof s3, "%lu.%lu",
                            delta.tv_sec, delta.tv_usec);
           } else {
                   /* Negative time */
                   timersub(&now, &end, &delta);
                   snprintf(s3, sizeof s3, "-%lu.%lu",
                            delta.tv_sec, delta.tv_usec);
           }
           printf(" %s", s3);
   
           printf("\n");
   }
   
 void  void
 mrt_stats(u_long mrpaddr, u_long mstaddr)  mrt_stats(u_long mrpaddr, u_long mstaddr)

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12