endpt * any6_interface; /* wildcard ipv6 interface */
endpt * loopback_interface; /* loopback ipv4 interface */
-isc_boolean_t broadcast_client_enabled; /* is broadcast client enabled */
+static isc_boolean_t broadcast_client_enabled; /* is broadcast client enabled */
u_int sys_ifnum; /* next .ifnum to assign */
int ninterfaces; /* Total number of interfaces */
*/
refresh_all_peerinterfaces();
- if (broadcast_client_enabled)
- io_setbclient();
-
- if (sys_bclient)
+ if (broadcast_client_enabled || sys_bclient)
io_setbclient();
#ifdef MCAST
/*
* return the broadcast client flag value
*/
-isc_boolean_t
+/*isc_boolean_t
get_broadcastclient_flag(void)
{
return (broadcast_client_enabled);
}
+*/
/*
* Check to see if the address is a multicast address
io_setbclient(void)
{
#ifdef OPEN_BCAST_SOCKET
- struct interface * interf;
- unsigned int nif;
+ endpt * ep;
+ unsigned int nif, ni4, ni6;
- nif = 0;
+ nif = ni4 = ni6 = 0;
set_reuseaddr(1);
- for (interf = ep_list;
- interf != NULL;
- interf = interf->elink) {
-
- if (interf->flags & (INT_WILDCARD | INT_LOOPBACK))
+ for (ep = ep_list; ep != NULL; ep = ep->elink) {
+ /* count IPv6 vs IPv4 interfaces. Needed later to decide
+ * if we should log an error or not.
+ */
+ switch (ep->family) {
+ case AF_INET : ++ni4; break;
+ case AF_INET6: ++ni6; break;
+ default : break;
+ }
+
+ if (ep->flags & (INT_WILDCARD | INT_LOOPBACK))
continue;
/* use only allowed addresses */
- if (interf->ignore_packets)
+ if (ep->ignore_packets)
continue;
/* Need a broadcast-capable interface */
- if (!(interf->flags & INT_BROADCAST))
+ if (!(ep->flags & INT_BROADCAST))
continue;
/* Only IPv4 addresses are valid for broadcast */
- REQUIRE(IS_IPV4(&interf->bcast));
+ REQUIRE(IS_IPV4(&ep->bcast));
/* Do we already have the broadcast address open? */
- if (interf->flags & INT_BCASTOPEN) {
+ if (ep->flags & INT_BCASTOPEN) {
/*
* account for already open interfaces to avoid
* misleading warning below
/*
* Try to open the broadcast address
*/
- interf->family = AF_INET;
- interf->bfd = open_socket(&interf->bcast, 1, 0, interf);
+ ep->family = AF_INET;
+ ep->bfd = open_socket(&ep->bcast, 1, 0, ep);
/*
* If we succeeded then we use it otherwise enable
* broadcast on the interface address
*/
- if (interf->bfd != INVALID_SOCKET) {
+ if (ep->bfd != INVALID_SOCKET) {
nif++;
- interf->flags |= INT_BCASTOPEN;
+ ep->flags |= INT_BCASTOPEN;
msyslog(LOG_INFO,
"Listen for broadcasts to %s on interface #%d %s",
- stoa(&interf->bcast), interf->ifnum, interf->name);
+ stoa(&ep->bcast), ep->ifnum, ep->name);
} else switch (errno) {
/* Silently ignore EADDRINUSE as we probably
* opened the socket already for an address in
* regular socket, it's quite useless to try this
* again.
*/
- if (interf->fd != INVALID_SOCKET) {
- interf->flags |= INT_BCASTOPEN;
+ if (ep->fd != INVALID_SOCKET) {
+ ep->flags |= INT_BCASTOPEN;
nif++;
}
# endif
default:
msyslog(LOG_INFO,
"failed to listen for broadcasts to %s on interface #%d %s",
- stoa(&interf->bcast), interf->ifnum, interf->name);
+ stoa(&ep->bcast), ep->ifnum, ep->name);
break;
}
}
DPRINTF(1, ("io_setbclient: listening to %d broadcast addresses\n", nif));
} else {
broadcast_client_enabled = ISC_FALSE;
- msyslog(LOG_ERR,
- "Unable to listen for broadcasts, no broadcast interfaces available");
+ /* This is expected when having only IPv6 interfaces
+ * and no IPv4 interfaces at all. We suppress the error
+ * log in that case... everything else should work!
+ */
+ if (ni4 && !ni6) {
+ msyslog(LOG_ERR,
+ "Unable to listen for broadcasts, no broadcast interfaces available");
+ }
}
#else
msyslog(LOG_ERR,