r26644: Janitorial: Pass resolve_context explicitly to various SMB functions, should...
[jelmer/samba4-debian.git] / source / libcli / smb_composite / connect.c
index 026fe0b029f7fb65aaa75268646bc22e857a0e35..b71cfc2c19b05c6dfc193ea074873852cf2f63c2 100644 (file)
@@ -28,6 +28,7 @@
 #include "libcli/resolve/resolve.h"
 #include "auth/credentials/credentials.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
 
 /* the stages of this call */
 enum connect_stage {CONNECT_RESOLVE, 
@@ -62,7 +63,8 @@ static NTSTATUS connect_send_negprot(struct composite_context *c,
 {
        struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
 
-       state->req = smb_raw_negotiate_send(state->transport, lp_cli_maxprotocol());
+       state->req = smb_raw_negotiate_send(state->transport, lp_unicode(global_loadparm),
+                                           lp_cli_maxprotocol(global_loadparm));
        NT_STATUS_HAVE_NO_MEMORY(state->req);
 
        state->req->async.fn = request_handler;
@@ -114,12 +116,12 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c,
        status = smb_composite_sesssetup_recv(state->creq);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       io->out.anonymous_fallback_done = True;
+       io->out.anonymous_fallback_done = true;
        
        state->session->vuid = state->io_setup->out.vuid;
        
        /* setup for a tconx */
-       io->out.tree = smbcli_tree_init(state->session, state, True);
+       io->out.tree = smbcli_tree_init(state->session, state, true);
        NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
 
        state->io_tcon = talloc(c, union smb_tcon);
@@ -171,7 +173,8 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
 
                state->io_setup->in.credentials = cli_credentials_init(state);
                NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials);
-               cli_credentials_set_conf(state->io_setup->in.credentials);
+               cli_credentials_set_conf(state->io_setup->in.credentials, 
+                                        global_loadparm);
                cli_credentials_set_anonymous(state->io_setup->in.credentials);
 
                /* If the preceding attempt was with extended security, we
@@ -200,7 +203,7 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
        state->session->vuid = state->io_setup->out.vuid;
        
        /* setup for a tconx */
-       io->out.tree = smbcli_tree_init(state->session, state, True);
+       io->out.tree = smbcli_tree_init(state->session, state, true);
        NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
 
        state->io_tcon = talloc(c, union smb_tcon);
@@ -248,7 +251,7 @@ static NTSTATUS connect_negprot(struct composite_context *c,
        NT_STATUS_NOT_OK_RETURN(status);
 
        /* next step is a session setup */
-       state->session = smbcli_session_init(state->transport, state, True);
+       state->session = smbcli_session_init(state->transport, state, true);
        NT_STATUS_HAVE_NO_MEMORY(state->session);
 
        state->io_setup = talloc(c, struct smb_composite_sesssetup);
@@ -304,7 +307,10 @@ static NTSTATUS connect_socket(struct composite_context *c,
        NT_STATUS_NOT_OK_RETURN(status);
 
        /* the socket is up - we can initialise the smbcli transport layer */
-       state->transport = smbcli_transport_init(state->sock, state, True);
+       state->transport = smbcli_transport_init(state->sock, state, true, 
+                                                lp_max_xmit(global_loadparm),
+                                                lp_maxmux(global_loadparm),
+                                                lp_use_spnego(global_loadparm) && lp_nt_status_support(global_loadparm));
        NT_STATUS_HAVE_NO_MEMORY(state->transport);
 
        if (is_ipaddress(state->sock->hostname) &&
@@ -355,8 +361,10 @@ static NTSTATUS connect_resolve(struct composite_context *c,
        status = resolve_name_recv(state->creq, state, &address);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       state->creq = smbcli_sock_connect_send(state, address, io->in.port,
-                                              io->in.dest_host, c->event_ctx);
+       state->creq = smbcli_sock_connect_send(state, address, 
+                                              io->in.dest_ports,
+                                              io->in.dest_host, 
+                                              NULL, c->event_ctx);
        NT_STATUS_HAVE_NO_MEMORY(state->creq);
 
        state->stage = CONNECT_SOCKET;
@@ -434,6 +442,7 @@ static void composite_handler(struct composite_context *creq)
 */
 struct composite_context *smb_composite_connect_send(struct smb_composite_connect *io,
                                                     TALLOC_CTX *mem_ctx,
+                                                    struct resolve_context *resolve_ctx,
                                                     struct event_context *event_ctx)
 {
        struct composite_context *c;
@@ -458,7 +467,7 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
 
        state->stage = CONNECT_RESOLVE;
        make_nbt_name_server(&name, io->in.dest_host);
-       state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
+       state->creq = resolve_name_send(resolve_ctx, &name, c->event_ctx);
 
        if (state->creq == NULL) goto failed;
        state->creq->async.private_data = c;
@@ -492,8 +501,9 @@ NTSTATUS smb_composite_connect_recv(struct composite_context *c, TALLOC_CTX *mem
   sync version of smb_composite_connect 
 */
 NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx,
+                              struct resolve_context *resolve_ctx,
                               struct event_context *ev)
 {
-       struct composite_context *c = smb_composite_connect_send(io, mem_ctx, ev);
+       struct composite_context *c = smb_composite_connect_send(io, mem_ctx, resolve_ctx, ev);
        return smb_composite_connect_recv(c, mem_ctx);
 }