Sending a broadcast packet to another network

Matt Crawford matt at oddjob.UUCP
Sun Apr 14 15:00:08 AEST 1985


At this university we have several class C networks connected by
gateways.  I modified our rwho daemon to send packets to selected
other networks with a local-address-portion of zero.  My intent
was to get the gateway to perform a broadcast on an adjacent net.
It didn't work, and the reason seems to be an accidental side effect
of the kernel's internet output code.  The gateway is actually a
SUN, but we don't have source so I quote the VAX 4.2bsd code below.

In netinet/ip_input.c, if a packet is to be forwarded the routine
ip_forward does:

	error = ip_output(dtom(ip), mopt, (struct route *)0, IP_FORWARDING);

while ip_output has:

ip_output(m, opt, ro, flags)
 . . .
{
	:
	:
	/*
	 * Look for broadcast address and
	 * and verify user is allowed to send
	 * such a packet.
	 */
	if (in_lnaof(((struct sockaddr_in *)dst)->sin_addr) == INADDR_ANY) {
		:
		:
		if ((flags & IP_ALLOWBROADCAST) == 0) {
			error = EACCES;
			goto bad;
		}
	}
	:
	:
}

So the gateway's refusal to forward my packet seems to be a by-product
of the restriction that only the super-user can broadcast and the need
not to repeat broadcasts endlessly.  Can someone out there give a good
reason not to allow what I am trying to do?  I would like to change the
last test above to:

		if ((flags & (IP_ALLOWBROADCAST|IP_FORWARDING) == 0) {

(If I had source for the gateways!)  ipintr() would also have to be
changed to forward broadcast packets whose source address is not on
the destination network.  This would mean that certain packets are
both forwarded and passed on to the next protocol level.  Comments?
_____________________________________________________
Matt		University	crawford at anl-mcs.arpa
Crawford	of Chicago	ihnp4!oddjob!matt



More information about the Comp.bugs.4bsd.ucb-fixes mailing list