MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sysctl_igmp_stat

Function sysctl_igmp_stat

freebsd/netinet/igmp.c:343–396  ·  view source on GitHub ↗

* IGMP statistics. */

Source from the content-addressed store, hash-verified

341 * IGMP statistics.
342 */
343static int
344sysctl_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 }
394out:
395 return (error);
396}
397
398/*
399 * Retrieve or set default IGMP version.

Callers

nothing calls this directly

Calls 1

sysctl_wire_old_bufferFunction · 0.85

Tested by

no test coverage detected