diff options
| author | David Lamparter <equinox@diac24.net> | 2020-03-29 11:05:30 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2020-07-14 11:05:45 +0200 |
| commit | 713de9e394ad0150c7f4485cef4d586d4504e9cc (patch) | |
| tree | 52fa65e5671c5a932653fe938d1125c392ae54c0 | |
| parent | 57edbd370e1d0009f1303a229d8aa9245eadb29e (diff) | |
lib/ipaddr: match constants to AF_*
No reason not to do this really.
Signed-off-by: David Lamparter <equinox@diac24.net>
| -rw-r--r-- | lib/ipaddr.h | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/ipaddr.h b/lib/ipaddr.h index cd7f79a04e..46e70966eb 100644 --- a/lib/ipaddr.h +++ b/lib/ipaddr.h @@ -33,9 +33,9 @@ extern "C" { * Generic IP address - union of IPv4 and IPv6 address. */ enum ipaddr_type_t { - IPADDR_NONE = 0, - IPADDR_V4 = 1, /* IPv4 */ - IPADDR_V6 = 2, /* IPv6 */ + IPADDR_NONE = AF_UNSPEC, + IPADDR_V4 = AF_INET, + IPADDR_V6 = AF_INET6, }; struct ipaddr { @@ -84,12 +84,8 @@ static inline int str2ipaddr(const char *str, struct ipaddr *ip) static inline char *ipaddr2str(const struct ipaddr *ip, char *buf, int size) { buf[0] = '\0'; - if (ip) { - if (IS_IPADDR_V4(ip)) - inet_ntop(AF_INET, &ip->ip.addr, buf, size); - else if (IS_IPADDR_V6(ip)) - inet_ntop(AF_INET6, &ip->ip.addr, buf, size); - } + if (ip) + inet_ntop(ip->ipa_type, &ip->ip.addr, buf, size); return buf; } |
