summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mrouted/igmp.c
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1995-06-13 18:05:16 +0000
committerwollman <wollman@FreeBSD.org>1995-06-13 18:05:16 +0000
commitd7ec2bee9b62915b2bfc4cbeffefb602d913f92d (patch)
tree251f664e3bb6640c0dc6968bd9a6ec402be8d14b /usr.sbin/mrouted/igmp.c
parent20ad4f8359820cf12331c0335034438fc23ad604 (diff)
downloadFreeBSD-src-d7ec2bee9b62915b2bfc4cbeffefb602d913f92d.zip
FreeBSD-src-d7ec2bee9b62915b2bfc4cbeffefb602d913f92d.tar.gz
This is mrouted version 3.5, with the route-change notification hook from
mrouted-3.5n. This is being splatted onto the head rather than properly imported thanks to the ``delete trailing whitespace'' screw. This code is now actively working in an operational environment (the DARTNET) so I have some confidence that the basic functionality actually works. Obtained from: Bill Fenner, PARC, and ISI
Diffstat (limited to 'usr.sbin/mrouted/igmp.c')
-rw-r--r--usr.sbin/mrouted/igmp.c80
1 files changed, 46 insertions, 34 deletions
diff --git a/usr.sbin/mrouted/igmp.c b/usr.sbin/mrouted/igmp.c
index f814e67..5fe08e7 100644
--- a/usr.sbin/mrouted/igmp.c
+++ b/usr.sbin/mrouted/igmp.c
@@ -7,7 +7,7 @@
* Leland Stanford Junior University.
*
*
- * igmp.c,v 1.2 1994/09/08 02:51:15 wollman Exp
+ * $Id: igmp.c,v 3.5 1995/05/09 01:00:39 fenner Exp $
*/
@@ -17,12 +17,13 @@
/*
* Exported variables.
*/
-char recv_buf[MAX_IP_PACKET_LEN]; /* input packet buffer */
-char send_buf[MAX_IP_PACKET_LEN]; /* output packet buffer */
+char *recv_buf; /* input packet buffer */
+char *send_buf; /* output packet buffer */
int igmp_socket; /* socket for all network I/O */
-u_long allhosts_group; /* allhosts addr in net order */
-u_long dvmrp_group; /* DVMRP grp addr in net order */
-u_long dvmrp_genid; /* IGMP generation id */
+u_int32 allhosts_group; /* All hosts addr in net order */
+u_int32 allrtrs_group; /* All-Routers " in net order */
+u_int32 dvmrp_group; /* DVMRP grp addr in net order */
+u_int32 dvmrp_genid; /* IGMP generation id */
/*
* Open and initialize the igmp socket, and fill in the non-changing
@@ -32,7 +33,10 @@ void init_igmp()
{
struct ip *ip;
- if ((igmp_socket = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP)) < 0)
+ recv_buf = malloc(RECV_BUF_SIZE);
+ send_buf = malloc(RECV_BUF_SIZE);
+
+ if ((igmp_socket = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP)) < 0)
log(LOG_ERR, errno, "IGMP socket");
k_hdr_include(TRUE); /* include IP header when sending */
@@ -50,10 +54,9 @@ void init_igmp()
allhosts_group = htonl(INADDR_ALLHOSTS_GROUP);
dvmrp_group = htonl(INADDR_DVMRP_GROUP);
+ allrtrs_group = htonl(INADDR_ALLRTRS_GROUP);
}
-/* %%% hack for PIM %%% */
-#define IGMP_PIM 0x14
#define PIM_QUERY 0
#define PIM_REGISTER 1
#define PIM_REGISTER_STOP 2
@@ -69,8 +72,8 @@ static char *packet_kind(type, code)
switch (type) {
case IGMP_HOST_MEMBERSHIP_QUERY: return "membership query ";
case IGMP_HOST_MEMBERSHIP_REPORT: return "membership report ";
- case IGMP_HOST_NEW_MEMBERSHIP_REPORT: return "new membership report ";
- case IGMP_HOST_LEAVE_MESSAGE: return "leave message";
+ case IGMP_HOST_NEW_MEMBERSHIP_REPORT: return "new member report ";
+ case IGMP_HOST_LEAVE_MESSAGE: return "leave message ";
case IGMP_DVMRP:
switch (code) {
case DVMRP_PROBE: return "neighbor probe ";
@@ -79,12 +82,12 @@ static char *packet_kind(type, code)
case DVMRP_NEIGHBORS: return "neighbor list ";
case DVMRP_ASK_NEIGHBORS2: return "neighbor request 2";
case DVMRP_NEIGHBORS2: return "neighbor list 2 ";
- case DVMRP_PRUNE: return "prune message ";
- case DVMRP_GRAFT: return "graft message ";
+ case DVMRP_PRUNE: return "prune message ";
+ case DVMRP_GRAFT: return "graft message ";
case DVMRP_GRAFT_ACK: return "graft message ack ";
default: return "unknown DVMRP msg ";
}
- case IGMP_PIM: /* %%% hack for PIM %%% */
+ case IGMP_PIM:
switch (code) {
case PIM_QUERY: return "PIM Router-Query ";
case PIM_REGISTER: return "PIM Register ";
@@ -109,7 +112,7 @@ static char *packet_kind(type, code)
void accept_igmp(recvlen)
int recvlen;
{
- register u_long src, dst, group;
+ register u_int32 src, dst, group;
struct ip *ip;
struct igmp *igmp;
int ipdatalen, iphdrlen, igmpdatalen;
@@ -124,9 +127,9 @@ void accept_igmp(recvlen)
src = ip->ip_src.s_addr;
dst = ip->ip_dst.s_addr;
- /*
+ /*
* this is most likely a message from the kernel indicating that
- * a new src grp pair message has arrived and so, it would be
+ * a new src grp pair message has arrived and so, it would be
* necessary to install a route into the kernel for this.
*/
if (ip->ip_p == 0) {
@@ -163,29 +166,30 @@ void accept_igmp(recvlen)
switch (igmp->igmp_type) {
case IGMP_HOST_MEMBERSHIP_QUERY:
- /* we have to do the determination of the querrier router here */
+ accept_membership_query(src, dst, group, igmp->igmp_code);
return;
case IGMP_HOST_MEMBERSHIP_REPORT:
case IGMP_HOST_NEW_MEMBERSHIP_REPORT:
- accept_group_report(src, dst, group,igmp->igmp_type);
+ accept_group_report(src, dst, group, igmp->igmp_type);
return;
-
+
case IGMP_HOST_LEAVE_MESSAGE:
- leave_group_message(src, dst, group);
+ accept_leave_message(src, dst, group);
return;
case IGMP_DVMRP:
- switch (igmp->igmp_code) {
+ group = ntohl(group);
+ switch (igmp->igmp_code) {
case DVMRP_PROBE:
accept_probe(src, dst,
- (char *)(igmp+1), igmpdatalen, ntohl(group));
+ (char *)(igmp+1), igmpdatalen, group);
return;
case DVMRP_REPORT:
accept_report(src, dst,
- (char *)(igmp+1), igmpdatalen, ntohl(group));
+ (char *)(igmp+1), igmpdatalen, group);
return;
case DVMRP_ASK_NEIGHBORS:
@@ -198,12 +202,12 @@ void accept_igmp(recvlen)
case DVMRP_NEIGHBORS:
accept_neighbors(src, dst, (char *)(igmp+1), igmpdatalen,
- group);
+ group);
return;
case DVMRP_NEIGHBORS2:
accept_neighbors2(src, dst, (char *)(igmp+1), igmpdatalen,
- group);
+ group);
return;
case DVMRP_PRUNE:
@@ -226,18 +230,20 @@ void accept_igmp(recvlen)
return;
}
-
- case IGMP_PIM: /* %%% hack for PIM %%% */
+ case IGMP_PIM:
return;
+ case IGMP_MTRACE_RESP:
+ return;
+
case IGMP_MTRACE:
- mtrace(src, dst, group, (char *)(igmp+1),
+ accept_mtrace(src, dst, group, (char *)(igmp+1),
igmp->igmp_code, igmpdatalen);
return;
default:
log(LOG_INFO, 0,
- "ignoring unknown IGMP message type %u from %s to %s",
+ "ignoring unknown IGMP message type %x from %s to %s",
igmp->igmp_type, inet_fmt(src, s1),
inet_fmt(dst, s2));
return;
@@ -250,13 +256,14 @@ void accept_igmp(recvlen)
* have already placed data in that buffer, of length 'datalen'. Then send
* the message from the interface with IP address 'src' to destination 'dst'.
*/
-void send_igmp(src, dst, type, code, group, datalen)
- u_long src, dst;
+void
+send_igmp(src, dst, type, code, group, datalen)
+ u_int32 src, dst;
int type, code;
- u_long group;
+ u_int32 group;
int datalen;
{
- static struct sockaddr_in sdst = {AF_INET, sizeof sdst};
+ static struct sockaddr_in sdst;
struct ip *ip;
struct igmp *igmp;
@@ -276,6 +283,11 @@ void send_igmp(src, dst, type, code, group, datalen)
if (IN_MULTICAST(ntohl(dst))) k_set_if(src);
if (dst == allhosts_group) k_set_loop(TRUE);
+ bzero(&sdst, sizeof(sdst));
+ sdst.sin_family = AF_INET;
+#if (defined(BSD) && (BSD >= 199103))
+ sdst.sin_len = sizeof(sdst);
+#endif
sdst.sin_addr.s_addr = dst;
if (sendto(igmp_socket, send_buf, ip->ip_len, 0,
(struct sockaddr *)&sdst, sizeof(sdst)) < 0) {
OpenPOWER on IntegriCloud