s4:lib/tevent: rename structs
[sfrench/samba-autobuild/.git] / source4 / lib / socket / connect_multi.c
index 9f060767af6b506d560797fbc20fc153283248a1..8fcfc0a8ea702f74727649851bb64015552e068c 100644 (file)
@@ -9,7 +9,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -18,8 +18,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -54,8 +53,8 @@ struct connect_one_state {
 };
 
 static void continue_resolve_name(struct composite_context *creq);
-static void connect_multi_timer(struct event_context *ev,
-                                   struct timed_event *te,
+static void connect_multi_timer(struct tevent_context *ev,
+                                   struct tevent_timer *te,
                                    struct timeval tv, void *p);
 static void connect_multi_next_socket(struct composite_context *result);
 static void continue_one(struct composite_context *creq);
@@ -63,11 +62,13 @@ static void continue_one(struct composite_context *creq);
 /*
   setup an async socket_connect, with multiple ports
 */
-struct composite_context *socket_connect_multi_send(TALLOC_CTX *mem_ctx,
+_PUBLIC_ struct composite_context *socket_connect_multi_send(
+                                                   TALLOC_CTX *mem_ctx,
                                                    const char *server_address,
                                                    int num_server_ports,
                                                    uint16_t *server_ports,
-                                                   struct event_context *event_ctx)
+                                                   struct resolve_context *resolve_ctx,
+                                                   struct tevent_context *event_ctx)
 {
        struct composite_context *result;
        struct connect_multi_state *multi;
@@ -101,9 +102,8 @@ struct composite_context *socket_connect_multi_send(TALLOC_CTX *mem_ctx,
                 */
                struct nbt_name name;
                struct composite_context *creq;
-               make_nbt_name_client(&name, server_address);
-               creq = resolve_name_send(&name, result->event_ctx,
-                                        lp_name_resolve_order());
+               make_nbt_name_server(&name, server_address);
+               creq = resolve_name_send(resolve_ctx, &name, result->event_ctx);
                if (composite_nomem(creq, result)) goto failed;
                composite_continue(result, creq, continue_resolve_name, result);
                return result;
@@ -156,7 +156,8 @@ static void connect_multi_next_socket(struct composite_context *result)
        talloc_steal(state, state->sock);
 
        creq = socket_connect_send(state->sock, NULL, 
-                                  state->addr, 0, result->event_ctx);
+                                  state->addr, 0,
+                                  result->event_ctx);
        if (composite_nomem(creq, result)) return;
        talloc_steal(state, creq);
 
@@ -178,8 +179,8 @@ static void connect_multi_next_socket(struct composite_context *result)
 /*
   a timer has gone off telling us that we should try the next port
 */
-static void connect_multi_timer(struct event_context *ev,
-                               struct timed_event *te,
+static void connect_multi_timer(struct tevent_context *ev,
+                               struct tevent_timer *te,
                                struct timeval tv, void *p)
 {
        struct composite_context *result = talloc_get_type(p, struct composite_context);
@@ -243,7 +244,7 @@ static void continue_one(struct composite_context *creq)
 /*
   async recv routine for socket_connect_multi()
  */
-NTSTATUS socket_connect_multi_recv(struct composite_context *ctx,
+_PUBLIC_ NTSTATUS socket_connect_multi_recv(struct composite_context *ctx,
                                   TALLOC_CTX *mem_ctx,
                                   struct socket_context **sock,
                                   uint16_t *port)
@@ -263,13 +264,15 @@ NTSTATUS socket_connect_multi_recv(struct composite_context *ctx,
 NTSTATUS socket_connect_multi(TALLOC_CTX *mem_ctx,
                              const char *server_address,
                              int num_server_ports, uint16_t *server_ports,
-                             struct event_context *event_ctx,
+                             struct resolve_context *resolve_ctx,
+                             struct tevent_context *event_ctx,
                              struct socket_context **result,
                              uint16_t *result_port)
 {
        struct composite_context *ctx =
                socket_connect_multi_send(mem_ctx, server_address,
                                          num_server_ports, server_ports,
+                                         resolve_ctx,
                                          event_ctx);
        return socket_connect_multi_recv(ctx, mem_ctx, result, result_port);
 }