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>
This commit is contained in:
Quentin Young 2019-02-01 21:23:02 +00:00
parent 0f1f98e837
commit 4f838de420

View 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;