summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorRichard Sharpe <sharpe@samba.org>2002-05-17 03:37:37 +0000
committerRichard Sharpe <sharpe@samba.org>2002-05-17 03:37:37 +0000
commit6ee4366093b24251aa52c272512b2efacb9582d8 (patch)
treebabf9b0cc7aefbb43019fefc580944a2a366d655 /source3
parent4f783edcf3a01572589866031fa312316a703a34 (diff)
downloadsamba-6ee4366093b24251aa52c272512b2efacb9582d8.tar.gz
samba-6ee4366093b24251aa52c272512b2efacb9582d8.tar.bz2
samba-6ee4366093b24251aa52c272512b2efacb9582d8.zip
Changes to allow head to translate NMB flags ...
(This used to be commit c986a19cde0dfa96b512eb24d873203981e68c48)
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/namequery.c22
-rw-r--r--source3/nsswitch/winbindd_wins.c8
-rw-r--r--source3/nsswitch/wins.c8
-rw-r--r--source3/utils/nmblookup.c34
-rw-r--r--source3/web/diagnose.c4
5 files changed, 59 insertions, 17 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index c578df6621..85f33aeda4 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -305,7 +305,7 @@ BOOL name_register(int fd, const char *name, int name_type,
****************************************************************************/
struct in_addr *name_query(int fd,const char *name,int name_type,
BOOL bcast,BOOL recurse,
- struct in_addr to_ip, int *count)
+ struct in_addr to_ip, int *count, int *flags)
{
BOOL found=False;
int i, retries = 3;
@@ -318,6 +318,7 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
memset((char *)&p,'\0',sizeof(p));
(*count) = 0;
+ (*flags) = 0;
nmb->header.name_trn_id = generate_trn_id();
nmb->header.opcode = 0;
@@ -440,6 +441,19 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
found=True;
retries=0;
+ /* We add the flags back ... */
+ if (nmb2->header.response)
+ (*flags) |= NM_FLAGS_RS;
+ if (nmb2->header.nm_flags.authoritative)
+ (*flags) |= NM_FLAGS_AA;
+ if (nmb2->header.nm_flags.trunc)
+ (*flags) |= NM_FLAGS_TC;
+ if (nmb2->header.nm_flags.recursion_desired)
+ (*flags) |= NM_FLAGS_RD;
+ if (nmb2->header.nm_flags.recursion_available)
+ (*flags) |= NM_FLAGS_RA;
+ if (nmb2->header.nm_flags.bcast)
+ (*flags) |= NM_FLAGS_B;
free_packet(p2);
/*
* If we're doing a unicast lookup we only
@@ -670,10 +684,11 @@ BOOL name_resolve_bcast(const char *name, int name_type,
*/
for( i = num_interfaces-1; i >= 0; i--) {
struct in_addr sendto_ip;
+ int flags;
/* Done this way to fix compiler error on IRIX 5.x */
sendto_ip = *iface_n_bcast(i);
*return_ip_list = name_query(sock, name, name_type, True,
- True, sendto_ip, return_count);
+ True, sendto_ip, return_count, &flags);
if(*return_ip_list != NULL) {
close(sock);
return True;
@@ -726,6 +741,7 @@ static BOOL resolve_wins(const char *name, int name_type,
DEBUG(3, ("resolve_wins: WINS server == <%s>\n", inet_ntoa(wins_ip)) );
if((wins_ismyip && !global_in_nmbd) || !wins_ismyip) {
+ int flags;
sock = open_socket_in( SOCK_DGRAM, 0, 3,
interpret_addr(lp_socket_address()),
True );
@@ -733,7 +749,7 @@ static BOOL resolve_wins(const char *name, int name_type,
*return_iplist = name_query( sock, name,
name_type, False,
True, wins_ip,
- return_count);
+ return_count, &flags);
if(*return_iplist != NULL) {
close(sock);
return True;
diff --git a/source3/nsswitch/winbindd_wins.c b/source3/nsswitch/winbindd_wins.c
index af624170eb..5163cfcea1 100644
--- a/source3/nsswitch/winbindd_wins.c
+++ b/source3/nsswitch/winbindd_wins.c
@@ -85,7 +85,7 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
int fd;
struct in_addr *ret = NULL;
struct in_addr p;
- int j;
+ int j, flags = 0;
*count = 0;
@@ -95,13 +95,13 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
p = wins_srv_ip();
if( !is_zero_ip(p) ) {
- ret = name_query(fd,name,0x20,False,True, p, count);
+ ret = name_query(fd,name,0x20,False,True, p, count, &flags);
goto out;
}
if (lp_wins_support()) {
/* we are our own WINS server */
- ret = name_query(fd,name,0x20,False,True, *interpret_addr2("127.0.0.1"), count);
+ ret = name_query(fd,name,0x20,False,True, *interpret_addr2("127.0.0.1"), count, &flags);
goto out;
}
@@ -110,7 +110,7 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
j >= 0;
j--) {
struct in_addr *bcast = iface_n_bcast(j);
- ret = name_query(fd,name,0x20,True,True,*bcast,count);
+ ret = name_query(fd,name,0x20,True,True,*bcast,count, &flags);
if (ret) break;
}
diff --git a/source3/nsswitch/wins.c b/source3/nsswitch/wins.c
index 2133f817d1..b8fad9f973 100644
--- a/source3/nsswitch/wins.c
+++ b/source3/nsswitch/wins.c
@@ -118,7 +118,7 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
int fd;
struct in_addr *ret = NULL;
struct in_addr p;
- int j;
+ int j, flags = 0;
if (!initialised) {
nss_wins_init();
@@ -132,13 +132,13 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
p = wins_srv_ip();
if( !is_zero_ip(p) ) {
- ret = name_query(fd,name,0x20,False,True, p, count);
+ ret = name_query(fd,name,0x20,False,True, p, count, &flags);
goto out;
}
if (lp_wins_support()) {
/* we are our own WINS server */
- ret = name_query(fd,name,0x20,False,True, *interpret_addr2("127.0.0.1"), count);
+ ret = name_query(fd,name,0x20,False,True, *interpret_addr2("127.0.0.1"), count, &flags);
goto out;
}
@@ -147,7 +147,7 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
j >= 0;
j--) {
struct in_addr *bcast = iface_n_bcast(j);
- ret = name_query(fd,name,0x20,True,True,*bcast,count);
+ ret = name_query(fd,name,0x20,True,True,*bcast,count, &flags);
if (ret) break;
}
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");
@@ -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);
} 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<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;
diff --git a/source3/web/diagnose.c b/source3/web/diagnose.c
index 73c23ea2bb..c1c8807e4d 100644
--- a/source3/web/diagnose.c
+++ b/source3/web/diagnose.c
@@ -27,14 +27,14 @@
BOOL nmbd_running(void)
{
extern struct in_addr loopback_ip;
- int fd, count;
+ int fd, count, flags;
struct in_addr *ip_list;
if ((fd = open_socket_in(SOCK_DGRAM, 0, 3,
interpret_addr("127.0.0.1"), True)) != -1) {
if ((ip_list = name_query(fd, "__SAMBA__", 0,
True, True, loopback_ip,
- &count)) != NULL) {
+ &count, &flags)) != NULL) {
SAFE_FREE(ip_list);
close(fd);
return True;