summaryrefslogtreecommitdiff
path: root/source4/libcli/smb2
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-11-30 08:50:11 +0100
committerStefan Metzmacher <metze@samba.org>2011-11-30 13:41:09 +0100
commit99ef6a4bec1058b3649e5e72f8ea85f6df93a154 (patch)
tree0577bfd74c49d603f623ef85573f418f562eded2 /source4/libcli/smb2
parent52dd549eb64ea9b79bd4cbeba0fa4183aad7bb4c (diff)
downloadsamba-99ef6a4bec1058b3649e5e72f8ea85f6df93a154.tar.gz
samba-99ef6a4bec1058b3649e5e72f8ea85f6df93a154.tar.bz2
samba-99ef6a4bec1058b3649e5e72f8ea85f6df93a154.zip
s4:libcli: do the nbss session request within smbcli_sock_connect_*()
metze
Diffstat (limited to 'source4/libcli/smb2')
-rw-r--r--source4/libcli/smb2/connect.c56
1 files changed, 17 insertions, 39 deletions
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index 0d97691a44..6b980f2e0e 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -29,6 +29,7 @@
#include "libcli/composite/composite.h"
#include "libcli/resolve/resolve.h"
#include "param/param.h"
+#include "auth/credentials/credentials.h"
#include "../libcli/smb/smbXcli_base.h"
struct smb2_connect_state {
@@ -39,6 +40,7 @@ struct smb2_connect_state {
const char *share;
const char **ports;
const char *socket_options;
+ struct nbt_name calling, called;
struct gensec_settings *gensec_settings;
struct smbcli_options options;
struct smb2_transport *transport;
@@ -47,7 +49,7 @@ struct smb2_connect_state {
struct smb2_tree *tree;
};
-static void smb2_connect_resolve_done(struct composite_context *creq);
+static void smb2_connect_socket_done(struct composite_context *creq);
/*
a composite function that does a full negprot/sesssetup/tcon, returning
@@ -66,8 +68,8 @@ struct tevent_req *smb2_connect_send(TALLOC_CTX *mem_ctx,
{
struct tevent_req *req;
struct smb2_connect_state *state;
- struct nbt_name name;
struct composite_context *creq;
+ static const char *default_ports[] = { "445", "139", NULL };
req = tevent_req_create(mem_ctx, &state,
struct smb2_connect_state);
@@ -85,52 +87,28 @@ struct tevent_req *smb2_connect_send(TALLOC_CTX *mem_ctx,
state->socket_options = socket_options;
state->gensec_settings = gensec_settings;
- ZERO_STRUCT(name);
- name.name = host;
-
- creq = resolve_name_send(resolve_ctx, state, &name, ev);
- if (tevent_req_nomem(creq, req)) {
- return tevent_req_post(req, ev);
+ if (state->ports == NULL) {
+ state->ports = default_ports;
}
- creq->async.fn = smb2_connect_resolve_done;
- creq->async.private_data = req;
- return req;
-}
-static void smb2_connect_socket_done(struct composite_context *creq);
+ make_nbt_name_client(&state->calling,
+ cli_credentials_get_workstation(credentials));
-static void smb2_connect_resolve_done(struct composite_context *creq)
-{
- struct tevent_req *req =
- talloc_get_type_abort(creq->async.private_data,
- struct tevent_req);
- struct smb2_connect_state *state =
- tevent_req_data(req,
- struct smb2_connect_state);
- NTSTATUS status;
- const char *addr;
- const char **ports;
- const char *default_ports[] = { "445", NULL };
-
- status = resolve_name_recv(creq, state, &addr);
- if (tevent_req_nterror(req, status)) {
- return;
- }
+ nbt_choose_called_name(state, &state->called,
+ host, NBT_NAME_SERVER);
- if (state->ports == NULL) {
- ports = default_ports;
- } else {
- ports = state->ports;
- }
-
- creq = smbcli_sock_connect_send(state, addr, ports,
+ creq = smbcli_sock_connect_send(state, NULL, state->ports,
state->host, state->resolve_ctx,
- state->ev, state->socket_options);
+ state->ev, state->socket_options,
+ &state->calling,
+ &state->called);
if (tevent_req_nomem(creq, req)) {
- return;
+ return tevent_req_post(req, ev);
}
creq->async.fn = smb2_connect_socket_done;
creq->async.private_data = req;
+
+ return req;
}
static void smb2_connect_negprot_done(struct tevent_req *subreq);