* 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 {
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;
}