1 diff -up ntp-4.2.4p7/ntpd/ntp_io.c.bcast ntp-4.2.4p7/ntpd/ntp_io.c
2 --- ntp-4.2.4p7/ntpd/ntp_io.c.bcast 2009-05-18 16:53:05.000000000 +0200
3 +++ ntp-4.2.4p7/ntpd/ntp_io.c 2009-05-18 16:54:19.000000000 +0200
4 @@ -150,6 +150,8 @@ int ninterfaces; /* Total number of in
6 volatile int disable_dynamic_updates; /* when set to != 0 dynamic updates won't happen */
8 +static int pktinfo_status = 0; /* is IP_PKTINFO on wildipv4 iface enabled? */
12 * Refclock stuff. We keep a chain of structures with data concerning
13 @@ -1611,6 +1613,18 @@ set_reuseaddr(int flag) {
14 #endif /* ! SO_EXCLUSIVEADDRUSE */
18 +set_pktinfo(int flag)
20 + if (wildipv4 == NULL)
22 + if (setsockopt(wildipv4->fd, SOL_IP, IP_PKTINFO, &flag, sizeof (flag))) {
24 + printf("setsockopt(IP_PKTINFO) failed: %s\n", strerror(errno));
26 + pktinfo_status = flag;
30 * This is just a wrapper around an internal function so we can
31 * make other changes as necessary later on
32 @@ -2027,6 +2041,7 @@ io_setbclient(void)
34 netsyslog(LOG_ERR, "io_setbclient: Broadcast Client disabled by build");
40 @@ -2049,6 +2064,7 @@ io_unsetbclient(void)
42 lstatus = socket_broadcast_disable(interf, &interf->sin);
48 @@ -2957,7 +2973,8 @@ read_network_packet(SOCKET fd, struct in
52 - char control[TIMESTAMP_CTLMSGBUF_SIZE]; /* pick up control messages */
53 + char control[sizeof (struct cmsghdr) * 2 + sizeof (struct timeval) +
54 + sizeof (struct in_pktinfo) + 32]; /* pick up control messages */
58 @@ -2969,7 +2986,7 @@ read_network_packet(SOCKET fd, struct in
60 rb = get_free_recv_buffer();
62 - if (rb == NULL || itf->ignore_packets == ISC_TRUE)
63 + if (rb == NULL || (itf->ignore_packets == ISC_TRUE && !(pktinfo_status && itf == wildipv4)))
65 char buf[RX_BUFF_SIZE];
66 struct sockaddr_storage from;
67 @@ -3031,6 +3048,34 @@ read_network_packet(SOCKET fd, struct in
71 + if (pktinfo_status && itf->ignore_packets == ISC_TRUE && itf == wildipv4) {
72 + /* check for broadcast on 255.255.255.255, exception allowed on wildipv4 */
73 + struct cmsghdr *cmsg;
74 + struct in_pktinfo *pktinfo = NULL;
76 + if ((cmsg = CMSG_FIRSTHDR(&msghdr)))
78 + if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_PKTINFO)
79 + pktinfo = (struct in_pktinfo *) CMSG_DATA(cmsg);
80 + } while ((cmsg = CMSG_NXTHDR(&msghdr, cmsg)));
81 + if (pktinfo && pktinfo->ipi_addr.s_addr == INADDR_BROADCAST) {
84 + printf("INADDR_BROADCAST\n");
90 + printf("%s on (%lu) fd=%d from %s\n", "ignore",
91 + free_recvbuffs(), fd, stoa(&rb->recv_srcadr));
101 if(rb->recv_srcadr.ss_family == AF_INET)
102 diff -up ntp-4.2.4p7/ntpd/ntp_peer.c.bcast ntp-4.2.4p7/ntpd/ntp_peer.c
103 --- ntp-4.2.4p7/ntpd/ntp_peer.c.bcast 2008-08-10 13:02:40.000000000 +0200
104 +++ ntp-4.2.4p7/ntpd/ntp_peer.c 2009-05-18 16:53:05.000000000 +0200
105 @@ -709,7 +709,8 @@ select_peerinterface(struct peer *peer,
106 * as our (network) source address would be undefined and
107 * crypto will not work without knowing the own transmit address
109 - if (interface != NULL && interface->flags & INT_WILDCARD)
110 + if (interface != NULL && interface->flags & INT_WILDCARD &&
111 + !(cast_flags & MDF_BCAST))
113 if ( !accept_wildcard_if_for_winnt )