summaryrefslogtreecommitdiff
path: root/Utilities/cmcurl/lib/if2ip.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmcurl/lib/if2ip.c')
-rw-r--r--Utilities/cmcurl/lib/if2ip.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/Utilities/cmcurl/lib/if2ip.c b/Utilities/cmcurl/lib/if2ip.c
index 132b3eeeea..1d34531932 100644
--- a/Utilities/cmcurl/lib/if2ip.c
+++ b/Utilities/cmcurl/lib/if2ip.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -60,12 +60,10 @@
/* ------------------------------------------------------------------ */
+#ifdef ENABLE_IPV6
/* Return the scope of the given address. */
unsigned int Curl_ipv6_scope(const struct sockaddr *sa)
{
-#ifndef ENABLE_IPV6
- (void) sa;
-#else
if(sa->sa_family == AF_INET6) {
const struct sockaddr_in6 * sa6 = (const struct sockaddr_in6 *)(void *) sa;
const unsigned char *b = sa6->sin6_addr.s6_addr;
@@ -88,27 +86,25 @@ unsigned int Curl_ipv6_scope(const struct sockaddr *sa)
break;
}
}
-#endif
-
return IPV6_SCOPE_GLOBAL;
}
-
+#endif
#if defined(HAVE_GETIFADDRS)
-if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
- unsigned int local_scope_id, const char *interf,
+if2ip_result_t Curl_if2ip(int af,
+#ifdef ENABLE_IPV6
+ unsigned int remote_scope,
+ unsigned int local_scope_id,
+#endif
+ const char *interf,
char *buf, int buf_size)
{
struct ifaddrs *iface, *head;
if2ip_result_t res = IF2IP_NOT_FOUND;
-#ifndef ENABLE_IPV6
- (void) remote_scope;
-#endif
-
-#if !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) || \
- !defined(ENABLE_IPV6)
+#if defined(ENABLE_IPV6) && \
+ !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
(void) local_scope_id;
#endif
@@ -181,8 +177,12 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
#elif defined(HAVE_IOCTL_SIOCGIFADDR)
-if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
- unsigned int local_scope_id, const char *interf,
+if2ip_result_t Curl_if2ip(int af,
+#ifdef ENABLE_IPV6
+ unsigned int remote_scope,
+ unsigned int local_scope_id,
+#endif
+ const char *interf,
char *buf, int buf_size)
{
struct ifreq req;
@@ -192,8 +192,10 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
size_t len;
const char *r;
+#ifdef ENABLE_IPV6
(void)remote_scope;
(void)local_scope_id;
+#endif
if(!interf || (af != AF_INET))
return IF2IP_NOT_FOUND;
@@ -230,13 +232,19 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
#else
-if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
- unsigned int local_scope_id, const char *interf,
+if2ip_result_t Curl_if2ip(int af,
+#ifdef ENABLE_IPV6
+ unsigned int remote_scope,
+ unsigned int local_scope_id,
+#endif
+ const char *interf,
char *buf, int buf_size)
{
(void) af;
+#ifdef ENABLE_IPV6
(void) remote_scope;
(void) local_scope_id;
+#endif
(void) interf;
(void) buf;
(void) buf_size;