[ntp:hackers] Weekend

mayer mayer at gis.net
Tue Oct 12 06:13:30 PDT 2004


Dave,

Just copy the following routine into your copy of ntp_io.c.

Danny

/*
 * Enable a broadcast address to a given socket
 * The socket is in the inter_list all we need to do is enable
 * broadcasting. It is not this function's job to select the socket
 */
void
enable_broadcast(struct interface *iface, struct sockaddr_storage
*maddr)
{
#ifdef SO_BROADCAST
	int on = 1;

	if (maddr->ss_family == AF_INET)
	{
		/* if this interface can support broadcast, set SO_BROADCAST */
		if (setsockopt(iface->fd, SOL_SOCKET, SO_BROADCAST,
			       (char *)&on, sizeof(on)))
		{
			netsyslog(LOG_ERR, "setsockopt(SO_BROADCAST) enable failure on
address %s: %m",
				stoa(maddr));
		}
#ifdef DEBUG
		else if (debug > 1) {
			printf("Broadcast enabled on socket %d for address %s\n",
				iface->fd, stoa(maddr));
		}
#endif
	}
	iface->flags |= INT_BCASTOPEN;
	modify_addr_in_list(maddr, iface->flags);
	return;
#else
	return;
#endif /* SO_BROADCAST */
}




More information about the hackers mailing list