diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-01-29 10:33:34 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-01-29 10:33:34 +0000 |
commit | 8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15 (patch) | |
tree | 998a337ecd57b737423a3793365519213f97da72 /networking/tftp.c | |
parent | c882f341cec8451ee87af6746abb7208272d5b1a (diff) | |
download | busybox-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.
Diffstat (limited to 'networking/tftp.c')
-rw-r--r-- | networking/tftp.c | 16 |
1 files changed, 8 insertions, 8 deletions
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 | ||