static int arp_find(in_addr_t ip, struct ether_addr *mac) { int i = 0; do { if (arp_cache_lookup(ip, mac, intf) == 0) return (1); #ifdef __linux__ /* XXX - force the kernel to arp. feh. */ arp_force(ip); #else arp_send(l, ARPOP_REQUEST, NULL, 0, NULL, ip, NULL); #endif usleep(10000); } while (i++ < 3); return (0); }
int arp_find(struct in_addr *ip, struct ether_addr *mac, char* net_ifname) { int i = 0; int result; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; do { // if(pthread_mutex_trylock(&mutex) == EBUSY) // goto sleep; result = arp_cache_lookup(ip, mac, net_ifname); if (result == 0) return (1); // pthread_mutex_unlock(&mutex); arp_force(ip); sleep: sleep(1); } while (i++ < 3); return (0); }