diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-23 02:48:44 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-23 02:48:44 +0000 |
commit | 1dc1b37b337030807d7b35b415373593e3f72dda (patch) | |
tree | 84b5f0ae68c3e1f1450b81af96b25c9a74aaf049 | |
parent | 7e46cf748ead14b4060f0825762fb6393cf89a91 (diff) | |
download | busybox-w32-1dc1b37b337030807d7b35b415373593e3f72dda.tar.gz busybox-w32-1dc1b37b337030807d7b35b415373593e3f72dda.tar.bz2 busybox-w32-1dc1b37b337030807d7b35b415373593e3f72dda.zip |
use xbind, xconnect where appropriate.
small edits to arping
-rw-r--r-- | libbb/xconnect.c | 3 | ||||
-rw-r--r-- | networking/arping.c | 127 | ||||
-rw-r--r-- | networking/libiproute/iplink.c | 4 | ||||
-rw-r--r-- | networking/nc.c | 3 |
4 files changed, 53 insertions, 84 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index b85648007..bc0691531 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -54,7 +54,8 @@ void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) | |||
54 | if (connect(s, s_addr, addrlen) < 0) { | 54 | if (connect(s, s_addr, addrlen) < 0) { |
55 | if (ENABLE_FEATURE_CLEAN_UP) close(s); | 55 | if (ENABLE_FEATURE_CLEAN_UP) close(s); |
56 | if (s_addr->sa_family == AF_INET) | 56 | if (s_addr->sa_family == AF_INET) |
57 | bb_perror_msg_and_die("cannot connect to remote host (%s)", | 57 | bb_perror_msg_and_die("%s (%s)", |
58 | "cannot connect to remote host", | ||
58 | inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr)); | 59 | inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr)); |
59 | bb_perror_msg_and_die("cannot connect to remote host"); | 60 | bb_perror_msg_and_die("cannot connect to remote host"); |
60 | } | 61 | } |
diff --git a/networking/arping.c b/networking/arping.c index 2d92bf4be..58d5b3bd6 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -11,11 +11,6 @@ | |||
11 | #include <sys/ioctl.h> | 11 | #include <sys/ioctl.h> |
12 | #include <signal.h> | 12 | #include <signal.h> |
13 | 13 | ||
14 | #include <errno.h> | ||
15 | #include <stdlib.h> | ||
16 | #include <string.h> | ||
17 | #include <unistd.h> | ||
18 | |||
19 | #include <arpa/inet.h> | 14 | #include <arpa/inet.h> |
20 | #include <net/if.h> | 15 | #include <net/if.h> |
21 | #include <netinet/ether.h> | 16 | #include <netinet/ether.h> |
@@ -49,12 +44,12 @@ static int received; | |||
49 | static int brd_recv; | 44 | static int brd_recv; |
50 | static int req_recv; | 45 | static int req_recv; |
51 | 46 | ||
52 | |||
53 | #define MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \ | 47 | #define MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \ |
54 | ((tv1).tv_usec-(tv2).tv_usec)/1000 ) | 48 | ((tv1).tv_usec-(tv2).tv_usec)/1000 ) |
49 | |||
55 | static int send_pack(int sock, struct in_addr *src_addr, | 50 | static int send_pack(int sock, struct in_addr *src_addr, |
56 | struct in_addr *dst_addr, struct sockaddr_ll *ME, | 51 | struct in_addr *dst_addr, struct sockaddr_ll *ME, |
57 | struct sockaddr_ll *HE) | 52 | struct sockaddr_ll *HE) |
58 | { | 53 | { |
59 | int err; | 54 | int err; |
60 | struct timeval now; | 55 | struct timeval now; |
@@ -67,7 +62,7 @@ static int send_pack(int sock, struct in_addr *src_addr, | |||
67 | ah->ar_pro = htons(ETH_P_IP); | 62 | ah->ar_pro = htons(ETH_P_IP); |
68 | ah->ar_hln = ME->sll_halen; | 63 | ah->ar_hln = ME->sll_halen; |
69 | ah->ar_pln = 4; | 64 | ah->ar_pln = 4; |
70 | ah->ar_op = cfg&advert ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST); | 65 | ah->ar_op = cfg & advert ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST); |
71 | 66 | ||
72 | memcpy(p, &ME->sll_addr, ah->ar_hln); | 67 | memcpy(p, &ME->sll_addr, ah->ar_hln); |
73 | p += ME->sll_halen; | 68 | p += ME->sll_halen; |
@@ -75,7 +70,7 @@ static int send_pack(int sock, struct in_addr *src_addr, | |||
75 | memcpy(p, src_addr, 4); | 70 | memcpy(p, src_addr, 4); |
76 | p += 4; | 71 | p += 4; |
77 | 72 | ||
78 | if (cfg&advert) | 73 | if (cfg & advert) |
79 | memcpy(p, &ME->sll_addr, ah->ar_hln); | 74 | memcpy(p, &ME->sll_addr, ah->ar_hln); |
80 | else | 75 | else |
81 | memcpy(p, &HE->sll_addr, ah->ar_hln); | 76 | memcpy(p, &HE->sll_addr, ah->ar_hln); |
@@ -89,7 +84,7 @@ static int send_pack(int sock, struct in_addr *src_addr, | |||
89 | if (err == p - buf) { | 84 | if (err == p - buf) { |
90 | last = now; | 85 | last = now; |
91 | sent++; | 86 | sent++; |
92 | if (!(cfg&unicasting)) | 87 | if (!(cfg & unicasting)) |
93 | brd_sent++; | 88 | brd_sent++; |
94 | } | 89 | } |
95 | RELEASE_CONFIG_BUFFER(buf); | 90 | RELEASE_CONFIG_BUFFER(buf); |
@@ -98,25 +93,17 @@ static int send_pack(int sock, struct in_addr *src_addr, | |||
98 | 93 | ||
99 | static void finish(void) | 94 | static void finish(void) |
100 | { | 95 | { |
101 | if (!(cfg&quiet)) { | 96 | if (!(cfg & quiet)) { |
102 | printf("Sent %d probes (%d broadcast(s))\n" | 97 | printf("Sent %d probe(s) (%d broadcast(s))\n" |
103 | "Received %d repl%s", | 98 | "Received %d repl%s" |
99 | " (%d request(s), %d broadcast(s))\n", | ||
104 | sent, brd_sent, | 100 | sent, brd_sent, |
105 | received, (received > 1) ? "ies" : "y"); | 101 | received, (received == 1) ? "ies" : "y", |
106 | if (brd_recv || req_recv) { | 102 | req_recv, brd_recv); |
107 | printf(" ("); | ||
108 | if (req_recv) | ||
109 | printf("%d request(s)", req_recv); | ||
110 | if (brd_recv) | ||
111 | printf("%s%d broadcast(s)", req_recv ? ", " : "", brd_recv); | ||
112 | putchar(')'); | ||
113 | } | ||
114 | putchar('\n'); | ||
115 | fflush(stdout); | ||
116 | } | 103 | } |
117 | if (cfg&dad) | 104 | if (cfg & dad) |
118 | exit(!!received); | 105 | exit(!!received); |
119 | if (cfg&unsolicited) | 106 | if (cfg & unsolicited) |
120 | exit(0); | 107 | exit(0); |
121 | exit(!received); | 108 | exit(!received); |
122 | } | 109 | } |
@@ -132,12 +119,12 @@ static void catcher(void) | |||
132 | start = tv; | 119 | start = tv; |
133 | 120 | ||
134 | if (count-- == 0 | 121 | if (count-- == 0 |
135 | || (timeout && MS_TDIFF(tv, start) > timeout * 1000 + 500)) | 122 | || (timeout && MS_TDIFF(tv, start) > timeout * 1000 + 500)) |
136 | finish(); | 123 | finish(); |
137 | 124 | ||
138 | if (last.tv_sec == 0 || MS_TDIFF(tv, last) > 500) { | 125 | if (last.tv_sec == 0 || MS_TDIFF(tv, last) > 500) { |
139 | send_pack(s, &src, &dst, &me, &he); | 126 | send_pack(s, &src, &dst, &me, &he); |
140 | if (count == 0 && cfg&unsolicited) | 127 | if (count == 0 && (cfg & unsolicited)) |
141 | finish(); | 128 | finish(); |
142 | } | 129 | } |
143 | alarm(1); | 130 | alarm(1); |
@@ -150,9 +137,9 @@ static int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
150 | struct in_addr src_ip, dst_ip; | 137 | struct in_addr src_ip, dst_ip; |
151 | 138 | ||
152 | /* Filter out wild packets */ | 139 | /* Filter out wild packets */ |
153 | if (FROM->sll_pkttype != PACKET_HOST && | 140 | if (FROM->sll_pkttype != PACKET_HOST |
154 | FROM->sll_pkttype != PACKET_BROADCAST && | 141 | && FROM->sll_pkttype != PACKET_BROADCAST |
155 | FROM->sll_pkttype != PACKET_MULTICAST) | 142 | && FROM->sll_pkttype != PACKET_MULTICAST) |
156 | return 0; | 143 | return 0; |
157 | 144 | ||
158 | /* Only these types are recognised */ | 145 | /* Only these types are recognised */ |
@@ -160,9 +147,8 @@ static int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
160 | return 0; | 147 | return 0; |
161 | 148 | ||
162 | /* ARPHRD check and this darned FDDI hack here :-( */ | 149 | /* ARPHRD check and this darned FDDI hack here :-( */ |
163 | if (ah->ar_hrd != htons(FROM->sll_hatype) && | 150 | if (ah->ar_hrd != htons(FROM->sll_hatype) |
164 | (FROM->sll_hatype != ARPHRD_FDDI | 151 | && (FROM->sll_hatype != ARPHRD_FDDI || ah->ar_hrd != htons(ARPHRD_ETHER))) |
165 | || ah->ar_hrd != htons(ARPHRD_ETHER))) | ||
166 | return 0; | 152 | return 0; |
167 | 153 | ||
168 | /* Protocol must be IP. */ | 154 | /* Protocol must be IP. */ |
@@ -176,7 +162,7 @@ static int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
176 | return 0; | 162 | return 0; |
177 | memcpy(&src_ip, p + ah->ar_hln, 4); | 163 | memcpy(&src_ip, p + ah->ar_hln, 4); |
178 | memcpy(&dst_ip, p + ah->ar_hln + 4 + ah->ar_hln, 4); | 164 | memcpy(&dst_ip, p + ah->ar_hln + 4 + ah->ar_hln, 4); |
179 | if (!(cfg&dad)) { | 165 | if (!(cfg & dad)) { |
180 | if (src_ip.s_addr != dst.s_addr) | 166 | if (src_ip.s_addr != dst.s_addr) |
181 | return 0; | 167 | return 0; |
182 | if (src.s_addr != dst_ip.s_addr) | 168 | if (src.s_addr != dst_ip.s_addr) |
@@ -204,15 +190,15 @@ static int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
204 | if (src.s_addr && src.s_addr != dst_ip.s_addr) | 190 | if (src.s_addr && src.s_addr != dst_ip.s_addr) |
205 | return 0; | 191 | return 0; |
206 | } | 192 | } |
207 | if (!(cfg&quiet)) { | 193 | if (!(cfg & quiet)) { |
208 | int s_printed = 0; | 194 | int s_printed = 0; |
209 | struct timeval tv; | 195 | struct timeval tv; |
210 | 196 | ||
211 | gettimeofday(&tv, NULL); | 197 | gettimeofday(&tv, NULL); |
212 | 198 | ||
213 | printf("%s %s from %s [%s]", | 199 | printf("%scast re%s from %s [%s]", |
214 | FROM->sll_pkttype == PACKET_HOST ? "Unicast" : "Broadcast", | 200 | FROM->sll_pkttype == PACKET_HOST ? "Uni" : "Broad", |
215 | ah->ar_op == htons(ARPOP_REPLY) ? "reply" : "request", | 201 | ah->ar_op == htons(ARPOP_REPLY) ? "ply" : "quest", |
216 | inet_ntoa(src_ip), | 202 | inet_ntoa(src_ip), |
217 | ether_ntoa((struct ether_addr *) p)); | 203 | ether_ntoa((struct ether_addr *) p)); |
218 | if (dst_ip.s_addr != src.s_addr) { | 204 | if (dst_ip.s_addr != src.s_addr) { |
@@ -223,7 +209,7 @@ static int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
223 | if (!s_printed) | 209 | if (!s_printed) |
224 | printf("for "); | 210 | printf("for "); |
225 | printf("[%s]", | 211 | printf("[%s]", |
226 | ether_ntoa((struct ether_addr *) p + ah->ar_hln + 4)); | 212 | ether_ntoa((struct ether_addr *) p + ah->ar_hln + 4)); |
227 | } | 213 | } |
228 | 214 | ||
229 | if (last.tv_sec) { | 215 | if (last.tv_sec) { |
@@ -243,9 +229,9 @@ static int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
243 | brd_recv++; | 229 | brd_recv++; |
244 | if (ah->ar_op == htons(ARPOP_REQUEST)) | 230 | if (ah->ar_op == htons(ARPOP_REQUEST)) |
245 | req_recv++; | 231 | req_recv++; |
246 | if (cfg&quit_on_reply) | 232 | if (cfg & quit_on_reply) |
247 | finish(); | 233 | finish(); |
248 | if (!(cfg&broadcast_only)) { | 234 | if (!(cfg & broadcast_only)) { |
249 | memcpy(he.sll_addr, p, me.sll_halen); | 235 | memcpy(he.sll_addr, p, me.sll_halen); |
250 | cfg |= unicasting; | 236 | cfg |= unicasting; |
251 | } | 237 | } |
@@ -279,11 +265,10 @@ int arping_main(int argc, char **argv) | |||
279 | count = xatou(_count); | 265 | count = xatou(_count); |
280 | if (opt & 0x80) /* -w: timeout */ | 266 | if (opt & 0x80) /* -w: timeout */ |
281 | timeout = xatoul_range(_timeout, 0, INT_MAX/2000); | 267 | timeout = xatoul_range(_timeout, 0, INT_MAX/2000); |
282 | if (opt & 0x100) { /* -i: interface */ | 268 | //if (opt & 0x100) /* -i: interface */ |
283 | if (strlen(device) > IF_NAMESIZE) { | 269 | if (strlen(device) > IF_NAMESIZE) { |
284 | bb_error_msg_and_die("interface name '%s' is too long", | 270 | bb_error_msg_and_die("interface name '%s' is too long", |
285 | device); | 271 | device); |
286 | } | ||
287 | } | 272 | } |
288 | //if (opt & 0x200) /* -s: source */ | 273 | //if (opt & 0x200) /* -s: source */ |
289 | } | 274 | } |
@@ -315,7 +300,7 @@ int arping_main(int argc, char **argv) | |||
315 | } | 300 | } |
316 | if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { | 301 | if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { |
317 | bb_error_msg("interface %s is not ARPable", device); | 302 | bb_error_msg("interface %s is not ARPable", device); |
318 | exit(cfg&dad ? 0 : 2); | 303 | return (cfg & dad ? 0 : 2); |
319 | } | 304 | } |
320 | } | 305 | } |
321 | 306 | ||
@@ -333,56 +318,44 @@ int arping_main(int argc, char **argv) | |||
333 | bb_error_msg_and_die("invalid source address %s", source); | 318 | bb_error_msg_and_die("invalid source address %s", source); |
334 | } | 319 | } |
335 | 320 | ||
336 | if (!(cfg&dad) && cfg&unsolicited && src.s_addr == 0) | 321 | if (!(cfg & dad) && (cfg & unsolicited) && src.s_addr == 0) |
337 | src = dst; | 322 | src = dst; |
338 | 323 | ||
339 | if (!(cfg&dad) || src.s_addr) { | 324 | if (!(cfg & dad) || src.s_addr) { |
340 | struct sockaddr_in saddr; | 325 | struct sockaddr_in saddr; |
341 | int probe_fd = xsocket(AF_INET, SOCK_DGRAM, 0); | 326 | int probe_fd = xsocket(AF_INET, SOCK_DGRAM, 0); |
342 | 327 | ||
343 | if (device) { | 328 | if (device) { |
344 | if (setsockopt | 329 | if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device) + 1) == -1) |
345 | (probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, | ||
346 | strlen(device) + 1) == -1) | ||
347 | bb_error_msg("warning: interface %s is ignored", device); | 330 | bb_error_msg("warning: interface %s is ignored", device); |
348 | } | 331 | } |
349 | memset(&saddr, 0, sizeof(saddr)); | 332 | memset(&saddr, 0, sizeof(saddr)); |
350 | saddr.sin_family = AF_INET; | 333 | saddr.sin_family = AF_INET; |
351 | if (src.s_addr) { | 334 | if (src.s_addr) { |
352 | saddr.sin_addr = src; | 335 | saddr.sin_addr = src; |
353 | if (bind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) { | 336 | xbind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); |
354 | bb_error_msg_and_die("bind"); | 337 | } else if (!(cfg & dad)) { |
355 | } | ||
356 | } else if (!(cfg&dad)) { | ||
357 | static const int on = 1; | 338 | static const int on = 1; |
358 | socklen_t alen = sizeof(saddr); | 339 | socklen_t alen = sizeof(saddr); |
359 | 340 | ||
360 | saddr.sin_port = htons(1025); | 341 | saddr.sin_port = htons(1025); |
361 | saddr.sin_addr = dst; | 342 | saddr.sin_addr = dst; |
362 | 343 | ||
363 | if (setsockopt | 344 | if (setsockopt(probe_fd, SOL_SOCKET, SO_DONTROUTE, (char *) &on, sizeof(on)) == -1) |
364 | (probe_fd, SOL_SOCKET, SO_DONTROUTE, (char *) &on, | ||
365 | sizeof(on)) == -1) | ||
366 | bb_perror_msg("warning: setsockopt(SO_DONTROUTE)"); | 345 | bb_perror_msg("warning: setsockopt(SO_DONTROUTE)"); |
367 | if (connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) | 346 | xconnect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); |
368 | == -1) { | 347 | if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == -1) { |
369 | bb_error_msg_and_die("connect"); | ||
370 | } | ||
371 | if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == | ||
372 | -1) { | ||
373 | bb_error_msg_and_die("getsockname"); | 348 | bb_error_msg_and_die("getsockname"); |
374 | } | 349 | } |
375 | src = saddr.sin_addr; | 350 | src = saddr.sin_addr; |
376 | } | 351 | } |
377 | close(probe_fd); | 352 | close(probe_fd); |
378 | }; | 353 | } |
379 | 354 | ||
380 | me.sll_family = AF_PACKET; | 355 | me.sll_family = AF_PACKET; |
381 | me.sll_ifindex = ifindex; | 356 | me.sll_ifindex = ifindex; |
382 | me.sll_protocol = htons(ETH_P_ARP); | 357 | me.sll_protocol = htons(ETH_P_ARP); |
383 | if (bind(s, (struct sockaddr *) &me, sizeof(me)) == -1) { | 358 | xbind(s, (struct sockaddr *) &me, sizeof(me)); |
384 | bb_error_msg_and_die("bind"); | ||
385 | } | ||
386 | 359 | ||
387 | { | 360 | { |
388 | socklen_t alen = sizeof(me); | 361 | socklen_t alen = sizeof(me); |
@@ -393,18 +366,18 @@ int arping_main(int argc, char **argv) | |||
393 | } | 366 | } |
394 | if (me.sll_halen == 0) { | 367 | if (me.sll_halen == 0) { |
395 | bb_error_msg("interface \"%s\" is not ARPable (no ll address)", device); | 368 | bb_error_msg("interface \"%s\" is not ARPable (no ll address)", device); |
396 | exit(cfg&dad ? 0 : 2); | 369 | return (cfg & dad ? 0 : 2); |
397 | } | 370 | } |
398 | he = me; | 371 | he = me; |
399 | memset(he.sll_addr, -1, he.sll_halen); | 372 | memset(he.sll_addr, -1, he.sll_halen); |
400 | 373 | ||
401 | if (!(cfg&quiet)) { | 374 | if (!(cfg & quiet)) { |
402 | printf("ARPING to %s from %s via %s\n", | 375 | printf("ARPING to %s from %s via %s\n", |
403 | inet_ntoa(dst), inet_ntoa(src), | 376 | inet_ntoa(dst), inet_ntoa(src), |
404 | device ? device : "unknown"); | 377 | device ? device : "unknown"); |
405 | } | 378 | } |
406 | 379 | ||
407 | if (!src.s_addr && !(cfg&dad)) { | 380 | if (!src.s_addr && !(cfg & dad)) { |
408 | bb_error_msg_and_die("no src address in the non-DAD mode"); | 381 | bb_error_msg_and_die("no src address in the non-DAD mode"); |
409 | } | 382 | } |
410 | 383 | ||
@@ -430,8 +403,8 @@ int arping_main(int argc, char **argv) | |||
430 | socklen_t alen = sizeof(from); | 403 | socklen_t alen = sizeof(from); |
431 | int cc; | 404 | int cc; |
432 | 405 | ||
433 | if ((cc = recvfrom(s, packet, 4096, 0, | 406 | cc = recvfrom(s, packet, 4096, 0, (struct sockaddr *) &from, &alen); |
434 | (struct sockaddr *) &from, &alen)) < 0) { | 407 | if (cc < 0) { |
435 | bb_perror_msg("recvfrom"); | 408 | bb_perror_msg("recvfrom"); |
436 | continue; | 409 | continue; |
437 | } | 410 | } |
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index 1ea11f60b..ea57d60ac 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c | |||
@@ -12,10 +12,6 @@ | |||
12 | #include <sys/ioctl.h> | 12 | #include <sys/ioctl.h> |
13 | #include <sys/socket.h> | 13 | #include <sys/socket.h> |
14 | 14 | ||
15 | #include <errno.h> | ||
16 | #include <string.h> | ||
17 | #include <unistd.h> | ||
18 | |||
19 | #include <net/if.h> | 15 | #include <net/if.h> |
20 | #include <net/if_packet.h> | 16 | #include <net/if_packet.h> |
21 | #include <netpacket/packet.h> | 17 | #include <netpacket/packet.h> |
diff --git a/networking/nc.c b/networking/nc.c index b2a4596d6..1419609e0 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -120,8 +120,7 @@ int nc_main(int argc, char **argv) | |||
120 | address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; | 120 | address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; |
121 | address.sin_port = bb_lookup_port(argv[1], "tcp", 0); | 121 | address.sin_port = bb_lookup_port(argv[1], "tcp", 0); |
122 | 122 | ||
123 | if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) | 123 | xconnect(sfd, (struct sockaddr *) &address, sizeof(address)); |
124 | bb_perror_msg_and_die("connect"); | ||
125 | cfd = sfd; | 124 | cfd = sfd; |
126 | } | 125 | } |
127 | } | 126 | } |