diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-02-01 22:23:02 +0100 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-05-17 02:27:08 +0200 |
commit | 4f838de4201322e6a74e1a0bb0639f22f27d4772 (patch) | |
tree | af535d33ec8403f263d926685cbac4d2b5393aa5 | |
parent | vrrpd: use address cmp for priority tiebreak (diff) | |
download | frr-4f838de4201322e6a74e1a0bb0639f22f27d4772.tar.xz frr-4f838de4201322e6a74e1a0bb0639f22f27d4772.zip |
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 <qlyoung@cumulusnetworks.com>
-rw-r--r-- | lib/ipaddr.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/ipaddr.h b/lib/ipaddr.h index f4ddadc66..503431a7c 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; |