* Dump IGMP statistics structure. */
| 1282 | * Dump IGMP statistics structure. |
| 1283 | */ |
| 1284 | void |
| 1285 | igmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) |
| 1286 | { |
| 1287 | struct igmpstat igmpstat; |
| 1288 | int error, zflag0; |
| 1289 | |
| 1290 | if (fetch_stats("net.inet.igmp.stats", 0, &igmpstat, |
| 1291 | sizeof(igmpstat), kread) != 0) |
| 1292 | return; |
| 1293 | /* |
| 1294 | * Reread net.inet.igmp.stats when zflag == 1. |
| 1295 | * This is because this MIB contains version number and |
| 1296 | * length of the structure which are not set when clearing |
| 1297 | * the counters. |
| 1298 | */ |
| 1299 | zflag0 = zflag; |
| 1300 | if (zflag) { |
| 1301 | zflag = 0; |
| 1302 | error = fetch_stats("net.inet.igmp.stats", 0, &igmpstat, |
| 1303 | sizeof(igmpstat), kread); |
| 1304 | zflag = zflag0; |
| 1305 | if (error) |
| 1306 | return; |
| 1307 | } |
| 1308 | |
| 1309 | if (igmpstat.igps_version != IGPS_VERSION_3) { |
| 1310 | xo_warnx("%s: version mismatch (%d != %d)", __func__, |
| 1311 | igmpstat.igps_version, IGPS_VERSION_3); |
| 1312 | return; |
| 1313 | } |
| 1314 | if (igmpstat.igps_len != IGPS_VERSION3_LEN) { |
| 1315 | xo_warnx("%s: size mismatch (%d != %d)", __func__, |
| 1316 | igmpstat.igps_len, IGPS_VERSION3_LEN); |
| 1317 | return; |
| 1318 | } |
| 1319 | |
| 1320 | xo_open_container(name); |
| 1321 | xo_emit("{T:/%s}:\n", name); |
| 1322 | |
| 1323 | #define p64(f, m) if (igmpstat.f || sflag <= 1) \ |
| 1324 | xo_emit(m, (uintmax_t) igmpstat.f, plural(igmpstat.f)) |
| 1325 | #define py64(f, m) if (igmpstat.f || sflag <= 1) \ |
| 1326 | xo_emit(m, (uintmax_t) igmpstat.f, pluralies(igmpstat.f)) |
| 1327 | |
| 1328 | p64(igps_rcv_total, "\t{:received-messages/%ju} " |
| 1329 | "{N:/message%s received}\n"); |
| 1330 | p64(igps_rcv_tooshort, "\t{:dropped-too-short/%ju} " |
| 1331 | "{N:/message%s received with too few bytes}\n"); |
| 1332 | p64(igps_rcv_badttl, "\t{:dropped-wrong-ttl/%ju} " |
| 1333 | "{N:/message%s received with wrong TTL}\n"); |
| 1334 | p64(igps_rcv_badsum, "\t{:dropped-bad-checksum/%ju} " |
| 1335 | "{N:/message%s received with bad checksum}\n"); |
| 1336 | py64(igps_rcv_v1v2_queries, "\t{:received-membership-queries/%ju} " |
| 1337 | "{N:/V1\\/V2 membership quer%s received}\n"); |
| 1338 | py64(igps_rcv_v3_queries, "\t{:received-v3-membership-queries/%ju} " |
| 1339 | "{N:/V3 membership quer%s received}\n"); |
| 1340 | py64(igps_rcv_badqueries, "\t{:dropped-membership-queries/%ju} " |
| 1341 | "{N:/membership quer%s received with invalid field(s)}\n"); |
nothing calls this directly
no test coverage detected