2 * IP address processing
3 * Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
14 const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf,
17 if (buflen == 0 || addr == NULL)
20 if (addr->af == AF_INET) {
21 os_strlcpy(buf, inet_ntoa(addr->u.v4), buflen);
26 if (addr->af == AF_INET6) {
27 if (inet_ntop(AF_INET6, &addr->u.v6, buf, buflen) == NULL)
30 #endif /* CONFIG_IPV6 */
36 int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b)
38 if (a == NULL && b == NULL)
40 if (a == NULL || b == NULL)
45 if (a->u.v4.s_addr != b->u.v4.s_addr)
50 if (os_memcmp(&a->u.v6, &b->u.v6, sizeof(a->u.v6)) != 0)
53 #endif /* CONFIG_IPV6 */
60 int hostapd_parse_ip_addr(const char *txt, struct hostapd_ip_addr *addr)
62 #ifndef CONFIG_NATIVE_WINDOWS
63 if (inet_aton(txt, &addr->u.v4)) {
69 if (inet_pton(AF_INET6, txt, &addr->u.v6) > 0) {
73 #endif /* CONFIG_IPV6 */
74 #endif /* CONFIG_NATIVE_WINDOWS */