Implement IGMP v2. Based on the Multicast 3.5 distribution.
This commit is contained in:
parent
ae4eae4f63
commit
f49ddb8b04
|
@ -1,47 +1,15 @@
|
|||
/* $NetBSD: igmp.c,v 1.9 1995/04/13 06:26:19 cgd Exp $ */
|
||||
/* $NetBSD: igmp.c,v 1.10 1995/05/31 06:08:17 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 Stephen Deering.
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Internet Group Management Protocol (IGMP) routines.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Stephen Deering of Stanford University.
|
||||
* Written by Steve Deering, Stanford, May 1988.
|
||||
* Modified by Rosen Sharma, Stanford, Aug 1994.
|
||||
* Modified by Bill Fenner, Xerox PARC, Feb 1995.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.1 (Berkeley) 7/19/93
|
||||
* MULTICAST Revision: 1.3
|
||||
*/
|
||||
|
||||
/* Internet Group Management Protocol (IGMP) routines. */
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -58,18 +26,76 @@
|
|||
#include <netinet/igmp.h>
|
||||
#include <netinet/igmp_var.h>
|
||||
|
||||
static int igmp_timers_are_running = 0;
|
||||
static u_int32_t igmp_all_hosts_group;
|
||||
#define IP_MULTICASTOPTS 0
|
||||
#define IN_LOCAL_GROUP(addr) \
|
||||
(((addr) & igmp_local_group_mask) == igmp_local_group)
|
||||
|
||||
static void igmp_sendreport __P((struct in_multi *));
|
||||
int igmp_timers_are_running;
|
||||
u_int32_t igmp_all_hosts_group;
|
||||
u_int32_t igmp_local_group;
|
||||
u_int32_t igmp_local_group_mask;
|
||||
static struct router_info *rti_head;
|
||||
|
||||
void igmp_sendpkt __P((struct in_multi *, int));
|
||||
|
||||
void
|
||||
igmp_init()
|
||||
{
|
||||
|
||||
/*
|
||||
* To avoid byte-swapping the same value over and over again.
|
||||
*/
|
||||
igmp_timers_are_running = 0;
|
||||
igmp_all_hosts_group = htonl(INADDR_ALLHOSTS_GROUP);
|
||||
igmp_local_group = htonl(INADDR_UNSPEC_GROUP);
|
||||
igmp_local_group_mask = htonl(IN_CLASSC_NET);
|
||||
rti_head = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rti_fill(inm)
|
||||
struct in_multi *inm;
|
||||
{
|
||||
register struct router_info *rti;
|
||||
|
||||
for (rti = rti_head; rti != 0; rti = rti->rti_next) {
|
||||
if (rti->rti_ifp == inm->inm_ifp) {
|
||||
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);
|
||||
rti->rti_ifp = inm->inm_ifp;
|
||||
rti->rti_type = IGMP_v2_ROUTER;
|
||||
rti->rti_next = rti_head;
|
||||
rti_head = rti;
|
||||
inm->inm_rti = rti;
|
||||
return (IGMP_v2_HOST_MEMBERSHIP_REPORT);
|
||||
}
|
||||
|
||||
static struct router_info *
|
||||
rti_find(ifp)
|
||||
struct ifnet *ifp;
|
||||
{
|
||||
register 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);
|
||||
rti->rti_ifp = ifp;
|
||||
rti->rti_type = IGMP_v2_ROUTER;
|
||||
rti->rti_next = rti_head;
|
||||
rti_head = rti;
|
||||
return (rti);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -77,18 +103,19 @@ igmp_input(m, iphlen)
|
|||
register struct mbuf *m;
|
||||
register int iphlen;
|
||||
{
|
||||
register struct igmp *igmp;
|
||||
register struct ip *ip;
|
||||
register int igmplen;
|
||||
register struct ifnet *ifp = m->m_pkthdr.rcvif;
|
||||
register struct ip *ip = mtod(m, struct ip *);
|
||||
register struct igmp *igmp;
|
||||
register int igmplen;
|
||||
register int minlen;
|
||||
register struct in_multi *inm;
|
||||
register struct in_ifaddr *ia;
|
||||
struct in_multi *inm;
|
||||
struct in_multistep step;
|
||||
struct router_info *rti;
|
||||
register struct in_ifaddr *ia;
|
||||
int timer;
|
||||
|
||||
++igmpstat.igps_rcv_total;
|
||||
|
||||
ip = mtod(m, struct ip *);
|
||||
igmplen = ip->ip_len;
|
||||
|
||||
/*
|
||||
|
@ -129,32 +156,85 @@ igmp_input(m, iphlen)
|
|||
if (ifp->if_flags & IFF_LOOPBACK)
|
||||
break;
|
||||
|
||||
if (ip->ip_dst.s_addr != igmp_all_hosts_group) {
|
||||
++igmpstat.igps_rcv_badqueries;
|
||||
m_freem(m);
|
||||
return;
|
||||
}
|
||||
if (igmp->igmp_code == 0) {
|
||||
rti = rti_find(ifp);
|
||||
rti->rti_type = IGMP_v1_ROUTER;
|
||||
rti->rti_age = 0;
|
||||
|
||||
/*
|
||||
* 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 the
|
||||
* "all-hosts" group.
|
||||
*/
|
||||
IN_FIRST_MULTI(step, inm);
|
||||
while (inm != NULL) {
|
||||
if (inm->inm_ifp == ifp && inm->inm_timer == 0 &&
|
||||
inm->inm_addr.s_addr != igmp_all_hosts_group) {
|
||||
inm->inm_timer =
|
||||
IGMP_RANDOM_DELAY(inm->inm_addr);
|
||||
igmp_timers_are_running = 1;
|
||||
if (ip->ip_dst.s_addr != igmp_all_hosts_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).
|
||||
*/
|
||||
IN_FIRST_MULTI(step, inm);
|
||||
while (inm != NULL) {
|
||||
if (inm->inm_ifp == ifp &&
|
||||
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;
|
||||
}
|
||||
IN_NEXT_MULTI(step, inm);
|
||||
}
|
||||
} 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;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
IN_FIRST_MULTI(step, inm);
|
||||
while (inm != NULL) {
|
||||
if (inm->inm_ifp == ifp &&
|
||||
!IN_LOCAL_GROUP(inm->inm_addr.s_addr) &&
|
||||
(ip->ip_dst.s_addr == igmp_all_hosts_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;
|
||||
}
|
||||
}
|
||||
IN_NEXT_MULTI(step, inm);
|
||||
}
|
||||
IN_NEXT_MULTI(step, inm);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case IGMP_HOST_MEMBERSHIP_REPORT:
|
||||
case IGMP_v1_HOST_MEMBERSHIP_REPORT:
|
||||
++igmpstat.igps_rcv_reports;
|
||||
|
||||
if (ifp->if_flags & IFF_LOOPBACK)
|
||||
|
@ -171,14 +251,15 @@ igmp_input(m, iphlen)
|
|||
* 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 demon can
|
||||
* 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 ((ntohl(ip->ip_src.s_addr) & IN_CLASSA_NET) == 0) {
|
||||
IFP_TO_IA(ifp, ia);
|
||||
if (ia) ip->ip_src.s_addr = htonl(ia->ia_subnet);
|
||||
if (ia)
|
||||
ip->ip_src.s_addr = htonl(ia->ia_subnet);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -189,9 +270,89 @@ igmp_input(m, iphlen)
|
|||
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_SIN(ia)->sin_addr.s_addr)
|
||||
break;
|
||||
#endif
|
||||
|
||||
++igmpstat.igps_rcv_reports;
|
||||
|
||||
if (ifp->if_flags & IFF_LOOPBACK)
|
||||
break;
|
||||
|
||||
if (!IN_MULTICAST(ntohl(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 ((ntohl(ip->ip_src.s_addr) & IN_CLASSA_NET) == 0) {
|
||||
#ifndef MROUTING
|
||||
IFP_TO_IA(ifp, ia);
|
||||
#endif
|
||||
if (ia)
|
||||
ip->ip_src.s_addr = htonl(ia->ia_subnet);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -205,16 +366,19 @@ void
|
|||
igmp_joingroup(inm)
|
||||
struct in_multi *inm;
|
||||
{
|
||||
register int s = splnet();
|
||||
int s = splnet();
|
||||
|
||||
if (inm->inm_addr.s_addr == igmp_all_hosts_group ||
|
||||
(inm->inm_ifp->if_flags & IFF_LOOPBACK))
|
||||
inm->inm_timer = 0;
|
||||
else {
|
||||
igmp_sendreport(inm);
|
||||
inm->inm_timer = IGMP_RANDOM_DELAY(inm->inm_addr);
|
||||
inm->inm_state = IGMP_IDLE_MEMBER;
|
||||
|
||||
if (!IN_LOCAL_GROUP(inm->inm_addr.s_addr) &&
|
||||
(inm->inm_ifp->if_flags & IFF_LOOPBACK) == 0) {
|
||||
igmp_sendpkt(inm, rti_fill(inm));
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -222,17 +386,28 @@ void
|
|||
igmp_leavegroup(inm)
|
||||
struct in_multi *inm;
|
||||
{
|
||||
/*
|
||||
* No action required on leaving a group.
|
||||
*/
|
||||
|
||||
switch (inm->inm_state) {
|
||||
case IGMP_DELAYING_MEMBER:
|
||||
case IGMP_IDLE_MEMBER:
|
||||
if (!IN_LOCAL_GROUP(inm->inm_addr.s_addr) &&
|
||||
(inm->inm_ifp->if_flags & IFF_LOOPBACK) == 0)
|
||||
if (inm->inm_rti->rti_type != IGMP_v1_ROUTER)
|
||||
igmp_sendpkt(inm, IGMP_HOST_LEAVE_MESSAGE);
|
||||
break;
|
||||
case IGMP_LAZY_MEMBER:
|
||||
case IGMP_AWAKENING_MEMBER:
|
||||
case IGMP_SLEEPING_MEMBER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
igmp_fasttimo()
|
||||
{
|
||||
register struct in_multi *inm;
|
||||
register int s;
|
||||
struct in_multistep step;
|
||||
int s;
|
||||
|
||||
/*
|
||||
* Quick check to see if any work needs to be done, in order
|
||||
|
@ -248,7 +423,15 @@ igmp_fasttimo()
|
|||
if (inm->inm_timer == 0) {
|
||||
/* do nothing */
|
||||
} else if (--inm->inm_timer == 0) {
|
||||
igmp_sendreport(inm);
|
||||
if (inm->inm_state == IGMP_DELAYING_MEMBER) {
|
||||
if (inm->inm_rti->rti_type == IGMP_v1_ROUTER)
|
||||
igmp_sendpkt(inm,
|
||||
IGMP_v1_HOST_MEMBERSHIP_REPORT);
|
||||
else
|
||||
igmp_sendpkt(inm,
|
||||
IGMP_v2_HOST_MEMBERSHIP_REPORT);
|
||||
inm->inm_state = IGMP_IDLE_MEMBER;
|
||||
}
|
||||
} else {
|
||||
igmp_timers_are_running = 1;
|
||||
}
|
||||
|
@ -257,15 +440,34 @@ igmp_fasttimo()
|
|||
splx(s);
|
||||
}
|
||||
|
||||
static void
|
||||
igmp_sendreport(inm)
|
||||
register struct in_multi *inm;
|
||||
void
|
||||
igmp_slowtimo()
|
||||
{
|
||||
register struct mbuf *m;
|
||||
register struct igmp *igmp;
|
||||
register struct ip *ip;
|
||||
register struct ip_moptions *imo;
|
||||
struct ip_moptions simo;
|
||||
register struct router_info *rti;
|
||||
int s;
|
||||
|
||||
s = splnet();
|
||||
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(inm, type)
|
||||
struct in_multi *inm;
|
||||
int type;
|
||||
{
|
||||
struct mbuf *m;
|
||||
struct igmp *igmp;
|
||||
struct ip *ip;
|
||||
struct ip_moptions imo;
|
||||
#ifdef MROUTING
|
||||
extern struct socket *ip_mrouter;
|
||||
#endif /* MROUTING */
|
||||
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
if (m == NULL)
|
||||
|
@ -289,7 +491,7 @@ igmp_sendreport(inm)
|
|||
m->m_data += sizeof(struct ip);
|
||||
m->m_len -= sizeof(struct ip);
|
||||
igmp = mtod(m, struct igmp *);
|
||||
igmp->igmp_type = IGMP_HOST_MEMBERSHIP_REPORT;
|
||||
igmp->igmp_type = type;
|
||||
igmp->igmp_code = 0;
|
||||
igmp->igmp_group = inm->inm_addr;
|
||||
igmp->igmp_cksum = 0;
|
||||
|
@ -297,21 +499,23 @@ igmp_sendreport(inm)
|
|||
m->m_data -= sizeof(struct ip);
|
||||
m->m_len += sizeof(struct ip);
|
||||
|
||||
imo = &simo;
|
||||
bzero((caddr_t)imo, sizeof(*imo));
|
||||
imo->imo_multicast_ifp = inm->inm_ifp;
|
||||
imo->imo_multicast_ttl = 1;
|
||||
imo.imo_multicast_ifp = inm->inm_ifp;
|
||||
imo.imo_multicast_ttl = 1;
|
||||
#ifdef RSVP_ISI
|
||||
imo.imo_multicast_vif = -1;
|
||||
#endif
|
||||
/*
|
||||
* Request loopback of the report if we are acting as a multicast
|
||||
* router, so that the process-level routing demon can hear it.
|
||||
*/
|
||||
#ifdef MROUTING
|
||||
{
|
||||
extern struct socket *ip_mrouter;
|
||||
imo->imo_multicast_loop = (ip_mrouter != NULL);
|
||||
}
|
||||
#endif
|
||||
ip_output(m, NULL, NULL, 0, imo);
|
||||
imo.imo_multicast_loop = (ip_mrouter != NULL);
|
||||
#else
|
||||
imo.imo_multicast_loop = 0;
|
||||
#endif /* MROUTING */
|
||||
|
||||
ip_output(m, (struct mbuf *)0, (struct route *)0, IP_MULTICASTOPTS,
|
||||
&imo);
|
||||
|
||||
++igmpstat.igps_snd_reports;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: igmp.h,v 1.5 1995/04/13 06:26:39 cgd Exp $ */
|
||||
/* $NetBSD: igmp.h,v 1.6 1995/05/31 06:08:21 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 Stephen Deering.
|
||||
|
@ -39,24 +39,54 @@
|
|||
* @(#)igmp.h 8.1 (Berkeley) 6/10/93
|
||||
*/
|
||||
|
||||
/* Internet Group Management Protocol (IGMP) definitions. */
|
||||
/*
|
||||
* Internet Group Management Protocol (IGMP) definitions.
|
||||
*
|
||||
* MULTICAST 1.3
|
||||
*/
|
||||
|
||||
/*
|
||||
* IGMP packet format.
|
||||
*/
|
||||
struct igmp {
|
||||
u_int8_t igmp_type; /* version & type of IGMP message */
|
||||
u_int8_t igmp_code; /* unused, should be zero */
|
||||
u_int8_t igmp_code; /* code for routing sub-messages */
|
||||
u_int16_t igmp_cksum; /* IP-style checksum */
|
||||
struct in_addr igmp_group; /* group address being reported */
|
||||
}; /* (zero for queries) */
|
||||
|
||||
#define IGMP_MINLEN 8
|
||||
|
||||
#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* message types, incl. version */
|
||||
#define IGMP_HOST_MEMBERSHIP_REPORT 0x12
|
||||
#define IGMP_DVMRP 0x13 /* for experimental multicast */
|
||||
/* routing protocol */
|
||||
#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* membership query */
|
||||
#define IGMP_v1_HOST_MEMBERSHIP_REPORT 0x12 /* v1 membership report */
|
||||
#define IGMP_DVMRP 0x13 /* DVMRP routing message */
|
||||
#define IGMP_PIM 0x14 /* PIM routing message */
|
||||
#define IGMP_v2_HOST_MEMBERSHIP_REPORT 0x16 /* v2 membership report */
|
||||
#define IGMP_HOST_LEAVE_MESSAGE 0x17 /* leave-group message */
|
||||
#define IGMP_MTRACE_REPLY 0x1e /* traceroute reply */
|
||||
#define IGMP_MTRACE_QUERY 0x1f /* traceroute query */
|
||||
|
||||
#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */
|
||||
/* query (in seconds) */
|
||||
#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */
|
||||
/* query (in seconds) */
|
||||
|
||||
#define IGMP_TIMER_SCALE 10 /* denominator for igmp_timer */
|
||||
|
||||
/*
|
||||
* States for the IGMP v2 state table.
|
||||
*/
|
||||
#define IGMP_DELAYING_MEMBER 1
|
||||
#define IGMP_IDLE_MEMBER 2
|
||||
#define IGMP_LAZY_MEMBER 3
|
||||
#define IGMP_SLEEPING_MEMBER 4
|
||||
#define IGMP_AWAKENING_MEMBER 5
|
||||
|
||||
/*
|
||||
* States for IGMP router version cache.
|
||||
*/
|
||||
#define IGMP_v1_ROUTER 1
|
||||
#define IGMP_v2_ROUTER 2
|
||||
|
||||
/*
|
||||
* Revert to v2 if we haven't heard from the router in this amount of time.
|
||||
*/
|
||||
#define IGMP_AGE_THRESHOLD 540
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: igmp_var.h,v 1.7 1995/03/26 20:32:22 jtc Exp $ */
|
||||
/* $NetBSD: igmp_var.h,v 1.8 1995/05/31 06:08:24 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 Stephen Deering.
|
||||
|
@ -44,8 +44,10 @@
|
|||
* implementation-specific definitions.
|
||||
*
|
||||
* Written by Steve Deering, Stanford, May 1988.
|
||||
* Modified by Rosen Sharma, Stanford, Aug 1994.
|
||||
* Modified by Bill Fenner, Xerox PARC, Feb 1995.
|
||||
*
|
||||
* MULTICAST 1.1
|
||||
* MULTICAST 1.3
|
||||
*/
|
||||
|
||||
struct igmpstat {
|
||||
|
@ -68,13 +70,12 @@ struct igmpstat igmpstat;
|
|||
* DELAY * countdown frequency). We assume that the routine random()
|
||||
* is defined somewhere (and that it returns a positive number).
|
||||
*/
|
||||
#define IGMP_RANDOM_DELAY(multiaddr) \
|
||||
/* struct in_addr multiaddr; */ \
|
||||
(random() % (IGMP_MAX_HOST_REPORT_DELAY * PR_FASTHZ) + 1)
|
||||
#define IGMP_RANDOM_DELAY(X) (random() % (X) + 1)
|
||||
|
||||
void igmp_init __P((void));
|
||||
void igmp_input __P((struct mbuf *, int));
|
||||
void igmp_joingroup __P((struct in_multi *));
|
||||
void igmp_leavegroup __P((struct in_multi *));
|
||||
void igmp_fasttimo __P((void));
|
||||
void igmp_slowtimo __P((void));
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: in_proto.c,v 1.9 1994/06/29 06:38:09 cgd Exp $ */
|
||||
/* $NetBSD: in_proto.c,v 1.10 1995/05/31 06:08:27 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
|
@ -109,7 +109,7 @@ struct protosw inetsw[] = {
|
|||
{ SOCK_RAW, &inetdomain, IPPROTO_IGMP, PR_ATOMIC|PR_ADDR,
|
||||
igmp_input, rip_output, 0, rip_ctloutput,
|
||||
rip_usrreq,
|
||||
igmp_init, igmp_fasttimo, 0, 0,
|
||||
igmp_init, igmp_fasttimo, igmp_slowtimo, 0,
|
||||
},
|
||||
#ifdef TPIP
|
||||
{ SOCK_SEQPACKET,&inetdomain, IPPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: in_var.h,v 1.11 1995/04/13 06:30:32 cgd Exp $ */
|
||||
/* $NetBSD: in_var.h,v 1.12 1995/05/31 06:08:29 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1986, 1993
|
||||
|
@ -114,6 +114,16 @@ void in_socktrim __P((struct sockaddr_in *));
|
|||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Per-interface router version information.
|
||||
*/
|
||||
struct router_info {
|
||||
struct ifnet *rti_ifp;
|
||||
int rti_type; /* type of router on this interface */
|
||||
int rti_age; /* time since last v1 query */
|
||||
struct router_info *rti_next;
|
||||
};
|
||||
|
||||
/*
|
||||
* Internet multicast address structure. There is one of these for each IP
|
||||
* multicast group to which this host belongs on a given network interface.
|
||||
|
@ -127,6 +137,8 @@ struct in_multi {
|
|||
u_int inm_refcount; /* no. membership claims by sockets */
|
||||
u_int inm_timer; /* IGMP membership report timer */
|
||||
struct in_multi *inm_next; /* ptr to next multicast address */
|
||||
u_int inm_state; /* state of membership */
|
||||
struct router_info *inm_rti; /* router version info */
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
|
Loading…
Reference in New Issue