--- sys/netinet/ip_output.c.ORIG	Fri Mar  4 10:49:02 2005
+++ sys/netinet/ip_output.c	Sat Jul  9 16:30:37 2005
@@ -92,6 +92,7 @@
 	&mbuf_frag_size, 0, "Fragment outgoing mbufs to this size");
 #endif
 
+
 static struct mbuf *ip_insertoptions(struct mbuf *, struct mbuf *, int *);
 static struct ifnet *ip_multicast_if(struct in_addr *, int *);
 static void	ip_mloopback
@@ -102,6 +103,7 @@
 
 int	ip_optcopy(struct ip *, struct ip *);
 
+static int reqbcflags = IP_ALLOWBROADCAST;
 
 extern	struct protosw inetsw[];
 
@@ -386,7 +388,7 @@
 			error = EADDRNOTAVAIL;
 			goto bad;
 		}
-		if ((flags & IP_ALLOWBROADCAST) == 0) {
+		if ((flags & reqbcflags) == 0) {
 			error = EACCES;
 			goto bad;
 		}
@@ -2016,3 +2018,39 @@
 #endif
 	}
 }
+
+static int
+sysctl_net_inet_ip_allownetbcast(SYSCTL_HANDLER_ARGS)
+{
+	int error, flags;
+
+	if ( reqbcflags == (IP_ALLOWBROADCAST | IP_FORWARDING) )
+		flags=1;
+	else
+		flags=0;
+
+	error = sysctl_handle_int(oidp, &flags, 0, req);
+	if (error || !req->newptr)
+		return (error);
+
+	switch (flags) {
+	case 0:
+		reqbcflags=IP_ALLOWBROADCAST;
+		break;
+		
+	case 1:
+		reqbcflags=IP_ALLOWBROADCAST | IP_FORWARDING;
+		break;
+		
+	default:
+		return (EINVAL);
+		break;
+	}
+                                 
+	return(0);
+}
+
+SYSCTL_PROC(_net_inet_ip, OID_AUTO, allownetbroadcast, CTLTYPE_INT|CTLFLAG_RW,
+    0, sizeof reqbcflags, sysctl_net_inet_ip_allownetbcast,
+    "I", "Enable forwarding of network bradcasts");
+        
