]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: add sizing macro to ipaddr.h
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 1 Feb 2019 21:23:02 +0000 (21:23 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 17 May 2019 00:27:08 +0000 (00:27 +0000)
Useful for getting the size of the relevant data in the `ip` field of
struct ipaddr.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/ipaddr.h

index f4ddadc66e18ec817f7ed001136ff40f60c7c225..503431a7c01438768df9f4ca7482425acf49999d 100644 (file)
@@ -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;