diff options
author | Gerald Carter <jerry@samba.org> | 2004-03-19 16:22:47 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2004-03-19 16:22:47 +0000 |
commit | 56ce6136792478c63d371a7b187c1318043e081f (patch) | |
tree | fba69d1c6080674e3056661f3c79c276c5672f44 /source3/libsmb/cliconnect.c | |
parent | ebf27cf5a12711ea12058876e609864ad642b53a (diff) | |
download | samba-56ce6136792478c63d371a7b187c1318043e081f.tar.gz samba-56ce6136792478c63d371a7b187c1318043e081f.tar.bz2 samba-56ce6136792478c63d371a7b187c1318043e081f.zip |
updating release notes & merging Derrel Lipman's libsmbclient patch from HEAD
(This used to be commit 5fbfaa687a3674287eeadd205f56b2b253a9e2a9)
Diffstat (limited to 'source3/libsmb/cliconnect.c')
-rw-r--r-- | source3/libsmb/cliconnect.c | 86 |
1 files changed, 66 insertions, 20 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 84159e5d62..e75a361e25 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1590,42 +1590,88 @@ struct cli_state *get_ipc_connect(char *server, struct in_addr *server_ip, return NULL; } -/* Return the IP address and workgroup of a master browser on the - network. */ +/* + * Given the IP address of a master browser on the network, return its + * workgroup and connect to it. + * + * This function is provided to allow additional processing beyond what + * get_ipc_connect_master_ip_bcast() does, e.g. to retrieve the list of master + * browsers and obtain each master browsers' list of domains (in case the + * first master browser is recently on the network and has not yet + * synchronized with other master browsers and therefore does not yet have the + * entire network browse list) + */ -struct cli_state *get_ipc_connect_master_ip_bcast(pstring workgroup, struct user_auth_info *user_info) +struct cli_state *get_ipc_connect_master_ip(struct ip_service * mb_ip, pstring workgroup, struct user_auth_info *user_info) { - struct ip_service *ip_list; + static fstring name; struct cli_state *cli; - int i, count; struct in_addr server_ip; - /* Go looking for workgroups by broadcasting on the local network */ + DEBUG(99, ("Looking up name of master browser %s\n", + inet_ntoa(mb_ip->ip))); + + /* + * Do a name status query to find out the name of the master browser. + * We use <01><02>__MSBROWSE__<02>#01 if *#00 fails because a domain + * master browser will not respond to a wildcard query (or, at least, + * an NT4 server acting as the domain master browser will not). + * + * We might be able to use ONLY the query on MSBROWSE, but that's not + * yet been tested with all Windows versions, so until it is, leave + * the original wildcard query as the first choice and fall back to + * MSBROWSE if the wildcard query fails. + */ + if (!name_status_find("*", 0, 0x1d, mb_ip->ip, name) && + !name_status_find(MSBROWSE, 1, 0x1d, mb_ip->ip, name)) { - if (!name_resolve_bcast(MSBROWSE, 1, &ip_list, &count)) { - return False; + DEBUG(99, ("Could not retrieve name status for %s\n", + inet_ntoa(mb_ip->ip))); + return NULL; } - for (i = 0; i < count; i++) { - static fstring name; - - if (!name_status_find("*", 0, 0x1d, ip_list[i].ip, name)) - continue; - - if (!find_master_ip(name, &server_ip)) - continue; + if (!find_master_ip(name, &server_ip)) { + DEBUG(99, ("Could not find master ip for %s\n", name)); + return NULL; + } pstrcpy(workgroup, name); DEBUG(4, ("found master browser %s, %s\n", - name, inet_ntoa(ip_list[i].ip))); + name, inet_ntoa(mb_ip->ip))); cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info); - if (!cli) - continue; - 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(pstring workgroup, struct user_auth_info *user_info) +{ + struct ip_service *ip_list; + struct cli_state *cli; + int i, count; + + DEBUG(99, ("Do broadcast lookup for workgroups on local network\n")); + + /* Go looking for workgroups by broadcasting on the local network */ + + if (!name_resolve_bcast(MSBROWSE, 1, &ip_list, &count)) { + DEBUG(99, ("No master browsers responded\n")); + return False; + } + + for (i = 0; i < count; i++) { + DEBUG(99, ("Found master browser %s\n", inet_ntoa(ip_list[i].ip))); + + cli = get_ipc_connect_master_ip(&ip_list[i], workgroup, user_info); + if (cli) + return(cli); } return NULL; |