Subject: Re: Public needs multicast tools for Linux

From: Ross Golder <[email-masked]>
Date: Thu, 15 Oct 1998 13:55:13 +0100

Julian Highfield wrote:
> 
> Ross,
>      I've tidied up my updated mrouted-3.9b3 building notes and put them
> at http://www.stile.lboro.ac.uk/~cojch/mrouted-notes.txt as before.
> 
> I haven't actually tested that it works properly yet :-) Still, the
> changes aren't likely to break anything, so it should be safe enough.
> 
> Regards,
>         Julian.
> 
> N.B. This afternoon I happened to find some mrouted-3.9b2 rpms!
> See ftp://ftp.jcu.cz/pub/mbone/5.1/

I've just been looking at the mrouted SRPM in
<ftp://ftp.jcu.cz/pub/mbone/5.1/>, which contains a patch to the stock
source to enable it to compile cleanly (at least on mine anyway). My
hunt is over!

(patch attached)

Thanks for your help.

--
Ross

diff -ruN mrouted-3.9-beta2.orig/Makefile mrouted-3.9-beta2/Makefile
--- mrouted-3.9-beta2.orig/Makefile	Thu Jun 12 00:31:23 1997
+++ mrouted-3.9-beta2/Makefile	Thu Jan 29 10:03:38 1998
@@ -29,10 +29,10 @@
 #RSRRO=		rsrr.o
 #
 LDFLAGS=
-CFLAGS=		-O ${MCAST_INCLUDE} ${SNMPDEF} ${RSRRDEF}	## SunOS, OSF1, FreeBSD, IRIX
+#CFLAGS=		-O ${MCAST_INCLUDE} ${SNMPDEF} ${RSRRDEF}	## SunOS, OSF1, FreeBSD, IRIX
 #CFLAGS=		-O ${MCAST_INCLUDE} ${SNMPDEF} ${RSRRDEF} -DSYSV -DSUNOS5	## Solaris 2.x
 #LIB2=-lsocket -lnsl	## Solaris 2.x
-#CFLAGS=		-O ${MCAST_INCLUDE} ${SNMPDEF} ${RSRRDEF} -D__BSD_SOURCE -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET	## Linux
+CFLAGS=		-O3 -fomit-frame-pointer ${MCAST_INCLUDE} ${SNMPDEF} ${RSRRDEF} -D__BSD_SOURCE -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET	## Linux
 LIBS=		${SNMPLIBDIR} ${SNMPLIBS} ${LIB2}
 LINTFLAGS=	${MCAST_INCLUDE}
 IGMP_SRCS=	igmp.c inet.c kern.c
diff -ruN mrouted-3.9-beta2.orig/defs.h mrouted-3.9-beta2/defs.h
--- mrouted-3.9-beta2.orig/defs.h	Thu Jun 12 00:28:44 1997
+++ mrouted-3.9-beta2/defs.h	Thu Jan 29 10:15:50 1998
@@ -40,7 +40,11 @@
 #undef rtentry
 #endif
 #endif
+#ifndef __linux__
 #include <netinet/ip_mroute.h>
+#else
+#include "mroute.h"
+#endif
 #ifdef RSRR
 #include <sys/un.h>
 #endif /* RSRR */
@@ -95,6 +99,11 @@
 #define	DEL_ALL_ROUTES		1
 			    /* for Deleting kernel table entries */
 
+#ifndef INADDR_ALLHOSTS_GROUP
+#define INADDR_ALLHOSTS_GROUP   0xe0000001      /* 224.0.0.1   */
+#define INADDR_ALLHOSTS_GROUP   0xe0000001      /* 224.0.0.1   */
+#endif
+
 /* obnoxious gcc gives an extraneous warning about this constant... */
 #if defined(__STDC__) || defined(__GNUC__)
 #define JAN_1970	2208988800UL	/* 1970 - 1900 in seconds */
@@ -167,7 +176,7 @@
 extern char		s3[];
 extern char		s4[];
 
-#if !(defined(BSD) && (BSD >= 199103))
+#if !(defined(BSD) && (BSD >= 199103)) && !defined(__linux__)
 extern int		errno;
 extern int		sys_nerr;
 extern char *		sys_errlist[];
diff -ruN mrouted-3.9-beta2.orig/mroute.h mrouted-3.9-beta2/mroute.h
--- mrouted-3.9-beta2.orig/mroute.h	Thu Jan  1 01:00:00 1970
+++ mrouted-3.9-beta2/mroute.h	Thu Jan 29 10:12:30 1998
@@ -0,0 +1,177 @@
+#ifndef __LINUX_MROUTE_H
+#define __LINUX_MROUTE_H
+
+#if 0
+#include <linux/sockios.h>
+#include <linux/in.h>
+#endif
+
+/*
+ *	Based on the MROUTING 3.5 defines primarily to keep
+ *	source compatibility with BSD.
+ *
+ *	See the mrouted code for the original history.
+ *
+ */
+
+#define MRT_BASE	200
+#define MRT_INIT	(MRT_BASE)	/* Activate the kernel mroute code 	*/
+#define MRT_DONE	(MRT_BASE+1)	/* Shutdown the kernel mroute		*/
+#define MRT_ADD_VIF	(MRT_BASE+2)	/* Add a virtual interface		*/
+#define MRT_DEL_VIF	(MRT_BASE+3)	/* Delete a virtual interface		*/
+#define MRT_ADD_MFC	(MRT_BASE+4)	/* Add a multicast forwarding entry	*/
+#define MRT_DEL_MFC	(MRT_BASE+5)	/* Delete a multicast forwarding entry	*/
+#define MRT_VERSION	(MRT_BASE+6)	/* Get the kernel multicast version	*/
+#define MRT_ASSERT	(MRT_BASE+7)	/* Activate PIM assert mode		*/
+
+#define SIOCGETVIFCNT	SIOCPROTOPRIVATE	/* IP protocol privates */
+#define SIOCGETSGCNT	(SIOCPROTOPRIVATE+1)
+
+#define MAXVIFS		32	
+typedef unsigned long vifbitmap_t;	/* User mode code depends on this lot */
+typedef unsigned short vifi_t;
+#define ALL_VIFS	((vifi_t)(-1))
+
+/*
+ *	Same idea as select
+ */
+ 
+#define VIFM_SET(n,m)	((m)|=(1<<(n)))
+#define VIFM_CLR(n,m)	((m)&=~(1<<(n)))
+#define VIFM_ISSET(n,m)	((m)&(1<<(n)))
+#define VIFM_CLRALL(m)	((m)=0)
+#define VIFM_COPY(mfrom,mto)	((mto)=(mfrom))
+#define VIFM_SAME(m1,m2)	((m1)==(m2))
+
+/*
+ *	Passed by mrouted for an MRT_ADD_VIF - again we use the
+ *	mrouted 3.6 structures for compatibility
+ */
+ 
+struct vifctl {
+	vifi_t	vifc_vifi;		/* Index of VIF */
+	unsigned char vifc_flags;	/* VIFF_ flags */
+	unsigned char vifc_threshold;	/* ttl limit */
+	unsigned int vifc_rate_limit;	/* Rate limiter values (NI) */
+	struct in_addr vifc_lcl_addr;	/* Our address */
+	struct in_addr vifc_rmt_addr;	/* IPIP tunnel addr */
+};
+
+#define VIFF_TUNNEL	0x1		/* IPIP tunnel */
+#define VIFF_SRCRT	0x02		/* NI */
+
+/*
+ *	Cache manipulation structures for mrouted
+ */
+ 
+struct mfcctl
+{
+	struct in_addr mfcc_origin;		/* Origin of mcast	*/
+	struct in_addr mfcc_mcastgrp;		/* Group in question	*/
+	vifi_t	mfcc_parent;			/* Where it arrived	*/
+	unsigned char mfcc_ttls[MAXVIFS];	/* Where it is going	*/
+};
+
+/* 
+ *	Group count retrieval for mrouted
+ */
+ 
+struct sioc_sg_req
+{
+	struct in_addr src;
+	struct in_addr grp;
+	unsigned long pktcnt;
+	unsigned long bytecnt;
+	unsigned long wrong_if;
+};
+
+/*
+ *	To get vif packet counts
+ */
+
+struct sioc_vif_req
+{
+	vifi_t	vifi;		/* Which iface */
+	unsigned long icount;	/* In packets */
+	unsigned long ocount;	/* Out packets */
+	unsigned long ibytes;	/* In bytes */
+	unsigned long obytes;	/* Out bytes */
+};
+
+/*
+ *	This is the format the mroute daemon expects to see IGMP control
+ *	data. Magically happens to be like an IP packet as per the original
+ */
+ 
+struct igmpmsg
+{
+	unsigned long unused1,unused2;
+	unsigned char im_msgtype;		/* What is this */
+	unsigned char im_mbz;			/* Must be zero */
+	unsigned char im_vif;			/* Interface (this ought to be a vifi_t!) */
+	unsigned char unused3;
+	struct in_addr im_src,im_dst;
+};
+
+/*
+ *	That's all usermode folks
+ */
+
+#ifdef __KERNEL__
+extern struct sock *mroute_socket;
+extern int ip_mroute_setsockopt(struct sock *, int, char *, int);
+extern int ip_mroute_getsockopt(struct sock *, int, char *, int *);
+extern int ipmr_ioctl(struct sock *sk, int cmd, unsigned long arg);
+extern void mroute_close(struct sock *sk);
+extern void ipmr_forward(struct sk_buff *skb, int is_frag);
+
+
+struct vif_device
+{
+	struct device 	*dev;			/* Device we are using */
+	struct route 	*rt_cache;		/* Tunnel route cache */
+	unsigned long	bytes_in,bytes_out;
+	unsigned long	pkt_in,pkt_out;		/* Statistics 			*/
+	unsigned long	rate_limit;		/* Traffic shaping (NI) 	*/
+	unsigned char	threshold;		/* TTL threshold 		*/
+	unsigned short	flags;			/* Control flags 		*/
+	unsigned long	local,remote;		/* Addresses(remote for tunnels)*/
+};
+
+struct mfc_cache 
+{
+	struct mfc_cache *next;			/* Next entry on cache line 	*/
+	__u32 mfc_mcastgrp;			/* Group the entry belongs to 	*/
+	__u32 mfc_origin;			/* Source of packet 		*/
+	vifi_t mfc_parent;			/* Source interface		*/
+	struct timer_list mfc_timer;		/* Expiry timer			*/
+	int mfc_flags;				/* Flags on line		*/
+	struct sk_buff_head mfc_unresolved;	/* Unresolved buffers		*/
+	int mfc_queuelen;			/* Unresolved buffer counter	*/
+	unsigned char mfc_ttls[MAXVIFS];	/* TTL thresholds		*/
+	unsigned long mfc_packets;		/* Packets on this entry	*/
+	unsigned long mfc_bytes;		/* Bytes on this entry		*/
+};
+
+#define MFC_QUEUED		1
+#define MFC_RESOLVED		2
+
+
+#define MFC_LINES		64
+
+#ifdef __BIG_ENDIAN
+#define MFC_HASH(a,b)	((((a)>>24)^((b)>>26))&(MFC_LINES-1))
+#else
+#define MFC_HASH(a,b)	(((a)^((b)>>2))&(MFC_LINES-1))
+#endif		
+
+#endif
+
+/*
+ *	Pseudo messages used by mrouted
+ */
+
+#define IGMPMSG_NOCACHE		1		/* Kernel cache fill request to mrouted */
+#define IGMPMSG_WRONGVIF	2		/* For PIM assert processing (unused) */
+
+#endif
--- mrouted-3.9-beta2.orig/pathnames.h	Wed Nov 29 23:36:57 1995
+++ mrouted-3.9-beta2/pathnames.h	Thu Jan 29 13:17:20 1998
@@ -12,7 +12,7 @@
 
 #define _PATH_MROUTED_CONF	"/etc/mrouted.conf"
 
-#if (defined(BSD) && (BSD >= 199103))
+#if (defined(BSD) && (BSD >= 199103)) || defined(__linux__)
 #define _PATH_MROUTED_PID	"/var/run/mrouted.pid"
 #define _PATH_MROUTED_GENID	"/var/run/mrouted.genid"
 #define _PATH_MROUTED_DUMP	"/var/tmp/mrouted.dump"

---

From: Peter Lothberg <[email-masked]>
Date: Fri, 16 Oct 98 15:18:13 CEST

> 2) Assuming I can get mrouted to work, how can I join multicast groups
> >From my fixed-address ISDN dial-up? Do I need to open/close a tunnel
> each time I bring the line up?

Your ISP should listen to IGMP messages and provide you with multicast
traffic from the corresponding multicast groups.

--Peter