2
* IP address processing
3
* Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation.
9
* Alternatively, this software may be distributed under the terms of BSD
12
* See README and COPYING for more details.
20
const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf,
23
if (buflen == 0 || addr == NULL)
26
if (addr->af == AF_INET) {
27
os_strlcpy(buf, inet_ntoa(addr->u.v4), buflen);
32
if (addr->af == AF_INET6) {
33
if (inet_ntop(AF_INET6, &addr->u.v6, buf, buflen) == NULL)
36
#endif /* CONFIG_IPV6 */
42
int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b)
44
if (a == NULL && b == NULL)
46
if (a == NULL || b == NULL)
51
if (a->u.v4.s_addr != b->u.v4.s_addr)
56
if (os_memcpy(&a->u.v6, &b->u.v6, sizeof(a->u.v6))
60
#endif /* CONFIG_IPV6 */
67
int hostapd_parse_ip_addr(const char *txt, struct hostapd_ip_addr *addr)
69
#ifndef CONFIG_NATIVE_WINDOWS
70
if (inet_aton(txt, &addr->u.v4)) {
76
if (inet_pton(AF_INET6, txt, &addr->u.v6) > 0) {
80
#endif /* CONFIG_IPV6 */
81
#endif /* CONFIG_NATIVE_WINDOWS */