s4:libcli: add smb2_transport_raw_init()
authorStefan Metzmacher <metze@samba.org>
Wed, 18 Jul 2018 14:43:04 +0000 (16:43 +0200)
committerAlexander Bokovoy <ab@samba.org>
Tue, 24 Jul 2018 04:55:23 +0000 (06:55 +0200)
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>
source4/libcli/smb2/transport.c

index 166f34b82569d01702f3f6d5b91405e6d74fd929..1d08289341bad2506a5f52c41a59b29f476ad579 100644 (file)
@@ -85,6 +85,41 @@ struct smb2_transport *smb2_transport_init(struct smbcli_socket *sock,
        return transport;
 }
 
+/*
+  create a transport structure based on an established socket
+*/
+NTSTATUS smb2_transport_raw_init(TALLOC_CTX *mem_ctx,
+                                struct tevent_context *ev,
+                                struct smbXcli_conn **_conn,
+                                const struct smbcli_options *options,
+                                struct smb2_transport **_transport)
+{
+       struct smb2_transport *transport = NULL;
+       enum protocol_types protocol;
+
+       if (*_conn == NULL) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       protocol = smbXcli_conn_protocol(*_conn);
+       if (protocol < PROTOCOL_SMB2_02) {
+               return NT_STATUS_REVISION_MISMATCH;
+       }
+
+       transport = talloc_zero(mem_ctx, struct smb2_transport);
+       if (transport == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       transport->ev = ev;
+       transport->options = *options;
+       transport->conn = talloc_move(transport, _conn);
+
+       talloc_set_destructor(transport, transport_destructor);
+       *_transport = transport;
+       return NT_STATUS_OK;
+}
+
 /*
   mark the transport as dead
 */