summaryrefslogtreecommitdiff
path: root/source3/utils/nmblookup.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-07-15 10:35:28 +0000
committerAndrew Tridgell <tridge@samba.org>2002-07-15 10:35:28 +0000
commite90b65284812aaa5ff9e9935ce9bbad7791cbbcd (patch)
tree9e744d1dc2f93934a4b49166a37383d3cb2b2139 /source3/utils/nmblookup.c
parentec167dc9cc0ec2ee461837c25a371d2981744208 (diff)
downloadsamba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.gz
samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.bz2
samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.zip
updated the 3.0 branch from the head branch - ready for alpha18
(This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce)
Diffstat (limited to 'source3/utils/nmblookup.c')
-rw-r--r--source3/utils/nmblookup.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c
index 9549d16d04..8e4f5aab03 100644
--- a/source3/utils/nmblookup.c
+++ b/source3/utils/nmblookup.c
@@ -25,6 +25,7 @@
extern BOOL AllowDebugChange;
+static BOOL give_flags = False;
static BOOL use_bcast = True;
static BOOL got_bcast = False;
static struct in_addr bcast_addr;
@@ -63,6 +64,7 @@ static void usage(void)
d_printf("Version %s\n",VERSION);
d_printf("\t-d debuglevel set the debuglevel\n");
d_printf("\t-B broadcast address the address to use for broadcasts\n");
+ d_printf("\t-f list the NMB flags returned\n");
d_printf("\t-U unicast address the address to use for unicast\n");
d_printf("\t-M searches for a master browser\n");
d_printf("\t-R set recursion desired in packet\n");
@@ -99,6 +101,24 @@ static char *node_status_flags(unsigned char flags)
}
/****************************************************************************
+turn the NMB Query flags into a string
+****************************************************************************/
+static char *query_flags(int flags)
+{
+ static fstring ret1;
+ fstrcpy(ret1, "");
+
+ if (flags & NM_FLAGS_RS) fstrcat(ret1, "Response ");
+ if (flags & NM_FLAGS_AA) fstrcat(ret1, "Authoritative ");
+ if (flags & NM_FLAGS_TC) fstrcat(ret1, "Truncated ");
+ if (flags & NM_FLAGS_RD) fstrcat(ret1, "Recursion_Desired ");
+ if (flags & NM_FLAGS_RA) fstrcat(ret1, "Recursion_Available ");
+ if (flags & NM_FLAGS_B) fstrcat(ret1, "Broadcast ");
+
+ return ret1;
+}
+
+/****************************************************************************
do a node status query
****************************************************************************/
static void do_node_status(int fd, char *name, int type, struct in_addr ip)
@@ -132,14 +152,14 @@ send out one query
****************************************************************************/
static BOOL query_one(char *lookup, unsigned int lookup_type)
{
- int j, count;
+ int j, count, flags = 0;
struct in_addr *ip_list=NULL;
if (got_bcast) {
d_printf("querying %s on %s\n", lookup, inet_ntoa(bcast_addr));
ip_list = name_query(ServerFD,lookup,lookup_type,use_bcast,
use_bcast?True:recursion_desired,
- bcast_addr,&count);
+ bcast_addr,&count, &flags, NULL);
} else {
struct in_addr *bcast;
for (j=iface_count() - 1;
@@ -151,12 +171,15 @@ static BOOL query_one(char *lookup, unsigned int lookup_type)
ip_list = name_query(ServerFD,lookup,lookup_type,
use_bcast,
use_bcast?True:recursion_desired,
- *bcast,&count);
+ *bcast,&count, &flags, NULL);
}
}
if (!ip_list) return False;
+ if (give_flags)
+ d_printf("Flags: %s\n", query_flags(flags));
+
for (j=0;j<count;j++) {
if (translate_addresses) {
struct hostent *host = gethostbyaddr((char *)&ip_list[j], sizeof(ip_list[j]), AF_INET);
@@ -203,7 +226,7 @@ int main(int argc,char *argv[])
setup_logging(argv[0],True);
- while ((opt = getopt(argc, argv, "d:B:U:i:s:SMrhART")) != EOF)
+ while ((opt = getopt(argc, argv, "d:fB:U:i:s:SMrhART")) != EOF)
switch (opt)
{
case 'B':
@@ -211,6 +234,9 @@ int main(int argc,char *argv[])
got_bcast = True;
use_bcast = True;
break;
+ case 'f':
+ give_flags = True;
+ break;
case 'U':
bcast_addr = *interpret_addr2(optarg);
got_bcast = True;