diff options
author | Elliott Hughes <enh@google.com> | 2019-07-08 16:02:56 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-07-11 22:02:12 -0500 |
commit | a57721d14642291696be4ffd5d8bb0915fbe861b (patch) | |
tree | 11a18894601df31ce1eb9c46c5d1faaa59e2f9e8 /toys/pending/arping.c | |
parent | 34f095fcbf0829719f9a130a359ebf2a3e223ca0 (diff) | |
download | toybox-a57721d14642291696be4ffd5d8bb0915fbe861b.tar.gz |
bind/connect cleanup.
Rename the existing xbind/xconnect to xbindany/xconnectany, to make room
for new xbind/xconnect that are more like 'x' versions of the regular
bind and connect. Move explicit bind/connect callers over to
xbind/xconnect.
Of the affected commands, only netcat is actually used by Android. It
was the most recent patch to netcat that made the lack of a more
traditional xbind/xconnect apparent.
Diffstat (limited to 'toys/pending/arping.c')
-rw-r--r-- | toys/pending/arping.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/toys/pending/arping.c b/toys/pending/arping.c index 6007845b..68ee5eac 100644 --- a/toys/pending/arping.c +++ b/toys/pending/arping.c @@ -242,15 +242,13 @@ void arping_main(void) saddr.sin_family = AF_INET; if (src_addr.s_addr) { saddr.sin_addr = src_addr; - if (bind(p_fd, (struct sockaddr*)&saddr, sizeof(saddr))) - perror_exit("bind"); + xbind(p_fd, (struct sockaddr*)&saddr, sizeof(saddr)); } else { uint32_t oip; saddr.sin_port = htons(1025); saddr.sin_addr = dest_addr; - if (connect(p_fd, (struct sockaddr *) &saddr, sizeof(saddr))) - perror_exit("cannot connect to remote host"); + xconnect(p_fd, (struct sockaddr *) &saddr, sizeof(saddr)); get_interface(TT.iface, NULL, &oip, NULL); src_addr.s_addr = htonl(oip); } @@ -259,8 +257,7 @@ void arping_main(void) src_pk.sll_family = AF_PACKET; src_pk.sll_protocol = htons(ETH_P_ARP); - if (bind(TT.sockfd, (struct sockaddr *)&src_pk, sizeof(src_pk))) - perror_exit("bind"); + xbind(TT.sockfd, (struct sockaddr *)&src_pk, sizeof(src_pk)); socklen_t alen = sizeof(src_pk); getsockname(TT.sockfd, (struct sockaddr *)&src_pk, &alen); |