aboutsummaryrefslogtreecommitdiff
path: root/networking/ntpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-04-01 16:31:04 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2012-04-01 16:31:04 +0200
commit3e3a8d50b3d9190c7b06787cb7639b53644e66c7 (patch)
tree0f65329bee09580f04561096c7fd17e8578670c6 /networking/ntpd.c
parent1c12b67705a4a2d5854d5e62fcbd2b241852ffe9 (diff)
downloadbusybox-w32-3e3a8d50b3d9190c7b06787cb7639b53644e66c7.tar.gz
busybox-w32-3e3a8d50b3d9190c7b06787cb7639b53644e66c7.tar.bz2
busybox-w32-3e3a8d50b3d9190c7b06787cb7639b53644e66c7.zip
ntpd: fix build failure if !NTPD_SERVER. Closes 4994
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r--networking/ntpd.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 4d939458c..603801ec6 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -276,6 +276,9 @@ struct globals {
276 llist_t *ntp_peers; 276 llist_t *ntp_peers;
277#if ENABLE_FEATURE_NTPD_SERVER 277#if ENABLE_FEATURE_NTPD_SERVER
278 int listen_fd; 278 int listen_fd;
279# define G_listen_fd (G.listen_fd)
280#else
281# define G_listen_fd (-1)
279#endif 282#endif
280 unsigned verbose; 283 unsigned verbose;
281 unsigned peer_cnt; 284 unsigned peer_cnt;
@@ -1815,10 +1818,10 @@ recv_and_process_client_pkt(void /*int fd*/)
1815 uint8_t query_status; 1818 uint8_t query_status;
1816 l_fixedpt_t query_xmttime; 1819 l_fixedpt_t query_xmttime;
1817 1820
1818 to = get_sock_lsa(G.listen_fd); 1821 to = get_sock_lsa(G_listen_fd);
1819 from = xzalloc(to->len); 1822 from = xzalloc(to->len);
1820 1823
1821 size = recv_from_to(G.listen_fd, &msg, sizeof(msg), MSG_DONTWAIT, from, &to->u.sa, to->len); 1824 size = recv_from_to(G_listen_fd, &msg, sizeof(msg), MSG_DONTWAIT, from, &to->u.sa, to->len);
1822 if (size != NTP_MSGSIZE_NOAUTH && size != NTP_MSGSIZE) { 1825 if (size != NTP_MSGSIZE_NOAUTH && size != NTP_MSGSIZE) {
1823 char *addr; 1826 char *addr;
1824 if (size < 0) { 1827 if (size < 0) {
@@ -1861,7 +1864,7 @@ recv_and_process_client_pkt(void /*int fd*/)
1861 1864
1862 /* We reply from the local address packet was sent to, 1865 /* We reply from the local address packet was sent to,
1863 * this makes to/from look swapped here: */ 1866 * this makes to/from look swapped here: */
1864 do_sendto(G.listen_fd, 1867 do_sendto(G_listen_fd,
1865 /*from:*/ &to->u.sa, /*to:*/ from, /*addrlen:*/ to->len, 1868 /*from:*/ &to->u.sa, /*to:*/ from, /*addrlen:*/ to->len,
1866 &msg, size); 1869 &msg, size);
1867 1870
@@ -2000,11 +2003,11 @@ static NOINLINE void ntp_init(char **argv)
2000 logmode = LOGMODE_NONE; 2003 logmode = LOGMODE_NONE;
2001 } 2004 }
2002#if ENABLE_FEATURE_NTPD_SERVER 2005#if ENABLE_FEATURE_NTPD_SERVER
2003 G.listen_fd = -1; 2006 G_listen_fd = -1;
2004 if (opts & OPT_l) { 2007 if (opts & OPT_l) {
2005 G.listen_fd = create_and_bind_dgram_or_die(NULL, 123); 2008 G_listen_fd = create_and_bind_dgram_or_die(NULL, 123);
2006 socket_want_pktinfo(G.listen_fd); 2009 socket_want_pktinfo(G_listen_fd);
2007 setsockopt(G.listen_fd, IPPROTO_IP, IP_TOS, &const_IPTOS_LOWDELAY, sizeof(const_IPTOS_LOWDELAY)); 2010 setsockopt(G_listen_fd, IPPROTO_IP, IP_TOS, &const_IPTOS_LOWDELAY, sizeof(const_IPTOS_LOWDELAY));
2008 } 2011 }
2009#endif 2012#endif
2010 /* I hesitate to set -20 prio. -15 should be high enough for timekeeping */ 2013 /* I hesitate to set -20 prio. -15 should be high enough for timekeeping */
@@ -2078,8 +2081,8 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
2078 2081
2079 i = 0; 2082 i = 0;
2080#if ENABLE_FEATURE_NTPD_SERVER 2083#if ENABLE_FEATURE_NTPD_SERVER
2081 if (G.listen_fd != -1) { 2084 if (G_listen_fd != -1) {
2082 pfd[0].fd = G.listen_fd; 2085 pfd[0].fd = G_listen_fd;
2083 pfd[0].events = POLLIN; 2086 pfd[0].events = POLLIN;
2084 i++; 2087 i++;
2085 } 2088 }
@@ -2125,7 +2128,7 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
2125 2128
2126 /* Here we may block */ 2129 /* Here we may block */
2127 VERB2 { 2130 VERB2 {
2128 if (i > (ENABLE_FEATURE_NTPD_SERVER && G.listen_fd != -1)) { 2131 if (i > (ENABLE_FEATURE_NTPD_SERVER && G_listen_fd != -1)) {
2129 /* We wait for at least one reply. 2132 /* We wait for at least one reply.
2130 * Poll for it, without wasting time for message. 2133 * Poll for it, without wasting time for message.
2131 * Since replies often come under 1 second, this also 2134 * Since replies often come under 1 second, this also