diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/lib/wins_srv.c | 42 |
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 |