summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-06-12 14:07:22 +0200
committerVolker Lendecke <vl@samba.org>2011-06-12 17:07:48 +0200
commit396b646123c1aef81c644ae744e65c71b30067d0 (patch)
tree77da893973426d6971998dedfeae16af85c2ba01 /source3
parent12c3c355966ba7c2da101219ae993fd0ef633026 (diff)
downloadsamba-396b646123c1aef81c644ae744e65c71b30067d0.tar.gz
samba-396b646123c1aef81c644ae744e65c71b30067d0.tar.bz2
samba-396b646123c1aef81c644ae744e65c71b30067d0.zip
s3: Add wins_server_tag_ips()
For a given tag, return the list of all wins servers
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/lib/wins_srv.c42
2 files changed, 44 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4a19f74d4c..815104881d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -913,6 +913,8 @@ unsigned wins_srv_count(void);
char **wins_srv_tags(void);
void wins_srv_tags_free(char **list);
struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip);
+bool wins_server_tag_ips(const char *tag, TALLOC_CTX *mem_ctx,
+ struct in_addr **pservers, int *pnum_servers);
unsigned wins_srv_count_tag(const char *tag);
/* The following definitions come from libsmb/clispnego.c */
diff --git a/source3/lib/wins_srv.c b/source3/lib/wins_srv.c
index 6676f02e94..f9e8f3b0e1 100644
--- a/source3/lib/wins_srv.c
+++ b/source3/lib/wins_srv.c
@@ -328,6 +328,48 @@ struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip)
return t_ip.ip;
}
+bool wins_server_tag_ips(const char *tag, TALLOC_CTX *mem_ctx,
+ struct in_addr **pservers, int *pnum_servers)
+{
+ const char **list;
+ int i, num_servers;
+ struct in_addr *servers;
+
+ list = lp_wins_server_list();
+ if ((list == NULL) || (list[0] == NULL)) {
+ return false;
+ }
+
+ num_servers = 0;
+
+ for (i=0; list[i] != NULL; i++) {
+ struct tagged_ip t_ip;
+ parse_ip(&t_ip, list[i]);
+ if (strcmp(tag, t_ip.tag) == 0) {
+ num_servers += 1;
+ }
+ }
+
+ servers = talloc_array(mem_ctx, struct in_addr, num_servers);
+ if (servers == NULL) {
+ return false;
+ }
+
+ num_servers = 0;
+
+ for (i=0; list[i] != NULL; i++) {
+ struct tagged_ip t_ip;
+ parse_ip(&t_ip, list[i]);
+ if (strcmp(tag, t_ip.tag) == 0) {
+ servers[num_servers] = t_ip.ip;
+ num_servers += 1;
+ }
+ }
+ *pnum_servers = num_servers;
+ *pservers = servers;
+ return true;
+}
+
/*
return a count of the number of IPs for a particular tag, including