diff options
author | Volker Lendecke <vl@samba.org> | 2011-06-12 14:07:22 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2011-06-12 17:07:48 +0200 |
commit | 396b646123c1aef81c644ae744e65c71b30067d0 (patch) | |
tree | 77da893973426d6971998dedfeae16af85c2ba01 /source3/lib | |
parent | 12c3c355966ba7c2da101219ae993fd0ef633026 (diff) | |
download | samba-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/lib')
-rw-r--r-- | source3/lib/wins_srv.c | 42 |
1 files changed, 42 insertions, 0 deletions
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 |