summaryrefslogtreecommitdiff
path: root/source4/libcli/raw
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-16 01:28:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:52 -0500
commit1e776edfc546f01341f153daa80e4155e5ff9855 (patch)
treee2763985c78dfa6e5aa3d6f0805f07588aa44ba9 /source4/libcli/raw
parent4da8abcf0d48f4e6ec14dc9fecab780e826df4ed (diff)
downloadsamba-1e776edfc546f01341f153daa80e4155e5ff9855.tar.gz
samba-1e776edfc546f01341f153daa80e4155e5ff9855.tar.bz2
samba-1e776edfc546f01341f153daa80e4155e5ff9855.zip
r4769: added a smb_composite_connect() function that provides a simple async
interface to a complete SMB connection setup. Internally it does: - socket connection - session request (if needed) - negprot - session setup - tcon This is the first example of a composite function that builds on other composite components (the socket connection is a composite function, which is used as a building block for this function). I think this will be quite common in composite functions in the future, building up ever more complex composite functions from smaller building blocks, while hiding the details from the caller. There are two things missing from this now. The first is async name resolution routines (wins, bcast, DNS etc), and the second is that this code currently only does a NT1 style session setup. I'll work on adding spnego and old style session setup support next. (This used to be commit 6bc9e17f5c5236f662c7c8f308d03e6d97379b23)
Diffstat (limited to 'source4/libcli/raw')
-rw-r--r--source4/libcli/raw/clisession.c6
-rw-r--r--source4/libcli/raw/clitree.c34
2 files changed, 37 insertions, 3 deletions
diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c
index 322d27688e..46236217ea 100644
--- a/source4/libcli/raw/clisession.c
+++ b/source4/libcli/raw/clisession.c
@@ -256,8 +256,8 @@ void smbcli_session_set_user_session_key(struct smbcli_session *session,
/*
setup signing for a NT1 style session setup
*/
-static void use_nt1_session_keys(struct smbcli_session *session,
- const char *password, const DATA_BLOB *nt_response)
+void smb_session_use_nt1_session_keys(struct smbcli_session *session,
+ const char *password, const DATA_BLOB *nt_response)
{
struct smbcli_transport *transport = session->transport;
uint8_t nt_hash[16];
@@ -352,7 +352,7 @@ static NTSTATUS smb_raw_session_setup_generic_nt1(struct smbcli_session *session
session->transport->negotiate.secblob);
s2.nt1.in.password2 = nt_blob(parms->generic.in.password,
session->transport->negotiate.secblob);
- use_nt1_session_keys(session, parms->generic.in.password, &s2.nt1.in.password2);
+ smb_session_use_nt1_session_keys(session, parms->generic.in.password, &s2.nt1.in.password2);
} else {
s2.nt1.in.password1 = data_blob(parms->generic.in.password,
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index cc7fefd084..7339ca07f1 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/composite/composite.h"
#define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \
req = smbcli_request_setup(tree, cmd, wct, buflen); \
@@ -289,3 +290,36 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
*ret_tree = tree;
return NT_STATUS_OK;
}
+
+
+/*
+ a convenient function to establish a smbcli_tree from scratch
+*/
+NTSTATUS async_smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
+ struct smbcli_tree **ret_tree,
+ const char *my_name,
+ const char *dest_host, int port,
+ const char *service, const char *service_type,
+ const char *user, const char *domain,
+ const char *password)
+{
+ struct smb_composite_connect io;
+ NTSTATUS status;
+
+ io.in.dest_host = dest_host;
+ io.in.port = port;
+ io.in.called_name = dest_host;
+ io.in.calling_name = my_name;
+ io.in.service = service;
+ io.in.service_type = service_type;
+ io.in.user = user;
+ io.in.domain = domain;
+ io.in.password = password;
+
+ status = smb_composite_connect(&io, parent_ctx);
+ if (NT_STATUS_IS_OK(status)) {
+ *ret_tree = io.out.tree;
+ }
+
+ return status;
+}