diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-08-16 19:56:16 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-08-16 19:56:16 +0200 |
commit | fb52769f4a18920e597359962addf60858f158b5 (patch) | |
tree | 2c78bc611ceb93f19f23588e97025ff4a0899c93 | |
parent | 26ccd3d062a1949d3fd73b01cdf55e700bde1981 (diff) | |
download | busybox-w32-fb52769f4a18920e597359962addf60858f158b5.tar.gz busybox-w32-fb52769f4a18920e597359962addf60858f158b5.tar.bz2 busybox-w32-fb52769f4a18920e597359962addf60858f158b5.zip |
arping: make help text clearer
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/arping.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/networking/arping.c b/networking/arping.c index dbfd75ef5..8be1aac2c 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -13,11 +13,11 @@ | |||
13 | //usage: "\n -f Quit on first ARP reply" | 13 | //usage: "\n -f Quit on first ARP reply" |
14 | //usage: "\n -q Quiet" | 14 | //usage: "\n -q Quiet" |
15 | //usage: "\n -b Keep broadcasting, don't go unicast" | 15 | //usage: "\n -b Keep broadcasting, don't go unicast" |
16 | //usage: "\n -D Duplicated address detection mode" | 16 | //usage: "\n -D Exit with 1 if DST_IP replies" |
17 | //usage: "\n -U Unsolicited ARP mode, update your neighbors" | 17 | //usage: "\n -U Unsolicited ARP mode, update your neighbors" |
18 | //usage: "\n -A ARP answer mode, update your neighbors" | 18 | //usage: "\n -A ARP answer mode, update your neighbors" |
19 | //usage: "\n -c N Stop after sending N ARP requests" | 19 | //usage: "\n -c N Stop after sending N ARP requests" |
20 | //usage: "\n -w TIMEOUT Time to wait for ARP reply, seconds" | 20 | //usage: "\n -w TIMEOUT Seconds to wait for ARP reply" |
21 | //usage: "\n -I IFACE Interface to use (default eth0)" | 21 | //usage: "\n -I IFACE Interface to use (default eth0)" |
22 | //usage: "\n -s SRC_IP Sender IP address" | 22 | //usage: "\n -s SRC_IP Sender IP address" |
23 | //usage: "\n DST_IP Target IP address" | 23 | //usage: "\n DST_IP Target IP address" |
@@ -162,7 +162,7 @@ static void catcher(void) | |||
162 | alarm(1); | 162 | alarm(1); |
163 | } | 163 | } |
164 | 164 | ||
165 | static bool recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | 165 | static void recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) |
166 | { | 166 | { |
167 | struct arphdr *ah = (struct arphdr *) buf; | 167 | struct arphdr *ah = (struct arphdr *) buf; |
168 | unsigned char *p = (unsigned char *) (ah + 1); | 168 | unsigned char *p = (unsigned char *) (ah + 1); |
@@ -181,33 +181,33 @@ static bool recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
181 | if (FROM->sll_pkttype != PACKET_HOST | 181 | if (FROM->sll_pkttype != PACKET_HOST |
182 | && FROM->sll_pkttype != PACKET_BROADCAST | 182 | && FROM->sll_pkttype != PACKET_BROADCAST |
183 | && FROM->sll_pkttype != PACKET_MULTICAST) | 183 | && FROM->sll_pkttype != PACKET_MULTICAST) |
184 | return false; | 184 | return; |
185 | 185 | ||
186 | /* Only these types are recognized */ | 186 | /* Only these types are recognized */ |
187 | if (ah->ar_op != htons(ARPOP_REQUEST) && ah->ar_op != htons(ARPOP_REPLY)) | 187 | if (ah->ar_op != htons(ARPOP_REQUEST) && ah->ar_op != htons(ARPOP_REPLY)) |
188 | return false; | 188 | return; |
189 | 189 | ||
190 | /* ARPHRD check and this darned FDDI hack here :-( */ | 190 | /* ARPHRD check and this darned FDDI hack here :-( */ |
191 | if (ah->ar_hrd != htons(FROM->sll_hatype) | 191 | if (ah->ar_hrd != htons(FROM->sll_hatype) |
192 | && (FROM->sll_hatype != ARPHRD_FDDI || ah->ar_hrd != htons(ARPHRD_ETHER))) | 192 | && (FROM->sll_hatype != ARPHRD_FDDI || ah->ar_hrd != htons(ARPHRD_ETHER))) |
193 | return false; | 193 | return; |
194 | 194 | ||
195 | /* Protocol must be IP. */ | 195 | /* Protocol must be IP. */ |
196 | if (ah->ar_pro != htons(ETH_P_IP) | 196 | if (ah->ar_pro != htons(ETH_P_IP) |
197 | || (ah->ar_pln != 4) | 197 | || (ah->ar_pln != 4) |
198 | || (ah->ar_hln != me.sll_halen) | 198 | || (ah->ar_hln != me.sll_halen) |
199 | || (len < (int)(sizeof(*ah) + 2 * (4 + ah->ar_hln)))) | 199 | || (len < (int)(sizeof(*ah) + 2 * (4 + ah->ar_hln)))) |
200 | return false; | 200 | return; |
201 | 201 | ||
202 | move_from_unaligned32(src_ip.s_addr, p + ah->ar_hln); | 202 | move_from_unaligned32(src_ip.s_addr, p + ah->ar_hln); |
203 | move_from_unaligned32(dst_ip.s_addr, p + ah->ar_hln + 4 + ah->ar_hln); | 203 | move_from_unaligned32(dst_ip.s_addr, p + ah->ar_hln + 4 + ah->ar_hln); |
204 | 204 | ||
205 | if (dst.s_addr != src_ip.s_addr) | 205 | if (dst.s_addr != src_ip.s_addr) |
206 | return false; | 206 | return; |
207 | if (!(option_mask32 & DAD)) { | 207 | if (!(option_mask32 & DAD)) { |
208 | if ((src.s_addr != dst_ip.s_addr) | 208 | if ((src.s_addr != dst_ip.s_addr) |
209 | || (memcmp(p + ah->ar_hln + 4, &me.sll_addr, ah->ar_hln))) | 209 | || (memcmp(p + ah->ar_hln + 4, &me.sll_addr, ah->ar_hln))) |
210 | return false; | 210 | return; |
211 | } else { | 211 | } else { |
212 | /* DAD packet was: | 212 | /* DAD packet was: |
213 | src_ip = 0 (or some src) | 213 | src_ip = 0 (or some src) |
@@ -224,7 +224,7 @@ static bool recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
224 | */ | 224 | */ |
225 | if ((memcmp(p, &me.sll_addr, me.sll_halen) == 0) | 225 | if ((memcmp(p, &me.sll_addr, me.sll_halen) == 0) |
226 | || (src.s_addr && src.s_addr != dst_ip.s_addr)) | 226 | || (src.s_addr && src.s_addr != dst_ip.s_addr)) |
227 | return false; | 227 | return; |
228 | } | 228 | } |
229 | if (!(option_mask32 & QUIET)) { | 229 | if (!(option_mask32 & QUIET)) { |
230 | int s_printed = 0; | 230 | int s_printed = 0; |
@@ -264,7 +264,6 @@ static bool recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
264 | memcpy(he.sll_addr, p, me.sll_halen); | 264 | memcpy(he.sll_addr, p, me.sll_halen); |
265 | option_mask32 |= UNICASTING; | 265 | option_mask32 |= UNICASTING; |
266 | } | 266 | } |
267 | return true; | ||
268 | } | 267 | } |
269 | 268 | ||
270 | int arping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 269 | int arping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |