Unix SMB/Netbios implementation.
Version 1.9.
NBT client - used to lookup netbios names
- Copyright (C) Andrew Tridgell 1994-1995
+ Copyright (C) Andrew Tridgell 1994-1997
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
int ServerFD= -1;
+int RootPort = 0;
+
/****************************************************************************
open the socket communication
**************************************************************************/
return False;
}
- ServerFD = open_socket_in(SOCK_DGRAM, NMB_PORT,3);
+ ServerFD = open_socket_in( SOCK_DGRAM,
+ (RootPort ? 137 :0),
+ 3,
+ interpret_addr(lp_socket_address()) );
if (ServerFD == -1)
return(False);
BOOL find_master=False;
BOOL find_status=False;
int i;
+ static pstring servicesf = CONFIGFILE;
+ struct in_addr bcast_addr;
+ BOOL got_bcast = False;
DEBUGLEVEL = 1;
*lookup = 0;
charset_initialise();
- while ((opt = getopt(argc, argv, "p:d:B:i:SMh")) != EOF)
+ while ((opt = getopt(argc, argv, "d:B:i:s:SMrh")) != EOF)
switch (opt)
{
case 'B':
iface_set_default(NULL,optarg,NULL);
+ bcast_addr = *interpret_addr2(optarg);
+ got_bcast = True;
break;
case 'i':
- strcpy(scope,optarg);
+ fstrcpy(scope,optarg);
strupper(scope);
break;
case 'M':
case 'd':
DEBUGLEVEL = atoi(optarg);
break;
+ case 's':
+ pstrcpy(servicesf, optarg);
+ break;
+ case 'r':
+ RootPort = -1;
+ break;
case 'h':
usage();
exit(0);
exit(1);
}
+ if (!lp_load(servicesf,True)) {
+ fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
+ }
+
load_interfaces();
init_structs();
if (!open_sockets()) return(1);
- DEBUG(1,("Sending queries to %s\n",inet_ntoa(*iface_bcast(ipzero))));
+ if (!got_bcast)
+ bcast_addr = *iface_bcast(ipzero);
+
+ DEBUG(1,("Sending queries to %s\n",inet_ntoa(bcast_addr)));
for (i=optind;i<argc;i++)
- {
+ {
BOOL bcast = True;
int retries = 2;
char *p;
struct in_addr ip;
- strcpy(lookup,argv[i]);
+ fstrcpy(lookup,argv[i]);
if (find_master) {
if (*lookup == '-') {
strcpy(lookup,"\01\02__MSBROWSE__\02");
lookup_type = 1;
} else {
- lookup_type = 0x1b;
+ lookup_type = 0x1d;
}
}
}
if (name_query(ServerFD,lookup,lookup_type,bcast,True,
- *iface_bcast(ipzero),&ip,NULL))
+ bcast_addr,&ip,NULL))
+ {
+ printf("%s %s\n",inet_ntoa(ip),lookup);
+
+ /* We can only do find_status if the ip address returned
+ was valid - ie. name_query returned true.
+ */
+ if (find_status)
{
- printf("%s %s\n",inet_ntoa(ip),lookup);
- if (find_status)
- {
printf("Looking up status of %s\n",inet_ntoa(ip));
name_status(ServerFD,lookup,lookup_type,True,ip,NULL,NULL,NULL);
printf("\n");
- }
- } else {
- printf("couldn't find name %s\n",lookup);
+ }
}
- }
+ else
+ {
+ printf("name_query failed to find name %s\n", lookup);
+ }
+ }
return(0);
}