| 168 | } |
| 169 | |
| 170 | static void |
| 171 | print_mfc(struct mfc *m, int maxvif, int *banner_printed) |
| 172 | { |
| 173 | struct sockaddr_in sin; |
| 174 | struct sockaddr *sa = (struct sockaddr *)&sin; |
| 175 | struct bw_meter bw_meter, *bwm; |
| 176 | int bw_banner_printed; |
| 177 | int error; |
| 178 | vifi_t vifi; |
| 179 | |
| 180 | bw_banner_printed = 0; |
| 181 | memset(&sin, 0, sizeof(sin)); |
| 182 | sin.sin_len = sizeof(sin); |
| 183 | sin.sin_family = AF_INET; |
| 184 | |
| 185 | if (! *banner_printed) { |
| 186 | xo_open_list("multicast-forwarding-entry"); |
| 187 | xo_emit("\n{T:IPv4 Multicast Forwarding Table}\n" |
| 188 | " {T:Origin} {T:Group} " |
| 189 | " {T:Packets In-Vif} {T:Out-Vifs:Ttls}\n"); |
| 190 | *banner_printed = 1; |
| 191 | } |
| 192 | |
| 193 | memcpy(&sin.sin_addr, &m->mfc_origin, sizeof(sin.sin_addr)); |
| 194 | xo_emit(" {:origin-address/%-15.15s}", routename(sa, numeric_addr)); |
| 195 | memcpy(&sin.sin_addr, &m->mfc_mcastgrp, sizeof(sin.sin_addr)); |
| 196 | xo_emit(" {:group-address/%-15.15s}", |
| 197 | routename(sa, numeric_addr)); |
| 198 | xo_emit(" {:sent-packets/%9lu}", m->mfc_pkt_cnt); |
| 199 | xo_emit(" {:parent/%3d} ", m->mfc_parent); |
| 200 | xo_open_list("vif-ttl"); |
| 201 | for (vifi = 0; vifi <= maxvif; vifi++) { |
| 202 | if (m->mfc_ttls[vifi] > 0) { |
| 203 | xo_open_instance("vif-ttl"); |
| 204 | xo_emit(" {k:vif/%u}:{:ttl/%u}", vifi, |
| 205 | m->mfc_ttls[vifi]); |
| 206 | xo_close_instance("vif-ttl"); |
| 207 | } |
| 208 | } |
| 209 | xo_close_list("vif-ttl"); |
| 210 | xo_emit("\n"); |
| 211 | |
| 212 | /* |
| 213 | * XXX We break the rules and try to use KVM to read the |
| 214 | * bandwidth meters, they are not retrievable via sysctl yet. |
| 215 | */ |
| 216 | bwm = m->mfc_bw_meter; |
| 217 | while (bwm != NULL) { |
| 218 | error = kread((u_long)bwm, (char *)&bw_meter, |
| 219 | sizeof(bw_meter)); |
| 220 | if (error) |
| 221 | break; |
| 222 | print_bw_meter(&bw_meter, &bw_banner_printed); |
| 223 | bwm = bw_meter.bm_mfc_next; |
| 224 | } |
| 225 | if (banner_printed) |
| 226 | xo_close_list("bandwidth-meter"); |
| 227 | } |
no test coverage detected