aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-01-29 10:33:34 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-01-29 10:33:34 +0000
commit8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15 (patch)
tree998a337ecd57b737423a3793365519213f97da72
parentc882f341cec8451ee87af6746abb7208272d5b1a (diff)
downloadbusybox-w32-8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15.tar.gz
busybox-w32-8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15.tar.bz2
busybox-w32-8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15.zip
- be C99 friendly. Anonymous unions are a GNU extension. This change is
size-neutral WRT -std=gnu99 and fixes several compilation errors for strict C99 mode.
-rw-r--r--include/libbb.h2
-rw-r--r--include/platform.h7
-rw-r--r--ipsvd/tcpudp.c38
-rw-r--r--libbb/xconnect.c28
-rw-r--r--networking/arping.c2
-rw-r--r--networking/dnsd.c10
-rw-r--r--networking/ftpgetput.c2
-rw-r--r--networking/httpd.c22
-rw-r--r--networking/ifconfig.c6
-rw-r--r--networking/nc.c6
-rw-r--r--networking/ping.c20
-rw-r--r--networking/pscan.c4
-rw-r--r--networking/tftp.c16
-rw-r--r--networking/udhcp/files.c2
-rw-r--r--networking/wget.c2
-rw-r--r--procps/top.c24
-rw-r--r--sysklogd/syslogd.c4
-rw-r--r--util-linux/mount.c2
18 files changed, 98 insertions, 99 deletions
diff --git a/include/libbb.h b/include/libbb.h
index c5b685985..525162d05 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -340,7 +340,7 @@ typedef struct len_and_sockaddr {
340#if ENABLE_FEATURE_IPV6 340#if ENABLE_FEATURE_IPV6
341 struct sockaddr_in6 sin6; 341 struct sockaddr_in6 sin6;
342#endif 342#endif
343 }; 343 } u;
344} len_and_sockaddr; 344} len_and_sockaddr;
345enum { 345enum {
346 LSA_SIZEOF_SA = sizeof( 346 LSA_SIZEOF_SA = sizeof(
diff --git a/include/platform.h b/include/platform.h
index 1706de0bf..2daa077af 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -154,12 +154,11 @@ typedef int socklen_t;
154 154
155/* linux/loop.h relies on __u64. Make sure we have that as a proper type 155/* linux/loop.h relies on __u64. Make sure we have that as a proper type
156 * until userspace is widely fixed. */ 156 * until userspace is widely fixed. */
157#ifndef __GNUC__ 157#if (defined __INTEL_COMPILER && !defined __GNUC__) || \
158#if defined __INTEL_COMPILER 158 (defined __GNUC__ && defined __STRICT_ANSI__)
159__extension__ typedef __signed__ long long __s64; 159__extension__ typedef __signed__ long long __s64;
160__extension__ typedef unsigned long long __u64; 160__extension__ typedef unsigned long long __u64;
161#endif /* __INTEL_COMPILER */ 161#endif
162#endif /* ifndef __GNUC__ */
163 162
164/*----- Kernel versioning ------------------------------------*/ 163/*----- Kernel versioning ------------------------------------*/
165#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 164#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
diff --git a/ipsvd/tcpudp.c b/ipsvd/tcpudp.c
index 6187eb985..dc61d6f76 100644
--- a/ipsvd/tcpudp.c
+++ b/ipsvd/tcpudp.c
@@ -254,10 +254,10 @@ int tcpudpsvd_main(int argc, char **argv)
254 254
255 local_port = bb_lookup_port(argv[1], tcp ? "tcp" : "udp", 0); 255 local_port = bb_lookup_port(argv[1], tcp ? "tcp" : "udp", 0);
256 lsa = xhost2sockaddr(argv[0], local_port); 256 lsa = xhost2sockaddr(argv[0], local_port);
257 sock = xsocket(lsa->sa.sa_family, tcp ? SOCK_STREAM : SOCK_DGRAM, 0); 257 sock = xsocket(lsa->u.sa.sa_family, tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
258 setsockopt_reuseaddr(sock); 258 setsockopt_reuseaddr(sock);
259 sa_len = lsa->len; /* I presume sockaddr len stays the same */ 259 sa_len = lsa->len; /* I presume sockaddr len stays the same */
260 xbind(sock, &lsa->sa, sa_len); 260 xbind(sock, &lsa->u.sa, sa_len);
261 if (tcp) 261 if (tcp)
262 xlisten(sock, backlog); 262 xlisten(sock, backlog);
263 else /* udp: needed for recv_from_to to work: */ 263 else /* udp: needed for recv_from_to to work: */
@@ -273,7 +273,7 @@ int tcpudpsvd_main(int argc, char **argv)
273#endif 273#endif
274 274
275 if (verbose) { 275 if (verbose) {
276 char *addr = xmalloc_sockaddr2dotted(&lsa->sa); 276 char *addr = xmalloc_sockaddr2dotted(&lsa->u.sa);
277 printf("%s: info: listening on %s", applet_name, addr); 277 printf("%s: info: listening on %s", applet_name, addr);
278 free(addr); 278 free(addr);
279#ifndef SSLSVD 279#ifndef SSLSVD
@@ -299,12 +299,12 @@ int tcpudpsvd_main(int argc, char **argv)
299 sig_unblock(SIGCHLD); 299 sig_unblock(SIGCHLD);
300 if (tcp) { 300 if (tcp) {
301 remote.len = sa_len; 301 remote.len = sa_len;
302 conn = accept(sock, &remote.sa, &remote.len); 302 conn = accept(sock, &remote.u.sa, &remote.len);
303 } else { 303 } else {
304 /* In case recv_from_to won't be able to recover local addr. 304 /* In case recv_from_to won't be able to recover local addr.
305 * Also sets port - recv_from_to is unable to do it. */ 305 * Also sets port - recv_from_to is unable to do it. */
306 local = *lsa; 306 local = *lsa;
307 conn = recv_from_to(sock, NULL, 0, MSG_PEEK, &remote.sa, &local.sa, sa_len); 307 conn = recv_from_to(sock, NULL, 0, MSG_PEEK, &remote.u.sa, &local.u.sa, sa_len);
308 } 308 }
309 sig_block(SIGCHLD); 309 sig_block(SIGCHLD);
310 if (conn < 0) { 310 if (conn < 0) {
@@ -317,7 +317,7 @@ int tcpudpsvd_main(int argc, char **argv)
317 if (max_per_host) { 317 if (max_per_host) {
318 /* Drop connection immediately if cur_per_host > max_per_host 318 /* Drop connection immediately if cur_per_host > max_per_host
319 * (minimizing load under SYN flood) */ 319 * (minimizing load under SYN flood) */
320 remote_ip = xmalloc_sockaddr2dotted_noport(&remote.sa); 320 remote_ip = xmalloc_sockaddr2dotted_noport(&remote.u.sa);
321 cur_per_host = ipsvd_perhost_add(remote_ip, max_per_host, &hccp); 321 cur_per_host = ipsvd_perhost_add(remote_ip, max_per_host, &hccp);
322 if (cur_per_host > max_per_host) { 322 if (cur_per_host > max_per_host) {
323 /* ipsvd_perhost_add detected that max is exceeded 323 /* ipsvd_perhost_add detected that max is exceeded
@@ -342,14 +342,14 @@ int tcpudpsvd_main(int argc, char **argv)
342 /* Make plain write/send work for this socket by supplying default 342 /* Make plain write/send work for this socket by supplying default
343 * destination address. This also restricts incoming packets 343 * destination address. This also restricts incoming packets
344 * to ones coming from this remote IP. */ 344 * to ones coming from this remote IP. */
345 xconnect(0, &remote.sa, sa_len); 345 xconnect(0, &remote.u.sa, sa_len);
346 /* hole? at this point we have no wildcard udp socket... 346 /* hole? at this point we have no wildcard udp socket...
347 * can this cause clients to get "port unreachable" icmp? 347 * can this cause clients to get "port unreachable" icmp?
348 * Yup, time window is very small, but it exists (is it?) */ 348 * Yup, time window is very small, but it exists (is it?) */
349 /* Open new non-connected UDP socket for further clients */ 349 /* Open new non-connected UDP socket for further clients */
350 sock = xsocket(lsa->sa.sa_family, tcp ? SOCK_STREAM : SOCK_DGRAM, 0); 350 sock = xsocket(lsa->u.sa.sa_family, tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
351 setsockopt_reuseaddr(sock); 351 setsockopt_reuseaddr(sock);
352 xbind(sock, &lsa->sa, sa_len); 352 xbind(sock, &lsa->u.sa, sa_len);
353 socket_want_pktinfo(sock); 353 socket_want_pktinfo(sock);
354 354
355 /* Doesn't work: 355 /* Doesn't work:
@@ -358,16 +358,16 @@ int tcpudpsvd_main(int argc, char **argv)
358 * instead - it will "intercept" all following packets, but child 358 * instead - it will "intercept" all following packets, but child
359 * does not expect data coming *from fd #1*! */ 359 * does not expect data coming *from fd #1*! */
360#if 0 360#if 0
361 /* Make it so that local addr is fixed to localp->sa 361 /* Make it so that local addr is fixed to localp->u.sa
362 * and we don't accidentally accept packets to other local IPs. */ 362 * and we don't accidentally accept packets to other local IPs. */
363 /* NB: we possibly bind to the _very_ same_ address & port as the one 363 /* NB: we possibly bind to the _very_ same_ address & port as the one
364 * already bound in parent! This seems to work in Linux. 364 * already bound in parent! This seems to work in Linux.
365 * (otherwise we can move socket to fd #0 only if bind succeeds) */ 365 * (otherwise we can move socket to fd #0 only if bind succeeds) */
366 close(0); 366 close(0);
367 set_nport(localp, htons(local_port)); 367 set_nport(localp, htons(local_port));
368 xmove_fd(xsocket(localp->sa.sa_family, SOCK_DGRAM, 0), 0); 368 xmove_fd(xsocket(localp->u.sa.sa_family, SOCK_DGRAM, 0), 0);
369 setsockopt_reuseaddr(0); /* crucial */ 369 setsockopt_reuseaddr(0); /* crucial */
370 xbind(0, &localp->sa, localp->len); 370 xbind(0, &localp->u.sa, localp->len);
371#endif 371#endif
372 } 372 }
373 373
@@ -395,11 +395,11 @@ int tcpudpsvd_main(int argc, char **argv)
395 close(sock); 395 close(sock);
396 396
397 if (need_remote_ip) 397 if (need_remote_ip)
398 remote_addr = xmalloc_sockaddr2dotted(&remote.sa); 398 remote_addr = xmalloc_sockaddr2dotted(&remote.u.sa);
399 399
400 if (need_hostnames) { 400 if (need_hostnames) {
401 if (option_mask32 & OPT_h) { 401 if (option_mask32 & OPT_h) {
402 remote_hostname = xmalloc_sockaddr2host_noport(&remote.sa); 402 remote_hostname = xmalloc_sockaddr2host_noport(&remote.u.sa);
403 if (!remote_hostname) { 403 if (!remote_hostname) {
404 bb_error_msg("warning: cannot look up hostname for %s", remote_addr); 404 bb_error_msg("warning: cannot look up hostname for %s", remote_addr);
405 remote_hostname = (char*)""; 405 remote_hostname = (char*)"";
@@ -410,11 +410,11 @@ int tcpudpsvd_main(int argc, char **argv)
410 * which doesn't know local IP). */ 410 * which doesn't know local IP). */
411 if (tcp) { 411 if (tcp) {
412 local.len = sa_len; 412 local.len = sa_len;
413 getsockname(0, &local.sa, &local.len); 413 getsockname(0, &local.u.sa, &local.len);
414 } 414 }
415 local_addr = xmalloc_sockaddr2dotted(&local.sa); 415 local_addr = xmalloc_sockaddr2dotted(&local.u.sa);
416 if (!local_hostname) { 416 if (!local_hostname) {
417 local_hostname = xmalloc_sockaddr2host_noport(&local.sa); 417 local_hostname = xmalloc_sockaddr2host_noport(&local.u.sa);
418 if (!local_hostname) 418 if (!local_hostname)
419 bb_error_msg_and_die("warning: cannot look up hostname for %s"+9, local_addr); 419 bb_error_msg_and_die("warning: cannot look up hostname for %s"+9, local_addr);
420 } 420 }
@@ -440,8 +440,8 @@ int tcpudpsvd_main(int argc, char **argv)
440 * from Linux firewall. Useful when you redirect 440 * from Linux firewall. Useful when you redirect
441 * an outbond connection to local handler, and it needs 441 * an outbond connection to local handler, and it needs
442 * to know where it originally tried to connect */ 442 * to know where it originally tried to connect */
443 if (tcp && getsockopt(0, SOL_IP, SO_ORIGINAL_DST, &lsa->sa, &lsa->len) == 0) { 443 if (tcp && getsockopt(0, SOL_IP, SO_ORIGINAL_DST, &lsa->u.sa, &lsa->len) == 0) {
444 char *addr = xmalloc_sockaddr2dotted(&lsa->sa); 444 char *addr = xmalloc_sockaddr2dotted(&lsa->u.sa);
445 xsetenv("TCPORIGDSTADDR", addr); 445 xsetenv("TCPORIGDSTADDR", addr);
446 free(addr); 446 free(addr);
447 } 447 }
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 91c12f4d3..03ae77329 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -99,13 +99,13 @@ int get_nport(const struct sockaddr *sa)
99void set_nport(len_and_sockaddr *lsa, unsigned port) 99void set_nport(len_and_sockaddr *lsa, unsigned port)
100{ 100{
101#if ENABLE_FEATURE_IPV6 101#if ENABLE_FEATURE_IPV6
102 if (lsa->sa.sa_family == AF_INET6) { 102 if (lsa->u.sa.sa_family == AF_INET6) {
103 lsa->sin6.sin6_port = port; 103 lsa->u.sin6.sin6_port = port;
104 return; 104 return;
105 } 105 }
106#endif 106#endif
107 if (lsa->sa.sa_family == AF_INET) { 107 if (lsa->u.sa.sa_family == AF_INET) {
108 lsa->sin.sin_port = port; 108 lsa->u.sin.sin_port = port;
109 return; 109 return;
110 } 110 }
111 /* What? UNIX socket? IPX?? :) */ 111 /* What? UNIX socket? IPX?? :) */
@@ -182,9 +182,9 @@ USE_FEATURE_IPV6(sa_family_t af,)
182 } 182 }
183 } 183 }
184#endif 184#endif
185 r = xmalloc(offsetof(len_and_sockaddr, sa) + used_res->ai_addrlen); 185 r = xmalloc(offsetof(len_and_sockaddr, u.sa) + used_res->ai_addrlen);
186 r->len = used_res->ai_addrlen; 186 r->len = used_res->ai_addrlen;
187 memcpy(&r->sa, used_res->ai_addr, used_res->ai_addrlen); 187 memcpy(&r->u.sa, used_res->ai_addr, used_res->ai_addrlen);
188 set_nport(r, htons(port)); 188 set_nport(r, htons(port));
189 ret: 189 ret:
190 freeaddrinfo(result); 190 freeaddrinfo(result);
@@ -246,9 +246,9 @@ int xsocket_type(len_and_sockaddr **lsap, USE_FEATURE_IPV6(int family,) int sock
246 len = sizeof(struct sockaddr_in6); 246 len = sizeof(struct sockaddr_in6);
247 } 247 }
248#endif 248#endif
249 lsa = xzalloc(offsetof(len_and_sockaddr, sa) + len); 249 lsa = xzalloc(offsetof(len_and_sockaddr, u.sa) + len);
250 lsa->len = len; 250 lsa->len = len;
251 lsa->sa.sa_family = family; 251 lsa->u.sa.sa_family = family;
252 *lsap = lsa; 252 *lsap = lsa;
253 return fd; 253 return fd;
254} 254}
@@ -266,13 +266,13 @@ static int create_and_bind_or_die(const char *bindaddr, int port, int sock_type)
266 if (bindaddr && bindaddr[0]) { 266 if (bindaddr && bindaddr[0]) {
267 lsa = xdotted2sockaddr(bindaddr, port); 267 lsa = xdotted2sockaddr(bindaddr, port);
268 /* user specified bind addr dictates family */ 268 /* user specified bind addr dictates family */
269 fd = xsocket(lsa->sa.sa_family, sock_type, 0); 269 fd = xsocket(lsa->u.sa.sa_family, sock_type, 0);
270 } else { 270 } else {
271 fd = xsocket_type(&lsa, USE_FEATURE_IPV6(AF_UNSPEC,) sock_type); 271 fd = xsocket_type(&lsa, USE_FEATURE_IPV6(AF_UNSPEC,) sock_type);
272 set_nport(lsa, htons(port)); 272 set_nport(lsa, htons(port));
273 } 273 }
274 setsockopt_reuseaddr(fd); 274 setsockopt_reuseaddr(fd);
275 xbind(fd, &lsa->sa, lsa->len); 275 xbind(fd, &lsa->u.sa, lsa->len);
276 free(lsa); 276 free(lsa);
277 return fd; 277 return fd;
278} 278}
@@ -294,17 +294,17 @@ int create_and_connect_stream_or_die(const char *peer, int port)
294 len_and_sockaddr *lsa; 294 len_and_sockaddr *lsa;
295 295
296 lsa = xhost2sockaddr(peer, port); 296 lsa = xhost2sockaddr(peer, port);
297 fd = xsocket(lsa->sa.sa_family, SOCK_STREAM, 0); 297 fd = xsocket(lsa->u.sa.sa_family, SOCK_STREAM, 0);
298 setsockopt_reuseaddr(fd); 298 setsockopt_reuseaddr(fd);
299 xconnect(fd, &lsa->sa, lsa->len); 299 xconnect(fd, &lsa->u.sa, lsa->len);
300 free(lsa); 300 free(lsa);
301 return fd; 301 return fd;
302} 302}
303 303
304int xconnect_stream(const len_and_sockaddr *lsa) 304int xconnect_stream(const len_and_sockaddr *lsa)
305{ 305{
306 int fd = xsocket(lsa->sa.sa_family, SOCK_STREAM, 0); 306 int fd = xsocket(lsa->u.sa.sa_family, SOCK_STREAM, 0);
307 xconnect(fd, &lsa->sa, lsa->len); 307 xconnect(fd, &lsa->u.sa, lsa->len);
308 return fd; 308 return fd;
309} 309}
310 310
diff --git a/networking/arping.c b/networking/arping.c
index 6383f9a88..f71a98498 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -311,7 +311,7 @@ int arping_main(int argc, char **argv)
311 /* if (!inet_aton(target, &dst)) - not needed */ { 311 /* if (!inet_aton(target, &dst)) - not needed */ {
312 len_and_sockaddr *lsa; 312 len_and_sockaddr *lsa;
313 lsa = xhost_and_af2sockaddr(target, 0, AF_INET); 313 lsa = xhost_and_af2sockaddr(target, 0, AF_INET);
314 memcpy(&dst, &lsa->sin.sin_addr.s_addr, 4); 314 memcpy(&dst, &lsa->u.sin.sin_addr.s_addr, 4);
315 if (ENABLE_FEATURE_CLEAN_UP) 315 if (ENABLE_FEATURE_CLEAN_UP)
316 free(lsa); 316 free(lsa);
317 } 317 }
diff --git a/networking/dnsd.c b/networking/dnsd.c
index 19720d6bc..5e7886167 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -371,11 +371,11 @@ int dnsd_main(int argc, char **argv)
371#endif 371#endif
372 372
373 lsa = xdotted2sockaddr(listen_interface, port); 373 lsa = xdotted2sockaddr(listen_interface, port);
374 udps = xsocket(lsa->sa.sa_family, SOCK_DGRAM, 0); 374 udps = xsocket(lsa->u.sa.sa_family, SOCK_DGRAM, 0);
375 xbind(udps, &lsa->sa, lsa->len); 375 xbind(udps, &lsa->u.sa, lsa->len);
376 /* xlisten(udps, 50); - ?!! DGRAM sockets are never listened on I think? */ 376 /* xlisten(udps, 50); - ?!! DGRAM sockets are never listened on I think? */
377 bb_info_msg("Accepting UDP packets on %s", 377 bb_info_msg("Accepting UDP packets on %s",
378 xmalloc_sockaddr2dotted(&lsa->sa)); 378 xmalloc_sockaddr2dotted(&lsa->u.sa));
379 379
380 while (1) { 380 while (1) {
381 int r; 381 int r;
@@ -385,7 +385,7 @@ int dnsd_main(int argc, char **argv)
385// Or else we can exhibit usual UDP ugliness: 385// Or else we can exhibit usual UDP ugliness:
386// [ip1.multihomed.ip2] <= query to ip1 <= peer 386// [ip1.multihomed.ip2] <= query to ip1 <= peer
387// [ip1.multihomed.ip2] => reply from ip2 => peer (confused) 387// [ip1.multihomed.ip2] => reply from ip2 => peer (confused)
388 r = recvfrom(udps, buf, sizeof(buf), 0, &lsa->sa, &fromlen); 388 r = recvfrom(udps, buf, sizeof(buf), 0, &lsa->u.sa, &fromlen);
389 if (OPT_verbose) 389 if (OPT_verbose)
390 bb_info_msg("Got UDP packet"); 390 bb_info_msg("Got UDP packet");
391 if (r < 12 || r > 512) { 391 if (r < 12 || r > 512) {
@@ -395,7 +395,7 @@ int dnsd_main(int argc, char **argv)
395 r = process_packet(buf); 395 r = process_packet(buf);
396 if (r <= 0) 396 if (r <= 0)
397 continue; 397 continue;
398 sendto(udps, buf, r, 0, &lsa->sa, fromlen); 398 sendto(udps, buf, r, 0, &lsa->u.sa, fromlen);
399 } 399 }
400 return 0; 400 return 0;
401} 401}
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 587f000ce..de11f912e 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -348,7 +348,7 @@ int ftpgetput_main(int argc, char **argv)
348 server->lsa = xhost2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21)); 348 server->lsa = xhost2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21));
349 if (verbose_flag) { 349 if (verbose_flag) {
350 printf("Connecting to %s (%s)\n", argv[0], 350 printf("Connecting to %s (%s)\n", argv[0],
351 xmalloc_sockaddr2dotted(&server->lsa->sa)); 351 xmalloc_sockaddr2dotted(&server->lsa->u.sa));
352 } 352 }
353 353
354 /* Connect/Setup/Configure the FTP session */ 354 /* Connect/Setup/Configure the FTP session */
diff --git a/networking/httpd.c b/networking/httpd.c
index 72949755a..0f18b0fd0 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1781,18 +1781,18 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
1781 iobuf = xmalloc(IOBUF_SIZE); 1781 iobuf = xmalloc(IOBUF_SIZE);
1782 1782
1783 rmt_ip = 0; 1783 rmt_ip = 0;
1784 if (fromAddr->sa.sa_family == AF_INET) { 1784 if (fromAddr->u.sa.sa_family == AF_INET) {
1785 rmt_ip = ntohl(fromAddr->sin.sin_addr.s_addr); 1785 rmt_ip = ntohl(fromAddr->u.sin.sin_addr.s_addr);
1786 } 1786 }
1787#if ENABLE_FEATURE_IPV6 1787#if ENABLE_FEATURE_IPV6
1788 if (fromAddr->sa.sa_family == AF_INET6 1788 if (fromAddr->u.sa.sa_family == AF_INET6
1789 && fromAddr->sin6.sin6_addr.s6_addr32[0] == 0 1789 && fromAddr->u.sin6.sin6_addr.s6_addr32[0] == 0
1790 && fromAddr->sin6.sin6_addr.s6_addr32[1] == 0 1790 && fromAddr->u.sin6.sin6_addr.s6_addr32[1] == 0
1791 && ntohl(fromAddr->sin6.sin6_addr.s6_addr32[2]) == 0xffff) 1791 && ntohl(fromAddr->u.sin6.sin6_addr.s6_addr32[2]) == 0xffff)
1792 rmt_ip = ntohl(fromAddr->sin6.sin6_addr.s6_addr32[3]); 1792 rmt_ip = ntohl(fromAddr->u.sin6.sin6_addr.s6_addr32[3]);
1793#endif 1793#endif
1794 if (ENABLE_FEATURE_HTTPD_CGI || DEBUG || verbose) { 1794 if (ENABLE_FEATURE_HTTPD_CGI || DEBUG || verbose) {
1795 rmt_ip_str = xmalloc_sockaddr2dotted(&fromAddr->sa); 1795 rmt_ip_str = xmalloc_sockaddr2dotted(&fromAddr->u.sa);
1796 } 1796 }
1797 if (verbose) { 1797 if (verbose) {
1798 /* this trick makes -v logging much simpler */ 1798 /* this trick makes -v logging much simpler */
@@ -2047,7 +2047,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
2047 lsa = host2sockaddr(proxy_entry->host_port, 80); 2047 lsa = host2sockaddr(proxy_entry->host_port, 80);
2048 if (lsa == NULL) 2048 if (lsa == NULL)
2049 send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR); 2049 send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);
2050 if (connect(proxy_fd, &lsa->sa, lsa->len) < 0) 2050 if (connect(proxy_fd, &lsa->u.sa, lsa->len) < 0)
2051 send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR); 2051 send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);
2052 fdprintf(proxy_fd, "%s %s%s%s%s HTTP/%c.%c\r\n", 2052 fdprintf(proxy_fd, "%s %s%s%s%s HTTP/%c.%c\r\n",
2053 prequest, /* GET or POST */ 2053 prequest, /* GET or POST */
@@ -2140,7 +2140,7 @@ static void mini_httpd(int server_socket)
2140 2140
2141 /* Wait for connections... */ 2141 /* Wait for connections... */
2142 fromAddr.len = LSA_SIZEOF_SA; 2142 fromAddr.len = LSA_SIZEOF_SA;
2143 n = accept(server_socket, &fromAddr.sa, &fromAddr.len); 2143 n = accept(server_socket, &fromAddr.u.sa, &fromAddr.len);
2144 2144
2145 if (n < 0) 2145 if (n < 0)
2146 continue; 2146 continue;
@@ -2222,7 +2222,7 @@ static void mini_httpd_inetd(void)
2222 len_and_sockaddr fromAddr; 2222 len_and_sockaddr fromAddr;
2223 2223
2224 fromAddr.len = LSA_SIZEOF_SA; 2224 fromAddr.len = LSA_SIZEOF_SA;
2225 getpeername(0, &fromAddr.sa, &fromAddr.len); 2225 getpeername(0, &fromAddr.u.sa, &fromAddr.len);
2226 handle_incoming_and_exit(&fromAddr); 2226 handle_incoming_and_exit(&fromAddr);
2227} 2227}
2228 2228
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index fff5f5d2e..fcbeb2420 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -392,12 +392,12 @@ int ifconfig_main(int argc, char **argv)
392 continue; /* compat stuff */ 392 continue; /* compat stuff */
393 lsa = xhost2sockaddr(host, 0); 393 lsa = xhost2sockaddr(host, 0);
394#if ENABLE_FEATURE_IPV6 394#if ENABLE_FEATURE_IPV6
395 if (lsa->sa.sa_family == AF_INET6) { 395 if (lsa->u.sa.sa_family == AF_INET6) {
396 int sockfd6; 396 int sockfd6;
397 struct in6_ifreq ifr6; 397 struct in6_ifreq ifr6;
398 398
399 memcpy((char *) &ifr6.ifr6_addr, 399 memcpy((char *) &ifr6.ifr6_addr,
400 (char *) &(lsa->sin6.sin6_addr), 400 (char *) &(lsa->u.sin6.sin6_addr),
401 sizeof(struct in6_addr)); 401 sizeof(struct in6_addr));
402 402
403 /* Create a channel to the NET kernel. */ 403 /* Create a channel to the NET kernel. */
@@ -411,7 +411,7 @@ int ifconfig_main(int argc, char **argv)
411 continue; 411 continue;
412 } 412 }
413#endif 413#endif
414 sai.sin_addr = lsa->sin.sin_addr; 414 sai.sin_addr = lsa->u.sin.sin_addr;
415 if (ENABLE_FEATURE_CLEAN_UP) 415 if (ENABLE_FEATURE_CLEAN_UP)
416 free(lsa); 416 free(lsa);
417 } 417 }
diff --git a/networking/nc.c b/networking/nc.c
index b2f590adf..feb9c5db6 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -103,14 +103,14 @@ int nc_main(int argc, char **argv)
103 if (lport) 103 if (lport)
104 set_nport(lsa, htons(lport)); 104 set_nport(lsa, htons(lport));
105 setsockopt_reuseaddr(sfd); 105 setsockopt_reuseaddr(sfd);
106 xbind(sfd, &lsa->sa, lsa->len); 106 xbind(sfd, &lsa->u.sa, lsa->len);
107 xlisten(sfd, do_listen); /* can be > 1 */ 107 xlisten(sfd, do_listen); /* can be > 1 */
108 /* If we didn't specify a port number, 108 /* If we didn't specify a port number,
109 * query and print it after listen() */ 109 * query and print it after listen() */
110 if (!lport) { 110 if (!lport) {
111 socklen_t addrlen = lsa->len; 111 socklen_t addrlen = lsa->len;
112 getsockname(sfd, &lsa->sa, &addrlen); 112 getsockname(sfd, &lsa->u.sa, &addrlen);
113 lport = get_nport(&lsa->sa); 113 lport = get_nport(&lsa->u.sa);
114 fdprintf(2, "%d\n", ntohs(lport)); 114 fdprintf(2, "%d\n", ntohs(lport));
115 } 115 }
116 close_on_exec_on(sfd); 116 close_on_exec_on(sfd);
diff --git a/networking/ping.c b/networking/ping.c
index 0b33abf9a..382389dc2 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -209,7 +209,7 @@ int ping_main(int argc, char **argv)
209 alarm(5); /* give the host 5000ms to respond */ 209 alarm(5); /* give the host 5000ms to respond */
210 210
211#if ENABLE_PING6 211#if ENABLE_PING6
212 if (lsa->sa.sa_family == AF_INET6) 212 if (lsa->u.sa.sa_family == AF_INET6)
213 ping6(lsa); 213 ping6(lsa);
214 else 214 else
215#endif 215#endif
@@ -532,12 +532,12 @@ static void ping4(len_and_sockaddr *lsa)
532 int sockopt; 532 int sockopt;
533 533
534 pingsock = create_icmp_socket(); 534 pingsock = create_icmp_socket();
535 pingaddr.sin = lsa->sin; 535 pingaddr.sin = lsa->u.sin;
536 if (source_lsa) { 536 if (source_lsa) {
537 if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF, 537 if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF,
538 &source_lsa->sa, source_lsa->len)) 538 &source_lsa->u.sa, source_lsa->len))
539 bb_error_msg_and_die("can't set multicast source interface"); 539 bb_error_msg_and_die("can't set multicast source interface");
540 xbind(pingsock, &source_lsa->sa, source_lsa->len); 540 xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
541 } 541 }
542 if (opt_I) 542 if (opt_I)
543 setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, opt_I, strlen(opt_I) + 1); 543 setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, opt_I, strlen(opt_I) + 1);
@@ -584,10 +584,10 @@ static void ping6(len_and_sockaddr *lsa)
584 char control_buf[CMSG_SPACE(36)]; 584 char control_buf[CMSG_SPACE(36)];
585 585
586 pingsock = create_icmp6_socket(); 586 pingsock = create_icmp6_socket();
587 pingaddr.sin6 = lsa->sin6; 587 pingaddr.sin6 = lsa->u.sin6;
588 /* untested whether "-I addr" really works for IPv6: */ 588 /* untested whether "-I addr" really works for IPv6: */
589 if (source_lsa) 589 if (source_lsa)
590 xbind(pingsock, &source_lsa->sa, source_lsa->len); 590 xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
591 if (opt_I) 591 if (opt_I)
592 setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, opt_I, strlen(opt_I) + 1); 592 setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, opt_I, strlen(opt_I) + 1);
593 593
@@ -670,12 +670,12 @@ static void ping(len_and_sockaddr *lsa)
670 printf("PING %s (%s)", hostname, dotted); 670 printf("PING %s (%s)", hostname, dotted);
671 if (source_lsa) { 671 if (source_lsa) {
672 printf(" from %s", 672 printf(" from %s",
673 xmalloc_sockaddr2dotted_noport(&source_lsa->sa)); 673 xmalloc_sockaddr2dotted_noport(&source_lsa->u.sa));
674 } 674 }
675 printf(": %d data bytes\n", datalen); 675 printf(": %d data bytes\n", datalen);
676 676
677#if ENABLE_PING6 677#if ENABLE_PING6
678 if (lsa->sa.sa_family == AF_INET6) 678 if (lsa->u.sa.sa_family == AF_INET6)
679 ping6(lsa); 679 ping6(lsa);
680 else 680 else
681#endif 681#endif
@@ -720,11 +720,11 @@ int ping_main(int argc, char **argv)
720 lsa = xhost_and_af2sockaddr(hostname, 0, AF_INET); 720 lsa = xhost_and_af2sockaddr(hostname, 0, AF_INET);
721#endif 721#endif
722 722
723 if (source_lsa && source_lsa->sa.sa_family != lsa->sa.sa_family) 723 if (source_lsa && source_lsa->u.sa.sa_family != lsa->u.sa.sa_family)
724 /* leaking it here... */ 724 /* leaking it here... */
725 source_lsa = NULL; 725 source_lsa = NULL;
726 726
727 dotted = xmalloc_sockaddr2dotted_noport(&lsa->sa); 727 dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
728 ping(lsa); 728 ping(lsa);
729 pingstats(0); 729 pingstats(0);
730 return EXIT_SUCCESS; 730 return EXIT_SUCCESS;
diff --git a/networking/pscan.c b/networking/pscan.c
index d18f8dbd9..830419371 100644
--- a/networking/pscan.c
+++ b/networking/pscan.c
@@ -73,14 +73,14 @@ int pscan_main(int argc, char **argv)
73 73
74 /* The SOCK_STREAM socket type is implemented on the TCP/IP protocol. */ 74 /* The SOCK_STREAM socket type is implemented on the TCP/IP protocol. */
75 set_nport(lsap, htons(port)); 75 set_nport(lsap, htons(port));
76 s = xsocket(lsap->sa.sa_family, SOCK_STREAM, 0); 76 s = xsocket(lsap->u.sa.sa_family, SOCK_STREAM, 0);
77 77
78 /* We need unblocking socket so we don't need to wait for ETIMEOUT. */ 78 /* We need unblocking socket so we don't need to wait for ETIMEOUT. */
79 /* Nonblocking connect typically "fails" with errno == EINPROGRESS */ 79 /* Nonblocking connect typically "fails" with errno == EINPROGRESS */
80 ndelay_on(s); 80 ndelay_on(s);
81 DMSG("connect to port %u", port); 81 DMSG("connect to port %u", port);
82 start = MONOTONIC_US(); 82 start = MONOTONIC_US();
83 if (connect(s, &lsap->sa, lsap->len) == 0) { 83 if (connect(s, &lsap->u.sa, lsap->len) == 0) {
84 /* Unlikely, for me even localhost fails :) */ 84 /* Unlikely, for me even localhost fails :) */
85 DMSG("connect succeeded"); 85 DMSG("connect succeeded");
86 goto open; 86 goto open;
diff --git a/networking/tftp.c b/networking/tftp.c
index a2683971a..737ae7893 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -127,7 +127,7 @@ static int tftp( USE_GETPUT(const int cmd,)
127 char *cp; 127 char *cp;
128 128
129 unsigned org_port; 129 unsigned org_port;
130 len_and_sockaddr *const from = alloca(offsetof(len_and_sockaddr, sa) + peer_lsa->len); 130 len_and_sockaddr *const from = alloca(offsetof(len_and_sockaddr, u.sa) + peer_lsa->len);
131 131
132 /* Can't use RESERVE_CONFIG_BUFFER here since the allocation 132 /* Can't use RESERVE_CONFIG_BUFFER here since the allocation
133 * size varies meaning BUFFERS_GO_ON_STACK would fail */ 133 * size varies meaning BUFFERS_GO_ON_STACK would fail */
@@ -138,7 +138,7 @@ static int tftp( USE_GETPUT(const int cmd,)
138 138
139 port = org_port = htons(port); 139 port = org_port = htons(port);
140 140
141 socketfd = xsocket(peer_lsa->sa.sa_family, SOCK_DGRAM, 0); 141 socketfd = xsocket(peer_lsa->u.sa.sa_family, SOCK_DGRAM, 0);
142 142
143 /* build opcode */ 143 /* build opcode */
144 opcode = TFTP_WRQ; 144 opcode = TFTP_WRQ;
@@ -216,7 +216,7 @@ static int tftp( USE_GETPUT(const int cmd,)
216 fprintf(stderr, "%02x ", (unsigned char) *cp); 216 fprintf(stderr, "%02x ", (unsigned char) *cp);
217 fprintf(stderr, "\n"); 217 fprintf(stderr, "\n");
218#endif 218#endif
219 xsendto(socketfd, xbuf, send_len, &peer_lsa->sa, peer_lsa->len); 219 xsendto(socketfd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len);
220 /* Was it final ACK? then exit */ 220 /* Was it final ACK? then exit */
221 if (finished && (opcode == TFTP_ACK)) 221 if (finished && (opcode == TFTP_ACK))
222 goto ret; 222 goto ret;
@@ -229,14 +229,14 @@ static int tftp( USE_GETPUT(const int cmd,)
229 unsigned from_port; 229 unsigned from_port;
230 case 1: 230 case 1:
231 from->len = peer_lsa->len; 231 from->len = peer_lsa->len;
232 memset(&from->sa, 0, peer_lsa->len); 232 memset(&from->u.sa, 0, peer_lsa->len);
233 len = recvfrom(socketfd, rbuf, tftp_bufsize, 0, 233 len = recvfrom(socketfd, rbuf, tftp_bufsize, 0,
234 &from->sa, &from->len); 234 &from->u.sa, &from->len);
235 if (len < 0) { 235 if (len < 0) {
236 bb_perror_msg("recvfrom"); 236 bb_perror_msg("recvfrom");
237 goto ret; 237 goto ret;
238 } 238 }
239 from_port = get_nport(&from->sa); 239 from_port = get_nport(&from->u.sa);
240 if (port == org_port) { 240 if (port == org_port) {
241 /* Our first query went to port 69 241 /* Our first query went to port 69
242 * but reply will come from different one. 242 * but reply will come from different one.
@@ -316,7 +316,7 @@ static int tftp( USE_GETPUT(const int cmd,)
316 /*static const uint16_t error_8[2] = { htons(TFTP_ERROR), htons(8) };*/ 316 /*static const uint16_t error_8[2] = { htons(TFTP_ERROR), htons(8) };*/
317 /* thus we open-code big-endian layout */ 317 /* thus we open-code big-endian layout */
318 static const uint8_t error_8[4] = { 0,TFTP_ERROR, 0,8 }; 318 static const uint8_t error_8[4] = { 0,TFTP_ERROR, 0,8 };
319 xsendto(socketfd, error_8, 4, &peer_lsa->sa, peer_lsa->len); 319 xsendto(socketfd, error_8, 4, &peer_lsa->u.sa, peer_lsa->len);
320 bb_error_msg("server proposes bad blksize %d, exiting", blksize); 320 bb_error_msg("server proposes bad blksize %d, exiting", blksize);
321 goto ret; 321 goto ret;
322 } 322 }
@@ -449,7 +449,7 @@ int tftp_main(int argc, char **argv)
449 449
450#if ENABLE_DEBUG_TFTP 450#if ENABLE_DEBUG_TFTP
451 fprintf(stderr, "using server '%s', remotefile '%s', localfile '%s'\n", 451 fprintf(stderr, "using server '%s', remotefile '%s', localfile '%s'\n",
452 xmalloc_sockaddr2dotted(&peer_lsa->sa), 452 xmalloc_sockaddr2dotted(&peer_lsa->u.sa),
453 remotefile, localfile); 453 remotefile, localfile);
454#endif 454#endif
455 455
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 491b8871e..5bf1a491c 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -19,7 +19,7 @@ static int read_ip(const char *line, void *arg)
19 lsa = host_and_af2sockaddr(line, 0, AF_INET); 19 lsa = host_and_af2sockaddr(line, 0, AF_INET);
20 if (!lsa) 20 if (!lsa)
21 return 0; 21 return 0;
22 *(uint32_t*)arg = lsa->sin.sin_addr.s_addr; 22 *(uint32_t*)arg = lsa->u.sin.sin_addr.s_addr;
23 free(lsa); 23 free(lsa);
24 return 1; 24 return 1;
25} 25}
diff --git a/networking/wget.c b/networking/wget.c
index 1147077e0..6c1c385b7 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -535,7 +535,7 @@ int wget_main(int argc, char **argv)
535 lsa = xhost2sockaddr(server.host, server.port); 535 lsa = xhost2sockaddr(server.host, server.port);
536 if (!(opt & WGET_OPT_QUIET)) { 536 if (!(opt & WGET_OPT_QUIET)) {
537 fprintf(stderr, "Connecting to %s (%s)\n", server.host, 537 fprintf(stderr, "Connecting to %s (%s)\n", server.host,
538 xmalloc_sockaddr2dotted(&lsa->sa)); 538 xmalloc_sockaddr2dotted(&lsa->u.sa));
539 /* We leak result of xmalloc_sockaddr2dotted */ 539 /* We leak result of xmalloc_sockaddr2dotted */
540 } 540 }
541 541
diff --git a/procps/top.c b/procps/top.c
index fc393d43b..4df58f227 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -594,20 +594,20 @@ static void display_topmem_header(int scr_width)
594 /* 9 */ char *anon; 594 /* 9 */ char *anon;
595 /* 10 */ char *map; 595 /* 10 */ char *map;
596 /* 11 */ char *slab; 596 /* 11 */ char *slab;
597 }; 597 } u;
598 char *str[11]; 598 char *str[11];
599 } Z; 599 } Z;
600#define total Z.total 600#define total Z.u.total
601#define mfree Z.mfree 601#define mfree Z.u.mfree
602#define buf Z.buf 602#define buf Z.u.buf
603#define cache Z.cache 603#define cache Z.u.cache
604#define swaptotal Z.swaptotal 604#define swaptotal Z.u.swaptotal
605#define swapfree Z.swapfree 605#define swapfree Z.u.swapfree
606#define dirty Z.dirty 606#define dirty Z.u.dirty
607#define mwrite Z.mwrite 607#define mwrite Z.u.mwrite
608#define anon Z.anon 608#define anon Z.u.anon
609#define map Z.map 609#define map Z.u.map
610#define slab Z.slab 610#define slab Z.u.slab
611#define str Z.str 611#define str Z.str
612 612
613 memset(&Z, 0, sizeof(Z)); 613 memset(&Z, 0, sizeof(Z));
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index de8aa04a8..f3ebf9392 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -525,7 +525,7 @@ static int try_to_resolve_remote(void)
525 if (!G.remoteAddr) 525 if (!G.remoteAddr)
526 return -1; 526 return -1;
527 } 527 }
528 return socket(G.remoteAddr->sa.sa_family, SOCK_DGRAM, 0); 528 return socket(G.remoteAddr->u.sa.sa_family, SOCK_DGRAM, 0);
529} 529}
530#endif 530#endif
531 531
@@ -592,7 +592,7 @@ static void do_syslogd(void)
592 } 592 }
593 /* send message to remote logger, ignore possible error */ 593 /* send message to remote logger, ignore possible error */
594 sendto(G.remoteFD, G.recvbuf, sz, MSG_DONTWAIT, 594 sendto(G.remoteFD, G.recvbuf, sz, MSG_DONTWAIT,
595 &G.remoteAddr->sa, G.remoteAddr->len); 595 &G.remoteAddr->u.sa, G.remoteAddr->len);
596 no_luck: ; 596 no_luck: ;
597 } 597 }
598#endif 598#endif
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 0b440ef16..4ac52cd02 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -1496,7 +1496,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1496 1496
1497 // insert ip=... option into string flags. 1497 // insert ip=... option into string flags.
1498 1498
1499 dotted = xmalloc_sockaddr2dotted_noport(&lsa->sa); 1499 dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
1500 ip = xasprintf("ip=%s", dotted); 1500 ip = xasprintf("ip=%s", dotted);
1501 parse_mount_options(ip, &filteropts); 1501 parse_mount_options(ip, &filteropts);
1502 1502