diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-02-01 21:23:02 +0000 | 
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-05-17 00:27:08 +0000 | 
| commit | 4f838de4201322e6a74e1a0bb0639f22f27d4772 (patch) | |
| tree | af535d33ec8403f263d926685cbac4d2b5393aa5 /lib/ipaddr.h | |
| parent | 0f1f98e8377b624b0c67e4ca845fb142d4db7812 (diff) | |
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>
Diffstat (limited to 'lib/ipaddr.h')
| -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 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;  | 
