[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.21 and 1.22

version 1.21, 2014/06/23 03:46:17 version 1.22, 2014/08/14 12:34:04
Line 63 
Line 63 
 #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 184 
   
                                 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,  
                                                     &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 216 
Line 194 
   
         printf("\n");          printf("\n");
         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, "%lld.%ld|%s|%s",  
                  (long long)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, "%lld.%ld|%s|%s",  
                  (long long)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, "%lld.%ld",  
                          (long long)delta.tv_sec, delta.tv_usec);  
         } else {  
                 /* Negative time */  
                 timersub(&now, &end, &delta);  
                 snprintf(s3, sizeof s3, "-%lld.%ld",  
                          (long long)delta.tv_sec, delta.tv_usec);  
         }  
         printf(" %s", s3);  
   
         printf("\n");  
 }  }
   
 void  void

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22