From c118bcf7556929aadf853a3e0bb7748210126dd2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 3 Jun 2011 16:11:17 +0200 Subject: [PATCH] s3: Use resolve_wins_send/recv in resolve_wins Autobuild-User: Volker Lendecke Autobuild-Date: Sun Jun 12 18:19:41 CEST 2011 on sn-devel-104 --- source3/libsmb/namequery.c | 125 ++++++--------------------------------------- 1 file changed, 15 insertions(+), 110 deletions(-) diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 28fc33e32bd..dc062fb0a0c 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -2133,120 +2133,25 @@ NTSTATUS resolve_wins(const char *name, struct sockaddr_storage **return_iplist, int *return_count) { - int t, i; - char **wins_tags; - struct sockaddr_storage src_ss; - struct in_addr src_ip; - NTSTATUS status; - - if (lp_disable_netbios()) { - DEBUG(5,("resolve_wins(%s#%02x): netbios is disabled\n", - name, name_type)); - return NT_STATUS_INVALID_PARAMETER; - } - - *return_iplist = NULL; - *return_count = 0; - - DEBUG(3,("resolve_wins: Attempting wins lookup for name %s<0x%x>\n", - name, name_type)); - - if (wins_srv_count() < 1) { - DEBUG(3,("resolve_wins: WINS server resolution selected " - "and no WINS servers listed.\n")); - return NT_STATUS_INVALID_PARAMETER; - } - - /* we try a lookup on each of the WINS tags in turn */ - wins_tags = wins_srv_tags(); - - if (!wins_tags) { - /* huh? no tags?? give up in disgust */ - return NT_STATUS_INVALID_PARAMETER; - } + struct tevent_context *ev; + struct tevent_req *req; + NTSTATUS status = NT_STATUS_NO_MEMORY; - /* the address we will be sending from */ - if (!interpret_string_addr(&src_ss, lp_socket_address(), - AI_NUMERICHOST|AI_PASSIVE)) { - zero_sockaddr(&src_ss); + ev = tevent_context_init(talloc_tos()); + if (ev == NULL) { + goto fail; } - - if (src_ss.ss_family != AF_INET) { - char addr[INET6_ADDRSTRLEN]; - print_sockaddr(addr, sizeof(addr), &src_ss); - DEBUG(3,("resolve_wins: cannot receive WINS replies " - "on IPv6 address %s\n", - addr)); - wins_srv_tags_free(wins_tags); - return NT_STATUS_INVALID_PARAMETER; + req = resolve_wins_send(ev, ev, name, name_type); + if (req == NULL) { + goto fail; } - - src_ip = ((struct sockaddr_in *)&src_ss)->sin_addr; - - /* in the worst case we will try every wins server with every - tag! */ - for (t=0; wins_tags && wins_tags[t]; t++) { - int srv_count = wins_srv_count_tag(wins_tags[t]); - for (i=0; i