summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-11-27 15:54:53 +0100
committerThomas Haller <thaller@redhat.com>2023-11-29 16:03:40 +0100
commit057aac1334afd58f81319fa1e39a0eca48aea2b3 (patch)
treec86fd4e33e0928f90cfd6d818fa440885e971288
parentcd4016bab267e6984693032338c8f43232ff6a3e (diff)
downloadlibnl-057aac1334afd58f81319fa1e39a0eca48aea2b3.tar.gz
nl-base-utils: add _nl_addr_family_to_size() helper
-rw-r--r--include/base/nl-base-utils.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/base/nl-base-utils.h b/include/base/nl-base-utils.h
index fb6bdf2d..6dd9c49f 100644
--- a/include/base/nl-base-utils.h
+++ b/include/base/nl-base-utils.h
@@ -663,6 +663,17 @@ static inline void *_nl_memdup(const void *ptr, size_t len)
/*****************************************************************************/
+static inline size_t _nl_addr_family_to_size(int addr_family)
+{
+ if (addr_family == AF_INET)
+ return sizeof(in_addr_t);
+ if (addr_family == AF_INET6)
+ return sizeof(struct in6_addr);
+ return 0;
+}
+
+/*****************************************************************************/
+
typedef union {
in_addr_t addr4;
struct in_addr a4;