From a57721d14642291696be4ffd5d8bb0915fbe861b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 8 Jul 2019 16:02:56 -0700 Subject: 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. --- toys/pending/arping.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'toys/pending/arping.c') 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); -- cgit v1.2.3