Index: net/if.c =================================================================== RCS file: /home/ncvs/src/sys/net/if.c,v retrieving revision 1.261 diff -u -p -r1.261 if.c --- net/if.c 9 Jul 2006 06:04:00 -0000 1.261 +++ net/if.c 30 Aug 2006 19:27:51 -0000 @@ -1006,6 +1006,33 @@ done: } /* + * Locate an interface based on the broadcast address. + */ +/* ARGSUSED */ +struct ifaddr * +ifa_ifwithbroadcaddr(struct sockaddr *addr) +{ + struct ifnet *ifp; + struct ifaddr *ifa; + + IFNET_RLOCK(); + TAILQ_FOREACH(ifp, &ifnet, if_link) + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + if (ifa->ifa_addr->sa_family != addr->sa_family) + continue; + if ((ifp->if_flags & IFF_BROADCAST) && + ifa->ifa_broadaddr && + ifa->ifa_broadaddr->sa_len != 0 && + sa_equal(ifa->ifa_broadaddr, addr)) + goto done; + } + ifa = NULL; +done: + IFNET_RUNLOCK(); + return (ifa); +} + +/* * Locate the point to point interface with a given destination address. */ /*ARGSUSED*/ Index: net/if_var.h =================================================================== RCS file: /home/ncvs/src/sys/net/if_var.h,v retrieving revision 1.108 diff -u -p -r1.108 if_var.h --- net/if_var.h 4 Aug 2006 21:27:37 -0000 1.108 +++ net/if_var.h 30 Aug 2006 19:27:51 -0000 @@ -683,6 +683,7 @@ int ifpromisc(struct ifnet *, int); struct ifnet *ifunit(const char *); struct ifaddr *ifa_ifwithaddr(struct sockaddr *); +struct ifaddr *ifa_ifwithbroadcaddr(struct sockaddr *); struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *); struct ifaddr *ifa_ifwithnet(struct sockaddr *); struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *); Index: netinet/ip_output.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/ip_output.c,v retrieving revision 1.259 diff -u -p -r1.259 ip_output.c --- netinet/ip_output.c 17 Aug 2006 00:37:03 -0000 1.259 +++ netinet/ip_output.c 30 Aug 2006 19:27:51 -0000 @@ -198,6 +198,17 @@ again: ifp = ia->ia_ifp; ip->ip_ttl = 1; isbroadcast = in_broadcast(dst->sin_addr, ifp); + } else if (flags & IP_SENDONES) { + if ((ia = ifatoia(ifa_ifwithbroadcaddr(sintosa(dst)))) == NULL) { + ipstat.ips_noroute++; + error = ENETUNREACH; + goto bad; + } + ifp = ia->ia_ifp; + ip->ip_dst.s_addr = INADDR_BROADCAST; + dst->sin_addr = ip->ip_dst; + ip->ip_ttl = 1; + isbroadcast = 1; } else if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && imo != NULL && imo->imo_multicast_ifp != NULL) { /* @@ -381,8 +392,6 @@ again: error = EMSGSIZE; goto bad; } - if (flags & IP_SENDONES) - ip->ip_dst.s_addr = INADDR_BROADCAST; m->m_flags |= M_BCAST; } else { m->m_flags &= ~M_BCAST; Index: netinet/raw_ip.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/raw_ip.c,v retrieving revision 1.164 diff -u -p -r1.164 raw_ip.c --- netinet/raw_ip.c 21 Jul 2006 17:11:14 -0000 1.164 +++ netinet/raw_ip.c 30 Aug 2006 19:27:51 -0000 @@ -333,7 +333,7 @@ rip_output(struct mbuf *m, struct socket ipstat.ips_rawout++; } - if (inp->inp_vflag & INP_ONESBCAST) + if (inp->inp_flags & INP_ONESBCAST) flags |= IP_SENDONES; #ifdef MAC Index: netinet/udp_usrreq.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/udp_usrreq.c,v retrieving revision 1.192 diff -u -p -r1.192 udp_usrreq.c --- netinet/udp_usrreq.c 21 Jul 2006 17:11:14 -0000 1.192 +++ netinet/udp_usrreq.c 30 Aug 2006 19:27:52 -0000 @@ -899,14 +899,14 @@ udp_output(inp, m, addr, control, td) ipflags |= IP_ROUTETOIF; if (inp->inp_socket->so_options & SO_BROADCAST) ipflags |= IP_ALLOWBROADCAST; - if (inp->inp_vflag & INP_ONESBCAST) + if (inp->inp_flags & INP_ONESBCAST) ipflags |= IP_SENDONES; /* * Set up checksum and output datagram. */ if (udpcksum) { - if (inp->inp_vflag & INP_ONESBCAST) + if (inp->inp_flags & INP_ONESBCAST) faddr.s_addr = INADDR_BROADCAST; ui->ui_sum = in_pseudo(ui->ui_src.s_addr, faddr.s_addr, htons((u_short)len + sizeof(struct udphdr) + IPPROTO_UDP));