summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-12-17 23:13:44 +0100
committerStefan Metzmacher <metze@samba.org>2008-12-18 13:32:51 +0100
commitfc31f2c5269fd405be96b9a036baf35a60141ccf (patch)
tree8e1a1a374fd892dcd4117e6dbf049b43bd3d0e13 /source4/lib
parent4c2a113dd06ab2ba0b6faef781a7c21b4a2f3db0 (diff)
downloadsamba-fc31f2c5269fd405be96b9a036baf35a60141ccf.tar.gz
samba-fc31f2c5269fd405be96b9a036baf35a60141ccf.tar.bz2
samba-fc31f2c5269fd405be96b9a036baf35a60141ccf.zip
s4:lib/socket: socket_connect_send() and socket_connect_ev() should only wrok with addresses
metze
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/socket/connect.c41
-rw-r--r--source4/lib/socket/connect_multi.c5
-rw-r--r--source4/lib/socket/socket.h2
-rw-r--r--source4/lib/socket/testsuite.c2
4 files changed, 5 insertions, 45 deletions
diff --git a/source4/lib/socket/connect.c b/source4/lib/socket/connect.c
index 409e19e7f5..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,7 +37,6 @@ 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);
/*
call the real socket_connect() call, and setup event handler
@@ -75,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;
@@ -113,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_server(&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;
@@ -147,26 +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);
-}
-
-/*
wait for a socket_connect_send() to finish
*/
NTSTATUS socket_connect_recv(struct composite_context *result)
@@ -183,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);
}
diff --git a/source4/lib/socket/connect_multi.c b/source4/lib/socket/connect_multi.c
index ad8637a597..14c475d0c3 100644
--- a/source4/lib/socket/connect_multi.c
+++ b/source4/lib/socket/connect_multi.c
@@ -37,8 +37,6 @@ struct connect_multi_state {
int num_ports;
uint16_t *ports;
- struct resolve_context *resolve_ctx;
-
struct socket_context *sock;
uint16_t result_port;
@@ -89,7 +87,6 @@ _PUBLIC_ struct composite_context *socket_connect_multi_send(
if (composite_nomem(multi->server_address, result)) goto failed;
multi->num_ports = num_server_ports;
- multi->resolve_ctx = talloc_reference(multi, resolve_ctx);
multi->ports = talloc_array(multi, uint16_t, multi->num_ports);
if (composite_nomem(multi->ports, result)) goto failed;
@@ -159,7 +156,7 @@ 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, multi->resolve_ctx,
+ state->addr, 0,
result->event_ctx);
if (composite_nomem(creq, result)) return;
talloc_steal(state, creq);
diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h
index 8b1b65db92..4741a67990 100644
--- a/source4/lib/socket/socket.h
+++ b/source4/lib/socket/socket.h
@@ -178,14 +178,12 @@ 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);
NTSTATUS socket_connect_recv(struct composite_context *ctx);
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,
struct event_context *ev);
struct composite_context *socket_connect_multi_send(TALLOC_CTX *mem_ctx,
diff --git a/source4/lib/socket/testsuite.c b/source4/lib/socket/testsuite.c
index 2c25d8f491..0fae880ca0 100644
--- a/source4/lib/socket/testsuite.c
+++ b/source4/lib/socket/testsuite.c
@@ -152,7 +152,7 @@ static bool test_tcp(struct torture_context *tctx)
torture_comment(tctx, "server port is %d\n", srv_addr->port);
- status = socket_connect_ev(sock2, NULL, srv_addr, 0, NULL, ev);
+ status = socket_connect_ev(sock2, NULL, srv_addr, 0, ev);
torture_assert_ntstatus_ok(tctx, status, "connect() on socket 2");
status = socket_accept(sock1, &sock3);