From 6ee4366093b24251aa52c272512b2efacb9582d8 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 17 May 2002 03:37:37 +0000 Subject: Changes to allow head to translate NMB flags ... (This used to be commit c986a19cde0dfa96b512eb24d873203981e68c48) --- source3/utils/nmblookup.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 9549d16d04..2373beb0c9 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"); @@ -98,6 +100,24 @@ static char *node_status_flags(unsigned char flags) return ret; } +/**************************************************************************** +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 ****************************************************************************/ @@ -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); } 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); } } if (!ip_list) return False; + if (give_flags) + d_printf("Flags: %s\n", query_flags(flags)); + for (j=0;j