-/* $OpenBSD: igmp.c,v 1.39 2014/04/21 12:22:26 henning Exp $ */
+/* $OpenBSD: igmp.c,v 1.40 2014/05/12 09:15:00 mpi Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
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_init(void)
{
+ struct ipoption *ra;
- /*
- * To avoid byte-swapping the same value over and over again.
- */
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. */
imo.imo_multicast_loop = 0;
#endif /* MROUTING */
- ip_output(m, NULL, NULL, IP_MULTICASTOPTS, &imo, NULL, 0);
+ ip_output(m, router_alert, NULL, IP_MULTICASTOPTS, &imo, NULL, 0);
++igmpstat.igps_snd_reports;
}
-/* $OpenBSD: ip.h,v 1.14 2013/10/24 15:21:21 deraadt Exp $ */
+/* $OpenBSD: ip.h,v 1.15 2014/05/12 09:15:00 mpi Exp $ */
/* $NetBSD: ip.h,v 1.9 1995/05/15 01:22:44 cgd Exp $ */
/*
#define IPOPT_LSRR 131 /* loose source route */
#define IPOPT_SATID 136 /* satnet id */
#define IPOPT_SSRR 137 /* strict source route */
+#define IPOPT_RA 148 /* router alert */
/*
* Offsets to fields in options other than EOL and NOP.