summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Schlyter <jakob@cvs.openbsd.org>2001-11-06 21:26:34 +0000
committerJakob Schlyter <jakob@cvs.openbsd.org>2001-11-06 21:26:34 +0000
commita0cc8d9cea95859745e56428c11cdca914d3eec1 (patch)
treec9596af109b7d570c0bd51a8fbb3bc4222ed8003
parent19dda2fe17987a2d727baf68e6eb0569867e91a7 (diff)
send igmp v2 leave messages to allrouters address (PR#2164)
patch based on parts from NetBSD submitted by goeran@cdg.chalmers.se
-rw-r--r--sys/netinet/igmp.c22
-rw-r--r--sys/netinet/in.h3
2 files changed, 16 insertions, 9 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index c0b1f76d6dc..dee72b61cef 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp.c,v 1.11 2001/06/08 03:53:45 angelos Exp $ */
+/* $OpenBSD: igmp.c,v 1.12 2001/11/06 21:26:33 jakob Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
@@ -35,7 +35,7 @@
int igmp_timers_are_running;
static struct router_info *rti_head;
-void igmp_sendpkt __P((struct in_multi *, int));
+void igmp_sendpkt __P((struct in_multi *, int, in_addr_t));
static int rti_fill __P((struct in_multi *));
static struct router_info * rti_find __P((struct ifnet *));
@@ -409,7 +409,7 @@ igmp_joingroup(inm)
(inm->inm_ifp->if_flags & IFF_LOOPBACK) == 0) {
if ((i = rti_fill(inm)) == -1)
return;
- igmp_sendpkt(inm, i);
+ igmp_sendpkt(inm, i, 0);
inm->inm_state = IGMP_DELAYING_MEMBER;
inm->inm_timer = IGMP_RANDOM_DELAY(
IGMP_MAX_HOST_REPORT_DELAY * PR_FASTHZ);
@@ -430,7 +430,8 @@ igmp_leavegroup(inm)
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);
+ igmp_sendpkt(inm, IGMP_HOST_LEAVE_MESSAGE,
+ INADDR_ALLROUTERS_GROUP);
break;
case IGMP_LAZY_MEMBER:
case IGMP_AWAKENING_MEMBER:
@@ -463,10 +464,10 @@ igmp_fasttimo()
if (inm->inm_state == IGMP_DELAYING_MEMBER) {
if (inm->inm_rti->rti_type == IGMP_v1_ROUTER)
igmp_sendpkt(inm,
- IGMP_v1_HOST_MEMBERSHIP_REPORT);
+ IGMP_v1_HOST_MEMBERSHIP_REPORT, 0);
else
igmp_sendpkt(inm,
- IGMP_v2_HOST_MEMBERSHIP_REPORT);
+ IGMP_v2_HOST_MEMBERSHIP_REPORT, 0);
inm->inm_state = IGMP_IDLE_MEMBER;
}
} else {
@@ -494,9 +495,10 @@ igmp_slowtimo()
}
void
-igmp_sendpkt(inm, type)
+igmp_sendpkt(inm, type, addr)
struct in_multi *inm;
int type;
+ in_addr_t addr;
{
struct mbuf *m;
struct igmp *igmp;
@@ -523,7 +525,11 @@ igmp_sendpkt(inm, type)
ip->ip_off = 0;
ip->ip_p = IPPROTO_IGMP;
ip->ip_src.s_addr = INADDR_ANY;
- ip->ip_dst = inm->inm_addr;
+ 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);
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 70bae98f3a7..4fe3ac49148 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.54 2001/07/05 08:40:12 angelos Exp $ */
+/* $OpenBSD: in.h,v 1.55 2001/11/06 21:26:33 jakob Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -201,6 +201,7 @@ struct in_addr {
#define INADDR_UNSPEC_GROUP __IPADDR(0xe0000000) /* 224.0.0.0 */
#define INADDR_ALLHOSTS_GROUP __IPADDR(0xe0000001) /* 224.0.0.1 */
+#define INADDR_ALLROUTERS_GROUP __IPADDR(0xe0000002) /* 224.0.0.2 */
#define INADDR_MAX_LOCAL_GROUP __IPADDR(0xe00000ff) /* 224.0.0.255 */
#define IN_LOOPBACKNET 127 /* official! */