* IGMP statistics. */
| 341 | * IGMP statistics. |
| 342 | */ |
| 343 | static int |
| 344 | sysctl_igmp_stat(SYSCTL_HANDLER_ARGS) |
| 345 | { |
| 346 | struct igmpstat igps0; |
| 347 | int error; |
| 348 | char *p; |
| 349 | |
| 350 | error = sysctl_wire_old_buffer(req, sizeof(struct igmpstat)); |
| 351 | if (error) |
| 352 | return (error); |
| 353 | |
| 354 | if (req->oldptr != NULL) { |
| 355 | if (req->oldlen < sizeof(struct igmpstat)) |
| 356 | error = ENOMEM; |
| 357 | else { |
| 358 | /* |
| 359 | * Copy the counters, and explicitly set the struct's |
| 360 | * version and length fields. |
| 361 | */ |
| 362 | COUNTER_ARRAY_COPY(VNET(igmpstat), &igps0, |
| 363 | sizeof(struct igmpstat) / sizeof(uint64_t)); |
| 364 | igps0.igps_version = IGPS_VERSION_3; |
| 365 | igps0.igps_len = IGPS_VERSION3_LEN; |
| 366 | error = SYSCTL_OUT(req, &igps0, |
| 367 | sizeof(struct igmpstat)); |
| 368 | } |
| 369 | } else |
| 370 | req->validlen = sizeof(struct igmpstat); |
| 371 | if (error) |
| 372 | goto out; |
| 373 | if (req->newptr != NULL) { |
| 374 | if (req->newlen < sizeof(struct igmpstat)) |
| 375 | error = ENOMEM; |
| 376 | else |
| 377 | error = SYSCTL_IN(req, &igps0, |
| 378 | sizeof(igps0)); |
| 379 | if (error) |
| 380 | goto out; |
| 381 | /* |
| 382 | * igps0 must be "all zero". |
| 383 | */ |
| 384 | p = (char *)&igps0; |
| 385 | while (*p == '\0' && p < (char *)&igps0 + sizeof(igps0)) |
| 386 | p++; |
| 387 | if (p != (char *)&igps0 + sizeof(igps0)) { |
| 388 | error = EINVAL; |
| 389 | goto out; |
| 390 | } |
| 391 | COUNTER_ARRAY_ZERO(VNET(igmpstat), |
| 392 | sizeof(struct igmpstat) / sizeof(uint64_t)); |
| 393 | } |
| 394 | out: |
| 395 | return (error); |
| 396 | } |
| 397 | |
| 398 | /* |
| 399 | * Retrieve or set default IGMP version. |
nothing calls this directly
no test coverage detected