123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693 |
- /* $OpenBSD: igmp.c,v 1.49 2015/06/16 11:09:40 mpi Exp $ */
- /* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
- /*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
- /*
- * Copyright (c) 1988 Stephen Deering.
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Stephen Deering of Stanford University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)igmp.c 8.2 (Berkeley) 5/3/95
- */
- /*
- * Internet Group Management Protocol (IGMP) routines.
- *
- * Written by Steve Deering, Stanford, May 1988.
- * Modified by Rosen Sharma, Stanford, Aug 1994.
- * Modified by Bill Fenner, Xerox PARC, Feb 1995.
- *
- * MULTICAST Revision: 1.3
- */
- #include <sys/param.h>
- #include <sys/mbuf.h>
- #include <sys/systm.h>
- #include <sys/socket.h>
- #include <sys/protosw.h>
- #include <sys/sysctl.h>
- #include <net/if.h>
- #include <net/if_var.h>
- #include <netinet/in.h>
- #include <netinet/in_var.h>
- #include <netinet/ip.h>
- #include <netinet/ip_var.h>
- #include <netinet/igmp.h>
- #include <netinet/igmp_var.h>
- #include <sys/stdarg.h>
- #define IP_MULTICASTOPTS 0
- int *igmpctl_vars[IGMPCTL_MAXID] = IGMPCTL_VARS;
- int igmp_timers_are_running;
- static struct router_info *rti_head;
- static struct mbuf *router_alert;
- struct igmpstat igmpstat;
- void igmp_checktimer(struct ifnet *);
- void igmp_sendpkt(struct in_multi *, int, in_addr_t);
- int rti_fill(struct in_multi *);
- struct router_info * rti_find(struct ifnet *);
- void
- igmp_init(void)
- {
- struct ipoption *ra;
- igmp_timers_are_running = 0;
- rti_head = 0;
- router_alert = m_get(M_DONTWAIT, MT_DATA);
- if (router_alert == NULL) {
- printf("%s: no mbuf\n", __func__);
- return;
- }
- /*
- * Construct a Router Alert option (RAO) to use in report
- * messages as required by RFC2236. This option has the
- * following format:
- *
- * | 10010100 | 00000100 | 2 octet value |
- *
- * where a value of "0" indicates that routers shall examine
- * the packet.
- */
- ra = mtod(router_alert, struct ipoption *);
- ra->ipopt_dst.s_addr = INADDR_ANY;
- ra->ipopt_list[0] = IPOPT_RA;
- ra->ipopt_list[1] = 0x04;
- ra->ipopt_list[2] = 0x00;
- ra->ipopt_list[3] = 0x00;
- router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1];
- }
- /* Return -1 for error. */
- int
- rti_fill(struct in_multi *inm)
- {
- struct router_info *rti;
- for (rti = rti_head; rti != 0; rti = rti->rti_next) {
- if (rti->rti_ifp->if_index == inm->inm_ifidx) {
- inm->inm_rti = rti;
- if (rti->rti_type == IGMP_v1_ROUTER)
- return (IGMP_v1_HOST_MEMBERSHIP_REPORT);
- else
- return (IGMP_v2_HOST_MEMBERSHIP_REPORT);
- }
- }
- rti = (struct router_info *)malloc(sizeof(struct router_info),
- M_MRTABLE, M_NOWAIT);
- if (rti == NULL)
- return (-1);
- rti->rti_ifp = if_get(inm->inm_ifidx);
- rti->rti_type = IGMP_v2_ROUTER;
- rti->rti_next = rti_head;
- rti_head = rti;
- inm->inm_rti = rti;
- return (IGMP_v2_HOST_MEMBERSHIP_REPORT);
- }
- struct router_info *
- rti_find(struct ifnet *ifp)
- {
- struct router_info *rti;
- for (rti = rti_head; rti != 0; rti = rti->rti_next) {
- if (rti->rti_ifp == ifp)
- return (rti);
- }
- rti = (struct router_info *)malloc(sizeof(struct router_info),
- M_MRTABLE, M_NOWAIT);
- if (rti == NULL)
- return (NULL);
- rti->rti_ifp = ifp;
- rti->rti_type = IGMP_v2_ROUTER;
- rti->rti_next = rti_head;
- rti_head = rti;
- return (rti);
- }
- void
- rti_delete(struct ifnet *ifp)
- {
- struct router_info *rti, **prti = &rti_head;
- for (rti = rti_head; rti != 0; rti = rti->rti_next) {
- if (rti->rti_ifp == ifp) {
- *prti = rti->rti_next;
- free(rti, M_MRTABLE, 0);
- break;
- }
- prti = &rti->rti_next;
- }
- }
- void
- igmp_input(struct mbuf *m, ...)
- {
- int iphlen;
- struct ifnet *ifp;
- struct ip *ip = mtod(m, struct ip *);
- struct igmp *igmp;
- int igmplen;
- int minlen;
- struct ifmaddr *ifma;
- struct in_multi *inm;
- struct router_info *rti;
- struct in_ifaddr *ia;
- int timer;
- va_list ap;
- va_start(ap, m);
- iphlen = va_arg(ap, int);
- va_end(ap);
- ++igmpstat.igps_rcv_total;
- igmplen = ntohs(ip->ip_len) - iphlen;
- ifp = if_get(m->m_pkthdr.ph_ifidx);
- if (ifp == NULL) {
- m_freem(m);
- return;
- }
- /*
- * Validate lengths
- */
- if (igmplen < IGMP_MINLEN) {
- ++igmpstat.igps_rcv_tooshort;
- m_freem(m);
- return;
- }
- minlen = iphlen + IGMP_MINLEN;
- if ((m->m_flags & M_EXT || m->m_len < minlen) &&
- (m = m_pullup(m, minlen)) == NULL) {
- ++igmpstat.igps_rcv_tooshort;
- return;
- }
- /*
- * Validate checksum
- */
- m->m_data += iphlen;
- m->m_len -= iphlen;
- igmp = mtod(m, struct igmp *);
- if (in_cksum(m, igmplen)) {
- ++igmpstat.igps_rcv_badsum;
- m_freem(m);
- return;
- }
- m->m_data -= iphlen;
- m->m_len += iphlen;
- ip = mtod(m, struct ip *);
- switch (igmp->igmp_type) {
- case IGMP_HOST_MEMBERSHIP_QUERY:
- ++igmpstat.igps_rcv_queries;
- if (ifp->if_flags & IFF_LOOPBACK)
- break;
- if (igmp->igmp_code == 0) {
- rti = rti_find(ifp);
- if (rti == NULL) {
- m_freem(m);
- return;
- }
- rti->rti_type = IGMP_v1_ROUTER;
- rti->rti_age = 0;
- if (ip->ip_dst.s_addr != INADDR_ALLHOSTS_GROUP) {
- ++igmpstat.igps_rcv_badqueries;
- m_freem(m);
- return;
- }
- /*
- * Start the timers in all of our membership records
- * for the interface on which the query arrived,
- * except those that are already running and those
- * that belong to a "local" group (224.0.0.X).
- */
- TAILQ_FOREACH(ifma, &ifp->if_maddrlist, ifma_list) {
- if (ifma->ifma_addr->sa_family != AF_INET)
- continue;
- inm = ifmatoinm(ifma);
- if (inm->inm_timer == 0 &&
- !IN_LOCAL_GROUP(inm->inm_addr.s_addr)) {
- inm->inm_state = IGMP_DELAYING_MEMBER;
- inm->inm_timer = IGMP_RANDOM_DELAY(
- IGMP_MAX_HOST_REPORT_DELAY * PR_FASTHZ);
- igmp_timers_are_running = 1;
- }
- }
- } else {
- if (!IN_MULTICAST(ip->ip_dst.s_addr)) {
- ++igmpstat.igps_rcv_badqueries;
- m_freem(m);
- return;
- }
- timer = igmp->igmp_code * PR_FASTHZ / IGMP_TIMER_SCALE;
- if (timer == 0)
- timer = 1;
- /*
- * Start the timers in all of our membership records
- * for the interface on which the query arrived,
- * except those that are already running and those
- * that belong to a "local" group (224.0.0.X). For
- * timers already running, check if they need to be
- * reset.
- */
- TAILQ_FOREACH(ifma, &ifp->if_maddrlist, ifma_list) {
- if (ifma->ifma_addr->sa_family != AF_INET)
- continue;
- inm = ifmatoinm(ifma);
- if (!IN_LOCAL_GROUP(inm->inm_addr.s_addr) &&
- (ip->ip_dst.s_addr == INADDR_ALLHOSTS_GROUP ||
- ip->ip_dst.s_addr == inm->inm_addr.s_addr)) {
- switch (inm->inm_state) {
- case IGMP_DELAYING_MEMBER:
- if (inm->inm_timer <= timer)
- break;
- /* FALLTHROUGH */
- case IGMP_IDLE_MEMBER:
- case IGMP_LAZY_MEMBER:
- case IGMP_AWAKENING_MEMBER:
- inm->inm_state =
- IGMP_DELAYING_MEMBER;
- inm->inm_timer =
- IGMP_RANDOM_DELAY(timer);
- igmp_timers_are_running = 1;
- break;
- case IGMP_SLEEPING_MEMBER:
- inm->inm_state =
- IGMP_AWAKENING_MEMBER;
- break;
- }
- }
- }
- }
- break;
- case IGMP_v1_HOST_MEMBERSHIP_REPORT:
- ++igmpstat.igps_rcv_reports;
- if (ifp->if_flags & IFF_LOOPBACK)
- break;
- if (!IN_MULTICAST(igmp->igmp_group.s_addr) ||
- igmp->igmp_group.s_addr != ip->ip_dst.s_addr) {
- ++igmpstat.igps_rcv_badreports;
- m_freem(m);
- return;
- }
- /*
- * KLUDGE: if the IP source address of the report has an
- * unspecified (i.e., zero) subnet number, as is allowed for
- * a booting host, replace it with the correct subnet number
- * so that a process-level multicast routing daemon can
- * determine which subnet it arrived from. This is necessary
- * to compensate for the lack of any way for a process to
- * determine the arrival interface of an incoming packet.
- */
- if ((ip->ip_src.s_addr & IN_CLASSA_NET) == 0) {
- IFP_TO_IA(ifp, ia);
- if (ia)
- ip->ip_src.s_addr = ia->ia_net;
- }
- /*
- * If we belong to the group being reported, stop
- * our timer for that group.
- */
- IN_LOOKUP_MULTI(igmp->igmp_group, ifp, inm);
- if (inm != NULL) {
- inm->inm_timer = 0;
- ++igmpstat.igps_rcv_ourreports;
- switch (inm->inm_state) {
- case IGMP_IDLE_MEMBER:
- case IGMP_LAZY_MEMBER:
- case IGMP_AWAKENING_MEMBER:
- case IGMP_SLEEPING_MEMBER:
- inm->inm_state = IGMP_SLEEPING_MEMBER;
- break;
- case IGMP_DELAYING_MEMBER:
- if (inm->inm_rti->rti_type == IGMP_v1_ROUTER)
- inm->inm_state = IGMP_LAZY_MEMBER;
- else
- inm->inm_state = IGMP_SLEEPING_MEMBER;
- break;
- }
- }
- break;
- case IGMP_v2_HOST_MEMBERSHIP_REPORT:
- #ifdef MROUTING
- /*
- * Make sure we don't hear our own membership report. Fast
- * leave requires knowing that we are the only member of a
- * group.
- */
- IFP_TO_IA(ifp, ia);
- if (ia && ip->ip_src.s_addr == ia->ia_addr.sin_addr.s_addr)
- break;
- #endif
- ++igmpstat.igps_rcv_reports;
- if (ifp->if_flags & IFF_LOOPBACK)
- break;
- if (!IN_MULTICAST(igmp->igmp_group.s_addr) ||
- igmp->igmp_group.s_addr != ip->ip_dst.s_addr) {
- ++igmpstat.igps_rcv_badreports;
- m_freem(m);
- return;
- }
- /*
- * KLUDGE: if the IP source address of the report has an
- * unspecified (i.e., zero) subnet number, as is allowed for
- * a booting host, replace it with the correct subnet number
- * so that a process-level multicast routing daemon can
- * determine which subnet it arrived from. This is necessary
- * to compensate for the lack of any way for a process to
- * determine the arrival interface of an incoming packet.
- */
- if ((ip->ip_src.s_addr & IN_CLASSA_NET) == 0) {
- #ifndef MROUTING
- IFP_TO_IA(ifp, ia);
- #endif
- if (ia)
- ip->ip_src.s_addr = ia->ia_net;
- }
- /*
- * If we belong to the group being reported, stop
- * our timer for that group.
- */
- IN_LOOKUP_MULTI(igmp->igmp_group, ifp, inm);
- if (inm != NULL) {
- inm->inm_timer = 0;
- ++igmpstat.igps_rcv_ourreports;
- switch (inm->inm_state) {
- case IGMP_DELAYING_MEMBER:
- case IGMP_IDLE_MEMBER:
- case IGMP_AWAKENING_MEMBER:
- inm->inm_state = IGMP_LAZY_MEMBER;
- break;
- case IGMP_LAZY_MEMBER:
- case IGMP_SLEEPING_MEMBER:
- break;
- }
- }
- break;
- }
- /*
- * Pass all valid IGMP packets up to any process(es) listening
- * on a raw IGMP socket.
- */
- rip_input(m);
- }
- void
- igmp_joingroup(struct in_multi *inm)
- {
- struct ifnet* ifp;
- int i, s;
- ifp = if_get(inm->inm_ifidx);
- s = splsoftnet();
- inm->inm_state = IGMP_IDLE_MEMBER;
- if (!IN_LOCAL_GROUP(inm->inm_addr.s_addr) &&
- ifp && (ifp->if_flags & IFF_LOOPBACK) == 0) {
- if ((i = rti_fill(inm)) == -1) {
- splx(s);
- return;
- }
- igmp_sendpkt(inm, i, 0);
- inm->inm_state = IGMP_DELAYING_MEMBER;
- inm->inm_timer = IGMP_RANDOM_DELAY(
- IGMP_MAX_HOST_REPORT_DELAY * PR_FASTHZ);
- igmp_timers_are_running = 1;
- } else
- inm->inm_timer = 0;
- splx(s);
- }
- void
- igmp_leavegroup(struct in_multi *inm)
- {
- struct ifnet* ifp;
- int s;
- ifp = if_get(inm->inm_ifidx);
- s = splsoftnet();
- switch (inm->inm_state) {
- case IGMP_DELAYING_MEMBER:
- case IGMP_IDLE_MEMBER:
- if (!IN_LOCAL_GROUP(inm->inm_addr.s_addr) &&
- ifp && (ifp->if_flags & IFF_LOOPBACK) == 0)
- if (inm->inm_rti->rti_type != IGMP_v1_ROUTER)
- igmp_sendpkt(inm, IGMP_HOST_LEAVE_MESSAGE,
- INADDR_ALLROUTERS_GROUP);
- break;
- case IGMP_LAZY_MEMBER:
- case IGMP_AWAKENING_MEMBER:
- case IGMP_SLEEPING_MEMBER:
- break;
- }
- splx(s);
- }
- void
- igmp_fasttimo(void)
- {
- struct ifnet *ifp;
- int s;
- /*
- * Quick check to see if any work needs to be done, in order
- * to minimize the overhead of fasttimo processing.
- */
- if (!igmp_timers_are_running)
- return;
- s = splsoftnet();
- igmp_timers_are_running = 0;
- TAILQ_FOREACH(ifp, &ifnet, if_list)
- igmp_checktimer(ifp);
- splx(s);
- }
- void
- igmp_checktimer(struct ifnet *ifp)
- {
- struct in_multi *inm;
- struct ifmaddr *ifma;
- splsoftassert(IPL_SOFTNET);
- TAILQ_FOREACH(ifma, &ifp->if_maddrlist, ifma_list) {
- if (ifma->ifma_addr->sa_family != AF_INET)
- continue;
- inm = ifmatoinm(ifma);
- if (inm->inm_timer == 0) {
- /* do nothing */
- } else if (--inm->inm_timer == 0) {
- if (inm->inm_state == IGMP_DELAYING_MEMBER) {
- if (inm->inm_rti->rti_type == IGMP_v1_ROUTER)
- igmp_sendpkt(inm,
- IGMP_v1_HOST_MEMBERSHIP_REPORT, 0);
- else
- igmp_sendpkt(inm,
- IGMP_v2_HOST_MEMBERSHIP_REPORT, 0);
- inm->inm_state = IGMP_IDLE_MEMBER;
- }
- } else {
- igmp_timers_are_running = 1;
- }
- }
- }
- void
- igmp_slowtimo(void)
- {
- struct router_info *rti;
- int s;
- s = splsoftnet();
- for (rti = rti_head; rti != 0; rti = rti->rti_next) {
- if (rti->rti_type == IGMP_v1_ROUTER &&
- ++rti->rti_age >= IGMP_AGE_THRESHOLD) {
- rti->rti_type = IGMP_v2_ROUTER;
- }
- }
- splx(s);
- }
- void
- igmp_sendpkt(struct in_multi *inm, int type, in_addr_t addr)
- {
- struct mbuf *m;
- struct igmp *igmp;
- struct ip *ip;
- struct ip_moptions imo;
- MGETHDR(m, M_DONTWAIT, MT_HEADER);
- if (m == NULL)
- return;
- /*
- * Assume max_linkhdr + sizeof(struct ip) + IGMP_MINLEN
- * is smaller than mbuf size returned by MGETHDR.
- */
- m->m_data += max_linkhdr;
- m->m_len = sizeof(struct ip) + IGMP_MINLEN;
- m->m_pkthdr.len = sizeof(struct ip) + IGMP_MINLEN;
- ip = mtod(m, struct ip *);
- ip->ip_tos = 0;
- ip->ip_len = htons(sizeof(struct ip) + IGMP_MINLEN);
- ip->ip_off = 0;
- ip->ip_p = IPPROTO_IGMP;
- ip->ip_src.s_addr = INADDR_ANY;
- if (addr) {
- ip->ip_dst.s_addr = addr;
- } else {
- ip->ip_dst = inm->inm_addr;
- }
- m->m_data += sizeof(struct ip);
- m->m_len -= sizeof(struct ip);
- igmp = mtod(m, struct igmp *);
- igmp->igmp_type = type;
- igmp->igmp_code = 0;
- igmp->igmp_group = inm->inm_addr;
- igmp->igmp_cksum = 0;
- igmp->igmp_cksum = in_cksum(m, IGMP_MINLEN);
- m->m_data -= sizeof(struct ip);
- m->m_len += sizeof(struct ip);
- imo.imo_ifidx = inm->inm_ifidx;
- imo.imo_ttl = 1;
- /*
- * Request loopback of the report if we are acting as a multicast
- * router, so that the process-level routing daemon can hear it.
- */
- #ifdef MROUTING
- imo.imo_loop = (ip_mrouter != NULL);
- #else
- imo.imo_loop = 0;
- #endif /* MROUTING */
- ip_output(m, router_alert, NULL, IP_MULTICASTOPTS, &imo, NULL, 0);
- ++igmpstat.igps_snd_reports;
- }
- /*
- * Sysctl for igmp variables.
- */
- int
- igmp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
- void *newp, size_t newlen)
- {
- /* All sysctl names at this level are terminal. */
- if (namelen != 1)
- return (ENOTDIR);
- switch (name[0]) {
- case IGMPCTL_STATS:
- if (newp != NULL)
- return (EPERM);
- return (sysctl_struct(oldp, oldlenp, newp, newlen,
- &igmpstat, sizeof(igmpstat)));
- default:
- if (name[0] < IGMPCTL_MAXID)
- return (sysctl_int_arr(igmpctl_vars, name, namelen,
- oldp, oldlenp, newp, newlen));
- return (ENOPROTOOPT);
- }
- /* NOTREACHED */
- }
|