diff options
author | Andrew Zaborowski <andrew.zaborowski@intel.com> | 2022-09-19 15:31:02 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2022-09-19 13:35:22 -0500 |
commit | 2eaa29005e18c711726a643bea09546a9af6bbe5 (patch) | |
tree | 9b6d255155f1e5bc42e02242df20d85f6bf28301 | |
parent | 638c333a252809374ad6ec69a2871a770fc84044 (diff) |
rtnl: Add l_rtnl_address_get_in_addr
Similar to l_rtnl_route_get_dst_in_addr add a getter for the raw address
value, avoiding extra string conversions.
-rw-r--r-- | ell/ell.sym | 1 | ||||
-rw-r--r-- | ell/rtnl.c | 9 | ||||
-rw-r--r-- | ell/rtnl.h | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/ell/ell.sym b/ell/ell.sym index a28eb550..d76b2eae 100644 --- a/ell/ell.sym +++ b/ell/ell.sym @@ -626,6 +626,7 @@ global: l_rtnl_address_clone; l_rtnl_address_free; l_rtnl_address_get_address; + l_rtnl_address_get_in_addr; l_rtnl_address_get_family; l_rtnl_address_get_prefix_length; l_rtnl_address_get_broadcast; @@ -180,6 +180,15 @@ LIB_EXPORT bool l_rtnl_address_get_address(const struct l_rtnl_address *addr, out_buf); } +LIB_EXPORT const void *l_rtnl_address_get_in_addr( + const struct l_rtnl_address *addr) +{ + if (unlikely(!addr)) + return NULL; + + return addr->family == AF_INET ? (void *) &addr->in_addr : &addr->in6_addr; +} + LIB_EXPORT uint8_t l_rtnl_address_get_family(const struct l_rtnl_address *addr) { if (unlikely(!addr)) @@ -44,6 +44,7 @@ void l_rtnl_address_free(struct l_rtnl_address *addr); DEFINE_CLEANUP_FUNC(l_rtnl_address_free); bool l_rtnl_address_get_address(const struct l_rtnl_address *addr, char *out_buf); +const void *l_rtnl_address_get_in_addr(const struct l_rtnl_address *addr); uint8_t l_rtnl_address_get_family(const struct l_rtnl_address *addr); uint8_t l_rtnl_address_get_prefix_length(const struct l_rtnl_address *addr); bool l_rtnl_address_get_broadcast(const struct l_rtnl_address *addr, |