diff options
author | Bernhard Reutner-Fischer | 2008-01-29 10:33:34 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer | 2008-01-29 10:33:34 +0000 |
commit | 8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15 (patch) | |
tree | 998a337ecd57b737423a3793365519213f97da72 /networking | |
parent | c882f341cec8451ee87af6746abb7208272d5b1a (diff) | |
download | busybox-8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15.zip busybox-8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15.tar.gz |
- 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.
Diffstat (limited to 'networking')
-rw-r--r-- | networking/arping.c | 2 | ||||
-rw-r--r-- | networking/dnsd.c | 10 | ||||
-rw-r--r-- | networking/ftpgetput.c | 2 | ||||
-rw-r--r-- | networking/httpd.c | 22 | ||||
-rw-r--r-- | networking/ifconfig.c | 6 | ||||
-rw-r--r-- | networking/nc.c | 6 | ||||
-rw-r--r-- | networking/ping.c | 20 | ||||
-rw-r--r-- | networking/pscan.c | 4 | ||||
-rw-r--r-- | networking/tftp.c | 16 | ||||
-rw-r--r-- | networking/udhcp/files.c | 2 | ||||
-rw-r--r-- | networking/wget.c | 2 |
11 files changed, 46 insertions, 46 deletions
diff --git a/networking/arping.c b/networking/arping.c index 6383f9a..f71a984 100644 --- a/networking/arping.c +++ b/networking/arping.c @@ -311,7 +311,7 @@ int arping_main(int argc, char **argv) /* if (!inet_aton(target, &dst)) - not needed */ { len_and_sockaddr *lsa; lsa = xhost_and_af2sockaddr(target, 0, AF_INET); - memcpy(&dst, &lsa->sin.sin_addr.s_addr, 4); + memcpy(&dst, &lsa->u.sin.sin_addr.s_addr, 4); if (ENABLE_FEATURE_CLEAN_UP) free(lsa); } diff --git a/networking/dnsd.c b/networking/dnsd.c index 19720d6..5e78861 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c @@ -371,11 +371,11 @@ int dnsd_main(int argc, char **argv) #endif lsa = xdotted2sockaddr(listen_interface, port); - udps = xsocket(lsa->sa.sa_family, SOCK_DGRAM, 0); - xbind(udps, &lsa->sa, lsa->len); + udps = xsocket(lsa->u.sa.sa_family, SOCK_DGRAM, 0); + xbind(udps, &lsa->u.sa, lsa->len); /* xlisten(udps, 50); - ?!! DGRAM sockets are never listened on I think? */ bb_info_msg("Accepting UDP packets on %s", - xmalloc_sockaddr2dotted(&lsa->sa)); + xmalloc_sockaddr2dotted(&lsa->u.sa)); while (1) { int r; @@ -385,7 +385,7 @@ int dnsd_main(int argc, char **argv) // Or else we can exhibit usual UDP ugliness: // [ip1.multihomed.ip2] <= query to ip1 <= peer // [ip1.multihomed.ip2] => reply from ip2 => peer (confused) - r = recvfrom(udps, buf, sizeof(buf), 0, &lsa->sa, &fromlen); + r = recvfrom(udps, buf, sizeof(buf), 0, &lsa->u.sa, &fromlen); if (OPT_verbose) bb_info_msg("Got UDP packet"); if (r < 12 || r > 512) { @@ -395,7 +395,7 @@ int dnsd_main(int argc, char **argv) r = process_packet(buf); if (r <= 0) continue; - sendto(udps, buf, r, 0, &lsa->sa, fromlen); + sendto(udps, buf, r, 0, &lsa->u.sa, fromlen); } return 0; } diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 587f000..de11f91 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c @@ -348,7 +348,7 @@ int ftpgetput_main(int argc, char **argv) server->lsa = xhost2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21)); if (verbose_flag) { printf("Connecting to %s (%s)\n", argv[0], - xmalloc_sockaddr2dotted(&server->lsa->sa)); + xmalloc_sockaddr2dotted(&server->lsa->u.sa)); } /* Connect/Setup/Configure the FTP session */ diff --git a/networking/httpd.c b/networking/httpd.c index 7294975..0f18b0f 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -1781,18 +1781,18 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) iobuf = xmalloc(IOBUF_SIZE); rmt_ip = 0; - if (fromAddr->sa.sa_family == AF_INET) { - rmt_ip = ntohl(fromAddr->sin.sin_addr.s_addr); + if (fromAddr->u.sa.sa_family == AF_INET) { + rmt_ip = ntohl(fromAddr->u.sin.sin_addr.s_addr); } #if ENABLE_FEATURE_IPV6 - if (fromAddr->sa.sa_family == AF_INET6 - && fromAddr->sin6.sin6_addr.s6_addr32[0] == 0 - && fromAddr->sin6.sin6_addr.s6_addr32[1] == 0 - && ntohl(fromAddr->sin6.sin6_addr.s6_addr32[2]) == 0xffff) - rmt_ip = ntohl(fromAddr->sin6.sin6_addr.s6_addr32[3]); + if (fromAddr->u.sa.sa_family == AF_INET6 + && fromAddr->u.sin6.sin6_addr.s6_addr32[0] == 0 + && fromAddr->u.sin6.sin6_addr.s6_addr32[1] == 0 + && ntohl(fromAddr->u.sin6.sin6_addr.s6_addr32[2]) == 0xffff) + rmt_ip = ntohl(fromAddr->u.sin6.sin6_addr.s6_addr32[3]); #endif if (ENABLE_FEATURE_HTTPD_CGI || DEBUG || verbose) { - rmt_ip_str = xmalloc_sockaddr2dotted(&fromAddr->sa); + rmt_ip_str = xmalloc_sockaddr2dotted(&fromAddr->u.sa); } if (verbose) { /* this trick makes -v logging much simpler */ @@ -2047,7 +2047,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) lsa = host2sockaddr(proxy_entry->host_port, 80); if (lsa == NULL) send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR); - if (connect(proxy_fd, &lsa->sa, lsa->len) < 0) + if (connect(proxy_fd, &lsa->u.sa, lsa->len) < 0) send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR); fdprintf(proxy_fd, "%s %s%s%s%s HTTP/%c.%c\r\n", prequest, /* GET or POST */ @@ -2140,7 +2140,7 @@ static void mini_httpd(int server_socket) /* Wait for connections... */ fromAddr.len = LSA_SIZEOF_SA; - n = accept(server_socket, &fromAddr.sa, &fromAddr.len); + n = accept(server_socket, &fromAddr.u.sa, &fromAddr.len); if (n < 0) continue; @@ -2222,7 +2222,7 @@ static void mini_httpd_inetd(void) len_and_sockaddr fromAddr; fromAddr.len = LSA_SIZEOF_SA; - getpeername(0, &fromAddr.sa, &fromAddr.len); + getpeername(0, &fromAddr.u.sa, &fromAddr.len); handle_incoming_and_exit(&fromAddr); } diff --git a/networking/ifconfig.c b/networking/ifconfig.c index fff5f5d..fcbeb24 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -392,12 +392,12 @@ int ifconfig_main(int argc, char **argv) continue; /* compat stuff */ lsa = xhost2sockaddr(host, 0); #if ENABLE_FEATURE_IPV6 - if (lsa->sa.sa_family == AF_INET6) { + if (lsa->u.sa.sa_family == AF_INET6) { int sockfd6; struct in6_ifreq ifr6; memcpy((char *) &ifr6.ifr6_addr, - (char *) &(lsa->sin6.sin6_addr), + (char *) &(lsa->u.sin6.sin6_addr), sizeof(struct in6_addr)); /* Create a channel to the NET kernel. */ @@ -411,7 +411,7 @@ int ifconfig_main(int argc, char **argv) continue; } #endif - sai.sin_addr = lsa->sin.sin_addr; + sai.sin_addr = lsa->u.sin.sin_addr; if (ENABLE_FEATURE_CLEAN_UP) free(lsa); } diff --git a/networking/nc.c b/networking/nc.c index b2f590a..feb9c5d 100644 --- a/networking/nc.c +++ b/networking/nc.c @@ -103,14 +103,14 @@ int nc_main(int argc, char **argv) if (lport) set_nport(lsa, htons(lport)); setsockopt_reuseaddr(sfd); - xbind(sfd, &lsa->sa, lsa->len); + xbind(sfd, &lsa->u.sa, lsa->len); xlisten(sfd, do_listen); /* can be > 1 */ /* If we didn't specify a port number, * query and print it after listen() */ if (!lport) { socklen_t addrlen = lsa->len; - getsockname(sfd, &lsa->sa, &addrlen); - lport = get_nport(&lsa->sa); + getsockname(sfd, &lsa->u.sa, &addrlen); + lport = get_nport(&lsa->u.sa); fdprintf(2, "%d\n", ntohs(lport)); } close_on_exec_on(sfd); diff --git a/networking/ping.c b/networking/ping.c index 0b33abf..382389d 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -209,7 +209,7 @@ int ping_main(int argc, char **argv) alarm(5); /* give the host 5000ms to respond */ #if ENABLE_PING6 - if (lsa->sa.sa_family == AF_INET6) + if (lsa->u.sa.sa_family == AF_INET6) ping6(lsa); else #endif @@ -532,12 +532,12 @@ static void ping4(len_and_sockaddr *lsa) int sockopt; pingsock = create_icmp_socket(); - pingaddr.sin = lsa->sin; + pingaddr.sin = lsa->u.sin; if (source_lsa) { if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF, - &source_lsa->sa, source_lsa->len)) + &source_lsa->u.sa, source_lsa->len)) bb_error_msg_and_die("can't set multicast source interface"); - xbind(pingsock, &source_lsa->sa, source_lsa->len); + xbind(pingsock, &source_lsa->u.sa, source_lsa->len); } if (opt_I) setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, opt_I, strlen(opt_I) + 1); @@ -584,10 +584,10 @@ static void ping6(len_and_sockaddr *lsa) char control_buf[CMSG_SPACE(36)]; pingsock = create_icmp6_socket(); - pingaddr.sin6 = lsa->sin6; + pingaddr.sin6 = lsa->u.sin6; /* untested whether "-I addr" really works for IPv6: */ if (source_lsa) - xbind(pingsock, &source_lsa->sa, source_lsa->len); + xbind(pingsock, &source_lsa->u.sa, source_lsa->len); if (opt_I) setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, opt_I, strlen(opt_I) + 1); @@ -670,12 +670,12 @@ static void ping(len_and_sockaddr *lsa) printf("PING %s (%s)", hostname, dotted); if (source_lsa) { printf(" from %s", - xmalloc_sockaddr2dotted_noport(&source_lsa->sa)); + xmalloc_sockaddr2dotted_noport(&source_lsa->u.sa)); } printf(": %d data bytes\n", datalen); #if ENABLE_PING6 - if (lsa->sa.sa_family == AF_INET6) + if (lsa->u.sa.sa_family == AF_INET6) ping6(lsa); else #endif @@ -720,11 +720,11 @@ int ping_main(int argc, char **argv) lsa = xhost_and_af2sockaddr(hostname, 0, AF_INET); #endif - if (source_lsa && source_lsa->sa.sa_family != lsa->sa.sa_family) + if (source_lsa && source_lsa->u.sa.sa_family != lsa->u.sa.sa_family) /* leaking it here... */ source_lsa = NULL; - dotted = xmalloc_sockaddr2dotted_noport(&lsa->sa); + dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); ping(lsa); pingstats(0); return EXIT_SUCCESS; diff --git a/networking/pscan.c b/networking/pscan.c index d18f8db..8304193 100644 --- a/networking/pscan.c +++ b/networking/pscan.c @@ -73,14 +73,14 @@ int pscan_main(int argc, char **argv) /* The SOCK_STREAM socket type is implemented on the TCP/IP protocol. */ set_nport(lsap, htons(port)); - s = xsocket(lsap->sa.sa_family, SOCK_STREAM, 0); + s = xsocket(lsap->u.sa.sa_family, SOCK_STREAM, 0); /* We need unblocking socket so we don't need to wait for ETIMEOUT. */ /* Nonblocking connect typically "fails" with errno == EINPROGRESS */ ndelay_on(s); DMSG("connect to port %u", port); start = MONOTONIC_US(); - if (connect(s, &lsap->sa, lsap->len) == 0) { + if (connect(s, &lsap->u.sa, lsap->len) == 0) { /* Unlikely, for me even localhost fails :) */ DMSG("connect succeeded"); goto open; diff --git a/networking/tftp.c b/networking/tftp.c index a268397..737ae78 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -127,7 +127,7 @@ static int tftp( USE_GETPUT(const int cmd,) char *cp; unsigned org_port; - len_and_sockaddr *const from = alloca(offsetof(len_and_sockaddr, sa) + peer_lsa->len); + len_and_sockaddr *const from = alloca(offsetof(len_and_sockaddr, u.sa) + peer_lsa->len); /* Can't use RESERVE_CONFIG_BUFFER here since the allocation * size varies meaning BUFFERS_GO_ON_STACK would fail */ @@ -138,7 +138,7 @@ static int tftp( USE_GETPUT(const int cmd,) port = org_port = htons(port); - socketfd = xsocket(peer_lsa->sa.sa_family, SOCK_DGRAM, 0); + socketfd = xsocket(peer_lsa->u.sa.sa_family, SOCK_DGRAM, 0); /* build opcode */ opcode = TFTP_WRQ; @@ -216,7 +216,7 @@ static int tftp( USE_GETPUT(const int cmd,) fprintf(stderr, "%02x ", (unsigned char) *cp); fprintf(stderr, "\n"); #endif - xsendto(socketfd, xbuf, send_len, &peer_lsa->sa, peer_lsa->len); + xsendto(socketfd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); /* Was it final ACK? then exit */ if (finished && (opcode == TFTP_ACK)) goto ret; @@ -229,14 +229,14 @@ static int tftp( USE_GETPUT(const int cmd,) unsigned from_port; case 1: from->len = peer_lsa->len; - memset(&from->sa, 0, peer_lsa->len); + memset(&from->u.sa, 0, peer_lsa->len); len = recvfrom(socketfd, rbuf, tftp_bufsize, 0, - &from->sa, &from->len); + &from->u.sa, &from->len); if (len < 0) { bb_perror_msg("recvfrom"); goto ret; } - from_port = get_nport(&from->sa); + from_port = get_nport(&from->u.sa); if (port == org_port) { /* Our first query went to port 69 * but reply will come from different one. @@ -316,7 +316,7 @@ static int tftp( USE_GETPUT(const int cmd,) /*static const uint16_t error_8[2] = { htons(TFTP_ERROR), htons(8) };*/ /* thus we open-code big-endian layout */ static const uint8_t error_8[4] = { 0,TFTP_ERROR, 0,8 }; - xsendto(socketfd, error_8, 4, &peer_lsa->sa, peer_lsa->len); + xsendto(socketfd, error_8, 4, &peer_lsa->u.sa, peer_lsa->len); bb_error_msg("server proposes bad blksize %d, exiting", blksize); goto ret; } @@ -449,7 +449,7 @@ int tftp_main(int argc, char **argv) #if ENABLE_DEBUG_TFTP fprintf(stderr, "using server '%s', remotefile '%s', localfile '%s'\n", - xmalloc_sockaddr2dotted(&peer_lsa->sa), + xmalloc_sockaddr2dotted(&peer_lsa->u.sa), remotefile, localfile); #endif diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 491b887..5bf1a49 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c @@ -19,7 +19,7 @@ static int read_ip(const char *line, void *arg) lsa = host_and_af2sockaddr(line, 0, AF_INET); if (!lsa) return 0; - *(uint32_t*)arg = lsa->sin.sin_addr.s_addr; + *(uint32_t*)arg = lsa->u.sin.sin_addr.s_addr; free(lsa); return 1; } diff --git a/networking/wget.c b/networking/wget.c index 1147077..6c1c385 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -535,7 +535,7 @@ int wget_main(int argc, char **argv) lsa = xhost2sockaddr(server.host, server.port); if (!(opt & WGET_OPT_QUIET)) { fprintf(stderr, "Connecting to %s (%s)\n", server.host, - xmalloc_sockaddr2dotted(&lsa->sa)); + xmalloc_sockaddr2dotted(&lsa->u.sa)); /* We leak result of xmalloc_sockaddr2dotted */ } |