From: Quentin Young Date: Fri, 1 Feb 2019 21:23:02 +0000 (+0000) Subject: lib: add sizing macro to ipaddr.h X-Git-Tag: base_7.2~330^2~107 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=4f838de4201322e6a74e1a0bb0639f22f27d4772;p=matthieu%2Ffrr.git lib: add sizing macro to ipaddr.h Useful for getting the size of the relevant data in the `ip` field of struct ipaddr. Signed-off-by: Quentin Young --- diff --git a/lib/ipaddr.h b/lib/ipaddr.h index f4ddadc66e..503431a7c0 100644 --- a/lib/ipaddr.h +++ b/lib/ipaddr.h @@ -56,6 +56,9 @@ struct ipaddr { #define SET_IPADDR_V4(p) (p)->ipa_type = IPADDR_V4 #define SET_IPADDR_V6(p) (p)->ipa_type = IPADDR_V6 +#define IPADDRSZ(p) \ + IS_IPADDR_V4((p)) ? sizeof(struct in_addr) : sizeof(struct in6_addr) + static inline int str2ipaddr(const char *str, struct ipaddr *ip) { int ret;