Bernhard Reutner-Fischer | dac7ff1 | 2006-04-12 17:55:51 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 2 | /* |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 4 | * |
Denys Vlasenko | 11872ca | 2010-10-30 02:24:48 +0200 | [diff] [blame] | 5 | * Author: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 6 | * Busybox port: Nick Fedchik <nick@fedchik.org.ua> |
| 7 | */ |
Denys Vlasenko | 47367e1 | 2016-11-23 09:05:14 +0100 | [diff] [blame] | 8 | //config:config ARPING |
Denys Vlasenko | b097a84 | 2018-12-28 03:20:17 +0100 | [diff] [blame] | 9 | //config: bool "arping (9 kb)" |
Denys Vlasenko | 47367e1 | 2016-11-23 09:05:14 +0100 | [diff] [blame] | 10 | //config: default y |
Samuel Thibault | 77216c3 | 2022-10-16 02:04:59 +0200 | [diff] [blame^] | 11 | //config: select PLATFORM_LINUX |
Denys Vlasenko | 47367e1 | 2016-11-23 09:05:14 +0100 | [diff] [blame] | 12 | //config: help |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 13 | //config: Ping hosts by ARP packets. |
Denys Vlasenko | 47367e1 | 2016-11-23 09:05:14 +0100 | [diff] [blame] | 14 | |
| 15 | //applet:IF_ARPING(APPLET(arping, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
| 16 | |
| 17 | //kbuild:lib-$(CONFIG_ARPING) += arping.o |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 18 | |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 19 | //usage:#define arping_trivial_usage |
| 20 | //usage: "[-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP" |
| 21 | //usage:#define arping_full_usage "\n\n" |
| 22 | //usage: "Send ARP requests/replies\n" |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 23 | //usage: "\n -f Quit on first ARP reply" |
| 24 | //usage: "\n -q Quiet" |
| 25 | //usage: "\n -b Keep broadcasting, don't go unicast" |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 26 | //usage: "\n -D Exit with 1 if DST_IP replies" |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 27 | //usage: "\n -U Unsolicited ARP mode, update your neighbors" |
| 28 | //usage: "\n -A ARP answer mode, update your neighbors" |
| 29 | //usage: "\n -c N Stop after sending N ARP requests" |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 30 | //usage: "\n -w TIMEOUT Seconds to wait for ARP reply" |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 31 | //NB: in iputils-s20160308, iface is mandatory, no default |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 32 | //usage: "\n -I IFACE Interface to use (default eth0)" |
| 33 | //usage: "\n -s SRC_IP Sender IP address" |
| 34 | //usage: "\n DST_IP Target IP address" |
| 35 | |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 36 | #include <arpa/inet.h> |
| 37 | #include <net/if.h> |
| 38 | #include <netinet/ether.h> |
| 39 | #include <netpacket/packet.h> |
| 40 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 41 | #include "libbb.h" |
Denys Vlasenko | e6a2f4c | 2016-04-21 16:26:30 +0200 | [diff] [blame] | 42 | #include "common_bufsiz.h" |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 43 | |
Denis Vlasenko | 459be35 | 2007-06-17 19:09:05 +0000 | [diff] [blame] | 44 | /* We don't expect to see 1000+ seconds delay, unsigned is enough */ |
| 45 | #define MONOTONIC_US() ((unsigned)monotonic_us()) |
| 46 | |
Denis Vlasenko | 459be35 | 2007-06-17 19:09:05 +0000 | [diff] [blame] | 47 | enum { |
Denys Vlasenko | f5d50fb | 2018-02-11 13:27:54 +0100 | [diff] [blame] | 48 | UNSOLICITED = 1 << 0, |
| 49 | DAD = 1 << 1, |
| 50 | ADVERT = 1 << 2, |
| 51 | QUIET = 1 << 3, |
| 52 | QUIT_ON_REPLY = 1 << 4, |
| 53 | BCAST_ONLY = 1 << 5, |
| 54 | UNICASTING = 1 << 6, |
| 55 | TIMEOUT = 1 << 7, |
Rob Landley | 8ea5205 | 2006-03-30 21:50:57 +0000 | [diff] [blame] | 56 | }; |
Denys Vlasenko | f5d50fb | 2018-02-11 13:27:54 +0100 | [diff] [blame] | 57 | #define GETOPT32(str_timeout, device, source) \ |
| 58 | getopt32(argv, "^" \ |
| 59 | "UDAqfbc:+w:I:s:" \ |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 60 | /* DAD also sets quit_on_reply, */ \ |
| 61 | /* advert also sets unsolicited: */ \ |
Denys Vlasenko | f5d50fb | 2018-02-11 13:27:54 +0100 | [diff] [blame] | 62 | "\0" "=1:Df:AU", \ |
| 63 | &count, &str_timeout, &device, &source \ |
| 64 | ); |
Rob Landley | 8ea5205 | 2006-03-30 21:50:57 +0000 | [diff] [blame] | 65 | |
Denis Vlasenko | fff9b69 | 2007-11-23 09:15:26 +0000 | [diff] [blame] | 66 | struct globals { |
| 67 | struct in_addr src; |
| 68 | struct in_addr dst; |
| 69 | struct sockaddr_ll me; |
| 70 | struct sockaddr_ll he; |
Denis Vlasenko | fff9b69 | 2007-11-23 09:15:26 +0000 | [diff] [blame] | 71 | |
| 72 | int count; // = -1; |
| 73 | unsigned last; |
| 74 | unsigned timeout_us; |
| 75 | unsigned start; |
| 76 | |
| 77 | unsigned sent; |
| 78 | unsigned brd_sent; |
| 79 | unsigned received; |
| 80 | unsigned brd_recv; |
| 81 | unsigned req_recv; |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 82 | |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 83 | /* should be in main(), but are here to reduce stack use: */ |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 84 | struct ifreq ifr; |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 85 | struct sockaddr_in probe_saddr; |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 86 | sigset_t sset; |
| 87 | unsigned char packet[4096]; |
Denys Vlasenko | 98a4c7c | 2010-02-04 15:00:15 +0100 | [diff] [blame] | 88 | } FIX_ALIASING; |
Denis Vlasenko | fff9b69 | 2007-11-23 09:15:26 +0000 | [diff] [blame] | 89 | #define src (G.src ) |
| 90 | #define dst (G.dst ) |
| 91 | #define me (G.me ) |
| 92 | #define he (G.he ) |
Denis Vlasenko | fff9b69 | 2007-11-23 09:15:26 +0000 | [diff] [blame] | 93 | #define count (G.count ) |
| 94 | #define last (G.last ) |
| 95 | #define timeout_us (G.timeout_us) |
| 96 | #define start (G.start ) |
| 97 | #define sent (G.sent ) |
| 98 | #define brd_sent (G.brd_sent ) |
| 99 | #define received (G.received ) |
| 100 | #define brd_recv (G.brd_recv ) |
| 101 | #define req_recv (G.req_recv ) |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 102 | //#define G (*(struct globals*)bb_common_bufsiz1) |
| 103 | #define G (*ptr_to_globals) |
Denis Vlasenko | 7049ff8 | 2008-06-25 09:53:17 +0000 | [diff] [blame] | 104 | #define INIT_G() do { \ |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 105 | /*setup_common_bufsiz();*/ \ |
| 106 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
Denis Vlasenko | 7049ff8 | 2008-06-25 09:53:17 +0000 | [diff] [blame] | 107 | count = -1; \ |
| 108 | } while (0) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 109 | |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 110 | #define sock_fd 3 |
| 111 | |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 112 | static int send_pack(struct in_addr *src_addr, |
Denys Vlasenko | f5d50fb | 2018-02-11 13:27:54 +0100 | [diff] [blame] | 113 | struct in_addr *dst_addr, |
| 114 | struct sockaddr_ll *ME, |
Denis Vlasenko | 1dc1b37 | 2006-12-23 02:48:44 +0000 | [diff] [blame] | 115 | struct sockaddr_ll *HE) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 116 | { |
| 117 | int err; |
Denis Vlasenko | 459be35 | 2007-06-17 19:09:05 +0000 | [diff] [blame] | 118 | unsigned char buf[256]; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 119 | struct arphdr *ah = (struct arphdr *) buf; |
Denys Vlasenko | f5d50fb | 2018-02-11 13:27:54 +0100 | [diff] [blame] | 120 | unsigned char *p; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 121 | |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 122 | ah->ar_hrd = htons(ARPHRD_ETHER); |
| 123 | ah->ar_pro = htons(ETH_P_IP); |
| 124 | ah->ar_hln = ME->sll_halen; |
| 125 | ah->ar_pln = 4; |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 126 | ah->ar_op = option_mask32 & ADVERT ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 127 | |
Denys Vlasenko | f5d50fb | 2018-02-11 13:27:54 +0100 | [diff] [blame] | 128 | p = (unsigned char *) (ah + 1); |
Denis Vlasenko | a6b3a1f | 2008-04-25 08:13:36 +0000 | [diff] [blame] | 129 | p = mempcpy(p, &ME->sll_addr, ah->ar_hln); |
| 130 | p = mempcpy(p, src_addr, 4); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 131 | |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 132 | if (option_mask32 & ADVERT) |
Denis Vlasenko | a6b3a1f | 2008-04-25 08:13:36 +0000 | [diff] [blame] | 133 | p = mempcpy(p, &ME->sll_addr, ah->ar_hln); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 134 | else |
Denis Vlasenko | a6b3a1f | 2008-04-25 08:13:36 +0000 | [diff] [blame] | 135 | p = mempcpy(p, &HE->sll_addr, ah->ar_hln); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 136 | |
Denis Vlasenko | a6b3a1f | 2008-04-25 08:13:36 +0000 | [diff] [blame] | 137 | p = mempcpy(p, dst_addr, 4); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 138 | |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 139 | err = sendto(sock_fd, buf, p - buf, 0, (struct sockaddr *) HE, sizeof(*HE)); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 140 | if (err == p - buf) { |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 141 | last = MONOTONIC_US(); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 142 | sent++; |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 143 | if (!(option_mask32 & UNICASTING)) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 144 | brd_sent++; |
| 145 | } |
| 146 | return err; |
| 147 | } |
| 148 | |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 149 | static void finish(void) NORETURN; |
Eric Andersen | 14f5c8d | 2005-04-16 19:39:00 +0000 | [diff] [blame] | 150 | static void finish(void) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 151 | { |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 152 | if (!(option_mask32 & QUIET)) { |
| 153 | printf("Sent %u probe(s) (%u broadcast(s))\n" |
Denys Vlasenko | a3ec3bd | 2018-02-11 13:37:07 +0100 | [diff] [blame] | 154 | "Received %u response(s)" |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 155 | " (%u request(s), %u broadcast(s))\n", |
Bernhard Reutner-Fischer | ebd1355 | 2006-04-03 12:29:12 +0000 | [diff] [blame] | 156 | sent, brd_sent, |
Denys Vlasenko | a3ec3bd | 2018-02-11 13:37:07 +0100 | [diff] [blame] | 157 | received, |
Denis Vlasenko | 1dc1b37 | 2006-12-23 02:48:44 +0000 | [diff] [blame] | 158 | req_recv, brd_recv); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 159 | } |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 160 | if (option_mask32 & DAD) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 161 | exit(!!received); |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 162 | if (option_mask32 & UNSOLICITED) |
Denys Vlasenko | db5546c | 2022-01-05 22:16:06 +0100 | [diff] [blame] | 163 | exit_SUCCESS(); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 164 | exit(!received); |
| 165 | } |
| 166 | |
Eric Andersen | 14f5c8d | 2005-04-16 19:39:00 +0000 | [diff] [blame] | 167 | static void catcher(void) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 168 | { |
Denis Vlasenko | 459be35 | 2007-06-17 19:09:05 +0000 | [diff] [blame] | 169 | unsigned now; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 170 | |
Denis Vlasenko | 459be35 | 2007-06-17 19:09:05 +0000 | [diff] [blame] | 171 | now = MONOTONIC_US(); |
| 172 | if (start == 0) |
| 173 | start = now; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 174 | |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 175 | if (count == 0 || (timeout_us && (now - start) > timeout_us)) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 176 | finish(); |
| 177 | |
Denis Vlasenko | fff9b69 | 2007-11-23 09:15:26 +0000 | [diff] [blame] | 178 | /* count < 0 means "infinite count" */ |
| 179 | if (count > 0) |
| 180 | count--; |
Denis Vlasenko | 459be35 | 2007-06-17 19:09:05 +0000 | [diff] [blame] | 181 | |
| 182 | if (last == 0 || (now - last) > 500000) { |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 183 | send_pack(&src, &dst, &me, &he); |
| 184 | if (count == 0 && (option_mask32 & UNSOLICITED)) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 185 | finish(); |
| 186 | } |
| 187 | alarm(1); |
| 188 | } |
| 189 | |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 190 | static void recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 191 | { |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 192 | struct arphdr *ah = (struct arphdr *) buf; |
| 193 | unsigned char *p = (unsigned char *) (ah + 1); |
| 194 | struct in_addr src_ip, dst_ip; |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 195 | |
Denis Vlasenko | efb545b | 2008-12-08 22:56:18 +0000 | [diff] [blame] | 196 | /* moves below assume in_addr is 4 bytes big, ensure that */ |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 197 | BUILD_BUG_ON(sizeof(struct in_addr) != 4); |
| 198 | BUILD_BUG_ON(sizeof(src_ip.s_addr) != 4); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 199 | |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 200 | /* Filter out wild packets */ |
Denis Vlasenko | 1dc1b37 | 2006-12-23 02:48:44 +0000 | [diff] [blame] | 201 | if (FROM->sll_pkttype != PACKET_HOST |
| 202 | && FROM->sll_pkttype != PACKET_BROADCAST |
| 203 | && FROM->sll_pkttype != PACKET_MULTICAST) |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 204 | return; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 205 | |
Denys Vlasenko | b22bbff | 2009-07-04 16:50:43 +0200 | [diff] [blame] | 206 | /* Only these types are recognized */ |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 207 | if (ah->ar_op != htons(ARPOP_REQUEST) && ah->ar_op != htons(ARPOP_REPLY)) |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 208 | return; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 209 | |
| 210 | /* ARPHRD check and this darned FDDI hack here :-( */ |
Denis Vlasenko | 1dc1b37 | 2006-12-23 02:48:44 +0000 | [diff] [blame] | 211 | if (ah->ar_hrd != htons(FROM->sll_hatype) |
| 212 | && (FROM->sll_hatype != ARPHRD_FDDI || ah->ar_hrd != htons(ARPHRD_ETHER))) |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 213 | return; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 214 | |
| 215 | /* Protocol must be IP. */ |
Bernhard Reutner-Fischer | f536b99 | 2008-02-11 13:26:54 +0000 | [diff] [blame] | 216 | if (ah->ar_pro != htons(ETH_P_IP) |
Denis Vlasenko | efb545b | 2008-12-08 22:56:18 +0000 | [diff] [blame] | 217 | || (ah->ar_pln != 4) |
| 218 | || (ah->ar_hln != me.sll_halen) |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 219 | || (len < (int)(sizeof(*ah) + 2 * (4 + ah->ar_hln))) |
| 220 | ) { |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 221 | return; |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 222 | } |
Bernhard Reutner-Fischer | f536b99 | 2008-02-11 13:26:54 +0000 | [diff] [blame] | 223 | |
Denis Vlasenko | efb545b | 2008-12-08 22:56:18 +0000 | [diff] [blame] | 224 | move_from_unaligned32(src_ip.s_addr, p + ah->ar_hln); |
| 225 | move_from_unaligned32(dst_ip.s_addr, p + ah->ar_hln + 4 + ah->ar_hln); |
Bernhard Reutner-Fischer | f536b99 | 2008-02-11 13:26:54 +0000 | [diff] [blame] | 226 | |
| 227 | if (dst.s_addr != src_ip.s_addr) |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 228 | return; |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 229 | if (!(option_mask32 & DAD)) { |
Bernhard Reutner-Fischer | f536b99 | 2008-02-11 13:26:54 +0000 | [diff] [blame] | 230 | if ((src.s_addr != dst_ip.s_addr) |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 231 | || (memcmp(p + ah->ar_hln + 4, &me.sll_addr, ah->ar_hln))) |
| 232 | return; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 233 | } else { |
| 234 | /* DAD packet was: |
| 235 | src_ip = 0 (or some src) |
| 236 | src_hw = ME |
| 237 | dst_ip = tested address |
| 238 | dst_hw = <unspec> |
| 239 | |
| 240 | We fail, if receive request/reply with: |
| 241 | src_ip = tested_address |
| 242 | src_hw != ME |
| 243 | if src_ip in request was not zero, check |
| 244 | also that it matches to dst_ip, otherwise |
| 245 | dst_ip/dst_hw do not matter. |
| 246 | */ |
Bernhard Reutner-Fischer | f536b99 | 2008-02-11 13:26:54 +0000 | [diff] [blame] | 247 | if ((memcmp(p, &me.sll_addr, me.sll_halen) == 0) |
Denis Vlasenko | efb545b | 2008-12-08 22:56:18 +0000 | [diff] [blame] | 248 | || (src.s_addr && src.s_addr != dst_ip.s_addr)) |
Denys Vlasenko | fb52769 | 2015-08-16 19:56:16 +0200 | [diff] [blame] | 249 | return; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 250 | } |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 251 | if (!(option_mask32 & QUIET)) { |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 252 | int s_printed = 0; |
| 253 | |
Denys Vlasenko | a3ec3bd | 2018-02-11 13:37:07 +0100 | [diff] [blame] | 254 | //TODO: arping from iputils-s20160308 print upprcase hex in MAC, follow them? |
Denys Vlasenko | 852e8dd | 2016-05-26 21:35:46 +0200 | [diff] [blame] | 255 | printf("%scast re%s from %s [%02x:%02x:%02x:%02x:%02x:%02x]", |
Denis Vlasenko | 1dc1b37 | 2006-12-23 02:48:44 +0000 | [diff] [blame] | 256 | FROM->sll_pkttype == PACKET_HOST ? "Uni" : "Broad", |
| 257 | ah->ar_op == htons(ARPOP_REPLY) ? "ply" : "quest", |
Bernhard Reutner-Fischer | ebd1355 | 2006-04-03 12:29:12 +0000 | [diff] [blame] | 258 | inet_ntoa(src_ip), |
Denys Vlasenko | 852e8dd | 2016-05-26 21:35:46 +0200 | [diff] [blame] | 259 | p[0], p[1], p[2], p[3], p[4], p[5] |
| 260 | ); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 261 | if (dst_ip.s_addr != src.s_addr) { |
Denys Vlasenko | a3ec3bd | 2018-02-11 13:37:07 +0100 | [diff] [blame] | 262 | printf("for %s", inet_ntoa(dst_ip)); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 263 | s_printed = 1; |
| 264 | } |
| 265 | if (memcmp(p + ah->ar_hln + 4, me.sll_addr, ah->ar_hln)) { |
Denys Vlasenko | 852e8dd | 2016-05-26 21:35:46 +0200 | [diff] [blame] | 266 | unsigned char *pp = p + ah->ar_hln + 4; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 267 | if (!s_printed) |
Denys Vlasenko | a3ec3bd | 2018-02-11 13:37:07 +0100 | [diff] [blame] | 268 | printf(" for"); |
| 269 | printf(" [%02x:%02x:%02x:%02x:%02x:%02x]", |
Denys Vlasenko | 852e8dd | 2016-05-26 21:35:46 +0200 | [diff] [blame] | 270 | pp[0], pp[1], pp[2], pp[3], pp[4], pp[5] |
| 271 | ); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 272 | } |
Rob Landley | 8ea5205 | 2006-03-30 21:50:57 +0000 | [diff] [blame] | 273 | |
Denis Vlasenko | 459be35 | 2007-06-17 19:09:05 +0000 | [diff] [blame] | 274 | if (last) { |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 275 | unsigned diff = MONOTONIC_US() - last; |
| 276 | printf(" %u.%03ums\n", diff / 1000, diff % 1000); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 277 | } else { |
Denys Vlasenko | d60752f | 2015-10-07 22:42:45 +0200 | [diff] [blame] | 278 | puts(" UNSOLICITED?"); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 279 | } |
Denys Vlasenko | 8131eea | 2009-11-02 14:19:51 +0100 | [diff] [blame] | 280 | fflush_all(); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 281 | } |
| 282 | received++; |
| 283 | if (FROM->sll_pkttype != PACKET_HOST) |
| 284 | brd_recv++; |
| 285 | if (ah->ar_op == htons(ARPOP_REQUEST)) |
| 286 | req_recv++; |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 287 | if (option_mask32 & QUIT_ON_REPLY) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 288 | finish(); |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 289 | if (!(option_mask32 & BCAST_ONLY)) { |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 290 | memcpy(he.sll_addr, p, me.sll_halen); |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 291 | option_mask32 |= UNICASTING; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 292 | } |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 295 | int arping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 296 | int arping_main(int argc UNUSED_PARAM, char **argv) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 297 | { |
Denis Vlasenko | b6aae0f | 2007-01-29 22:51:25 +0000 | [diff] [blame] | 298 | const char *device = "eth0"; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 299 | char *source = NULL; |
| 300 | char *target; |
Bernhard Reutner-Fischer | f536b99 | 2008-02-11 13:26:54 +0000 | [diff] [blame] | 301 | char *err_str; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 302 | |
Denis Vlasenko | fff9b69 | 2007-11-23 09:15:26 +0000 | [diff] [blame] | 303 | INIT_G(); |
| 304 | |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 305 | xmove_fd(xsocket(AF_PACKET, SOCK_DGRAM, 0), sock_fd); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 306 | |
Denys Vlasenko | fbecca1 | 2017-08-06 14:03:27 +0200 | [diff] [blame] | 307 | // If you ever change BB_SUID_DROP to BB_SUID_REQUIRE, |
| 308 | // drop suid root privileges here: |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 309 | //xsetuid(getuid()); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 310 | |
Bernhard Reutner-Fischer | 1376694 | 2006-03-31 18:02:46 +0000 | [diff] [blame] | 311 | { |
Denis Vlasenko | 67b23e6 | 2006-10-03 21:00:06 +0000 | [diff] [blame] | 312 | unsigned opt; |
Denis Vlasenko | 1d42665 | 2008-03-17 09:09:09 +0000 | [diff] [blame] | 313 | char *str_timeout; |
Bernhard Reutner-Fischer | a0f75e2 | 2006-04-03 11:52:01 +0000 | [diff] [blame] | 314 | |
Denys Vlasenko | f5d50fb | 2018-02-11 13:27:54 +0100 | [diff] [blame] | 315 | opt = GETOPT32(str_timeout, device, source); |
| 316 | if (opt & TIMEOUT) |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 317 | timeout_us = xatou_range(str_timeout, 0, INT_MAX/2000000) * 1000000 + 500000; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 318 | } |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 319 | |
Denis Vlasenko | 459be35 | 2007-06-17 19:09:05 +0000 | [diff] [blame] | 320 | target = argv[optind]; |
Alexander Korolkov | 748fb60 | 2015-03-12 13:05:33 +0100 | [diff] [blame] | 321 | err_str = xasprintf("interface %s %%s", device); |
Denis Vlasenko | 4092082 | 2006-10-03 20:28:06 +0000 | [diff] [blame] | 322 | xfunc_error_retval = 2; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 323 | |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 324 | /*memset(&G.ifr, 0, sizeof(G.ifr)); - zeroed by INIT_G */ |
| 325 | strncpy_IFNAMSIZ(G.ifr.ifr_name, device); |
| 326 | ioctl_or_perror_and_die(sock_fd, SIOCGIFINDEX, &G.ifr, err_str, "not found"); |
| 327 | me.sll_ifindex = G.ifr.ifr_ifindex; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 328 | |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 329 | xioctl(sock_fd, SIOCGIFFLAGS, (char *) &G.ifr); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 330 | |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 331 | if (!(G.ifr.ifr_flags & IFF_UP)) { |
| 332 | bb_error_msg_and_die(err_str, "is down"); |
| 333 | } |
| 334 | if (G.ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { |
| 335 | bb_error_msg(err_str, "is not ARPable"); |
| 336 | BUILD_BUG_ON(DAD != 2); |
| 337 | /* exit 0 if DAD, else exit 2 */ |
| 338 | return (~option_mask32 & DAD); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 339 | } |
| 340 | |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 341 | /* if (!inet_aton(target, &dst)) - not needed */ { |
Denis Vlasenko | 90ec4dc | 2007-01-25 19:44:38 +0000 | [diff] [blame] | 342 | len_and_sockaddr *lsa; |
Denis Vlasenko | 42823d5 | 2007-02-04 02:39:08 +0000 | [diff] [blame] | 343 | lsa = xhost_and_af2sockaddr(target, 0, AF_INET); |
Denis Vlasenko | efb545b | 2008-12-08 22:56:18 +0000 | [diff] [blame] | 344 | dst = lsa->u.sin.sin_addr; |
Denis Vlasenko | 90ec4dc | 2007-01-25 19:44:38 +0000 | [diff] [blame] | 345 | if (ENABLE_FEATURE_CLEAN_UP) |
| 346 | free(lsa); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 347 | } |
| 348 | |
Glenn L McGrath | a837e2d | 2003-02-09 07:01:33 +0000 | [diff] [blame] | 349 | if (source && !inet_aton(source, &src)) { |
Rob Landley | 8ea5205 | 2006-03-30 21:50:57 +0000 | [diff] [blame] | 350 | bb_error_msg_and_die("invalid source address %s", source); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 353 | if ((option_mask32 & (DAD|UNSOLICITED)) == UNSOLICITED && src.s_addr == 0) |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 354 | src = dst; |
| 355 | |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 356 | if (!(option_mask32 & DAD) || src.s_addr) { |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 357 | /*struct sockaddr_in probe_saddr;*/ |
Denis Vlasenko | 27af5a0 | 2006-09-03 12:21:59 +0000 | [diff] [blame] | 358 | int probe_fd = xsocket(AF_INET, SOCK_DGRAM, 0); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 359 | |
Denis Vlasenko | e537385 | 2008-12-10 11:12:16 +0000 | [diff] [blame] | 360 | setsockopt_bindtodevice(probe_fd, device); |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 361 | |
| 362 | /*memset(&G.probe_saddr, 0, sizeof(G.probe_saddr)); - zeroed by INIT_G */ |
| 363 | G.probe_saddr.sin_family = AF_INET; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 364 | if (src.s_addr) { |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 365 | /* Check that this is indeed our IP */ |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 366 | G.probe_saddr.sin_addr = src; |
| 367 | xbind(probe_fd, (struct sockaddr *) &G.probe_saddr, sizeof(G.probe_saddr)); |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 368 | } else { /* !(option_mask32 & DAD) case */ |
| 369 | /* Find IP address on this iface */ |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 370 | G.probe_saddr.sin_port = htons(1025); |
| 371 | G.probe_saddr.sin_addr = dst; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 372 | |
Denys Vlasenko | c52cbea | 2015-08-24 19:48:03 +0200 | [diff] [blame] | 373 | if (setsockopt_SOL_SOCKET_1(probe_fd, SO_DONTROUTE) != 0) |
Denys Vlasenko | 2db782b | 2015-08-24 19:08:14 +0200 | [diff] [blame] | 374 | bb_perror_msg("setsockopt(%s)", "SO_DONTROUTE"); |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 375 | xconnect(probe_fd, (struct sockaddr *) &G.probe_saddr, sizeof(G.probe_saddr)); |
| 376 | bb_getsockname(probe_fd, (struct sockaddr *) &G.probe_saddr, sizeof(G.probe_saddr)); |
| 377 | if (G.probe_saddr.sin_family != AF_INET) |
James Byrne | 6937487 | 2019-07-02 11:35:03 +0200 | [diff] [blame] | 378 | bb_simple_error_msg_and_die("no IP address configured"); |
Denys Vlasenko | b5257a6 | 2018-02-11 21:16:24 +0100 | [diff] [blame] | 379 | src = G.probe_saddr.sin_addr; |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 380 | } |
| 381 | close(probe_fd); |
Denis Vlasenko | 1dc1b37 | 2006-12-23 02:48:44 +0000 | [diff] [blame] | 382 | } |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 383 | |
| 384 | me.sll_family = AF_PACKET; |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 385 | //me.sll_ifindex = ifindex; - done before |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 386 | me.sll_protocol = htons(ETH_P_ARP); |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 387 | xbind(sock_fd, (struct sockaddr *) &me, sizeof(me)); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 388 | |
Denys Vlasenko | ba3b9db | 2018-02-11 14:55:46 +0100 | [diff] [blame] | 389 | bb_getsockname(sock_fd, (struct sockaddr *) &me, sizeof(me)); |
| 390 | //never happens: |
| 391 | //if (getsockname(sock_fd, (struct sockaddr *) &me, &alen) == -1) |
| 392 | // bb_perror_msg_and_die("getsockname"); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 393 | if (me.sll_halen == 0) { |
Bernhard Reutner-Fischer | f536b99 | 2008-02-11 13:26:54 +0000 | [diff] [blame] | 394 | bb_error_msg(err_str, "is not ARPable (no ll address)"); |
Denys Vlasenko | f5d50fb | 2018-02-11 13:27:54 +0100 | [diff] [blame] | 395 | BUILD_BUG_ON(DAD != 2); |
| 396 | /* exit 0 if DAD, else exit 2 */ |
| 397 | return (~option_mask32 & DAD); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 398 | } |
| 399 | he = me; |
| 400 | memset(he.sll_addr, -1, he.sll_halen); |
| 401 | |
Denis Vlasenko | bd7bb29 | 2007-06-17 23:40:26 +0000 | [diff] [blame] | 402 | if (!(option_mask32 & QUIET)) { |
Denis Vlasenko | a09300a | 2007-11-25 12:40:56 +0000 | [diff] [blame] | 403 | /* inet_ntoa uses static storage, can't use in same printf */ |
Denys Vlasenko | a3ec3bd | 2018-02-11 13:37:07 +0100 | [diff] [blame] | 404 | printf("ARPING %s", inet_ntoa(dst)); |
| 405 | printf(" from %s %s\n", inet_ntoa(src), device); |
Glenn L McGrath | a837e2d | 2003-02-09 07:01:33 +0000 | [diff] [blame] | 406 | } |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 407 | |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 408 | /*sigemptyset(&G.sset); - zeroed by INIT_G */ |
| 409 | sigaddset(&G.sset, SIGALRM); |
| 410 | sigaddset(&G.sset, SIGINT); |
Denis Vlasenko | 8e2cfec | 2008-03-12 23:19:35 +0000 | [diff] [blame] | 411 | signal_SA_RESTART_empty_mask(SIGINT, (void (*)(int))finish); |
| 412 | signal_SA_RESTART_empty_mask(SIGALRM, (void (*)(int))catcher); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 413 | |
Denys Vlasenko | e015d06 | 2018-02-11 13:48:52 +0100 | [diff] [blame] | 414 | /* Send the first packet, arm ALRM */ |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 415 | catcher(); |
| 416 | |
| 417 | while (1) { |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 418 | struct sockaddr_ll from; |
Eric Andersen | 0cb6f35 | 2006-01-30 22:30:41 +0000 | [diff] [blame] | 419 | socklen_t alen = sizeof(from); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 420 | int cc; |
| 421 | |
Denys Vlasenko | e015d06 | 2018-02-11 13:48:52 +0100 | [diff] [blame] | 422 | /* Unblock SIGALRM so that the previously called alarm() |
| 423 | * can prevent recvfrom from blocking forever in case the |
| 424 | * inherited procmask is blocking SIGALRM. |
| 425 | */ |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 426 | sigprocmask(SIG_UNBLOCK, &G.sset, NULL); |
Denys Vlasenko | e015d06 | 2018-02-11 13:48:52 +0100 | [diff] [blame] | 427 | |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 428 | cc = recvfrom(sock_fd, G.packet, sizeof(G.packet), 0, (struct sockaddr *) &from, &alen); |
Denys Vlasenko | e015d06 | 2018-02-11 13:48:52 +0100 | [diff] [blame] | 429 | |
| 430 | /* Don't allow SIGALRMs while we process the reply */ |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 431 | sigprocmask(SIG_BLOCK, &G.sset, NULL); |
Denis Vlasenko | 1dc1b37 | 2006-12-23 02:48:44 +0000 | [diff] [blame] | 432 | if (cc < 0) { |
James Byrne | 6937487 | 2019-07-02 11:35:03 +0200 | [diff] [blame] | 433 | bb_simple_perror_msg("recvfrom"); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 434 | continue; |
| 435 | } |
Denys Vlasenko | d316277 | 2018-02-11 14:35:05 +0100 | [diff] [blame] | 436 | recv_pack(G.packet, cc, &from); |
Glenn L McGrath | 9e59841 | 2003-01-09 10:06:01 +0000 | [diff] [blame] | 437 | } |
| 438 | } |