From: Joseph C. Lehner Date: Mon, 10 Sep 2018 18:30:28 +0000 (+0200) Subject: Use SIOCxARP instead of libnl for Linux ARP stuff (WIP) X-Git-Tag: v0.9.13~3 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f6a08220f1329a8802c03765129adb4e4d55b5b4;p=oweals%2Fnmrpflash.git Use SIOCxARP instead of libnl for Linux ARP stuff (WIP) --- diff --git a/ethsock.c b/ethsock.c index d8a7326..088ec9c 100644 --- a/ethsock.c +++ b/ethsock.c @@ -253,6 +253,33 @@ out: static bool intf_add_del_arp(const char *intf, uint32_t ipaddr, uint8_t *hwaddr, bool add) { +#if 0 + struct arpreq arp; + memset(&arp, 0, sizeof(arp)); + arp.arp_ha.sa_family = ARPHRD_ETHER; + memcpy(&arp.arp_ha.sa_data, hwaddr, 6); + arp.arp_flags = ATF_PERM | ATF_COM; + + struct sockaddr_in *in = (struct sockaddr_in*)&req.arp_pa; + in->sin_addr.s_addr = htonl(ipaddr); + in->sin_family = AF_INET; + + int fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { + perror("socket"); + return false; + } + + bool ret = true; + + if (ioctl(fd, add ? SIOCSARP : SIOCDARP, &req) < 0) { + perror(add ? "ioctl(SIOCSARP)" : "ioctl(SIOCDARP"); + ret = false; + } + + close(fd); + return ret; +#else struct nl_sock *sk; struct rtnl_neigh *neigh; struct nl_addr *mac, *ip; @@ -303,6 +330,7 @@ out: nl_socket_free(sk); return !err; +#endif } #endif