--- nc110/netcat.c Thu Mar 21 00:38:04 1996 +++ nc110mc/netcat.c Tue Jun 11 11:44:10 2002 @@ -114,6 +114,10 @@ static char p_tcp[] = "tcp"; /* for getservby* */ static char p_udp[] = "udp"; #ifdef HAVE_BIND +#include +#include +#include + extern int h_errno; /* stolen almost wholesale from bsd herror.c */ static char * h_errs[] = { @@ -666,6 +670,33 @@ if (rr) bail ("Can't grab %s:%d with bind", inet_ntoa(lclend->sin_addr), lp); +#ifdef LINUX +#ifdef LINUXMULTICAST + +/* + Shameless rip from the videolan client: www.videolan.org + Minor include changes for RedHat7.2 (really needed ?) + Compile with: + cc -O -s -DLINUX -DLINUXMULTICAST -static -lresolv netcat.c -o nc + pmsac@toxyn.org, 2002.06.07 + */ + if(IN_MULTICAST(ntohl(lad->s_addr))) + { + struct ip_mreq imr; + + printf("Wowowowow, multicasting, are we ?\n"); + + imr.imr_interface.s_addr = INADDR_ANY; + imr.imr_multiaddr.s_addr = lad->s_addr; + if( setsockopt( nnetfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, + (char*)&imr, sizeof(struct ip_mreq) ) == -1 ) + { + holler ("Brrr... ipv4 error: failed to join IP multicast group (%s)", + strerror(errno) ); + } + } +#endif +#endif if (o_listen) return (nnetfd); /* thanks, that's all for today */