diff options
author | Andrew Bartlett <abartlet@samba.org> | 2009-09-15 07:42:54 -0700 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2009-09-15 07:42:54 -0700 |
commit | 668470c9923364c6c43afbf94162b549c8baef9a (patch) | |
tree | 43584485ac1a94195b201bc7fd5f2da80acfacda /source3/lib | |
parent | f07e77e13ff86c76644660e2d574e663c9ffdeb8 (diff) | |
download | samba-668470c9923364c6c43afbf94162b549c8baef9a.tar.gz samba-668470c9923364c6c43afbf94162b549c8baef9a.tar.bz2 samba-668470c9923364c6c43afbf94162b549c8baef9a.zip |
libcli:nbt make the lmhosts parsing code and dependicies common
This starts the process to have Samba4 use lmhosts.
Andrew Bartlett
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_sock.c | 115 |
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. ****************************************************************************/ |