summaryrefslogtreecommitdiff
path: root/source3/lib/util_sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r--source3/lib/util_sock.c115
1 files changed, 0 insertions, 115 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 6cc2e53811..08cbced1e5 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -21,121 +21,6 @@
#include "includes.h"
-/*******************************************************************
- Map a text hostname or IP address (IPv4 or IPv6) into a
- struct sockaddr_storage. Takes a flag which allows it to
- prefer an IPv4 address (needed for DC's).
-******************************************************************/
-
-static bool interpret_string_addr_pref(struct sockaddr_storage *pss,
- const char *str,
- int flags,
- bool prefer_ipv4)
-{
- struct addrinfo *res = NULL;
-#if defined(HAVE_IPV6)
- char addr[INET6_ADDRSTRLEN];
- unsigned int scope_id = 0;
-
- if (strchr_m(str, ':')) {
- char *p = strchr_m(str, '%');
-
- /*
- * Cope with link-local.
- * This is IP:v6:addr%ifname.
- */
-
- if (p && (p > str) && ((scope_id = if_nametoindex(p+1)) != 0)) {
- strlcpy(addr, str,
- MIN(PTR_DIFF(p,str)+1,
- sizeof(addr)));
- str = addr;
- }
- }
-#endif
-
- zero_sockaddr(pss);
-
- if (!interpret_string_addr_internal(&res, str, flags|AI_ADDRCONFIG)) {
- return false;
- }
- if (!res) {
- return false;
- }
-
- if (prefer_ipv4) {
- struct addrinfo *p;
-
- for (p = res; p; p = p->ai_next) {
- if (p->ai_family == AF_INET) {
- memcpy(pss, p->ai_addr, p->ai_addrlen);
- break;
- }
- }
- if (p == NULL) {
- /* Copy the first sockaddr. */
- memcpy(pss, res->ai_addr, res->ai_addrlen);
- }
- } else {
- /* Copy the first sockaddr. */
- memcpy(pss, res->ai_addr, res->ai_addrlen);
- }
-
-#if defined(HAVE_IPV6)
- if (pss->ss_family == AF_INET6 && scope_id) {
- struct sockaddr_in6 *ps6 = (struct sockaddr_in6 *)pss;
- if (IN6_IS_ADDR_LINKLOCAL(&ps6->sin6_addr) &&
- ps6->sin6_scope_id == 0) {
- ps6->sin6_scope_id = scope_id;
- }
- }
-#endif
-
- freeaddrinfo(res);
- return true;
-}
-
-/*******************************************************************
- Map a text hostname or IP address (IPv4 or IPv6) into a
- struct sockaddr_storage. Address agnostic version.
-******************************************************************/
-
-bool interpret_string_addr(struct sockaddr_storage *pss,
- const char *str,
- int flags)
-{
- return interpret_string_addr_pref(pss,
- str,
- flags,
- false);
-}
-
-/*******************************************************************
- Map a text hostname or IP address (IPv4 or IPv6) into a
- struct sockaddr_storage. Version that prefers IPv4.
-******************************************************************/
-
-bool interpret_string_addr_prefer_ipv4(struct sockaddr_storage *pss,
- const char *str,
- int flags)
-{
- return interpret_string_addr_pref(pss,
- str,
- flags,
- true);
-}
-
-/*******************************************************************
- Set an address to INADDR_ANY.
-******************************************************************/
-
-void zero_sockaddr(struct sockaddr_storage *pss)
-{
- memset(pss, '\0', sizeof(*pss));
- /* Ensure we're at least a valid sockaddr-storage. */
- pss->ss_family = AF_INET;
-}
-
/****************************************************************************
Get a port number in host byte order from a sockaddr_storage.
****************************************************************************/