diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-02 16:23:43 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-02 16:23:43 +0000 |
commit | 7cff01ec2dcdd04657fca1b5c572cb2b53d2d4aa (patch) | |
tree | d88f37c62c8753e68f99f2136831efc3ebf239bf /networking/nc_bloaty.c | |
parent | 0b2b5842a1c47bc7a3f872e9d06ab2bcc2cf4be8 (diff) | |
download | busybox-w32-7cff01ec2dcdd04657fca1b5c572cb2b53d2d4aa.tar.gz busybox-w32-7cff01ec2dcdd04657fca1b5c572cb2b53d2d4aa.tar.bz2 busybox-w32-7cff01ec2dcdd04657fca1b5c572cb2b53d2d4aa.zip |
nc: fix fallout from C99 standard compliance change
Diffstat (limited to 'networking/nc_bloaty.c')
-rw-r--r-- | networking/nc_bloaty.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index cbc0a6471..0b9428b71 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* Based on netcat 1.10 RELEASE 960320 written by hobbit@avian.org. | 1 | /* Based on netcat 1.10 RELEASE 960320 written by hobbit@avian.org. |
2 | * Released into public domain by the author. | 2 | * Released into public domain by the author. |
3 | * | 3 | * |
4 | * Copyright (C) 2007 Denis Vlasenko. | 4 | * Copyright (C) 2007 Denys Vlasenko. |
5 | * | 5 | * |
6 | * Licensed under GPLv2, see file LICENSE in this tarball for details. | 6 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
7 | */ | 7 | */ |
@@ -243,7 +243,7 @@ static int connect_w_timeout(int fd) | |||
243 | /* wrap connect inside a timer, and hit it */ | 243 | /* wrap connect inside a timer, and hit it */ |
244 | arm(o_wait); | 244 | arm(o_wait); |
245 | if (setjmp(jbuf) == 0) { | 245 | if (setjmp(jbuf) == 0) { |
246 | rr = connect(fd, &themaddr->sa, themaddr->len); | 246 | rr = connect(fd, &themaddr->u.sa, themaddr->len); |
247 | unarm(); | 247 | unarm(); |
248 | } else { /* setjmp: connect failed... */ | 248 | } else { /* setjmp: connect failed... */ |
249 | rr = -1; | 249 | rr = -1; |
@@ -275,10 +275,10 @@ static void dolisten(void) | |||
275 | random unknown port is probably not very useful without "netstat". */ | 275 | random unknown port is probably not very useful without "netstat". */ |
276 | if (o_verbose) { | 276 | if (o_verbose) { |
277 | char *addr; | 277 | char *addr; |
278 | rr = getsockname(netfd, &ouraddr->sa, &ouraddr->len); | 278 | rr = getsockname(netfd, &ouraddr->u.sa, &ouraddr->len); |
279 | if (rr < 0) | 279 | if (rr < 0) |
280 | bb_perror_msg_and_die("getsockname after bind"); | 280 | bb_perror_msg_and_die("getsockname after bind"); |
281 | addr = xmalloc_sockaddr2dotted(&ouraddr->sa); | 281 | addr = xmalloc_sockaddr2dotted(&ouraddr->u.sa); |
282 | fprintf(stderr, "listening on %s ...\n", addr); | 282 | fprintf(stderr, "listening on %s ...\n", addr); |
283 | free(addr); | 283 | free(addr); |
284 | } | 284 | } |
@@ -306,7 +306,7 @@ static void dolisten(void) | |||
306 | remend.len = LSA_SIZEOF_SA; | 306 | remend.len = LSA_SIZEOF_SA; |
307 | if (themaddr) { | 307 | if (themaddr) { |
308 | remend = *themaddr; | 308 | remend = *themaddr; |
309 | xconnect(netfd, &themaddr->sa, themaddr->len); | 309 | xconnect(netfd, &themaddr->u.sa, themaddr->len); |
310 | } | 310 | } |
311 | /* peek first packet and remember peer addr */ | 311 | /* peek first packet and remember peer addr */ |
312 | arm(o_wait); /* might as well timeout this, too */ | 312 | arm(o_wait); /* might as well timeout this, too */ |
@@ -314,7 +314,7 @@ static void dolisten(void) | |||
314 | /* (*ouraddr) is prefilled with "default" address */ | 314 | /* (*ouraddr) is prefilled with "default" address */ |
315 | /* and here we block... */ | 315 | /* and here we block... */ |
316 | rr = recv_from_to(netfd, NULL, 0, MSG_PEEK, /*was bigbuf_net, BIGSIZ*/ | 316 | rr = recv_from_to(netfd, NULL, 0, MSG_PEEK, /*was bigbuf_net, BIGSIZ*/ |
317 | &remend.sa, &ouraddr->sa, ouraddr->len); | 317 | &remend.u.sa, &ouraddr->u.sa, ouraddr->len); |
318 | if (rr < 0) | 318 | if (rr < 0) |
319 | bb_perror_msg_and_die("recvfrom"); | 319 | bb_perror_msg_and_die("recvfrom"); |
320 | unarm(); | 320 | unarm(); |
@@ -323,25 +323,25 @@ static void dolisten(void) | |||
323 | /* Now we learned *to which IP* peer has connected, and we want to anchor | 323 | /* Now we learned *to which IP* peer has connected, and we want to anchor |
324 | our socket on it, so that our outbound packets will have correct local IP. | 324 | our socket on it, so that our outbound packets will have correct local IP. |
325 | Unfortunately, bind() on already bound socket will fail now (EINVAL): | 325 | Unfortunately, bind() on already bound socket will fail now (EINVAL): |
326 | xbind(netfd, &ouraddr->sa, ouraddr->len); | 326 | xbind(netfd, &ouraddr->u.sa, ouraddr->len); |
327 | Need to read the packet, save data, close this socket and | 327 | Need to read the packet, save data, close this socket and |
328 | create new one, and bind() it. TODO */ | 328 | create new one, and bind() it. TODO */ |
329 | if (!themaddr) | 329 | if (!themaddr) |
330 | xconnect(netfd, &remend.sa, ouraddr->len); | 330 | xconnect(netfd, &remend.u.sa, ouraddr->len); |
331 | } else { | 331 | } else { |
332 | /* TCP */ | 332 | /* TCP */ |
333 | arm(o_wait); /* wrap this in a timer, too; 0 = forever */ | 333 | arm(o_wait); /* wrap this in a timer, too; 0 = forever */ |
334 | if (setjmp(jbuf) == 0) { | 334 | if (setjmp(jbuf) == 0) { |
335 | again: | 335 | again: |
336 | remend.len = LSA_SIZEOF_SA; | 336 | remend.len = LSA_SIZEOF_SA; |
337 | rr = accept(netfd, &remend.sa, &remend.len); | 337 | rr = accept(netfd, &remend.u.sa, &remend.len); |
338 | if (rr < 0) | 338 | if (rr < 0) |
339 | bb_perror_msg_and_die("accept"); | 339 | bb_perror_msg_and_die("accept"); |
340 | if (themaddr && memcmp(&remend.sa, &themaddr->sa, remend.len) != 0) { | 340 | if (themaddr && memcmp(&remend.u.sa, &themaddr->u.sa, remend.len) != 0) { |
341 | /* nc 1.10 bails out instead, and its error message | 341 | /* nc 1.10 bails out instead, and its error message |
342 | * is not suppressed by o_verbose */ | 342 | * is not suppressed by o_verbose */ |
343 | if (o_verbose) { | 343 | if (o_verbose) { |
344 | char *remaddr = xmalloc_sockaddr2dotted(&remend.sa); | 344 | char *remaddr = xmalloc_sockaddr2dotted(&remend.u.sa); |
345 | bb_error_msg("connect from wrong ip/port %s ignored", remaddr); | 345 | bb_error_msg("connect from wrong ip/port %s ignored", remaddr); |
346 | free(remaddr); | 346 | free(remaddr); |
347 | } | 347 | } |
@@ -356,7 +356,7 @@ create new one, and bind() it. TODO */ | |||
356 | doing a listen-on-any on a multihomed machine. This allows one to | 356 | doing a listen-on-any on a multihomed machine. This allows one to |
357 | offer different services via different alias addresses, such as the | 357 | offer different services via different alias addresses, such as the |
358 | "virtual web site" hack. */ | 358 | "virtual web site" hack. */ |
359 | rr = getsockname(netfd, &ouraddr->sa, &ouraddr->len); | 359 | rr = getsockname(netfd, &ouraddr->u.sa, &ouraddr->len); |
360 | if (rr < 0) | 360 | if (rr < 0) |
361 | bb_perror_msg_and_die("getsockname after accept"); | 361 | bb_perror_msg_and_die("getsockname after accept"); |
362 | } | 362 | } |
@@ -393,9 +393,9 @@ create new one, and bind() it. TODO */ | |||
393 | accept the connection and then reject undesireable ones by closing. | 393 | accept the connection and then reject undesireable ones by closing. |
394 | In other words, we need a TCP MSG_PEEK. */ | 394 | In other words, we need a TCP MSG_PEEK. */ |
395 | /* bbox: removed most of it */ | 395 | /* bbox: removed most of it */ |
396 | lcladdr = xmalloc_sockaddr2dotted(&ouraddr->sa); | 396 | lcladdr = xmalloc_sockaddr2dotted(&ouraddr->u.sa); |
397 | remaddr = xmalloc_sockaddr2dotted(&remend.sa); | 397 | remaddr = xmalloc_sockaddr2dotted(&remend.u.sa); |
398 | remhostname = o_nflag ? remaddr : xmalloc_sockaddr2host(&remend.sa); | 398 | remhostname = o_nflag ? remaddr : xmalloc_sockaddr2host(&remend.u.sa); |
399 | fprintf(stderr, "connect to %s from %s (%s)\n", | 399 | fprintf(stderr, "connect to %s from %s (%s)\n", |
400 | lcladdr, remhostname, remaddr); | 400 | lcladdr, remhostname, remaddr); |
401 | free(lcladdr); | 401 | free(lcladdr); |
@@ -433,7 +433,7 @@ static int udptest(void) | |||
433 | /* Set a temporary connect timeout, so packet filtration doesnt cause | 433 | /* Set a temporary connect timeout, so packet filtration doesnt cause |
434 | us to hang forever, and hit it */ | 434 | us to hang forever, and hit it */ |
435 | o_wait = 5; /* enough that we'll notice?? */ | 435 | o_wait = 5; /* enough that we'll notice?? */ |
436 | rr = xsocket(ouraddr->sa.sa_family, SOCK_STREAM, 0); | 436 | rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0); |
437 | set_nport(themaddr, htons(SLEAZE_PORT)); | 437 | set_nport(themaddr, htons(SLEAZE_PORT)); |
438 | connect_w_timeout(rr); | 438 | connect_w_timeout(rr); |
439 | /* don't need to restore themaddr's port, it's not used anymore */ | 439 | /* don't need to restore themaddr's port, it's not used anymore */ |
@@ -746,12 +746,12 @@ int nc_main(int argc, char **argv) | |||
746 | if (option_mask32 & OPT_s) { /* local address */ | 746 | if (option_mask32 & OPT_s) { /* local address */ |
747 | /* if o_lport is still 0, then we will use random port */ | 747 | /* if o_lport is still 0, then we will use random port */ |
748 | ouraddr = xhost2sockaddr(str_s, o_lport); | 748 | ouraddr = xhost2sockaddr(str_s, o_lport); |
749 | x = xsocket(ouraddr->sa.sa_family, x, 0); | 749 | x = xsocket(ouraddr->u.sa.sa_family, x, 0); |
750 | } else { | 750 | } else { |
751 | /* We try IPv6, then IPv4, unless addr family is | 751 | /* We try IPv6, then IPv4, unless addr family is |
752 | * implicitly set by way of remote addr/port spec */ | 752 | * implicitly set by way of remote addr/port spec */ |
753 | x = xsocket_type(&ouraddr, | 753 | x = xsocket_type(&ouraddr, |
754 | USE_FEATURE_IPV6((themaddr ? themaddr->sa.sa_family : AF_UNSPEC),) | 754 | USE_FEATURE_IPV6((themaddr ? themaddr->u.sa.sa_family : AF_UNSPEC),) |
755 | x); | 755 | x); |
756 | if (o_lport) | 756 | if (o_lport) |
757 | set_nport(ouraddr, htons(o_lport)); | 757 | set_nport(ouraddr, htons(o_lport)); |
@@ -760,7 +760,7 @@ int nc_main(int argc, char **argv) | |||
760 | setsockopt_reuseaddr(netfd); | 760 | setsockopt_reuseaddr(netfd); |
761 | if (o_udpmode) | 761 | if (o_udpmode) |
762 | socket_want_pktinfo(netfd); | 762 | socket_want_pktinfo(netfd); |
763 | xbind(netfd, &ouraddr->sa, ouraddr->len); | 763 | xbind(netfd, &ouraddr->u.sa, ouraddr->len); |
764 | #if 0 | 764 | #if 0 |
765 | setsockopt(netfd, SOL_SOCKET, SO_RCVBUF, &o_rcvbuf, sizeof o_rcvbuf); | 765 | setsockopt(netfd, SOL_SOCKET, SO_RCVBUF, &o_rcvbuf, sizeof o_rcvbuf); |
766 | setsockopt(netfd, SOL_SOCKET, SO_SNDBUF, &o_sndbuf, sizeof o_sndbuf); | 766 | setsockopt(netfd, SOL_SOCKET, SO_SNDBUF, &o_sndbuf, sizeof o_sndbuf); |
@@ -796,7 +796,7 @@ int nc_main(int argc, char **argv) | |||
796 | 796 | ||
797 | remend = *themaddr; | 797 | remend = *themaddr; |
798 | if (o_verbose) | 798 | if (o_verbose) |
799 | themdotted = xmalloc_sockaddr2dotted(&themaddr->sa); | 799 | themdotted = xmalloc_sockaddr2dotted(&themaddr->u.sa); |
800 | 800 | ||
801 | x = connect_w_timeout(netfd); | 801 | x = connect_w_timeout(netfd); |
802 | if (o_zero && x == 0 && o_udpmode) /* if UDP scanning... */ | 802 | if (o_zero && x == 0 && o_udpmode) /* if UDP scanning... */ |