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.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index 6e254f604..587339f9b 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -43,13 +43,13 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
43 time_t prevTime; 43 time_t prevTime;
44 44
45 45
46 if ((s = socket (PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP))) == -1) { 46 if ((s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP))) == -1) {
47 LOG(LOG_ERR, bb_msg_can_not_create_raw_socket); 47 bb_perror_msg(bb_msg_can_not_create_raw_socket);
48 return -1; 48 return -1;
49 } 49 }
50 50
51 if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) { 51 if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) {
52 LOG(LOG_ERR, "Could not setsocketopt on raw socket"); 52 bb_perror_msg("Could not setsocketopt on raw socket");
53 close(s); 53 close(s);
54 return -1; 54 return -1;
55 } 55 }
@@ -81,14 +81,14 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
81 FD_SET(s, &fdset); 81 FD_SET(s, &fdset);
82 tm.tv_sec = timeout; 82 tm.tv_sec = timeout;
83 if (select(s + 1, &fdset, (fd_set *) NULL, (fd_set *) NULL, &tm) < 0) { 83 if (select(s + 1, &fdset, (fd_set *) NULL, (fd_set *) NULL, &tm) < 0) {
84 DEBUG(LOG_ERR, "Error on ARPING request: %m"); 84 bb_perror_msg("Error on ARPING request");
85 if (errno != EINTR) rv = 0; 85 if (errno != EINTR) rv = 0;
86 } else if (FD_ISSET(s, &fdset)) { 86 } else if (FD_ISSET(s, &fdset)) {
87 if (recv(s, &arp, sizeof(arp), 0) < 0 ) rv = 0; 87 if (recv(s, &arp, sizeof(arp), 0) < 0 ) rv = 0;
88 if (arp.operation == htons(ARPOP_REPLY) && 88 if (arp.operation == htons(ARPOP_REPLY) &&
89 memcmp(arp.tHaddr, mac, 6) == 0 && 89 memcmp(arp.tHaddr, mac, 6) == 0 &&
90 *((uint32_t *) arp.sInaddr) == yiaddr) { 90 *((uint32_t *) arp.sInaddr) == yiaddr) {
91 DEBUG(LOG_INFO, "Valid arp reply receved for this address"); 91 DEBUG("Valid arp reply received for this address");
92 rv = 0; 92 rv = 0;
93 break; 93 break;
94 } 94 }
@@ -97,6 +97,6 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
97 prevTime = uptime(); 97 prevTime = uptime();
98 } 98 }
99 close(s); 99 close(s);
100 DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); 100 DEBUG("%salid arp replies for this address", rv ? "No v" : "V");
101 return rv; 101 return rv;
102} 102}