/*
- * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
&igmpstat, igmpstat, "");
static int igmp_timers_are_running;
-static u_long igmp_all_hosts_group;
-static u_long igmp_all_rtrs_group;
+static uint32_t igmp_all_hosts_group;
+static uint32_t igmp_all_rtrs_group;
static struct mbuf *router_alert;
static struct router_info *Head;
-static void igmp_sendpkt(struct in_multi *, int, unsigned long);
+static void igmp_sendpkt(struct in_multi *, int, uint32_t);
void
igmp_init(void)
/*
* Construct a Router Alert option to use in outgoing packets
*/
- MGET(router_alert, M_DONTWAIT, MT_DATA);
+ MGET(router_alert, M_WAIT, MT_DATA);
ra = mtod(router_alert, struct ipoption *);
ra->ipopt_dst.s_addr = 0;
ra->ipopt_list[0] = IPOPT_RA; /* Router Alert Option */
* - Use the value specified in the query message as
* the maximum timeout.
*/
- lck_mtx_lock(rt_mtx);
+ lck_mtx_lock(rnh_lock);
IN_FIRST_MULTI(step, inm);
while (inm != NULL) {
if (inm->inm_ifp == ifp &&
}
IN_NEXT_MULTI(step, inm);
}
- lck_mtx_unlock(rt_mtx);
+ lck_mtx_unlock(rnh_lock);
break;
* router, so discard reports sourced by me.
*/
IFP_TO_IA(ifp, ia);
- if (ia && ip->ip_src.s_addr == IA_SIN(ia)->sin_addr.s_addr)
+ if (ia && ip->ip_src.s_addr == IA_SIN(ia)->sin_addr.s_addr) {
+ ifafree(&ia->ia_ifa);
break;
+ }
++igmpstat.igps_rcv_reports;
- if (ifp->if_flags & IFF_LOOPBACK)
+ if (ifp->if_flags & IFF_LOOPBACK) {
+ if (ia != NULL)
+ ifafree(&ia->ia_ifa);
break;
+ }
if (!IN_MULTICAST(ntohl(igmp->igmp_group.s_addr))) {
++igmpstat.igps_rcv_badreports;
m_freem(m);
+ if (ia != NULL)
+ ifafree(&ia->ia_ifa);
return;
}
inm->inm_state = IGMP_OTHERMEMBER;
}
+ if (ia != NULL)
+ ifafree(&ia->ia_ifa);
break;
}
#endif
}
-static struct route igmprt;
-
static void
-igmp_sendpkt(struct in_multi *inm, int type, unsigned long addr)
+igmp_sendpkt(struct in_multi *inm, int type, uint32_t addr)
{
struct mbuf *m;
struct igmp *igmp;
struct ip *ip;
struct ip_moptions imo;
+ struct route ro;
MGETHDR(m, M_DONTWAIT, MT_HEADER); /* MAC-OK */
if (m == NULL)
* XXX
* Do we have to worry about reentrancy here? Don't think so.
*/
- ip_output(m, router_alert, &igmprt, 0, &imo, NULL);
+ bzero(&ro, sizeof (ro));
+ (void) ip_output(m, router_alert, &ro, 0, &imo, NULL);
+ if (ro.ro_rt != NULL) {
+ rtfree(ro.ro_rt);
+ ro.ro_rt = NULL;
+ }
++igmpstat.igps_snd_reports;
}