|
|
|
@ -734,18 +734,19 @@ error: |
|
|
|
return op.error_status; |
|
|
|
} |
|
|
|
|
|
|
|
static char * |
|
|
|
vlc_smb2_resolve(stream_t *access, const char *host, unsigned port) |
|
|
|
static int |
|
|
|
vlc_smb2_resolve(stream_t *access, const char *host, unsigned port, |
|
|
|
char **out_host) |
|
|
|
{ |
|
|
|
(void) access; |
|
|
|
if (!host) |
|
|
|
return NULL; |
|
|
|
return -ENOENT; |
|
|
|
|
|
|
|
#ifdef HAVE_DSM |
|
|
|
/* Test if the host is an IP */ |
|
|
|
struct in_addr addr; |
|
|
|
if (inet_pton(AF_INET, host, &addr) == 1) |
|
|
|
return NULL; |
|
|
|
return -ENOENT; |
|
|
|
|
|
|
|
/* Test if the host can be resolved */ |
|
|
|
struct addrinfo *info = NULL; |
|
|
|
@ -753,28 +754,32 @@ vlc_smb2_resolve(stream_t *access, const char *host, unsigned port) |
|
|
|
{ |
|
|
|
freeaddrinfo(info); |
|
|
|
/* Let smb2 resolve it */ |
|
|
|
return NULL; |
|
|
|
return -ENOENT; |
|
|
|
} |
|
|
|
|
|
|
|
/* Test if the host is a netbios name */ |
|
|
|
char *out_host = NULL; |
|
|
|
netbios_ns *ns = netbios_ns_new(); |
|
|
|
if (!ns) |
|
|
|
return NULL; |
|
|
|
return -ENOMEM; |
|
|
|
|
|
|
|
int ret = -ENOENT; |
|
|
|
netbios_ns_interrupt_register(ns); |
|
|
|
uint32_t ip4_addr; |
|
|
|
if (netbios_ns_resolve(ns, host, NETBIOS_FILESERVER, &ip4_addr) == 0) |
|
|
|
{ |
|
|
|
char ip[INET_ADDRSTRLEN]; |
|
|
|
if (inet_ntop(AF_INET, &ip4_addr, ip, sizeof(ip))) |
|
|
|
out_host = strdup(ip); |
|
|
|
{ |
|
|
|
*out_host = strdup(ip); |
|
|
|
ret = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
netbios_ns_interrupt_unregister(); |
|
|
|
netbios_ns_destroy(ns); |
|
|
|
return out_host; |
|
|
|
return ret; |
|
|
|
#else |
|
|
|
(void) port; |
|
|
|
return NULL; |
|
|
|
return -ENOENT; |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
@ -797,13 +802,14 @@ Open(vlc_object_t *p_obj) |
|
|
|
if (sys->encoded_url.psz_path == NULL) |
|
|
|
sys->encoded_url.psz_path = (char *) "/"; |
|
|
|
|
|
|
|
char *resolved_host = vlc_smb2_resolve(access, sys->encoded_url.psz_host, |
|
|
|
sys->encoded_url.i_port); |
|
|
|
char *resolved_host = NULL; |
|
|
|
ret = vlc_smb2_resolve(access, sys->encoded_url.psz_host, |
|
|
|
sys->encoded_url.i_port, &resolved_host); |
|
|
|
|
|
|
|
/* smb2_* functions need a decoded url. Re compose the url from the
|
|
|
|
* modified sys->encoded_url (with the resolved host). */ |
|
|
|
char *url; |
|
|
|
if (resolved_host != NULL) |
|
|
|
if (ret == 0) |
|
|
|
{ |
|
|
|
vlc_url_t resolved_url = sys->encoded_url; |
|
|
|
resolved_url.psz_host = resolved_host; |
|
|
|
|