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,
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;
/* 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);
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) {
*/
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);
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);
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
}
}
- SAFE_FREE(ip_list);
+ TALLOC_FREE(ip_list);
} else {
/*
* Server not an empty string ... Check the rest and see what
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;
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;
}
}
}
} 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 {