aboutsummaryrefslogtreecommitdiff
path: root/networking/ntpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-03 00:20:58 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-03 00:20:58 +0100
commit6a110c969f357d5ab3503660c6404a1ee9d916eb (patch)
tree1b340877fc1ff3d8ae26e8709e84f05eb87782b9 /networking/ntpd.c
parent7cb1d6ccf36eccb294bd26e1c6da6866e7fc0ab7 (diff)
downloadbusybox-w32-6a110c969f357d5ab3503660c6404a1ee9d916eb.tar.gz
busybox-w32-6a110c969f357d5ab3503660c6404a1ee9d916eb.tar.bz2
busybox-w32-6a110c969f357d5ab3503660c6404a1ee9d916eb.zip
ntpd: remove dynamic dns resolution code, too complex. -69 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r--networking/ntpd.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 375f009a6..ca79e0338 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -108,7 +108,6 @@ typedef struct {
108#define OFFSET_ARRAY_SIZE 8 108#define OFFSET_ARRAY_SIZE 8
109typedef struct { 109typedef struct {
110 len_and_sockaddr *lsa; 110 len_and_sockaddr *lsa;
111 char *hostname;
112 char *dotted; 111 char *dotted;
113 /* When to send new query (if fd == -1) 112 /* When to send new query (if fd == -1)
114 * or when receive times out (if fd >= 0): */ 113 * or when receive times out (if fd >= 0): */
@@ -166,24 +165,14 @@ set_next(ntp_peer_t *p, unsigned t)
166 p->next_action_time = time(NULL) + t; 165 p->next_action_time = time(NULL) + t;
167} 166}
168 167
169static len_and_sockaddr*
170resolve_hostname(ntp_peer_t *p)
171{
172 p->lsa = host2sockaddr(p->hostname, 123);
173 if (p->lsa)
174 p->dotted = xmalloc_sockaddr2dotted_noport(&p->lsa->u.sa);
175 return p->lsa;
176}
177
178static void 168static void
179add_peers(char *s) 169add_peers(char *s)
180{ 170{
181 ntp_peer_t *p; 171 ntp_peer_t *p;
182 172
183 p = xzalloc(sizeof(*p)); 173 p = xzalloc(sizeof(*p));
184 p->hostname = s; 174 p->lsa = xhost2sockaddr(s, 123);
185 p->dotted = s; 175 p->dotted = xmalloc_sockaddr2dotted_noport(&p->lsa->u.sa);
186 resolve_hostname(p);
187 p->fd = -1; 176 p->fd = -1;
188 p->msg.m_status = MODE_CLIENT | (NTP_VERSION << 3); 177 p->msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
189 p->trustlevel = TRUSTLEVEL_PATHETIC; 178 p->trustlevel = TRUSTLEVEL_PATHETIC;
@@ -307,15 +296,6 @@ send_query_to_peer(ntp_peer_t *p)
307 int fd, family; 296 int fd, family;
308 len_and_sockaddr *local_lsa; 297 len_and_sockaddr *local_lsa;
309 298
310//TODO: big ntpd uses all IPs, not just 1st, do we need to mimic that?
311//TODO: periodically re-resolve DNS names?
312 if (!p->lsa) {
313 if (!resolve_hostname(p)) {
314 set_next(p, INTERVAL_QUERY_PATHETIC);
315 return -1;
316 }
317 }
318
319 family = p->lsa->u.sa.sa_family; 299 family = p->lsa->u.sa.sa_family;
320 p->fd = fd = xsocket_type(&local_lsa, family, SOCK_DGRAM); 300 p->fd = fd = xsocket_type(&local_lsa, family, SOCK_DGRAM);
321 /* local_lsa has "null" address and port 0 now. 301 /* local_lsa has "null" address and port 0 now.