| 80 | static void print_mfc(struct mfc *, int, int *); |
| 81 | |
| 82 | static void |
| 83 | print_bw_meter(struct bw_meter *bw_meter, int *banner_printed) |
| 84 | { |
| 85 | char s1[256], s2[256], s3[256]; |
| 86 | struct timeval now, end, delta; |
| 87 | |
| 88 | gettimeofday(&now, NULL); |
| 89 | |
| 90 | if (! *banner_printed) { |
| 91 | xo_open_list("bandwidth-meter"); |
| 92 | xo_emit(" {T:Bandwidth Meters}\n"); |
| 93 | xo_emit(" {T:/%-30s}", "Measured(Start|Packets|Bytes)"); |
| 94 | xo_emit(" {T:/%s}", "Type"); |
| 95 | xo_emit(" {T:/%-30s}", "Thresh(Interval|Packets|Bytes)"); |
| 96 | xo_emit(" {T:Remain}"); |
| 97 | xo_emit("\n"); |
| 98 | *banner_printed = 1; |
| 99 | } |
| 100 | |
| 101 | xo_open_instance("bandwidth-meter"); |
| 102 | |
| 103 | /* The measured values */ |
| 104 | if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) { |
| 105 | snprintf(s1, sizeof(s1), "%ju", |
| 106 | (uintmax_t)bw_meter->bm_measured.b_packets); |
| 107 | xo_emit("{e:measured-packets/%ju}", |
| 108 | (uintmax_t)bw_meter->bm_measured.b_packets); |
| 109 | } else |
| 110 | strcpy(s1, "?"); |
| 111 | if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) { |
| 112 | snprintf(s2, sizeof(s2), "%ju", |
| 113 | (uintmax_t)bw_meter->bm_measured.b_bytes); |
| 114 | xo_emit("{e:measured-bytes/%ju}", |
| 115 | (uintmax_t)bw_meter->bm_measured.b_bytes); |
| 116 | } else |
| 117 | strcpy(s2, "?"); |
| 118 | xo_emit(" {[:-30}{:start-time/%lu.%06lu}|{q:measured-packets/%s}" |
| 119 | "|{q:measured-bytes%s}{]:}", |
| 120 | (u_long)bw_meter->bm_start_time.tv_sec, |
| 121 | (u_long)bw_meter->bm_start_time.tv_usec, s1, s2); |
| 122 | |
| 123 | /* The type of entry */ |
| 124 | xo_emit(" {t:type/%-3s}", (bw_meter->bm_flags & BW_METER_GEQ) ? ">=" : |
| 125 | (bw_meter->bm_flags & BW_METER_LEQ) ? "<=" : "?"); |
| 126 | |
| 127 | /* The threshold values */ |
| 128 | if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) { |
| 129 | snprintf(s1, sizeof(s1), "%ju", |
| 130 | (uintmax_t)bw_meter->bm_threshold.b_packets); |
| 131 | xo_emit("{e:threshold-packets/%ju}", |
| 132 | (uintmax_t)bw_meter->bm_threshold.b_packets); |
| 133 | } else |
| 134 | strcpy(s1, "?"); |
| 135 | if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) { |
| 136 | snprintf(s2, sizeof(s2), "%ju", |
| 137 | (uintmax_t)bw_meter->bm_threshold.b_bytes); |
| 138 | xo_emit("{e:threshold-bytes/%ju}", |
| 139 | (uintmax_t)bw_meter->bm_threshold.b_bytes); |
no test coverage detected