summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-10-25 18:28:36 -0700
committerJeremy Allison <jra@samba.org>2007-10-25 18:28:36 -0700
commit6128d116b3f09ce0b055d2df89b2f7282185782e (patch)
tree4ad151c7224422b1c8f4e1cdca1ffba3d29391f0 /source3/libsmb
parent922db252728b6a9cf72f463a7ce9d5c13f04f5f8 (diff)
downloadsamba-6128d116b3f09ce0b055d2df89b2f7282185782e.tar.gz
samba-6128d116b3f09ce0b055d2df89b2f7282185782e.tar.bz2
samba-6128d116b3f09ce0b055d2df89b2f7282185782e.zip
Fix resolve name to resolve IPv6 addresses of link-local%ifaddr
Jeremy. (This used to be commit e6609cab732d5cd5cc9a5ae50aee15147f2ec6ec)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/namequery.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 34fe09b8c2..90e6be6a90 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -1594,6 +1594,32 @@ bool resolve_name(const char *name,
char *sitename = NULL;
int count = 0;
+#if defined(HAVE_IPV6)
+ unsigned int if_idx = 0;
+ const char *p = strchr_m(name, '%');
+
+ if (p && (if_idx = if_nametoindex(p+1)) != 0) {
+ char *newname = SMB_STRDUP(name);
+ if (!newname) {
+ return false;
+ }
+ newname[PTR_DIFF(p,name)] = '\0';
+ if (is_ipaddress(newname) &&
+ interpret_string_addr(return_ss,
+ newname, AI_NUMERICHOST)) {
+ struct sockaddr_in6 *psa6 =
+ (struct sockaddr_in6 *)&return_ss;
+ if (psa6->sin6_scope_id == 0 &&
+ IN6_IS_ADDR_LINKLOCAL(&psa6->sin6_addr)) {
+ psa6->sin6_scope_id = if_idx;
+ }
+ SAFE_FREE(newname);
+ return true;
+ }
+ SAFE_FREE(newname);
+ }
+#endif
+
if (is_ipaddress(name)) {
return interpret_string_addr(return_ss, name, AI_NUMERICHOST);
}