summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-04-30 19:23:55 +0200
committerVolker Lendecke <vlendec@samba.org>2011-04-30 20:40:46 +0200
commitd87427973c0f43d85546f5875b223929ac1a50d4 (patch)
tree4c474aac1d731057146fab833cb962898202b92d
parent020b691cf842f30ff42474c2b0102751b5fa17ac (diff)
downloadsamba-d87427973c0f43d85546f5875b223929ac1a50d4.tar.gz
samba-d87427973c0f43d85546f5875b223929ac1a50d4.tar.bz2
samba-d87427973c0f43d85546f5875b223929ac1a50d4.zip
s3: Make name_resolve_bcast return sockaddr_storage
Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Sat Apr 30 20:40:46 CEST 2011 on sn-devel-104
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/libsmb/cliconnect.c15
-rw-r--r--source3/libsmb/libsmb_dir.c25
-rw-r--r--source3/libsmb/namequery.c21
4 files changed, 37 insertions, 27 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index eccf0f9400..c296487eac 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1958,7 +1958,8 @@ NTSTATUS name_query(const char *name, int name_type,
int *num_addrs, uint8_t *flags);
NTSTATUS name_resolve_bcast(const char *name,
int name_type,
- struct ip_service **return_iplist,
+ TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **return_iplist,
int *return_count);
NTSTATUS resolve_wins(const char *name,
int name_type,
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index cb7b7d1bbd..1383978c91 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -3472,9 +3472,10 @@ struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
const struct user_auth_info *user_info,
char **pp_workgroup_out)
{
- struct ip_service *ip_list;
+ struct sockaddr_storage *ip_list;
struct cli_state *cli;
int i, count;
+ NTSTATUS status;
*pp_workgroup_out = NULL;
@@ -3482,18 +3483,20 @@ struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
/* Go looking for workgroups by broadcasting on the local network */
- if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list,
- &count))) {
- DEBUG(99, ("No master browsers responded\n"));
+ status = name_resolve_bcast(MSBROWSE, 1, talloc_tos(),
+ &ip_list, &count);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(99, ("No master browsers responded: %s\n",
+ nt_errstr(status)));
return False;
}
for (i = 0; i < count; i++) {
char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), &ip_list[i].ss);
+ print_sockaddr(addr, sizeof(addr), &ip_list[i]);
DEBUG(99, ("Found master browser %s\n", addr));
- cli = get_ipc_connect_master_ip(ctx, &ip_list[i].ss,
+ cli = get_ipc_connect_master_ip(ctx, &ip_list[i],
user_info, pp_workgroup_out);
if (cli)
return(cli);
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index b0f3c904b4..3602bc5377 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -456,9 +456,10 @@ SMBC_opendir_ctx(SMBCCTX *context,
int i;
int count;
int max_lmb_count;
- struct ip_service *ip_list;
- struct ip_service server_addr;
+ struct sockaddr_storage *ip_list;
+ struct sockaddr_storage server_addr;
struct user_auth_info u_info;
+ NTSTATUS status;
if (share[0] != (char)0 || path[0] != (char)0) {
@@ -498,13 +499,14 @@ SMBC_opendir_ctx(SMBCCTX *context,
*/
ip_list = NULL;
- if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list,
- &count)))
+ status = name_resolve_bcast(MSBROWSE, 1, talloc_tos(),
+ &ip_list, &count);
+ if (!NT_STATUS_IS_OK(status))
{
- SAFE_FREE(ip_list);
+ TALLOC_FREE(ip_list);
- if (!find_master_ip(workgroup, &server_addr.ss)) {
+ if (!find_master_ip(workgroup, &server_addr)) {
if (dir) {
SAFE_FREE(dir->fname);
@@ -515,8 +517,9 @@ SMBC_opendir_ctx(SMBCCTX *context,
return NULL;
}
- ip_list = (struct ip_service *)memdup(
- &server_addr, sizeof(server_addr));
+ ip_list = (struct sockaddr_storage *)talloc_memdup(
+ talloc_tos(), &server_addr,
+ sizeof(server_addr));
if (ip_list == NULL) {
if (dir) {
SAFE_FREE(dir->fname);
@@ -534,13 +537,13 @@ SMBC_opendir_ctx(SMBCCTX *context,
char *wg_ptr = NULL;
struct cli_state *cli = NULL;
- print_sockaddr(addr, sizeof(addr), &ip_list[i].ss);
+ print_sockaddr(addr, sizeof(addr), &ip_list[i]);
DEBUG(99, ("Found master browser %d of %d: %s\n",
i+1, MAX(count, max_lmb_count),
addr));
cli = get_ipc_connect_master_ip(talloc_tos(),
- &ip_list[i].ss,
+ &ip_list[i],
&u_info,
&wg_ptr);
/* cli == NULL is the master browser refused to talk or
@@ -594,7 +597,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
}
}
- SAFE_FREE(ip_list);
+ TALLOC_FREE(ip_list);
} else {
/*
* Server not an empty string ... Check the rest and see what
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 61814f490c..49b2061c09 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -1489,7 +1489,8 @@ static bool convert_ss2service(struct ip_service **return_iplist,
NTSTATUS name_resolve_bcast(const char *name,
int name_type,
- struct ip_service **return_iplist,
+ TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **return_iplist,
int *return_count)
{
int i;
@@ -1537,11 +1538,7 @@ NTSTATUS name_resolve_bcast(const char *name,
return status;
success:
-
- if (!convert_ss2service(return_iplist, ss_list, *return_count) )
- status = NT_STATUS_NO_MEMORY;
-
- TALLOC_FREE(ss_list);
+ *return_iplist = ss_list;
return status;
}
@@ -2075,10 +2072,16 @@ NTSTATUS internal_resolve_name(const char *name,
}
}
} else if(strequal( tok, "bcast")) {
- status = name_resolve_bcast(name, name_type,
- return_iplist,
- return_count);
+ struct sockaddr_storage *ss_list;
+ status = name_resolve_bcast(
+ name, name_type, talloc_tos(),
+ &ss_list, return_count);
if (NT_STATUS_IS_OK(status)) {
+ if (!convert_ss2service(return_iplist,
+ ss_list,
+ *return_count)) {
+ status = NT_STATUS_NO_MEMORY;
+ }
goto done;
}
} else {