diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/network.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/toxcore/network.h b/toxcore/network.h index e804379d..aa0c4661 100644 --- a/toxcore/network.h +++ b/toxcore/network.h | |||
@@ -136,6 +136,14 @@ typedef IP4_Port IP_Port; | |||
136 | */ | 136 | */ |
137 | const char *ip_ntoa(IP *ip); | 137 | const char *ip_ntoa(IP *ip); |
138 | 138 | ||
139 | /* ip_equal | ||
140 | * compares two IPAny structures | ||
141 | * unset means unequal | ||
142 | * | ||
143 | * returns 0 when not equal or when uninitialized | ||
144 | */ | ||
145 | int ip_equal(IP *a, IP *b); | ||
146 | |||
139 | /* ipport_equal | 147 | /* ipport_equal |
140 | * compares two IPAny_Port structures | 148 | * compares two IPAny_Port structures |
141 | * unset means unequal | 149 | * unset means unequal |
@@ -158,6 +166,24 @@ void ip_copy(IP *target, IP *source); | |||
158 | void ipport_copy(IP_Port *target, IP_Port *source); | 166 | void ipport_copy(IP_Port *target, IP_Port *source); |
159 | 167 | ||
160 | /* | 168 | /* |
169 | * addr_resolve(): | ||
170 | * uses getaddrinfo to resolve an address into an IP address | ||
171 | * uses the first IPv4/IPv6 addresses returned by getaddrinfo | ||
172 | * | ||
173 | * input | ||
174 | * address: a hostname (or something parseable to an IP address) | ||
175 | * ip: ip.family MUST be initialized, either set to a specific IP version | ||
176 | * (AF_INET/AF_INET6) or to the unspecified AF_UNSPEC (= 0), if both | ||
177 | * IP versions are acceptable | ||
178 | * | ||
179 | * returns in ip a valid IPAny (v4/v6), | ||
180 | * prefers v6 if ip.family was AF_UNSPEC and both available | ||
181 | * returns 0 on failure | ||
182 | */ | ||
183 | |||
184 | int addr_resolve(const char *address, IP *to); | ||
185 | |||
186 | /* | ||
161 | * addr_resolve_or_parse_ip | 187 | * addr_resolve_or_parse_ip |
162 | * resolves string into an IP address | 188 | * resolves string into an IP address |
163 | * | 189 | * |