From b3b606e7f3e2f8bab7c92e70e8d0e15bf06e3e3b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 9 Sep 2012 04:15:05 +0200 Subject: Implement sending of neigh announcements --- ffd/netif.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ffd/netif.c') diff --git a/ffd/netif.c b/ffd/netif.c index c63b19b..d521a12 100644 --- a/ffd/netif.c +++ b/ffd/netif.c @@ -43,6 +43,7 @@ #define SYSFS_PATH_MAX 256 #define SYSFS_CLASS_NET "/sys/class/net" +#define SYSFS_BATADV "/sys/kernel/debug/batman_adv" static bool netif_file_read(const char *ifname, const char *file, const char *format, ...) { @@ -67,6 +68,19 @@ static bool netif_file_exists(const char *ifname, const char *file) { return (stat(filename, &st) == 0); } +static bool batadv_file_read(const char *ifname, const char *file, const char *format, ...) { + char filename[SYSFS_PATH_MAX]; + + snprintf(filename, SYSFS_PATH_MAX, SYSFS_BATADV"/%s/%s", ifname, file); + + va_list ap; + va_start(ap, format); + bool ret = file_readv(filename, format, ap); + va_end(ap); + + return ret; +} + bool netif_is_mesh(const char *ifname) { return netif_file_exists(ifname, "mesh"); } @@ -180,3 +194,13 @@ void netif_foreach(netif_cb cb, void *arg) { if_freenameindex(ifaces); } + +eth_addr_t netif_mesh_get_primary_addr(const char *ifname) { + eth_addr_t ret; + uint8_t *a = ret.d; + + if (!batadv_file_read(ifname, "originators", "%*[^,], MainIF/MAC: %*[^/]/%x:%x:%x:%x:%x:%x", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5])) + return ETH_ADDR_UNSPEC; + + return ret; +} -- cgit v1.2.3