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.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c
index a134b218f61..4fffed74fd9 100644
--- a/source/utils/nmblookup.c
+++ b/source/utils/nmblookup.c
@@ -26,6 +26,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;
@@ -64,6 +65,7 @@ static void usage(void)
printf("Version %s\n",VERSION);
printf("\t-d debuglevel set the debuglevel\n");
printf("\t-B broadcast address the address to use for broadcasts\n");
+ printf("\t-f lists flags returned from a name query\n");
printf("\t-U unicast address the address to use for unicast\n");
printf("\t-M searches for a master browser\n");
printf("\t-R set recursion desired in packet\n");
@@ -100,6 +102,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)
@@ -133,14 +153,14 @@ send out one query
****************************************************************************/
static BOOL query_one(char *lookup, unsigned int lookup_type)
{
- int j, count;
+ int j, count, flags;
struct in_addr *ip_list=NULL;
if (got_bcast) {
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);
} else {
struct in_addr *bcast;
for (j=iface_count() - 1;
@@ -152,10 +172,13 @@ 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);
}
}
+ if (give_flags)
+ printf("Flags: %s\n", query_flags(flags));
+
if (!ip_list) return False;
for (j=0;j<count;j++) {
@@ -208,7 +231,7 @@ int main(int argc,char *argv[])
charset_initialise();
- 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':
@@ -216,6 +239,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;