igmpproxy is a simple multicast routing daemon which uses IGMP

forwarding to dynamically route multicast traffic.  Routing is done
by defining an "upstream" interface on which the daemon acts as a
normal Multicast client, and one or more "downstream" interfaces
that serves clients on the destination networks. This is useful in
situations where other dynamic multicast routers cannot be used.

from markus with small adjustments.
ok markus
This commit is contained in:
sthen 2008-02-08 19:30:51 +00:00
parent 7e3934804a
commit 99d5e52b90
17 changed files with 1476 additions and 0 deletions

40
net/igmpproxy/Makefile Normal file
View File

@ -0,0 +1,40 @@
# $OpenBSD: Makefile,v 1.1.1.1 2008/02/08 19:30:51 sthen Exp $
COMMENT = Multicast router utilizing IGMP forwarding
VERSION = 0.1-beta2
DISTNAME = igmpproxy-src-${VERSION}
PKGNAME = igmpproxy-${VERSION}
CATEGORIES = net
MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=igmpproxy/}
HOMEPAGE = http://igmpproxy.sourceforge.net/
MAINTAINER = Markus Friedl <markus@openbsd.org>
# GPL
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM =Yes
PERMIT_DISTFILES_FTP = Yes
WANTLIB = c
USE_GMAKE = Yes
WRKDIST = ${WRKDIR}/igmpproxy/src
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/igmpproxy ${PREFIX}/sbin
${INSTALL_MAN} ${WRKSRC}/../doc/igmpproxy.8 ${PREFIX}/man/man8
${INSTALL_MAN} ${WRKSRC}/../doc/igmpproxy.conf.5 ${PREFIX}/man/man5
${INSTALL_DATA_DIR} ${PREFIX}/share/examples/igmpproxy
${INSTALL_DATA} ${WRKSRC}/igmpproxy.conf \
${PREFIX}/share/examples/igmpproxy
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/igmpproxy
${INSTALL_DATA} ${FILESDIR}/README.OpenBSD \
${PREFIX}/share/doc/igmpproxy
@perl -pi -e 's,%%PREFIX%%,${TRUEPREFIX},g;' \
-e 's,%%SYSCONFDIR%%,${SYSCONFDIR},g' \
${PREFIX}/share/doc/igmpproxy/README.OpenBSD
.include <bsd.port.mk>

5
net/igmpproxy/distinfo Normal file
View File

@ -0,0 +1,5 @@
MD5 (igmpproxy-src-0.1-beta2.tar.gz) = KlpZSA9E1LFAd6a1MZ6ZQA==
RMD160 (igmpproxy-src-0.1-beta2.tar.gz) = cRGxIUE57Er/skpBnuoT1OmlYzM=
SHA1 (igmpproxy-src-0.1-beta2.tar.gz) = liuApKS3DNFCgiNxp8yY1srrGsY=
SHA256 (igmpproxy-src-0.1-beta2.tar.gz) = f25UhuhIJxUMjKQClnyWM0u9Yrn3hRlcTuhNoSGKu0A=
SIZE (igmpproxy-src-0.1-beta2.tar.gz) = 35103

View File

@ -0,0 +1,356 @@
To use igmpproxy on OpenBSD, you will need to configure it by
editing %%SYSCONFDIR%%/igmpproxy.conf, and configure the OS for
multicast forwarding:
# echo multicast_router=YES >> /etc/rc.conf.local
# echo net.inet.ip.mforwarding=1 >> /etc/sysctl.conf
and restart. Note that client machines using OpenBSD should
be configured with multicast_host=YES.
To have igmpproxy start at boot time, add this to /etc/rc.local:
if [ -x %%PREFIX%%/sbin/igmpproxy ]; then
echo -n ' igmpproxy'; %%PREFIX%%/sbin/igmpproxy
fi
PF must be configured so that control packets (proto igmp) and
data packets (destination address within 224.0.0.0/4) are passed.
igmpproxy is licensed under GPLv2 and is based on mrouted code,
the applicable licenses are below:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The mrouted program is covered by the following license. Use of the
mrouted program represents acceptance of these terms and conditions.
1. STANFORD grants to LICENSEE a nonexclusive and nontransferable license
to use, copy and modify the computer software ``mrouted'' (hereinafter
called the ``Program''), upon the terms and conditions hereinafter set
out and until Licensee discontinues use of the Licensed Program.
2. LICENSEE acknowledges that the Program is a research tool still in
the development state, that it is being supplied ``as is,'' without any
accompanying services from STANFORD, and that this license is entered
into in order to encourage scientific collaboration aimed at further
development and application of the Program.
3. LICENSEE may copy the Program and may sublicense others to use object
code copies of the Program or any derivative version of the Program.
All copies must contain all copyright and other proprietary notices found
in the Program as provided by STANFORD. Title to copyright to the
Program remains with STANFORD.
4. LICENSEE may create derivative versions of the Program. LICENSEE
hereby grants STANFORD a royalty-free license to use, copy, modify,
distribute and sublicense any such derivative works. At the time
LICENSEE provides a copy of a derivative version of the Program to a
third party, LICENSEE shall provide STANFORD with one copy of the source
code of the derivative version at no charge to STANFORD.
5. STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.
By way of example, but not limitation, STANFORD MAKES NO REPRESENTATION
OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
THAT THE USE OF THE LICENSED PROGRAM WILL NOT INFRINGE ANY PATENTS,
COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. STANFORD shall not be held liable
for any liability nor for any direct, indirect or consequential damages
with respect to any claim by LICENSEE or any third party on account of or
arising from this Agreement or use of the Program.
6. This agreement shall be construed, interpreted and applied in
accordance with the State of California and any legal action arising
out of this Agreement or use of the Program shall be filed in a court
in the State of California.
7. Nothing in this Agreement shall be construed as conferring rights to
use in advertising, publicity or otherwise any trademark or the name
of ``Stanford''.
The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
Leland Stanford Junior University.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-Makefile,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $
--- Makefile.orig Sat Aug 20 13:34:18 2005
+++ Makefile Sat Jan 26 13:16:23 2008
@@ -6,12 +6,11 @@ MANDIR=/usr/share/man
# CFLAGS=-g
-CFLAGS=-O
+CFLAGS?=-O
+CFLAGS+=-Wall
-default : build.h igmpproxy
+all : build.h igmpproxy
-all : igmpproxy
-
clean :
rm -f *.o *.asm build.h igmpproxy
@@ -21,7 +20,7 @@ install :
cp ../doc/igmpproxy.conf.5 ${MANDIR}/man5
if [ ! -e ${ETCDIR}/igmpproxy.conf ]; then cp igmpproxy.conf ${ETCDIR}; fi
-igmpproxy : igmpproxy.o config.o confread.o request.o udpsock.o mcgroup.o rttable.o \
+igmpproxy : igmpproxy.o config.o confread.o request.o mcgroup.o rttable.o \
igmp.o ifvc.o callout.o kern.o syslog.o lib.o mroute-api.o
build.h :

View File

@ -0,0 +1,41 @@
$OpenBSD: patch-config_c,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $
--- config.c.orig Tue May 24 16:49:29 2005
+++ config.c Fri Jan 25 14:05:44 2008
@@ -328,29 +328,18 @@ struct vifconfig *parsePhyintToken() {
*/
struct SubnetList *parseSubnetAddress(char *addrstr) {
struct SubnetList *tmpSubnet;
- char *tmpStr;
uint32 addr = 0x00000000;
uint32 mask = 0xFFFFFFFF;
+ int bitcnt;
- // First get the network part of the address...
- tmpStr = strtok(addrstr, "/");
- addr = inet_addr(tmpStr);
-
- tmpStr = strtok(NULL, "/");
- if(tmpStr != NULL) {
- int bitcnt = atoi(tmpStr);
- if(bitcnt <= 0 || bitcnt > 32) {
- log(LOG_WARNING, 0, "The bits part of the address is invalid : %d.",tmpStr);
- return NULL;
- }
-
- mask <<= (32 - bitcnt);
- }
-
- if(addr == -1 || addr == 0) {
- log(LOG_WARNING, 0, "Unable to parse address token '%s'.", addrstr);
+ bitcnt = inet_net_pton(AF_INET, addrstr, &addr, sizeof(addr));
+ if(bitcnt<0) {
+ log(LOG_WARNING, 0, "Unable to parse address token '%s'.",addrstr);
return NULL;
- }
+ } else if(bitcnt>0)
+ mask <<= (32 - bitcnt);
+ else
+ mask = 0;
tmpSubnet = (struct SubnetList*) malloc(sizeof(struct SubnetList));
tmpSubnet->subnet_addr = addr;

View File

@ -0,0 +1,104 @@
$OpenBSD: patch-defs_h,v 1.1.1.1 2008/02/08 19:30:51 sthen Exp $
--- defs.h.orig Sat Aug 20 13:44:47 2005
+++ defs.h Mon Nov 19 12:56:50 2007
@@ -40,10 +40,18 @@
#include <stdlib.h>
#include <syslog.h>
#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+//#include <sys/socket.h>
+//#include <sys/un.h>
+//#include <sys/time.h>
+#include <sys/param.h>
+#include <sys/errno.h>
+#include <sys/types.h>
#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/uio.h>
#include <net/if.h>
@@ -52,13 +60,32 @@
#include <linux/in.h>
#include <linux/mroute.h>
#else
+ #include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/igmp.h>
+ #include <netinet/ip_mroute.h>
#include <arpa/inet.h>
#endif
+#ifndef IGMP_MEMBERSHIP_QUERY
+#define IGMP_MEMBERSHIP_QUERY IGMP_HOST_MEMBERSHIP_QUERY
+#endif
+#ifndef IGMP_V1_MEMBERSHIP_REPORT
+#define IGMP_V1_MEMBERSHIP_REPORT IGMP_v1_HOST_MEMBERSHIP_REPORT
+#endif
+#ifndef IGMP_V2_MEMBERSHIP_REPORT
+#define IGMP_V2_MEMBERSHIP_REPORT IGMP_v2_HOST_MEMBERSHIP_REPORT
+#endif
+#ifndef IGMP_V2_LEAVE_GROUP
+#define IGMP_V2_LEAVE_GROUP IGMP_HOST_LEAVE_MESSAGE
+#endif
+#ifndef INADDR_ALLRTRS_GROUP
+/* address for multicast mtrace msg */
+#define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */
+#endif
+
// The default path for the config file...
#define IGMPPROXY_CONFIG_FILEPATH "/etc/igmpproxy.conf"
#define ENABLE_DEBUG 1
@@ -73,8 +100,12 @@
#define MAX_MC_VIFS 32 // !!! check this const in the specific includes
// Useful macros..
+#ifndef MIN
#define MIN( a, b ) ((a) < (b) ? (a) : (b))
+#endif
+#ifndef MAX
#define MAX( a, b ) ((a) < (b) ? (b) : (a))
+#endif
#define VCMC( Vc ) (sizeof( Vc ) / sizeof( (Vc)[ 0 ] ))
#define VCEP( Vc ) (&(Vc)[ VCMC( Vc ) ])
@@ -126,6 +157,7 @@ extern char LogLastMsg[ 128 ]; // last logged messa
#define IF_DEBUG if(Log2Stderr & LOG_DEBUG)
+#define log logit
void log( int Serverity, int Errno, const char *FmtSt, ... );
/* ifvc.c
@@ -196,6 +228,7 @@ void buildIfVc( void );
struct IfDesc *getIfByName( const char *IfName );
struct IfDesc *getIfByIx( unsigned Ix );
struct IfDesc *getIfByAddress( uint32 Ix );
+int isAdressValidForIf( struct IfDesc* intrface, uint32 ipaddr );
/* mroute-api.c
*/
@@ -235,7 +268,7 @@ void sendIgmp (uint32, uint32, int, int, uint32,int);
char *fmtInAdr( char *St, struct in_addr InAdr );
char *inetFmt(uint32 addr, char *s);
char *inetFmts(uint32 addr, uint32 mask, char *s);
-int inetCksum(u_short *addr, u_int len);
+int inetChksum(u_short *addr, u_int len);
/* kern.c
*/
@@ -264,7 +297,7 @@ int leaveMcGroup( int UdpSock, struct IfDesc *IfDp, ui
void initRouteTable();
void clearAllRoutes();
int insertRoute(uint32 group, int ifx);
-int activateRoute(uint32 group, uint32 originAddr);
+int activateRoute(uint32 group, uint32 originAddr, int downIf);
void ageActiveRoutes();
void setRouteLastMemberMode(uint32 group);
int lastMemberGroupAge(uint32 group);

View File

@ -0,0 +1,187 @@
$OpenBSD: patch-ifvc_c,v 1.1.1.1 2008/02/08 19:30:51 sthen Exp $
--- ifvc.c.orig Tue May 24 16:49:18 2005
+++ ifvc.c Mon Nov 19 12:56:50 2007
@@ -32,7 +32,8 @@
*/
#include "defs.h"
-#include <linux/sockios.h>
+//#include <linux/sockios.h>
+#include <ifaddrs.h>
struct IfDesc IfDescVc[ MAX_IF ], *IfDescEp = IfDescVc;
@@ -42,119 +43,91 @@ struct IfDesc IfDescVc[ MAX_IF ], *IfDescEp = IfDescVc
**
*/
void buildIfVc() {
- struct ifreq IfVc[ sizeof( IfDescVc ) / sizeof( IfDescVc[ 0 ] ) ];
- struct ifreq *IfEp;
+ struct ifaddrs *ifap, *ifa;
+ struct IfDesc *ifp;
+ struct SubnetList *net;
- int Sock;
+ if (getifaddrs(&ifap) < 0)
+ log( LOG_ERR, errno, "getifaddrs" );
- if ( (Sock = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 )
- log( LOG_ERR, errno, "RAW socket open" );
-
- /* get If vector
- */
- {
- struct ifconf IoCtlReq;
-
- IoCtlReq.ifc_buf = (void *)IfVc;
- IoCtlReq.ifc_len = sizeof( IfVc );
-
- if ( ioctl( Sock, SIOCGIFCONF, &IoCtlReq ) < 0 )
- log( LOG_ERR, errno, "ioctl SIOCGIFCONF" );
-
- IfEp = (void *)((char *)IfVc + IoCtlReq.ifc_len);
- }
-
/* loop over interfaces and copy interface info to IfDescVc
*/
{
- struct ifreq *IfPt;
- struct IfDesc *IfDp;
-
// Temp keepers of interface params...
uint32 addr, subnet, mask;
- for ( IfPt = IfVc; IfPt < IfEp; IfPt++ ) {
- struct ifreq IfReq;
+ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
char FmtBu[ 32 ];
- strncpy( IfDescEp->Name, IfPt->ifr_name, sizeof( IfDescEp->Name ) );
+ if (IfDescEp >= &IfDescVc[ MAX_IF ]) {
+ log(LOG_WARNING, 0, "Too many interfaces, skipping %d", ifa->ifa_name);
+ continue;
+ }
- // Currently don't set any allowed nets...
- //IfDescEp->allowednets = NULL;
-
- // Set the index to -1 by default.
- IfDescEp->index = -1;
-
- /* don't retrieve more info for non-IP interfaces
+ /* ignore non-IP interfaces
*/
- if ( IfPt->ifr_addr.sa_family != AF_INET ) {
- IfDescEp->InAdr.s_addr = 0; /* mark as non-IP interface */
- IfDescEp++;
+ if ( ifa->ifa_addr->sa_family != AF_INET )
continue;
- }
- // Get the interface adress...
- IfDescEp->InAdr = ((struct sockaddr_in *)&IfPt->ifr_addr)->sin_addr;
- addr = IfDescEp->InAdr.s_addr;
+ if ((ifp = getIfByName(ifa->ifa_name)) == NULL) {
- memcpy( IfReq.ifr_name, IfDescEp->Name, sizeof( IfReq.ifr_name ) );
+ strlcpy( IfDescEp->Name, ifa->ifa_name, sizeof( IfDescEp->Name ) );
- // Get the subnet mask...
- if (ioctl(Sock, SIOCGIFNETMASK, &IfReq ) < 0)
- log(LOG_ERR, errno, "ioctl SIOCGIFNETMASK for %s", IfReq.ifr_name);
- mask = ((struct sockaddr_in *)&IfReq.ifr_addr)->sin_addr.s_addr;
- subnet = addr & mask;
+ log(LOG_DEBUG, 0, "Adding Physical Index value of IF '%s' is %d",
+ IfDescEp->Name, if_nametoindex(IfDescEp->Name));
- // Get the physical index of the Interface
- if (ioctl(Sock, SIOCGIFINDEX, &IfReq ) < 0)
- log(LOG_ERR, errno, "ioctl SIOCGIFINDEX for %s", IfReq.ifr_name);
-
- log(LOG_DEBUG, 0, "Physical Index value of IF '%s' is %d",
- IfDescEp->Name, IfReq.ifr_ifindex);
+ // Set the index to -1 by default.
+ IfDescEp->index = -1;
+ // Get the interface adress...
+ IfDescEp->InAdr = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
- /* get if flags
- **
- ** typical flags:
- ** lo 0x0049 -> Running, Loopback, Up
- ** ethx 0x1043 -> Multicast, Running, Broadcast, Up
- ** ipppx 0x0091 -> NoArp, PointToPoint, Up
- ** grex 0x00C1 -> NoArp, Running, Up
- ** ipipx 0x00C1 -> NoArp, Running, Up
- */
- if ( ioctl( Sock, SIOCGIFFLAGS, &IfReq ) < 0 )
- log( LOG_ERR, errno, "ioctl SIOCGIFFLAGS" );
+ /* get if flags
+ **
+ ** typical flags:
+ ** lo 0x0049 -> Running, Loopback, Up
+ ** ethx 0x1043 -> Multicast, Running, Broadcast, Up
+ ** ipppx 0x0091 -> NoArp, PointToPoint, Up
+ ** grex 0x00C1 -> NoArp, Running, Up
+ ** ipipx 0x00C1 -> NoArp, Running, Up
+ */
- IfDescEp->Flags = IfReq.ifr_flags;
+ IfDescEp->Flags = ifa->ifa_flags;
+ // Set the default params for the IF...
+ IfDescEp->state = IF_STATE_DOWNSTREAM;
+ IfDescEp->robustness = DEFAULT_ROBUSTNESS;
+ IfDescEp->threshold = DEFAULT_THRESHOLD; /* ttl limit */
+ IfDescEp->ratelimit = DEFAULT_RATELIMIT;
+ IfDescEp->allowednets = NULL;
+ ifp = IfDescEp++;
+ }
+
// Insert the verified subnet as an allowed net...
- IfDescEp->allowednets = (struct SubnetList *)malloc(sizeof(struct SubnetList));
- if(IfDescEp->allowednets == NULL) log(LOG_ERR, 0, "Out of memory !");
+ addr = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
+ mask = ((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr.s_addr;
+ subnet = addr & mask;
+
+ net = (struct SubnetList *)malloc(sizeof(struct SubnetList));
+ if(net == NULL) log(LOG_ERR, 0, "Out of memory !");
// Create the network address for the IF..
- IfDescEp->allowednets->next = NULL;
- IfDescEp->allowednets->subnet_mask = mask;
- IfDescEp->allowednets->subnet_addr = subnet;
-
- // Set the default params for the IF...
- IfDescEp->state = IF_STATE_DOWNSTREAM;
- IfDescEp->robustness = DEFAULT_ROBUSTNESS;
- IfDescEp->threshold = DEFAULT_THRESHOLD; /* ttl limit */
- IfDescEp->ratelimit = DEFAULT_RATELIMIT;
+ net->next = ifp->allowednets;
+ net->subnet_mask = mask;
+ net->subnet_addr = subnet;
+ ifp->allowednets = net;
-
// Debug log the result...
IF_DEBUG log( LOG_DEBUG, 0, "buildIfVc: Interface %s Addr: %s, Flags: 0x%04x, Network: %s",
- IfDescEp->Name,
- fmtInAdr( FmtBu, IfDescEp->InAdr ),
- IfDescEp->Flags,
+ ifp->Name,
+ fmtInAdr( FmtBu, ifp->InAdr ),
+ ifp->Flags,
inetFmts(subnet,mask, s1));
- IfDescEp++;
}
- }
- close( Sock );
+ }
+ freeifaddrs(ifap);
}
/*

View File

@ -0,0 +1,82 @@
$OpenBSD: patch-igmp_c,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $
--- igmp.c.orig Tue May 24 17:49:16 2005
+++ igmp.c Mon Aug 13 15:16:51 2007
@@ -41,8 +41,6 @@
uint32 allhosts_group; /* All hosts addr in net order */
uint32 allrouters_group; /* All hosts addr in net order */
-extern int MRouterFD;
-
/*
* Open and initialize the igmp socket, and fill in the non-changing
* IP header fields in the output packet buffer.
@@ -128,6 +126,7 @@ void acceptIgmp(int recvlen) {
}
else {
struct IfDesc *checkVIF;
+ int downIf = -1;
// Check if the source address matches a valid address on upstream vif.
checkVIF = getIfByIx( upStreamVif );
@@ -141,15 +140,30 @@ void acceptIgmp(int recvlen) {
return;
}
else if(!isAdressValidForIf(checkVIF, src)) {
- log(LOG_WARNING, 0, "The source address %s for group %s, is not in any valid net for upstream VIF.",
- inetFmt(src, s1), inetFmt(dst, s2));
- return;
+ unsigned Ix;
+ struct IfDesc *Dp;
+
+ for ( Ix = 0; (Dp = getIfByIx( Ix )); Ix++ ) {
+ if ((Dp->state == IF_STATE_DOWNSTREAM) &&isAdressValidForIf(Dp, src)) {
+ downIf = Ix;
+ break;
+ }
+ }
+
+ if (downIf == -1) {
+ log(LOG_WARNING, 0, "The source address %s for group %s, is not in any valid net for upstream VIF.",
+ inetFmt(src, s1), inetFmt(dst, s2));
+ return;
+ } else {
+ log(LOG_NOTICE, 0, "The source address %s for group %s, is valid DOWNSTREAM VIF #%d.",
+ inetFmt(src, s1), inetFmt(dst, s2), downIf);
+ }
}
// Activate the route.
- IF_DEBUG log(LOG_DEBUG, 0, "Route activate request from %s to %s",
- inetFmt(src,s1), inetFmt(dst,s2));
- activateRoute(dst, src);
+ IF_DEBUG log(LOG_DEBUG, 0, "Route activate request from %s to %s, downIf %d",
+ inetFmt(src,s1), inetFmt(dst,s2), downIf);
+ activateRoute(dst, src, downIf);
}
@@ -176,9 +190,9 @@ void acceptIgmp(int recvlen) {
return;
}
- log(LOG_NOTICE, 0, "RECV %s from %-15s to %s",
+ log(LOG_NOTICE, 0, "RECV %s from %-15s to %s (ip_hl %d, data %d)",
igmpPacketKind(igmp->igmp_type, igmp->igmp_code),
- inetFmt(src, s1), inetFmt(dst, s2) );
+ inetFmt(src, s1), inetFmt(dst, s2), iphdrlen, ipdatalen);
switch (igmp->igmp_type) {
case IGMP_V1_MEMBERSHIP_REPORT:
@@ -190,12 +204,9 @@ void acceptIgmp(int recvlen) {
acceptLeaveMessage(src, group);
return;
- /*
case IGMP_MEMBERSHIP_QUERY:
//accept_membership_query(src, dst, group, igmp->igmp_code);
return;
-
- */
default:
log(LOG_INFO, 0,

View File

@ -0,0 +1,84 @@
$OpenBSD: patch-igmpproxy_c,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $
--- igmpproxy.c.orig Sat Aug 20 13:56:32 2005
+++ igmpproxy.c Mon Nov 19 12:56:50 2007
@@ -41,8 +41,8 @@
#include "version.h"
#include "build.h"
+#include <sys/sysctl.h>
-
// Constants
static const char Version[] =
"igmpproxy, Version " VERSION ", Build" BUILD "\n"
@@ -80,7 +80,7 @@ int upStreamVif;
* on commandline. The number of commandline arguments, and a
* pointer to the arguments are recieved on the line...
*/
-int main( int ArgCn, const char *ArgVc[] ) {
+int main( int ArgCn, char *ArgVc[] ) {
int debugMode = 0;
@@ -133,6 +133,24 @@ int main( int ArgCn, const char *ArgVc[] ) {
exit(1);
}
+ {
+ int ipmforwarding = 0;
+ int mib[4];
+ size_t len;
+
+ /* multicast IP forwarding must be enabled */
+ mib[0] = CTL_NET;
+ mib[1] = PF_INET;
+ mib[2] = IPPROTO_IP;
+ mib[3] = IPCTL_MFORWARDING;
+ len = sizeof(ipmforwarding);
+ if (sysctl(mib, 4, &ipmforwarding, &len, NULL, 0) == -1)
+ log(LOG_ERR, 0, "sysctl");
+
+ if (!ipmforwarding)
+ log(LOG_ERR, 0, "multicast IP forwarding not enabled");
+ }
+
// Write debug notice with file path...
IF_DEBUG log(LOG_DEBUG, 0, "Searching for config file at '%s'" , configFilePath);
@@ -155,17 +173,8 @@ int main( int ArgCn, const char *ArgVc[] ) {
if ( ! debugMode ) {
IF_DEBUG log( LOG_DEBUG, 0, "Starting daemon mode.");
-
- // Only daemon goes past this line...
- if (fork()) exit(0);
-
- // Detach deamon from terminal
- if ( close( 0 ) < 0 || close( 1 ) < 0 || close( 2 ) < 0
- || open( "/dev/null", 0 ) != 0 || dup2( 0, 1 ) < 0 || dup2( 0, 2 ) < 0
- || setpgrp() < 0
- ) {
+ if ( daemon(1, 0) < 0)
log( LOG_ERR, errno, "failed to detach deamon" );
- }
}
// Go to the main loop.
@@ -218,7 +227,7 @@ int igmpProxyInit() {
int vifcount = 0;
upStreamVif = -1;
- for ( Ix = 0; Dp = getIfByIx( Ix ); Ix++ ) {
+ for ( Ix = 0; (Dp = getIfByIx( Ix )); Ix++ ) {
if ( Dp->InAdr.s_addr && ! (Dp->Flags & IFF_LOOPBACK) ) {
if(Dp->state == IF_STATE_UPSTREAM) {
@@ -237,7 +246,7 @@ int igmpProxyInit() {
// If there is only one VIF, or no defined upstream VIF, we send an error.
if(vifcount < 2 || upStreamVif < 0) {
- log(LOG_ERR, 0, "There must be at least 2 Vif's where one is upstream.");
+ log(LOG_ERR, 0, "There must be at least 2 Vif's where one is upstream. (vifcount %d, upStreamVif %d)", vifcount, upStreamVif);
}
}

View File

@ -0,0 +1,50 @@
$OpenBSD: patch-igmpproxy_conf,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $
--- igmpproxy.conf.orig Fri Apr 29 20:27:50 2005
+++ igmpproxy.conf Sat Jan 26 12:05:26 2008
@@ -9,11 +9,11 @@
# If multicast traffic originates outside the
# upstream subnet, the "altnet" option can be
# used in order to define legal multicast sources.
-# (Se example...)
+# (See example...)
#
# The "quickleave" should be used to avoid saturation
# of the upstream link. The option should only
-# be used if it's absolutely nessecary to
+# be used if it's absolutely necessary to
# accurately imitate just one Client.
#
########################################################
@@ -25,22 +25,23 @@ quickleave
##------------------------------------------------------
-## Configuration for eth0 (Upstream Interface)
+## Configuration for em0 (Upstream Interface)
##------------------------------------------------------
-phyint eth0 upstream ratelimit 0 threshold 1
- altnet 10.0.0.0/8
- altnet 192.168.0.0/24
+phyint em0 upstream ratelimit 0 threshold 1
+ altnet 10.0.0.0/8
+# altnet 132.185.0.0/16 # BBC multicast trial
+# altnet 217.0.119.0/24 # T-Home Entertain
+# altnet 193.158.35.0/24 # T-Home Entertain
-
##------------------------------------------------------
-## Configuration for eth1 (Downstream Interface)
+## Configuration for ipw0 (Downstream Interface)
##------------------------------------------------------
-phyint eth1 downstream ratelimit 0 threshold 1
+phyint ipw0 downstream ratelimit 0 threshold 1
##------------------------------------------------------
-## Configuration for eth2 (Disabled Interface)
+## Configuration for lo0 (Disabled Interface)
##------------------------------------------------------
-phyint eth2 disabled
+phyint lo0 disabled

View File

@ -0,0 +1,53 @@
$OpenBSD: patch-mroute-api_c,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $
--- mroute-api.c.orig Tue May 24 17:48:33 2005
+++ mroute-api.c Mon Aug 13 15:12:06 2007
@@ -37,7 +37,7 @@
*/
-#define USE_LINUX_IN_H
+//#define USE_LINUX_IN_H
#include "defs.h"
// MAX_MC_VIFS from mclab.h must have same value as MAXVIFS from mroute.h
@@ -47,7 +47,7 @@
// need an IGMP socket as interface for the mrouted API
// - receives the IGMP messages
-int MRouterFD; /* socket for all network I/O */
+int MRouterFD = -1; /* socket for all network I/O */
char *recv_buf; /* input packet buffer */
char *send_buf; /* output packet buffer */
@@ -177,13 +177,14 @@ int addMRoute( struct MRouteDesc *Dp )
log( LOG_NOTICE, 0, "Adding MFC: %s -> %s, InpVIf: %d",
fmtInAdr( FmtBuO, CtlReq.mfcc_origin ),
fmtInAdr( FmtBuM, CtlReq.mfcc_mcastgrp ),
- CtlReq.mfcc_parent == ALL_VIFS ? -1 : CtlReq.mfcc_parent
+ CtlReq.mfcc_parent
);
}
if ( setsockopt( MRouterFD, IPPROTO_IP, MRT_ADD_MFC,
(void *)&CtlReq, sizeof( CtlReq ) ) )
log( LOG_WARNING, errno, "MRT_ADD_MFC" );
+ return (0);
}
/*
@@ -210,13 +211,14 @@ int delMRoute( struct MRouteDesc *Dp )
log( LOG_NOTICE, 0, "Removing MFC: %s -> %s, InpVIf: %d",
fmtInAdr( FmtBuO, CtlReq.mfcc_origin ),
fmtInAdr( FmtBuM, CtlReq.mfcc_mcastgrp ),
- CtlReq.mfcc_parent == ALL_VIFS ? -1 : CtlReq.mfcc_parent
+ CtlReq.mfcc_parent
);
}
if ( setsockopt( MRouterFD, IPPROTO_IP, MRT_DEL_MFC,
(void *)&CtlReq, sizeof( CtlReq ) ) )
log( LOG_WARNING, errno, "MRT_DEL_MFC" );
+ return (0);
}
/*

View File

@ -0,0 +1,31 @@
$OpenBSD: patch-request_c,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $
--- request.c.orig Tue May 24 16:48:29 2005
+++ request.c Mon Nov 19 12:56:50 2007
@@ -88,7 +88,7 @@ void acceptGroupReport(uint32 src, uint32 group, uint8
} else {
// Log the state of the interface the report was recieved on.
- log(LOG_INFO, 0, "Mebership report was recieved on %s. Ignoring.",
+ log(LOG_INFO, 0, "Membership report was recieved on %s. Ignoring.",
sourceVif->state==IF_STATE_UPSTREAM?"the upstream interface":"a disabled interface");
}
@@ -136,7 +136,8 @@ void acceptLeaveMessage(uint32 src, uint32 group) {
} else {
// just ignore the leave request...
- IF_DEBUG log(LOG_DEBUG, 0, "The found if for %s was not downstream. Ignoring leave request.");
+ IF_DEBUG log(LOG_DEBUG, 0, "The found if for %s was not downstream. Ignoring leave request.",
+ inetFmt(src, s1));
}
}
@@ -184,7 +185,7 @@ void sendGeneralMembershipQuery() {
int Ix;
// Loop through all downstream vifs...
- for ( Ix = 0; Dp = getIfByIx( Ix ); Ix++ ) {
+ for ( Ix = 0; (Dp = getIfByIx( Ix )); Ix++ ) {
if ( Dp->InAdr.s_addr && ! (Dp->Flags & IFF_LOOPBACK) ) {
if(Dp->state == IF_STATE_DOWNSTREAM) {
// Send the membership query...

View File

@ -0,0 +1,386 @@
$OpenBSD: patch-rttable_c,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $
--- rttable.c.orig Sat Aug 20 13:46:20 2005
+++ rttable.c Mon Nov 19 12:56:50 2007
@@ -38,15 +38,22 @@
*/
#include "defs.h"
+#include <sys/queue.h>
/**
* Routing table structure definition. Double linked list...
*/
+struct Origin {
+ TAILQ_ENTRY(Origin) next;
+ uint32 originAddr;
+ int flood;
+ uint32 pktcnt;
+};
+
struct RouteTable {
struct RouteTable *nextroute; // Pointer to the next group in line.
struct RouteTable *prevroute; // Pointer to the previous group in line.
uint32 group; // The group to route
- uint32 originAddr; // The origin adress (only set on activated routes)
uint32 vifBits; // Bits representing recieving VIFs.
// Keeps the upstream membership state...
@@ -56,6 +63,7 @@ struct RouteTable {
uint32 ageVifBits; // Bits representing aging VIFs.
int ageValue; // Downcounter for death.
int ageActivity; // Records any acitivity that notes there are still listeners.
+ TAILQ_HEAD(originhead, Origin) originList; // The origin adresses (non-empty on activated routes)
};
@@ -65,19 +73,17 @@ static struct RouteTable *routing_table;
// Prototypes
void logRouteTable(char *header);
int internAgeRoute(struct RouteTable* croute);
+int internUpdateKernelRoute(struct RouteTable *route, int activate, struct Origin *o);
-// Socket for sending join or leave requests.
-int mcGroupSock = 0;
-
/**
* Function for retrieving the Multicast Group socket.
*/
int getMcGroupSock() {
- if( ! mcGroupSock ) {
- mcGroupSock = openUdpSocket( INADDR_ANY, 0 );;
+ if (MRouterFD < 0) {
+ log(LOG_ERR, errno, "no MRouterFD.");
}
- return mcGroupSock;
+ return MRouterFD;
}
/**
@@ -91,7 +97,7 @@ void initRouteTable() {
routing_table = NULL;
// Join the all routers group on downstream vifs...
- for ( Ix = 0; Dp = getIfByIx( Ix ); Ix++ ) {
+ for ( Ix = 0; (Dp = getIfByIx( Ix )); Ix++ ) {
// If this is a downstream vif, we should join the All routers group...
if( Dp->InAdr.s_addr && ! (Dp->Flags & IFF_LOOPBACK) && Dp->state == IF_STATE_DOWNSTREAM) {
IF_DEBUG log(LOG_DEBUG, 0, "Joining all-routers group %s on vif %s",
@@ -160,6 +166,7 @@ void sendJoinLeaveUpstream(struct RouteTable* route, i
*/
void clearAllRoutes() {
struct RouteTable *croute, *remainroute;
+ struct Origin *o;
// Loop through all routes...
for(croute = routing_table; croute; croute = remainroute) {
@@ -171,7 +178,7 @@ void clearAllRoutes() {
inetFmt(croute->group, s1));
// Uninstall current route
- if(!internUpdateKernelRoute(croute, 0)) {
+ if(!internUpdateKernelRoute(croute, 0, NULL)) {
log(LOG_WARNING, 0, "The removal from Kernel failed.");
}
@@ -179,6 +186,10 @@ void clearAllRoutes() {
sendJoinLeaveUpstream(croute, 0);
// Clear memory, and set pointer to next route...
+ while ((o = TAILQ_FIRST(&croute->originList))) {
+ TAILQ_REMOVE(&croute->originList, o, next);
+ free(o);
+ }
free(croute);
}
routing_table = NULL;
@@ -212,7 +223,6 @@ int insertRoute(uint32 group, int ifx) {
struct Config *conf = getCommonConfig();
struct RouteTable* croute;
- int result = 1;
// Sanitycheck the group adress...
if( ! IN_MULTICAST( ntohl(group) )) {
@@ -241,7 +251,8 @@ int insertRoute(uint32 group, int ifx) {
newroute = (struct RouteTable*)malloc(sizeof(struct RouteTable));
// Insert the route desc and clear all pointers...
newroute->group = group;
- newroute->originAddr = 0;
+ TAILQ_INIT(&newroute->originList);
+
newroute->nextroute = NULL;
newroute->prevroute = NULL;
@@ -325,10 +336,10 @@ int insertRoute(uint32 group, int ifx) {
inetFmt(croute->group, s1), ifx);
// If the route is active, it must be reloaded into the Kernel..
- if(croute->originAddr != 0) {
+ if(!TAILQ_EMPTY(&croute->originList)) {
// Update route in kernel...
- if(!internUpdateKernelRoute(croute, 1)) {
+ if(!internUpdateKernelRoute(croute, 1, NULL)) {
log(LOG_WARNING, 0, "The insertion into Kernel failed.");
return 0;
}
@@ -351,7 +362,7 @@ int insertRoute(uint32 group, int ifx) {
* activated, it's reinstalled in the kernel. If
* the route is activated, no originAddr is needed.
*/
-int activateRoute(uint32 group, uint32 originAddr) {
+int activateRoute(uint32 group, uint32 originAddr, int downIf) {
struct RouteTable* croute;
int result = 0;
@@ -369,21 +380,42 @@ int activateRoute(uint32 group, uint32 originAddr) {
}
if(croute != NULL) {
+ struct Origin *o = NULL;
+ int found = 0;
+
// If the origin address is set, update the route data.
- if(originAddr > 0) {
- if(croute->originAddr > 0 && croute->originAddr!=originAddr) {
- log(LOG_WARNING, 0, "The origin for route %s changed from %s to %s",
- inetFmt(croute->group, s1),
- inetFmt(croute->originAddr, s2),
- inetFmt(originAddr, s3));
- }
- croute->originAddr = originAddr;
- }
+ if(originAddr > 0) {
- // Only update kernel table if there are listeners !
- if(croute->vifBits > 0) {
- result = internUpdateKernelRoute(croute, 1);
- }
+ TAILQ_FOREACH(o, &croute->originList, next) {
+ log(LOG_INFO, 0, "Origin for route %s have %s, new %s",
+ inetFmt(croute->group, s1),
+ inetFmt(o->originAddr, s2),
+ inetFmt(originAddr, s3));
+ if (o->originAddr==originAddr) {
+ found++;
+ break;
+ }
+ }
+ if (!found) {
+ log(LOG_NOTICE, 0, "New origin for route %s is %s, flood %d",
+ inetFmt(croute->group, s1),
+ inetFmt(originAddr, s3), downIf);
+ o = malloc(sizeof(*o));
+ o->originAddr = originAddr;
+ o->flood = downIf;
+ o->pktcnt = 0;
+ TAILQ_INSERT_TAIL(&croute->originList, o, next);
+ } else {
+ log(LOG_INFO, 0, "Have origin for route %s at %s, pktcnt %d",
+ inetFmt(croute->group, s1),
+ inetFmt(o->originAddr, s3),
+ o->pktcnt);
+ }
+ }
+
+ // Only update kernel table if there are listeners, but flood upstream!
+ if(croute->vifBits > 0 || downIf >= 0)
+ result = internUpdateKernelRoute(croute, 1, o);
}
IF_DEBUG logRouteTable("Activate Route");
@@ -443,7 +475,6 @@ void setRouteLastMemberMode(uint32 group) {
* route is not found, or not in this state, 0 is returned.
*/
int lastMemberGroupAge(uint32 group) {
- struct Config *conf = getCommonConfig();
struct RouteTable *croute;
croute = findRoute(group);
@@ -463,6 +494,7 @@ int lastMemberGroupAge(uint32 group) {
*/
int removeRoute(struct RouteTable* croute) {
struct Config *conf = getCommonConfig();
+ struct Origin *o;
int result = 1;
// If croute is null, no routes was found.
@@ -477,7 +509,7 @@ int removeRoute(struct RouteTable* croute) {
//BIT_ZERO(croute->vifBits);
// Uninstall current route from kernel
- if(!internUpdateKernelRoute(croute, 0)) {
+ if(!internUpdateKernelRoute(croute, 0, NULL)) {
log(LOG_WARNING, 0, "The removal from Kernel failed.");
result = 0;
}
@@ -503,7 +535,12 @@ int removeRoute(struct RouteTable* croute) {
croute->nextroute->prevroute = croute->prevroute;
}
}
+
// Free the memory, and set the route to NULL...
+ while ((o = TAILQ_FIRST(&croute->originList))) {
+ TAILQ_REMOVE(&croute->originList, o, next);
+ free(o);
+ }
free(croute);
croute = NULL;
@@ -551,6 +588,36 @@ int internAgeRoute(struct RouteTable* croute) {
}
}
+ {
+ struct Origin *o, *nxt;
+ struct sioc_sg_req sg_req;
+
+ sg_req.grp.s_addr = croute->group;
+ for (o = TAILQ_FIRST(&croute->originList); o; o = nxt) {
+ nxt = TAILQ_NEXT(o, next);
+ sg_req.src.s_addr = o->originAddr;
+ if (ioctl(MRouterFD, SIOCGETSGCNT, (char *)&sg_req) < 0) {
+ log(LOG_WARNING, errno, "%s (%s %s)",
+ "age_table_entry: SIOCGETSGCNT failing for",
+ inetFmt(o->originAddr, s1),
+ inetFmt(croute->group, s2));
+ /* Make sure it gets deleted below */
+ sg_req.pktcnt = o->pktcnt;
+ }
+ log(LOG_DEBUG, 0, "Aging Origin %s Dst %s PktCnt %d -> %d",
+ inetFmt(o->originAddr, s1), inetFmt(croute->group, s2),
+ o->pktcnt, sg_req.pktcnt);
+ if (sg_req.pktcnt == o->pktcnt) {
+ /* no traffic, remove from kernel cache */
+ internUpdateKernelRoute(croute, 0, o);
+ TAILQ_REMOVE(&croute->originList, o, next);
+ free(o);
+ } else {
+ o->pktcnt = sg_req.pktcnt;
+ }
+ }
+ }
+
// If the aging counter has reached zero, its time for updating...
if(croute->ageValue == 0) {
// Check for activity in the aging process,
@@ -560,7 +627,7 @@ int internAgeRoute(struct RouteTable* croute) {
inetFmt(croute->group,s1));
// Just update the routing settings in kernel...
- internUpdateKernelRoute(croute, 1);
+ internUpdateKernelRoute(croute, 1, NULL);
// We append the activity counter to the age, and continue...
croute->ageValue = croute->ageActivity;
@@ -586,34 +653,58 @@ int internAgeRoute(struct RouteTable* croute) {
/**
* Updates the Kernel routing table. If activate is 1, the route
* is (re-)activated. If activate is false, the route is removed.
+* if 'origin' is given, only the route with 'origin' will be
+* updated, otherwise all MFC routes for the group will updated.
*/
-int internUpdateKernelRoute(struct RouteTable *route, int activate) {
+int internUpdateKernelRoute(struct RouteTable *route, int activate, struct Origin *origin) {
struct MRouteDesc mrDesc;
struct IfDesc *Dp;
unsigned Ix;
+ struct Origin *o;
- if(route->originAddr>0) {
+ if (TAILQ_EMPTY(&route->originList)) {
+ log(LOG_NOTICE, 0, "Route is not active. No kernel updates done.");
+ return 1;
+ }
+ TAILQ_FOREACH(o, &route->originList, next) {
+ if (origin && origin != o)
+ continue;
// Build route descriptor from table entry...
// Set the source address and group address...
mrDesc.McAdr.s_addr = route->group;
- mrDesc.OriginAdr.s_addr = route->originAddr;
+ mrDesc.OriginAdr.s_addr = o->originAddr;
// clear output interfaces
memset( mrDesc.TtlVc, 0, sizeof( mrDesc.TtlVc ) );
- IF_DEBUG log(LOG_DEBUG, 0, "Vif bits : 0x%08x", route->vifBits);
+ IF_DEBUG log(LOG_DEBUG, 0, "Origin %s Vif bits : 0x%08x", inetFmt(o->originAddr, s1), route->vifBits);
// Set the TTL's for the route descriptor...
- for ( Ix = 0; Dp = getIfByIx( Ix ); Ix++ ) {
- if(Dp->state == IF_STATE_UPSTREAM) {
- //IF_DEBUG log(LOG_DEBUG, 0, "Identified VIF #%d as upstream.", Dp->index);
- mrDesc.InVif = Dp->index;
- }
- else if(BIT_TST(route->vifBits, Dp->index)) {
- IF_DEBUG log(LOG_DEBUG, 0, "Setting TTL for Vif %d to %d", Dp->index, Dp->threshold);
- mrDesc.TtlVc[ Dp->index ] = Dp->threshold;
- }
+ for ( Ix = 0; (Dp = getIfByIx( Ix )); Ix++ ) {
+ if (o->flood >= 0) {
+ if(Ix == o->flood) {
+ IF_DEBUG log(LOG_DEBUG, 0, "Identified Input VIF #%d as DOWNSTREAM.", Dp->index);
+ mrDesc.InVif = Dp->index;
+ }
+ else if(Dp->state == IF_STATE_UPSTREAM) {
+ IF_DEBUG log(LOG_DEBUG, 0, "Setting TTL for UPSTREAM Vif %d to %d", Dp->index, Dp->threshold);
+ mrDesc.TtlVc[ Dp->index ] = Dp->threshold;
+ }
+ else if(BIT_TST(route->vifBits, Dp->index)) {
+ IF_DEBUG log(LOG_DEBUG, 0, "Setting TTL for DOWNSTREAM Vif %d to %d", Dp->index, Dp->threshold);
+ mrDesc.TtlVc[ Dp->index ] = Dp->threshold;
+ }
+ } else {
+ if(Dp->state == IF_STATE_UPSTREAM) {
+ IF_DEBUG log(LOG_DEBUG, 0, "Identified VIF #%d as upstream.", Dp->index);
+ mrDesc.InVif = Dp->index;
+ }
+ else if(BIT_TST(route->vifBits, Dp->index)) {
+ IF_DEBUG log(LOG_DEBUG, 0, "Setting TTL for Vif %d to %d", Dp->index, Dp->threshold);
+ mrDesc.TtlVc[ Dp->index ] = Dp->threshold;
+ }
+ }
}
// Do the actual Kernel route update...
@@ -625,9 +716,6 @@ int internUpdateKernelRoute(struct RouteTable *route,
// Delete the route from Kernel...
delMRoute( &mrDesc );
}
-
- } else {
- log(LOG_NOTICE, 0, "Route is not active. No kernel updates done.");
}
return 1;
@@ -647,16 +735,17 @@ void logRouteTable(char *header) {
log(LOG_DEBUG, 0, "No routes in table...");
} else {
do {
- /*
- log(LOG_DEBUG, 0, "#%d: Src: %s, Dst: %s, Age:%d, St: %s, Prev: 0x%08x, T: 0x%08x, Next: 0x%08x",
- rcount, inetFmt(croute->originAddr, s1), inetFmt(croute->group, s2),
- croute->ageValue,(croute->originAddr>0?"A":"I"),
- croute->prevroute, croute, croute->nextroute);
- */
- log(LOG_DEBUG, 0, "#%d: Src: %s, Dst: %s, Age:%d, St: %s, OutVifs: 0x%08x",
- rcount, inetFmt(croute->originAddr, s1), inetFmt(croute->group, s2),
- croute->ageValue,(croute->originAddr>0?"A":"I"),
- croute->vifBits);
+ log(LOG_DEBUG, 0, "#%d: Dst: %s, Age:%d, St: %s, OutVifs: 0x%08x",
+ rcount, inetFmt(croute->group, s2),
+ croute->ageValue,(TAILQ_EMPTY(&croute->originList)?"I":"A"),
+ croute->vifBits);
+ {
+ struct Origin *o;
+ TAILQ_FOREACH(o, &croute->originList, next) {
+ log(LOG_DEBUG, 0, "#%d: Origin: %s floodIf %d pktcnt %d",
+ rcount, inetFmt(o->originAddr, s1), o->flood, o->pktcnt);
+ }
+ }
croute = croute->nextroute;

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-udpsock_c,v 1.1.1.1 2008/02/08 19:30:51 sthen Exp $
--- udpsock.c.orig Sat Aug 20 13:35:00 2005
+++ udpsock.c Mon Nov 19 12:56:50 2007
@@ -58,7 +58,7 @@ int openUdpSocket( uint32 PeerInAdr, uint16 PeerPort )
memset( &SockAdr.sin_zero, 0, sizeof( SockAdr.sin_zero ) );
if( connect( Sock, (struct sockaddr *)&SockAdr, sizeof( SockAdr ) ) )
- log( LOG_ERR, errno, "UDP socket connect" );
+ log( LOG_ERR, errno, "UDP socket connect (port %d)", PeerPort);
return Sock;
}

6
net/igmpproxy/pkg/DESCR Normal file
View File

@ -0,0 +1,6 @@
igmpproxy is a simple multicast routing daemon which uses IGMP
forwarding to dynamically route multicast traffic. Routing is done
by defining an "upstream" interface on which the daemon acts as a
normal Multicast client, and one or more "downstream" interfaces
that serves clients on the destination networks. This is useful in
situations where other dynamic multicast routers cannot be used.

View File

@ -0,0 +1,2 @@
Please see ${PREFIX}/share/doc/igmpproxy/README.OpenBSD for
information about using igmpproxy on OpenBSD.

9
net/igmpproxy/pkg/PLIST Normal file
View File

@ -0,0 +1,9 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2008/02/08 19:30:51 sthen Exp $
@man man/man5/igmpproxy.conf.5
@man man/man8/igmpproxy.8
sbin/igmpproxy
share/doc/igmpproxy/
share/doc/igmpproxy/README.OpenBSD
share/examples/igmpproxy/
share/examples/igmpproxy/igmpproxy.conf
@sample ${SYSCONFDIR}/igmpproxy.conf