eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit f3f343c04bc8bfef533da315b19301a2454b8e1a
parent 4e3e1fbf60803196a0137312d7286a655a1517cf
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date:   Tue, 25 Jun 2019 15:20:53 -0700

rtnlutil: Add parser for ifaddrmsg struct

Its purpose is to extract interface label, ip, and
broadcast addresses out of ifaddrmsg rntl message.

Diffstat:
Msrc/rtnlutil.c | 36++++++++++++++++++++++++++++++++++++
Msrc/rtnlutil.h | 3+++
2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/rtnlutil.c b/src/rtnlutil.c @@ -26,6 +26,7 @@ #include <sys/socket.h> #include <linux/rtnetlink.h> +#include <arpa/inet.h> #include <ell/ell.h> @@ -74,3 +75,38 @@ uint32_t rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex, return id; } + +void rtnl_ifaddr_extract(const struct ifaddrmsg *ifa, int bytes, + char **label, char **ip, char **broadcast) +{ + struct in_addr in_addr; + struct rtattr *attr; + + for (attr = IFA_RTA(ifa); RTA_OK(attr, bytes); + attr = RTA_NEXT(attr, bytes)) { + switch (attr->rta_type) { + case IFA_LOCAL: + if (!ip) + break; + + in_addr = *((struct in_addr *) RTA_DATA(attr)); + *ip = l_strdup(inet_ntoa(in_addr)); + + break; + case IFA_BROADCAST: + if (!broadcast) + break; + + in_addr = *((struct in_addr *) RTA_DATA(attr)); + *broadcast = l_strdup(inet_ntoa(in_addr)); + + break; + case IFA_LABEL: + if (!label) + break; + + *label = l_strdup(RTA_DATA(attr)); + break; + } + } +} diff --git a/src/rtnlutil.h b/src/rtnlutil.h @@ -25,3 +25,6 @@ uint32_t rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex, l_netlink_command_func_t cb, void *user_data, l_netlink_destroy_func_t destroy); + +void rtnl_ifaddr_extract(const struct ifaddrmsg *ifa, int bytes, + char **label, char **ip, char **broadcast);