summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2018-07-18 15:36:52 +0200
committerKarolin Seeger <kseeger@samba.org>2018-08-13 12:56:33 +0200
commit19e65aff16bf57ab007ab101bc6094ab54123f01 (patch)
tree86fb77158b9cce8891b7d2db30a21b4ad3ba1592 /source4/libcli
parent92b6b9098c510de1b7e4e4183b2b3dda8ca45eab (diff)
downloadsamba-19e65aff16bf57ab007ab101bc6094ab54123f01.tar.gz
s4:libcli: add smbcli_transport_raw_init()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13308 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> (cherry picked from commit b7e99c2571e31971a6d7f1898e7458c16dc1031e)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/raw/clitransport.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index d0dd1f9dee6..47b8dbf3ae7 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -114,6 +114,50 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
}
/*
+ create a transport structure based on an established socket
+*/
+NTSTATUS smbcli_transport_raw_init(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct smbXcli_conn **_conn,
+ const struct smbcli_options *options,
+ struct smbcli_transport **_transport)
+{
+ struct smbcli_transport *transport = NULL;
+ NTSTATUS status;
+
+ if (*_conn == NULL) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ transport = talloc_zero(mem_ctx, struct smbcli_transport);
+ if (transport == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ transport->ev = ev;
+ transport->options = *options;
+
+ /*
+ * First only set the pointer without move.
+ */
+ transport->conn = *_conn;
+ status = smb_raw_negotiate_fill_transport(transport);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(transport);
+ return status;
+ }
+
+ talloc_set_destructor(transport, transport_destructor);
+
+ /*
+ * Now move it away from the caller...
+ */
+ transport->conn = talloc_move(transport, _conn);
+ *_transport = transport;
+ return NT_STATUS_OK;
+}
+
+/*
mark the transport as dead
*/
void smbcli_transport_dead(struct smbcli_transport *transport, NTSTATUS status)