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_ntop.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_ntop.c')
-rw-r--r-- | lib/inet_ntop.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c index 024f8da36..770ed3a59 100644 --- a/lib/inet_ntop.c +++ b/lib/inet_ntop.c @@ -42,6 +42,15 @@ #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 + +/* * Format an IPv4 address, more or less like inet_ntop(). * * Returns `dst' (as a const) @@ -72,7 +81,6 @@ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size) return dst; } -#ifdef ENABLE_IPV6 /* * Convert IPv6 binary address into presentation (printable) format. */ @@ -168,7 +176,6 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size) strcpy(dst, tmp); return dst; } -#endif /* ENABLE_IPV6 */ /* * Convert a network format address to presentation format. @@ -187,10 +194,8 @@ char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size) switch(af) { case AF_INET: return inet_ntop4((const unsigned char *)src, buf, size); -#ifdef ENABLE_IPV6 case AF_INET6: return inet_ntop6((const unsigned char *)src, buf, size); -#endif default: errno = EAFNOSUPPORT; return NULL; |