From f6a08220f1329a8802c03765129adb4e4d55b5b4 Mon Sep 17 00:00:00 2001 From: "Joseph C. Lehner" Date: Mon, 10 Sep 2018 20:30:28 +0200 Subject: [PATCH] Use SIOCxARP instead of libnl for Linux ARP stuff (WIP) --- ethsock.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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 -- 2.25.1