summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Sharpe <sharpe@samba.org>2004-04-16 03:57:30 +0000
committerRichard Sharpe <sharpe@samba.org>2004-04-16 03:57:30 +0000
commit1f71693777006047a53da3282bb6e1eadf257a1e (patch)
tree9a7ffcd40309842c699676ed19efb8db10a2b167
parent1f12d3298942bb45dd617ffb373ec8bb0466f805 (diff)
downloadsamba-1f71693777006047a53da3282bb6e1eadf257a1e.tar.gz
samba-1f71693777006047a53da3282bb6e1eadf257a1e.tar.xz
samba-1f71693777006047a53da3282bb6e1eadf257a1e.zip
r248: Add support for printing out the MAC address on nmblookup.
-rw-r--r--source/include/smb.h6
-rw-r--r--source/libsmb/namequery.c15
-rw-r--r--source/nsswitch/winbindd_wins.c2
-rw-r--r--source/nsswitch/wins.c2
-rw-r--r--source/utils/nmblookup.c6
5 files changed, 24 insertions, 7 deletions
diff --git a/source/include/smb.h b/source/include/smb.h
index aab61deaabb..30eb82ddf56 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -1526,6 +1526,12 @@ struct node_status {
unsigned char flags;
};
+/* The extra info from a NetBIOS node status query */
+struct node_status_extra {
+ unsigned char mac_addr[6];
+ /* There really is more here ... */
+};
+
struct pwd_info
{
BOOL null_pwd;
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index b9bc4e11664..2bb7359e742 100644
--- a/source/libsmb/namequery.c
+++ b/source/libsmb/namequery.c
@@ -45,7 +45,7 @@ static int generate_trn_id(void)
Parse a node status response into an array of structures.
****************************************************************************/
-static struct node_status *parse_node_status(char *p, int *num_names)
+static struct node_status *parse_node_status(char *p, int *num_names, struct node_status_extra *extra)
{
struct node_status *ret;
int i;
@@ -68,6 +68,12 @@ static struct node_status *parse_node_status(char *p, int *num_names)
DEBUG(10, ("%s#%02x: flags = 0x%02x\n", ret[i].name,
ret[i].type, ret[i].flags));
}
+ /*
+ * Also, pick up the MAC address ...
+ */
+ if (extra) {
+ memcpy(&extra->mac_addr, p, 6); /* Fill in the mac addr */
+ }
return ret;
}
@@ -78,7 +84,8 @@ static struct node_status *parse_node_status(char *p, int *num_names)
**************************************************************************/
struct node_status *node_status_query(int fd,struct nmb_name *name,
- struct in_addr to_ip, int *num_names)
+ struct in_addr to_ip, int *num_names,
+ struct node_status_extra *extra)
{
BOOL found=False;
int retries = 2;
@@ -149,7 +156,7 @@ struct node_status *node_status_query(int fd,struct nmb_name *name,
continue;
}
- ret = parse_node_status(&nmb2->answers->rdata[0], num_names);
+ ret = parse_node_status(&nmb2->answers->rdata[0], num_names, extra);
free_packet(p2);
return ret;
}
@@ -190,7 +197,7 @@ BOOL name_status_find(const char *q_name, int q_type, int type, struct in_addr t
/* W2K PDC's seem not to respond to '*'#0. JRA */
make_nmb_name(&nname, q_name, q_type);
- status = node_status_query(sock, &nname, to_ip, &count);
+ status = node_status_query(sock, &nname, to_ip, &count, NULL);
close(sock);
if (!status)
goto done;
diff --git a/source/nsswitch/winbindd_wins.c b/source/nsswitch/winbindd_wins.c
index a1eef159c0a..59d600d1eaa 100644
--- a/source/nsswitch/winbindd_wins.c
+++ b/source/nsswitch/winbindd_wins.c
@@ -78,7 +78,7 @@ static struct node_status *lookup_byaddr_backend(char *addr, int *count)
make_nmb_name(&nname, "*", 0);
ip = *interpret_addr2(addr);
- status = node_status_query(fd,&nname,ip, count);
+ status = node_status_query(fd,&nname,ip, count, NULL);
close(fd);
return status;
diff --git a/source/nsswitch/wins.c b/source/nsswitch/wins.c
index 100a103924c..88c65b767f5 100644
--- a/source/nsswitch/wins.c
+++ b/source/nsswitch/wins.c
@@ -145,7 +145,7 @@ static struct node_status *lookup_byaddr_backend(char *addr, int *count)
make_nmb_name(&nname, "*", 0);
ip = *interpret_addr2(addr);
- status = node_status_query(fd,&nname,ip, count);
+ status = node_status_query(fd,&nname,ip, count, NULL);
close(fd);
return status;
diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c
index 3c5a22841ea..7285712c0b7 100644
--- a/source/utils/nmblookup.c
+++ b/source/utils/nmblookup.c
@@ -102,11 +102,12 @@ static void do_node_status(int fd, const char *name, int type, struct in_addr ip
struct nmb_name nname;
int count, i, j;
struct node_status *status;
+ struct node_status_extra extra;
fstring cleanname;
d_printf("Looking up status of %s\n",inet_ntoa(ip));
make_nmb_name(&nname, name, type);
- status = node_status_query(fd,&nname,ip, &count);
+ status = node_status_query(fd,&nname,ip, &count, &extra);
if (status) {
for (i=0;i<count;i++) {
pull_ascii_fstring(cleanname, status[i].name);
@@ -119,6 +120,9 @@ static void do_node_status(int fd, const char *name, int type, struct in_addr ip
}
SAFE_FREE(status);
}
+ d_printf("\n\tMAC Address = %02X-%02X-%02X-%02X-%02X-%02X\n",
+ extra.mac_addr[0], extra.mac_addr[1], extra.mac_addr[2],
+ extra.mac_addr[3], extra.mac_addr[4], extra.mac_addr[5]);
d_printf("\n");
}