aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/arpping.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/arpping.c')
-rw-r--r--networking/udhcp/arpping.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index 89400e296..48158fc43 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -7,14 +7,12 @@
7 * 7 *
8 * Licensed under GPLv2, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2, see file LICENSE in this tarball for details.
9 */ 9 */
10
11#include <netinet/if_ether.h> 10#include <netinet/if_ether.h>
12#include <net/if_arp.h> 11#include <net/if_arp.h>
13 12
14#include "common.h" 13#include "common.h"
15#include "dhcpd.h" 14#include "dhcpd.h"
16 15
17
18struct arpMsg { 16struct arpMsg {
19 /* Ethernet header */ 17 /* Ethernet header */
20 uint8_t h_dest[6]; /* 00 destination ether addr */ 18 uint8_t h_dest[6]; /* 00 destination ether addr */
@@ -38,9 +36,7 @@ enum {
38 ARP_MSG_SIZE = 0x2a 36 ARP_MSG_SIZE = 0x2a
39}; 37};
40 38
41
42/* Returns 1 if no reply received */ 39/* Returns 1 if no reply received */
43
44int FAST_FUNC arpping(uint32_t test_nip, 40int FAST_FUNC arpping(uint32_t test_nip,
45 const uint8_t *safe_mac, 41 const uint8_t *safe_mac,
46 uint32_t from_ip, 42 uint32_t from_ip,
@@ -103,7 +99,7 @@ int FAST_FUNC arpping(uint32_t test_nip,
103 if (r < 0) 99 if (r < 0)
104 break; 100 break;
105 101
106 //bb_error_msg("sHaddr %02x:%02x:%02x:%02x:%02x:%02x", 102 //log3("sHaddr %02x:%02x:%02x:%02x:%02x:%02x",
107 // arp.sHaddr[0], arp.sHaddr[1], arp.sHaddr[2], 103 // arp.sHaddr[0], arp.sHaddr[1], arp.sHaddr[2],
108 // arp.sHaddr[3], arp.sHaddr[4], arp.sHaddr[5]); 104 // arp.sHaddr[3], arp.sHaddr[4], arp.sHaddr[5]);
109 105
@@ -113,13 +109,13 @@ int FAST_FUNC arpping(uint32_t test_nip,
113 /* && memcmp(arp.tHaddr, from_mac, 6) == 0 */ 109 /* && memcmp(arp.tHaddr, from_mac, 6) == 0 */
114 && *((uint32_t *) arp.sInaddr) == test_nip 110 && *((uint32_t *) arp.sInaddr) == test_nip
115 ) { 111 ) {
116 /* if ARP source MAC matches safe_mac 112 /* if ARP source MAC matches safe_mac
117 * (which is client's MAC), then it's not a conflict 113 * (which is client's MAC), then it's not a conflict
118 * (client simply already has this IP and replies to ARPs!) 114 * (client simply already has this IP and replies to ARPs!)
119 */ 115 */
120 if (!safe_mac || memcmp(safe_mac, arp.sHaddr, 6) != 0) 116 if (!safe_mac || memcmp(safe_mac, arp.sHaddr, 6) != 0)
121 rv = 0; 117 rv = 0;
122 //else bb_error_msg("sHaddr == safe_mac"); 118 //else log2("sHaddr == safe_mac");
123 break; 119 break;
124 } 120 }
125 } 121 }