diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-11 22:45:56 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-11 22:45:56 +0000 |
commit | 0746baa7c3e4924ac6a687d0d1fff3b33138eca0 (patch) | |
tree | 22fd4320a4eb7323e817b6e4ac878dec168d65d1 /src/include/gnunet_strings_lib.h | |
parent | 494f33365cb6b1c8d290fb6ad06aa6be45b880a7 (diff) | |
download | gnunet-0746baa7c3e4924ac6a687d0d1fff3b33138eca0.tar.gz gnunet-0746baa7c3e4924ac6a687d0d1fff3b33138eca0.zip |
-LRN: Generalize ip-address str->addr conversion
Diffstat (limited to 'src/include/gnunet_strings_lib.h')
-rw-r--r-- | src/include/gnunet_strings_lib.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index 385b6c042..2beaa9534 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h | |||
@@ -315,6 +315,50 @@ GNUNET_STRINGS_check_filename (const char *filename, | |||
315 | enum GNUNET_STRINGS_FilenameCheck checks); | 315 | enum GNUNET_STRINGS_FilenameCheck checks); |
316 | 316 | ||
317 | 317 | ||
318 | /** | ||
319 | * Tries to convert @zt_addr string to an IPv6 address. | ||
320 | * | ||
321 | * @param zt_addr 0-terminated string. May be mangled by the function. | ||
322 | * @param addrlen length of zt_addr (not counting 0-terminator). | ||
323 | * @param r_buf a buffer to fill. Initially gets filled with zeroes, | ||
324 | * then its sin6_port, sin6_family and sin6_addr are set appropriately. | ||
325 | * @return GNUNET_OK if conversion succeded. GNUNET_SYSERR otherwise, in which | ||
326 | * case the contents of r_buf are undefined. | ||
327 | */ | ||
328 | int | ||
329 | GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen, | ||
330 | struct sockaddr_in6 *r_buf); | ||
331 | |||
332 | /** | ||
333 | * Tries to convert @zt_addr string to an IPv4 address. | ||
334 | * | ||
335 | * @param zt_addr 0-terminated string. May be mangled by the function. | ||
336 | * @param addrlen length of zt_addr (not counting 0-terminator). | ||
337 | * @param r_buf a buffer to fill. | ||
338 | * @return GNUNET_OK if conversion succeded. GNUNET_SYSERR otherwise, in which case | ||
339 | * the contents of r_buf are undefined. | ||
340 | */ | ||
341 | int | ||
342 | GNUNET_STRINGS_to_address_ipv4 (char *zt_addr, uint16_t addrlen, | ||
343 | struct sockaddr_in *r_buf); | ||
344 | |||
345 | /** | ||
346 | * Tries to convert @addr string to an IP (v4 or v6) address. | ||
347 | * IPv6 address must have its address part enclosed in '()' parens | ||
348 | * instead of '[]'. | ||
349 | * Will automatically decide whether to treat @addr as v4 or v6 address. | ||
350 | * | ||
351 | * @param addr a string, may not be 0-terminated. | ||
352 | * @param addrlen number of bytes in addr (if addr is 0-terminated, | ||
353 | * 0-terminator should not be counted towards addrlen). | ||
354 | * @param r_buf a buffer to fill. | ||
355 | * @return GNUNET_OK if conversion succeded. GNUNET_SYSERR otherwise, in which | ||
356 | * case the contents of r_buf are undefined. | ||
357 | */ | ||
358 | int | ||
359 | GNUNET_STRINGS_to_address_ip (const char *addr, uint16_t addrlen, | ||
360 | struct sockaddr_storage *r_buf); | ||
361 | |||
318 | /* ifndef GNUNET_UTIL_STRING_H */ | 362 | /* ifndef GNUNET_UTIL_STRING_H */ |
319 | #endif | 363 | #endif |
320 | /* end of gnunet_util_string.h */ | 364 | /* end of gnunet_util_string.h */ |