summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2010-03-10 16:01:41 +1100
committerAndrew Bartlett <abartlet@samba.org>2010-03-11 11:27:48 +1100
commite999472e36076e432187371b0853b887effe1067 (patch)
treed6dba34f70f1a7179ddf3e45c04074c7564fb3d1 /source4/libcli
parent1af2cd2bd1c74c88dd00088eb37ad6286af7561f (diff)
downloadsamba-e999472e36076e432187371b0853b887effe1067.tar.gz
samba-e999472e36076e432187371b0853b887effe1067.tar.bz2
samba-e999472e36076e432187371b0853b887effe1067.zip
s4:libcli Use integrated name resolution when connecting SMB
This avoids pulling the address into a string and back again if given a name, by letting the next async layer down do the name resolution. If it was an IP address to start with, then the resolver library just converts that to the struct socket_address. Andrew Bartlett
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/raw/clisocket.c4
-rw-r--r--source4/libcli/smb_composite/connect.c47
2 files changed, 13 insertions, 38 deletions
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 02da4917e3..84bf250f6a 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -80,6 +80,10 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
}
state->socket_options = talloc_reference(state, socket_options);
+ if (!host_addr) {
+ host_addr = host_name;
+ }
+
ctx = socket_connect_multi_send(state, host_addr,
state->num_ports, state->ports,
resolve_ctx,
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index 3d35018acb..14e8a1ab7f 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -32,8 +32,7 @@
#include "param/param.h"
/* the stages of this call */
-enum connect_stage {CONNECT_RESOLVE,
- CONNECT_SOCKET,
+enum connect_stage {CONNECT_SOCKET,
CONNECT_SESSION_REQUEST,
CONNECT_NEGPROT,
CONNECT_SESSION_SETUP,
@@ -362,34 +361,6 @@ static NTSTATUS connect_socket(struct composite_context *c,
/*
- called when name resolution is finished
-*/
-static NTSTATUS connect_resolve(struct composite_context *c,
- struct smb_composite_connect *io)
-{
- struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
- NTSTATUS status;
- const char *address;
-
- status = resolve_name_recv(state->creq, state, &address);
- NT_STATUS_NOT_OK_RETURN(status);
-
- state->creq = smbcli_sock_connect_send(state, address,
- io->in.dest_ports,
- io->in.dest_host,
- NULL, c->event_ctx,
- io->in.socket_options);
- NT_STATUS_HAVE_NO_MEMORY(state->creq);
-
- state->stage = CONNECT_SOCKET;
- state->creq->async.private_data = c;
- state->creq->async.fn = composite_handler;
-
- return NT_STATUS_OK;
-}
-
-
-/*
handle and dispatch state transitions
*/
static void state_handler(struct composite_context *c)
@@ -397,9 +368,6 @@ static void state_handler(struct composite_context *c)
struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
switch (state->stage) {
- case CONNECT_RESOLVE:
- c->status = connect_resolve(c, state->io);
- break;
case CONNECT_SOCKET:
c->status = connect_socket(c, state->io);
break;
@@ -461,7 +429,6 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
{
struct composite_context *c;
struct connect_state *state;
- struct nbt_name name;
c = talloc_zero(mem_ctx, struct composite_context);
if (c == NULL) goto failed;
@@ -478,11 +445,15 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
c->state = COMPOSITE_STATE_IN_PROGRESS;
c->private_data = state;
- state->stage = CONNECT_RESOLVE;
- make_nbt_name_server(&name, io->in.dest_host);
- state->creq = resolve_name_send(resolve_ctx, state, &name, c->event_ctx);
-
+ state->creq = smbcli_sock_connect_send(state,
+ NULL,
+ io->in.dest_ports,
+ io->in.dest_host,
+ resolve_ctx, c->event_ctx,
+ io->in.socket_options);
if (state->creq == NULL) goto failed;
+
+ state->stage = CONNECT_SOCKET;
state->creq->async.private_data = c;
state->creq->async.fn = composite_handler;