igmp.c (111119) | igmp.c (119180) |
---|---|
1/* 2 * Copyright (c) 1988 Stephen Deering. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Stephen Deering of Stanford University. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)igmp.c 8.1 (Berkeley) 7/19/93 | 1/* 2 * Copyright (c) 1988 Stephen Deering. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Stephen Deering of Stanford University. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)igmp.c 8.1 (Berkeley) 7/19/93 |
38 * $FreeBSD: head/sys/netinet/igmp.c 111119 2003-02-19 05:47:46Z imp $ | 38 * $FreeBSD: head/sys/netinet/igmp.c 119180 2003-08-20 17:09:01Z rwatson $ |
39 */ 40 41/* 42 * Internet Group Management Protocol (IGMP) routines. 43 * 44 * Written by Steve Deering, Stanford, May 1988. 45 * Modified by Rosen Sharma, Stanford, Aug 1994. 46 * Modified by Bill Fenner, Xerox PARC, Feb 1995. --- 36 unchanged lines hidden (view full) --- 83 84SYSCTL_STRUCT(_net_inet_igmp, IGMPCTL_STATS, stats, CTLFLAG_RW, 85 &igmpstat, igmpstat, ""); 86 87static int igmp_timers_are_running; 88static u_long igmp_all_hosts_group; 89static u_long igmp_all_rtrs_group; 90static struct mbuf *router_alert; | 39 */ 40 41/* 42 * Internet Group Management Protocol (IGMP) routines. 43 * 44 * Written by Steve Deering, Stanford, May 1988. 45 * Modified by Rosen Sharma, Stanford, Aug 1994. 46 * Modified by Bill Fenner, Xerox PARC, Feb 1995. --- 36 unchanged lines hidden (view full) --- 83 84SYSCTL_STRUCT(_net_inet_igmp, IGMPCTL_STATS, stats, CTLFLAG_RW, 85 &igmpstat, igmpstat, ""); 86 87static int igmp_timers_are_running; 88static u_long igmp_all_hosts_group; 89static u_long igmp_all_rtrs_group; 90static struct mbuf *router_alert; |
91static struct router_info *Head; | 91static SLIST_HEAD(, router_info) router_info_head; |
92 93static void igmp_sendpkt(struct in_multi *, int, unsigned long); 94 | 92 93static void igmp_sendpkt(struct in_multi *, int, unsigned long); 94 |
95#ifdef IGMP_DEBUG 96#define IGMP_PRINTF(x) printf(x) 97#else 98#define IGMP_PRINTF(x) 99#endif 100 |
|
95void 96igmp_init() 97{ 98 struct ipoption *ra; 99 100 /* 101 * To avoid byte-swapping the same value over and over again. 102 */ --- 9 unchanged lines hidden (view full) --- 112 ra = mtod(router_alert, struct ipoption *); 113 ra->ipopt_dst.s_addr = 0; 114 ra->ipopt_list[0] = IPOPT_RA; /* Router Alert Option */ 115 ra->ipopt_list[1] = 0x04; /* 4 bytes long */ 116 ra->ipopt_list[2] = 0x00; 117 ra->ipopt_list[3] = 0x00; 118 router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1]; 119 | 101void 102igmp_init() 103{ 104 struct ipoption *ra; 105 106 /* 107 * To avoid byte-swapping the same value over and over again. 108 */ --- 9 unchanged lines hidden (view full) --- 118 ra = mtod(router_alert, struct ipoption *); 119 ra->ipopt_dst.s_addr = 0; 120 ra->ipopt_list[0] = IPOPT_RA; /* Router Alert Option */ 121 ra->ipopt_list[1] = 0x04; /* 4 bytes long */ 122 ra->ipopt_list[2] = 0x00; 123 ra->ipopt_list[3] = 0x00; 124 router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1]; 125 |
120 Head = (struct router_info *) 0; | 126 SLIST_INIT(&router_info_head); |
121} 122 123static struct router_info * 124find_rti(ifp) 125 struct ifnet *ifp; 126{ | 127} 128 129static struct router_info * 130find_rti(ifp) 131 struct ifnet *ifp; 132{ |
127 register struct router_info *rti = Head; | 133 struct router_info *rti; |
128 | 134 |
129#ifdef IGMP_DEBUG 130 printf("[igmp.c, _find_rti] --> entering \n"); 131#endif 132 while (rti) { 133 if (rti->rti_ifp == ifp) { 134#ifdef IGMP_DEBUG 135 printf("[igmp.c, _find_rti] --> found old entry \n"); 136#endif | 135 rti = SLIST_FIRST(&router_info_head); 136 IGMP_PRINTF("[igmp.c, _find_rti] --> entering \n"); 137 SLIST_FOREACH(rti, &router_info_head, rti_list) { 138 if (rti->rti_ifp == ifp) { 139 IGMP_PRINTF( 140 "[igmp.c, _find_rti] --> found old entry \n"); |
137 return rti; 138 } | 141 return rti; 142 } |
139 rti = rti->rti_next; | |
140 } 141 MALLOC(rti, struct router_info *, sizeof *rti, M_IGMP, M_NOWAIT); 142 rti->rti_ifp = ifp; 143 rti->rti_type = IGMP_V2_ROUTER; 144 rti->rti_time = 0; | 143 } 144 MALLOC(rti, struct router_info *, sizeof *rti, M_IGMP, M_NOWAIT); 145 rti->rti_ifp = ifp; 146 rti->rti_type = IGMP_V2_ROUTER; 147 rti->rti_time = 0; |
145 rti->rti_next = Head; 146 Head = rti; 147#ifdef IGMP_DEBUG 148 printf("[igmp.c, _find_rti] --> created an entry \n"); 149#endif | 148 SLIST_INSERT_HEAD(&router_info_head, rti, rti_list); 149 150 IGMP_PRINTF("[igmp.c, _find_rti] --> created an entry \n"); |
150 return rti; 151} 152 153void 154igmp_input(m, off) 155 register struct mbuf *m; 156 int off; 157{ --- 249 unchanged lines hidden (view full) --- 407 } 408 splx(s); 409} 410 411void 412igmp_slowtimo() 413{ 414 int s = splnet(); | 151 return rti; 152} 153 154void 155igmp_input(m, off) 156 register struct mbuf *m; 157 int off; 158{ --- 249 unchanged lines hidden (view full) --- 408 } 409 splx(s); 410} 411 412void 413igmp_slowtimo() 414{ 415 int s = splnet(); |
415 register struct router_info *rti = Head; | 416 struct router_info *rti; |
416 | 417 |
417#ifdef IGMP_DEBUG 418 printf("[igmp.c,_slowtimo] -- > entering \n"); 419#endif 420 while (rti) { | 418 IGMP_PRINTF("[igmp.c,_slowtimo] -- > entering \n"); 419 SLIST_FOREACH(rti, &router_info_head, rti_list) { |
421 if (rti->rti_type == IGMP_V1_ROUTER) { 422 rti->rti_time++; 423 if (rti->rti_time >= IGMP_AGE_THRESHOLD) { 424 rti->rti_type = IGMP_V2_ROUTER; 425 } 426 } | 420 if (rti->rti_type == IGMP_V1_ROUTER) { 421 rti->rti_time++; 422 if (rti->rti_time >= IGMP_AGE_THRESHOLD) { 423 rti->rti_type = IGMP_V2_ROUTER; 424 } 425 } |
427 rti = rti->rti_next; | |
428 } | 426 } |
429#ifdef IGMP_DEBUG 430 printf("[igmp.c,_slowtimo] -- > exiting \n"); 431#endif | 427 IGMP_PRINTF("[igmp.c,_slowtimo] -- > exiting \n"); |
432 splx(s); 433} 434 435static struct route igmprt; 436 437static void 438igmp_sendpkt(inm, type, addr) 439 struct in_multi *inm; --- 54 unchanged lines hidden --- | 428 splx(s); 429} 430 431static struct route igmprt; 432 433static void 434igmp_sendpkt(inm, type, addr) 435 struct in_multi *inm; --- 54 unchanged lines hidden --- |