summaryrefslogtreecommitdiffstats
path: root/source/libsmb/namequery.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-04 11:25:06 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-04 11:25:06 +0000
commit64699810e2d94e8648a0a3341b1cc826d4e8bfd9 (patch)
treea41a8b912e5d896d3deb5b57a7f778adf1a362b4 /source/libsmb/namequery.c
parentbf409a40e21e44ec653d4d8fd34b52d0e7b64aed (diff)
downloadsamba-64699810e2d94e8648a0a3341b1cc826d4e8bfd9.tar.gz
samba-64699810e2d94e8648a0a3341b1cc826d4e8bfd9.tar.xz
samba-64699810e2d94e8648a0a3341b1cc826d4e8bfd9.zip
support NetServerEnum in smbwrapper. You can now do a ls in /smb/ and
it will list all servers in your workgroup. You can set your workgroup with the SMBW_WORKGROUP environment variable.
Diffstat (limited to 'source/libsmb/namequery.c')
-rw-r--r--source/libsmb/namequery.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index f988504bba5..a9da735f362 100644
--- a/source/libsmb/namequery.c
+++ b/source/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;
+}