Skip to contentSkip to conversation

batctl ping: add IPv6 to ethernet address resolution

RFC New Marco Dalla Torre 1 participant 1 message Sep 16, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

RFC v2 1/1 batctl ping: add IPv6 to ethernet address resolution

Extends "batctl ping" command by allowing the user to specify a valid IPv6 address as target node. The corresponding ethernet link layer (MAC) address is then automatically resolved by the tool.
This is possible by leveraging on a new set of library functions, added by this patch, when performing netlink queries towards the kernel network infrastructure.
This new library can be found in "bat-mnl.c" and corresponding header "bat-mnl.h". The code has been taken from the libmnl project version 1.0.3 with minor modifications.

The netlink query is needed to extract the ethernet address, corresponding to the target IPv6 address, from the local neighbor discovery table. If the target address is not initially found in the table, one or more datagrams are sent to initialize neighbor discovery exchange just like what already happens for ARP tables in the IPv4 case. The old IPv4 address resolution has also been updated to make use netlink queries (instead of looking into "/proc/net/arp") to allow for better code reuse and avoid depending on proc fs if not necessary.

---
NOTABLE CHANGES FROM v1
- fixed accessing invalid memory
- reuse code for IPv4 case

 Makefile    |   2 +-
 bat-mnl.c   | 560 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 bat-mnl.h   |  92 ++++++++++
 functions.c | 288 +++++++++++++++++++++----------
 4 files changed, 850 insertions(+), 92 deletions(-)
 create mode 100644 bat-mnl.c
 create mode 100644 bat-mnl.h
Makefile +1 -1
index 1961298..c62b064 100755
@@ -24,7 +24,7 @@ export CONFIG_BATCTL_BISECT=n
 
 # batctl build
 BINARY_NAME = batctl
-OBJ = main.o bat-hosts.o functions.o sys.o debug.o ping.o traceroute.o tcpdump.o  hash.o debugfs.o ioctl.o list-batman.o translate.o
+OBJ = main.o bat-hosts.o functions.o sys.o debug.o ping.o traceroute.o tcpdump.o  hash.o debugfs.o ioctl.o list-batman.o translate.o bat-mnl.o
 OBJ_BISECT = bisect_iv.o
 MANPAGE = man/batctl.8
 
bat-mnl.c new file +560 -0

560 lines not on this page · raw message

bat-mnl.h new file +92 -0

92 lines not on this page · raw message

functions.c +197 -91

353 lines not on this page · raw message

Signature · 1 line
1.8.3.2