summaryrefslogtreecommitdiffstats
path: root/source/utils/nmblookup.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/utils/nmblookup.c')
-rw-r--r--source/utils/nmblookup.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c
index aa431733322..a543b90762f 100644
--- a/source/utils/nmblookup.c
+++ b/source/utils/nmblookup.c
@@ -25,16 +25,13 @@
#endif
#include "includes.h"
-#include "nameserv.h"
extern int DEBUGLEVEL;
extern pstring scope;
-extern struct in_addr bcast_ip;
extern pstring myhostname;
-
-static BOOL got_bcast = False;
+extern struct in_addr ipzero;
int ServerFD= -1;
@@ -52,7 +49,7 @@ static BOOL open_sockets(void)
return False;
}
- ServerFD = open_socket_in(SOCK_DGRAM, 0,3);
+ ServerFD = open_socket_in(SOCK_DGRAM, NMB_PORT,3);
if (ServerFD == -1)
return(False);
@@ -69,24 +66,9 @@ static BOOL open_sockets(void)
****************************************************************************/
static BOOL init_structs(void )
{
- struct in_addr myip;
-
- if (!get_myname(myhostname,&myip))
+ if (!get_myname(myhostname,NULL))
return(False);
- /* Read the broadcast address from the interface */
- {
- struct in_addr ip0,ip2;
-
- ip0 = myip;
-
- if (!got_bcast) {
- get_broadcast(&ip0,&bcast_ip,&ip2);
-
- DEBUG(2,("Using broadcast %s\n",inet_ntoa(bcast_ip)));
- }
- }
-
return True;
}
@@ -111,7 +93,7 @@ static void usage(void)
int main(int argc,char *argv[])
{
int opt;
- unsigned int lookup_type = 0x20;
+ unsigned int lookup_type = 0x0;
pstring lookup;
extern int optind;
extern char *optarg;
@@ -132,11 +114,7 @@ int main(int argc,char *argv[])
switch (opt)
{
case 'B':
- {
- unsigned long a = interpret_addr(optarg);
- putip((char *)&bcast_ip,(char *)&a);
- got_bcast = True;
- }
+ iface_set_default(NULL,optarg,NULL);
break;
case 'i':
strcpy(scope,optarg);
@@ -165,10 +143,11 @@ int main(int argc,char *argv[])
exit(1);
}
+ load_interfaces();
init_structs();
if (!open_sockets()) return(1);
- DEBUG(1,("Sending queries to %s\n",inet_ntoa(bcast_ip)));
+ DEBUG(1,("Sending queries to %s\n",inet_ntoa(*iface_bcast(ipzero))));
for (i=optind;i<argc;i++)
@@ -185,7 +164,7 @@ int main(int argc,char *argv[])
strcpy(lookup,"\01\02__MSBROWSE__\02");
lookup_type = 1;
} else {
- lookup_type = 0x1d;
+ lookup_type = 0x1b;
}
}
@@ -199,7 +178,7 @@ int main(int argc,char *argv[])
}
if (name_query(ServerFD,lookup,lookup_type,bcast,True,
- bcast_ip,&ip,NULL))
+ *iface_bcast(ipzero),&ip,NULL))
{
printf("%s %s\n",inet_ntoa(ip),lookup);
if (find_status)