summaryrefslogtreecommitdiff
path: root/source4/lib/socket/connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/socket/connect.c')
-rw-r--r--source4/lib/socket/connect.c63
1 files changed, 3 insertions, 60 deletions
diff --git a/source4/lib/socket/connect.c b/source4/lib/socket/connect.c
index 2b64668b9b..d74a7b4833 100644
--- a/source4/lib/socket/connect.c
+++ b/source4/lib/socket/connect.c
@@ -25,7 +25,6 @@
#include "lib/socket/socket.h"
#include "lib/events/events.h"
#include "libcli/composite/composite.h"
-#include "libcli/resolve/resolve.h"
struct connect_state {
@@ -38,26 +37,16 @@ struct connect_state {
static void socket_connect_handler(struct event_context *ev,
struct fd_event *fde,
uint16_t flags, void *private);
-static void continue_resolve_name(struct composite_context *ctx);
-static void continue_socket_connect(struct composite_context *creq);
/*
call the real socket_connect() call, and setup event handler
*/
static void socket_send_connect(struct composite_context *result)
{
- struct composite_context *creq;
struct fd_event *fde;
struct connect_state *state = talloc_get_type(result->private_data,
struct connect_state);
- creq = talloc_zero(state, struct composite_context);
- if (composite_nomem(creq, result)) return;
- creq->state = COMPOSITE_STATE_IN_PROGRESS;
- creq->event_ctx = result->event_ctx;
- creq->async.fn = continue_socket_connect;
- creq->async.private_data = result;
-
result->status = socket_connect(state->sock,
state->my_address,
state->server_address,
@@ -84,16 +73,13 @@ struct composite_context *socket_connect_send(struct socket_context *sock,
struct socket_address *my_address,
struct socket_address *server_address,
uint32_t flags,
- struct resolve_context *resolve_ctx,
struct event_context *event_ctx)
{
struct composite_context *result;
struct connect_state *state;
- result = talloc_zero(sock, struct composite_context);
+ result = composite_create(sock, event_ctx);
if (result == NULL) return NULL;
- result->state = COMPOSITE_STATE_IN_PROGRESS;
- result->event_ctx = event_ctx;
state = talloc_zero(result, struct connect_state);
if (composite_nomem(state, result)) return result;
@@ -122,16 +108,6 @@ struct composite_context *socket_connect_send(struct socket_context *sock,
set_blocking(socket_get_fd(sock), false);
- if (resolve_ctx != NULL && server_address->addr && strcmp(sock->backend_name, "ipv4") == 0) {
- struct nbt_name name;
- struct composite_context *creq;
- make_nbt_name_client(&name, server_address->addr);
- creq = resolve_name_send(resolve_ctx, &name, result->event_ctx);
- if (composite_nomem(creq, result)) return result;
- composite_continue(result, creq, continue_resolve_name, result);
- return result;
- }
-
socket_send_connect(result);
return result;
@@ -156,39 +132,6 @@ static void socket_connect_handler(struct event_context *ev,
}
/*
- recv name resolution reply then send the connect
-*/
-static void continue_resolve_name(struct composite_context *creq)
-{
- struct composite_context *result = talloc_get_type(creq->async.private_data,
- struct composite_context);
- struct connect_state *state = talloc_get_type(result->private_data, struct connect_state);
- const char *addr;
-
- result->status = resolve_name_recv(creq, state, &addr);
- if (!composite_is_ok(result)) return;
-
- state->server_address = socket_address_from_strings(state, state->sock->backend_name,
- addr, state->server_address->port);
- if (composite_nomem(state->server_address, result)) return;
-
- socket_send_connect(result);
-}
-
-/*
- called when a connect has finished. Complete the top level composite context
-*/
-static void continue_socket_connect(struct composite_context *creq)
-{
- struct composite_context *result = talloc_get_type(creq->async.private_data,
- struct composite_context);
- result->status = creq->status;
- if (!composite_is_ok(result)) return;
- composite_done(result);
-}
-
-
-/*
wait for a socket_connect_send() to finish
*/
NTSTATUS socket_connect_recv(struct composite_context *result)
@@ -205,11 +148,11 @@ NTSTATUS socket_connect_recv(struct composite_context *result)
NTSTATUS socket_connect_ev(struct socket_context *sock,
struct socket_address *my_address,
struct socket_address *server_address,
- uint32_t flags, struct resolve_context *resolve_ctx,
+ uint32_t flags,
struct event_context *ev)
{
struct composite_context *ctx;
ctx = socket_connect_send(sock, my_address,
- server_address, flags, resolve_ctx, ev);
+ server_address, flags, ev);
return socket_connect_recv(ctx);
}