diff options
author | Brad Spencer <bspencer@blackberry.com> | 2023-02-17 16:01:05 -0400 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2023-03-03 10:05:08 +0100 |
commit | ad4997e5b289c97724fdcbaeb3c8c50222a757c4 (patch) | |
tree | a8c2f4097c794d47ec4b3e19d5559136e122c49c /lib/inet_pton.c | |
parent | 73e9e6d767296c5759972d07f2441c8993ccbb9d (diff) | |
download | curl-ad4997e5b289c97724fdcbaeb3c8c50222a757c4.tar.gz |
urlapi: parse IPv6 literals without ENABLE_IPV6
This makes the URL parser API stable and working the same way
independently of libcurl supporting IPv6 transfers or not.
Closes #10660
Diffstat (limited to 'lib/inet_pton.c')
-rw-r--r-- | lib/inet_pton.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/inet_pton.c b/lib/inet_pton.c index f2e17b874..7d3c69879 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -39,14 +39,21 @@ #define INT16SZ 2 /* + * If ENABLE_IPV6 is disabled, we still want to parse IPv6 addresses, so make + * sure we have _some_ value for AF_INET6 without polluting our fake value + * everywhere. + */ +#if !defined(ENABLE_IPV6) && !defined(AF_INET6) +#define AF_INET6 (AF_INET + 1) +#endif + +/* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ static int inet_pton4(const char *src, unsigned char *dst); -#ifdef ENABLE_IPV6 static int inet_pton6(const char *src, unsigned char *dst); -#endif /* int * inet_pton(af, src, dst) @@ -70,10 +77,8 @@ Curl_inet_pton(int af, const char *src, void *dst) switch(af) { case AF_INET: return (inet_pton4(src, (unsigned char *)dst)); -#ifdef ENABLE_IPV6 case AF_INET6: return (inet_pton6(src, (unsigned char *)dst)); -#endif default: errno = EAFNOSUPPORT; return (-1); @@ -135,7 +140,6 @@ inet_pton4(const char *src, unsigned char *dst) return (1); } -#ifdef ENABLE_IPV6 /* int * inet_pton6(src, dst) * convert presentation level address to network order binary form. @@ -234,6 +238,5 @@ inet_pton6(const char *src, unsigned char *dst) memcpy(dst, tmp, IN6ADDRSZ); return (1); } -#endif /* ENABLE_IPV6 */ #endif /* HAVE_INET_PTON */ |