# include "win32_io.h"
#endif
+#include <isc/boolean.h>
/*
* Define FNDELAY and FASYNC using O_NONBLOCK and O_ASYNC if we need
* to (and can). This is here initially for QNX, but may help for
# endif
#endif
+isc_boolean_t get_broadcastclient_flag(void); /* Get the status of client broadcast */
+
#endif
#define _NTP_REQUEST_H
#include "ntp_types.h"
+#include "recvbuff.h"
/*
* A mode 7 packet is used exchanging data between an NTP server
associd_t associd; /* association ID */
char hostname[NTP_MAXHOSTNAME]; /* hostname */
};
+
+/*
+ * function declarations
+ */
+int get_packet_mode(struct recvbuf *rbufp); /* Return packet mode */
+
#endif /* NTP_REQUEST_H */
struct interface *any6_interface; /* default ipv6 interface */
struct interface *loopback_interface; /* loopback ipv4 interface */
+isc_boolean_t broadcast_client_enabled = ISC_FALSE; /* is broadcast client enabled */
int ninterfaces; /* Total number of interfaces */
volatile int disable_dynamic_updates; /* when set to != 0 dynamic updates won't happen */
}
/*
- * remove interface from known interface list and clean up
+ * remove interface from knoen interface list and clean up
* associated resources
*/
static void
#endif
}
iface->flags |= INT_BCASTOPEN;
+ broadcast_client_enabled = ISC_TRUE;
return ISC_TRUE;
#else
return ISC_FALSE;
}
}
iface->flags &= ~INT_BCASTOPEN;
+ broadcast_client_enabled = ISC_FALSE;
return ISC_TRUE;
#else
return ISC_FALSE;
}
#endif /* OPEN_BCAST_SOCKET */
+
+/*
+ * return the broadcast client flag value
+ */
+isc_boolean_t
+get_broadcastclient_flag(void)
+{
+ return (broadcast_client_enabled);
+}
/*
* Check to see if the address is a multicast address
*/
{
GETSOCKNAME_SOCKLEN_TYPE fromlen;
int buflen;
+ isc_boolean_t ignore_this;
register struct recvbuf *rb;
#ifdef HAVE_TIMESTAMP
struct msghdr msghdr;
rb = get_free_recv_buffer();
- if (rb == NULL || itf->ignore_packets == ISC_TRUE)
+ /* For broadcast packet received on the IPv4 wildcard socket
+ * we carve out an exception but only if the client has requested
+ * to receive wildcard sockets
+ */
+ ignore_this = itf->ignore_packets;
+ if (ignore_this == ISC_TRUE && itf->family == AF_INET &&
+ itf->flags == (INT_BROADCAST | INT_WILDCARD) &&
+ get_packet_mode(rb) == MODE_BROADCAST &&
+ get_broadcastclient_flag() == ISC_TRUE
+ )
+ ignore_this = ISC_FALSE;
+
+ if (rb == NULL || ignore_this == ISC_TRUE)
{
char buf[RX_BUFF_SIZE];
struct sockaddr_storage from;
+/*
+ * Given a buffer, return the packet mode
+ */
+int
+get_packet_mode(struct recvbuf *rbufp)
+{
+ struct req_pkt *inpkt = (struct req_pkt *)&rbufp->recv_pkt;
+ return (INFO_MODE(inpkt->rm_vn_mode));
+}
/*
* process_private - process private mode (7) packets
*/
#include "ntp_refclock.h"
#include "ntp_iocompletionport.h"
#include "transmitbuff.h"
+#include "ntp_request.h"
+#include "ntp_io.h"
/*
* Request types
{
struct recvbuf *buff = NULL;
recvbuf_t *newbuff;
+ isc_boolean_t ignore_this;
+ l_fp arrival_time;
struct interface * inter = (struct interface *) i;
+ get_systime(&arrival_time);
+
/* Convert the overlapped pointer back to a recvbuf pointer.
*/
}
else
{
+ /* For broadcast packet received on the IPv4 wildcard socket
+ * we carve out an exception but only if the client has requested
+ * to receive wildcard sockets
+ */
+ ignore_this = inter->ignore_packets;
+ if (ignore_this == ISC_TRUE && inter->family == AF_INET &&
+ inter->flags == (INT_BROADCAST | INT_WILDCARD) &&
+ get_packet_mode(buff) == MODE_BROADCAST &&
+ get_broadcastclient_flag() == ISC_TRUE
+ )
+ ignore_this = ISC_FALSE;
+
/*
* If we keep it add some info to the structure
*/
- if (Bytes > 0 && inter->ignore_packets == ISC_FALSE) {
- get_systime(&buff->recv_time);
+ if (Bytes > 0 && ignore_this == ISC_FALSE) {
+ memcpy(&buff->recv_time, &arrival_time, sizeof(arrival_time));
buff->recv_length = (int) Bytes;
buff->receiver = receive;
buff->dstadr = inter;