From: Volker Lendecke Date: Sun, 5 Apr 2020 11:01:07 +0000 (+0200) Subject: libsmb: Move get_ipc_connect_master_ip_bcast() to smbtree.c X-Git-Tag: ldb-2.2.0~940 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67b097b8235d8651c237bff757f9dc2067cd634c;p=thirdparty%2Fsamba.git libsmb: Move get_ipc_connect_master_ip_bcast() to smbtree.c ... the only user Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 13d035a8d41..b87287fa24d 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -3873,45 +3873,3 @@ struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx, return cli; } - -/* - * Return the IP address and workgroup of a master browser on the network, and - * connect to it. - */ - -struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx, - const struct user_auth_info *user_info, - char **pp_workgroup_out) -{ - struct sockaddr_storage *ip_list; - struct cli_state *cli; - int i, count; - NTSTATUS status; - - *pp_workgroup_out = NULL; - - DEBUG(99, ("Do broadcast lookup for workgroups on local network\n")); - - /* Go looking for workgroups by broadcasting on the local network */ - - 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 NULL; - } - - for (i = 0; i < count; i++) { - char addr[INET6_ADDRSTRLEN]; - 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], - user_info, pp_workgroup_out); - if (cli) - return(cli); - } - - return NULL; -} diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 879a9dae8ef..b9764a4aae2 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -129,9 +129,6 @@ struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx, struct sockaddr_storage *mb_ip, const struct user_auth_info *user_info, char **pp_workgroup_out); -struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx, - const struct user_auth_info *user_info, - char **pp_workgroup_out); /* The following definitions come from libsmb/clidfs.c */ diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 626279a96fd..123ae35d663 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -27,6 +27,7 @@ #include "libsmb/namequery.h" #include "libsmb/clirap.h" #include "../libcli/smb/smbXcli_base.h" +#include "nameserv.h" static int use_bcast; @@ -78,6 +79,50 @@ static void add_name(const char *machine_name, uint32_t server_type, DLIST_ADD(*name_list, new_name); } +/* + * Return the IP address and workgroup of a master browser on the network, and + * connect to it. + */ + +static struct cli_state *get_ipc_connect_master_ip_bcast( + TALLOC_CTX *ctx, + const struct user_auth_info *user_info, + char **pp_workgroup_out) +{ + struct sockaddr_storage *ip_list; + struct cli_state *cli; + int i, count; + NTSTATUS status; + + *pp_workgroup_out = NULL; + + DEBUG(99, ("Do broadcast lookup for workgroups on local network\n")); + + /* Go looking for workgroups by broadcasting on the local network */ + + 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 NULL; + } + + for (i = 0; i < count; i++) { + char addr[INET6_ADDRSTRLEN]; + 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], user_info, pp_workgroup_out); + if (cli != NULL) { + return(cli); + } + } + + return NULL; +} + /**************************************************************************** display tree of smb workgroups, servers and shares ****************************************************************************/