diff options
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/clientgen.c | 2 | ||||
-rw-r--r-- | source3/libsmb/namequery.c | 41 |
2 files changed, 41 insertions, 2 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 20c0c36166..6b07eb65b3 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -535,7 +535,7 @@ The callback function takes 3 arguments: the machine name, the server type and the comment. ****************************************************************************/ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(char *, uint32, char *)) + void (*fn)(const char *, uint32, const char *)) { char *rparam = NULL; char *rdata = NULL; diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index f988504bba..a9da735f36 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -420,7 +420,6 @@ void endlmhosts(FILE *fp) or NetBIOS name. This uses the name switch in the smb.conf to determine the order of name resolution. *********************************************************/ - BOOL resolve_name(char *name, struct in_addr *return_ip) { int i; @@ -573,3 +572,43 @@ BOOL resolve_name(char *name, struct in_addr *return_ip) return False; } + + + +/******************************************************** +find the IP address of the master browser for a workgroup +*********************************************************/ +BOOL find_master(char *group, struct in_addr *master_ip) +{ + int sock; + struct in_addr *iplist = NULL; + int count, i; + int num_interfaces = iface_count(); + + sock = open_socket_in( SOCK_DGRAM, 0, 3, + interpret_addr(lp_socket_address()) ); + + if (sock == -1) return False; + + set_socket_options(sock,"SO_BROADCAST"); + + /* + * Lookup the name on all the interfaces, return on + * the first successful match. + */ + for( i = 0; i < num_interfaces; i++) { + struct in_addr sendto_ip; + /* Done this way to fix compiler error on IRIX 5.x */ + sendto_ip = *iface_bcast(*iface_n_ip(i)); + iplist = name_query(sock, group, 0x1D, True, False, + sendto_ip, &count, NULL); + if(iplist != NULL) { + *master_ip = iplist[0]; + free((char *)iplist); + close(sock); + return True; + } + } + close(sock); + return False; +} |