? .swp ? work Index: Makefile =================================================================== RCS file: /home/pcvs/ports/net/olsrd/Makefile,v retrieving revision 1.5 diff -u -p -r1.5 Makefile --- Makefile 18 Apr 2006 10:40:42 -0000 1.5 +++ Makefile 26 Apr 2007 14:25:14 -0000 @@ -15,10 +15,6 @@ COMMENT= OLSR routing daemon BUILD_DEPENDS= makedepend:${PORTSDIR}/devel/makedepend -.if defined(WITH_MULTI_IF) -BUILD_DEPENDS+= libnet*>=1.1.2,1:${PORTSDIR}/net/libnet -.endif - USE_BISON= yes USE_GMAKE= yes @@ -30,9 +26,6 @@ MANCOMPRESSED= yes ALL_TARGET= build_all INSTALL_TARGET= install_all -.if defined(WITH_MULTI_IF) -MAKE_ARGS+= LIBNET=1 -.endif .if defined(PREFIX) MAKE_ARGS+= INSTALL_PREFIX=${PREFIX} .endif @@ -47,14 +40,6 @@ IGNORE= needs ieee80211.h headers CFLAGS+= -fPIC .endif -.if !defined(WITH_MULTI_IF) -pre-everything:: - @${ECHO_MSG} "" - @${ECHO_MSG} " To enable multiple interface support make with" - @${ECHO_MSG} " WITH_MULTI_IF defined" - @${ECHO_MSG} "" -.endif - post-install: @${ECHO_MSG} "" @${ECHO_MSG} " Set olsrd_enable=\"YES\" in /etc/rc.conf to enable" Index: files/patch-src__bsd__net.c =================================================================== RCS file: files/patch-src__bsd__net.c diff -N files/patch-src__bsd__net.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src__bsd__net.c 26 Apr 2007 14:25:14 -0000 @@ -0,0 +1,229 @@ +--- src/bsd/net.c.orig Sun Aug 28 20:30:29 2005 ++++ src/bsd/net.c Thu Apr 26 15:09:25 2007 +@@ -71,16 +71,12 @@ + #endif + #endif + +-#ifdef SPOOF + #include +-#include +-#endif /* SPOOF */ +- +-//#define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */ +-//#define SIOCGWAVELAN SIOCGIFGENERIC + + #include + ++#include ++ + static int ignore_redir; + static int send_redir; + static int gateway; +@@ -335,7 +331,6 @@ + return (-1); + } + +-#ifdef SPOOF + if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0) + { + perror("SO_REUSEPORT failed"); +@@ -347,7 +342,6 @@ + perror("IP_RECVIF failed"); + return (-1); + } +-#endif /* SPOOF */ + + for (on = bufspace; ; on -= 1024) + { +@@ -504,10 +498,6 @@ + * Wrapper for sendto(2) + */ + +-#ifdef SPOOF +-static u_int16_t ip_id = 0; +-#endif /* SPOOF */ +- + ssize_t + olsr_sendto(int s, + const void *buf, +@@ -516,96 +506,68 @@ + const struct sockaddr *to, + socklen_t tolen) + { +-#ifdef SPOOF +- /* IPv4 for now! */ +- +- libnet_t *context; +- char errbuf[LIBNET_ERRBUF_SIZE]; +- libnet_ptag_t udp_tag, ip_tag, ether_tag; +- unsigned char enet_broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +- int status; +- struct sockaddr_in *to_in = (struct sockaddr_in *) to; +- u_int32_t destip; +- struct interface *iface; +- +- udp_tag = ip_tag = ether_tag = 0; +- destip = to_in->sin_addr.s_addr; +- iface = if_ifwithsock (s); +- +- /* initialize libnet */ +- context = libnet_init(LIBNET_LINK, iface->int_name, errbuf); +- if (context == NULL) +- { +- OLSR_PRINTF (1, "libnet init: %s\n", libnet_geterror (context)) +- return (0); +- } +- +- /* initialize IP ID field if necessary */ +- if (ip_id == 0) +- { +- ip_id = (u_int16_t) (arc4random () & 0xffff); +- } +- +- udp_tag = libnet_build_udp (698, /* src port */ +- 698, /* dest port */ +- LIBNET_UDP_H + len, /* length */ +- 0, /* checksum */ +- buf, /* payload */ +- len, /* payload size */ +- context, /* context */ +- udp_tag); /* pblock */ +- if (udp_tag == -1) +- { +- OLSR_PRINTF (1, "libnet UDP header: %s\n", libnet_geterror (context)) +- return (0); +- } +- +- ip_tag = libnet_build_ipv4 (LIBNET_IPV4_H + LIBNET_UDP_H + len, /* len */ +- 0, /* TOS */ +- ip_id++, /* IP id */ +- 0, /* IP frag */ +- 1, /* IP TTL */ +- IPPROTO_UDP, /* protocol */ +- 0, /* checksum */ +- libnet_get_ipaddr4 (context), /* src IP */ +- destip, /* dest IP */ +- NULL, /* payload */ +- 0, /* payload len */ +- context, /* context */ +- ip_tag); /* pblock */ +- if (ip_tag == -1) +- { +- OLSR_PRINTF (1, "libnet IP header: %s\n", libnet_geterror (context)) +- return (0); +- } ++ struct sockaddr_in *psin = (struct sockaddr_in *)to; ++ int err; + +- ether_tag = libnet_build_ethernet (enet_broadcast, /* ethernet dest */ +- libnet_get_hwaddr (context), /* ethernet source */ +- ETHERTYPE_IP, /* protocol type */ +- NULL, /* payload */ +- 0, /* payload size */ +- context, /* libnet handle */ +- ether_tag); /* pblock tag */ +- if (ether_tag == -1) +- { +- OLSR_PRINTF (1, "libnet ethernet header: %s\n", libnet_geterror (context)) +- return (0); +- } +- +- status = libnet_write (context); +- if (status == -1) +- { +- OLSR_PRINTF (1, "libnet packet write: %s\n", libnet_geterror (context)) +- return (0); +- } +- +- libnet_destroy (context); +- +- return (len); ++ /* XXX Workaround a bug in code further up in call graph whereby ++ * the family field of a sockaddr was not set. */ ++ if (psin->sin_family == 0 && tolen == sizeof(struct sockaddr_in)) ++ psin->sin_family = AF_INET; ++ ++ /* Check if 255.255.255.255 and use BSD IP_ONESBCAST if so. */ ++ if (psin->sin_family == AF_INET && psin->sin_addr.s_addr == INADDR_BROADCAST) ++ { ++ struct sockaddr_in nbcast; ++ struct interface *iface; ++ uint32_t addr, mask; ++ int on; ++ ++ on = 1; ++ if (setsockopt(s, IPPROTO_IP, IP_ONESBCAST, &on, sizeof(on)) < 0) ++ { ++ perror("IP_ONESBCAST failed"); ++ return (-1); ++ } ++ ++ /* Get broadcast address of ifnet for use with IP_ONESBCAST; it will ++ * be turned into 255.255.255.255 by ip_output(). ++ * Note that the rest of the code does not fill out ++ * iface->int_broadaddr for us, so we compute the broadcast address ++ * assuming it is the all-ones portion of the host address, which ++ * is not an assumption that always holds. ++ */ ++ iface = if_ifwithsock (s); ++ ++ memset(&nbcast, 0, sizeof(struct sockaddr_in)); ++ nbcast.sin_len = sizeof(struct sockaddr_in); ++ nbcast.sin_family = AF_INET; ++ addr = ntohl(((struct sockaddr_in *)&iface->int_addr)->sin_addr.s_addr); ++ mask = ntohl(((struct sockaddr_in *)&iface->int_netmask)->sin_addr.s_addr); ++ addr &= mask; ++ addr |= ~mask; ++ nbcast.sin_addr.s_addr = htonl(addr); ++ nbcast.sin_port = psin->sin_port; ++ ++ err = sendto(s, buf, len, flags, (struct sockaddr *)&nbcast, ++ sizeof(nbcast)); ++ if (err == -1) perror("internal_sendto_bcast"); ++ ++ on = 0; ++ if (setsockopt(s, IPPROTO_IP, IP_ONESBCAST, &on, sizeof(on)) < 0) ++ { ++ perror("IP_ONESBCAST failed"); ++ return (-1); ++ } ++ ++ } else { ++ /* destinations other than 255.255.255.255 */ ++ fprintf(stderr, "to->sa_family %d tolen %d\n", to->sa_family, tolen); ++ fprintf(stderr, "sizeof(sockaddr_in) is %d\n", sizeof(struct sockaddr_in)); ++ err = sendto(s, buf, len, flags, to, tolen); ++ if (err == -1) perror("internal_sendto"); ++ } + +-#else +- return sendto(s, buf, len, flags, to, tolen); +-#endif ++ return ((err == 0) ? (ssize_t)len : err) ; + } + + +@@ -621,7 +583,6 @@ + struct sockaddr *from, + socklen_t *fromlen) + { +-#if SPOOF + struct msghdr mhdr; + struct iovec iov; + struct cmsghdr *cm; +@@ -673,15 +634,6 @@ + iname); + + return (count); +- +-#else /* SPOOF */ +- return recvfrom(s, +- buf, +- len, +- 0, +- from, +- fromlen); +-#endif /* SPOOF */ + } + + /**