s3/libsmb: Generalise cli_state in smb2 logoff calls
[mat/samba.git] / source3 / libsmb / smb2cli_session.c
index 0de82f6d83747e9c776cb6f78261c09e3ada8e25..077ba9a52eb706d18f1c5eced22106dd8490137a 100644 (file)
@@ -28,7 +28,6 @@
 #include "../auth/ntlmssp/ntlmssp.h"
 
 struct smb2cli_logoff_state {
-       struct cli_state *cli;
        uint8_t fixed[4];
 };
 
@@ -36,7 +35,9 @@ static void smb2cli_logoff_done(struct tevent_req *subreq);
 
 struct tevent_req *smb2cli_logoff_send(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev,
-                                      struct cli_state *cli)
+                                      struct smbXcli_conn *conn,
+                                      uint32_t timeout_msec,
+                                      struct smbXcli_session *session)
 {
        struct tevent_req *req, *subreq;
        struct smb2cli_logoff_state *state;
@@ -46,16 +47,15 @@ struct tevent_req *smb2cli_logoff_send(TALLOC_CTX *mem_ctx,
        if (req == NULL) {
                return NULL;
        }
-       state->cli = cli;
        SSVAL(state->fixed, 0, 4);
 
        subreq = smb2cli_req_send(state, ev,
-                                 cli->conn, SMB2_OP_LOGOFF,
+                                 conn, SMB2_OP_LOGOFF,
                                  0, 0, /* flags */
-                                 cli->timeout,
-                                 cli->smb2.pid,
+                                 timeout_msec,
+                                 0xFEFF, /* pid */
                                  0, /* tid */
-                                 cli->smb2.session,
+                                 session,
                                  state->fixed, sizeof(state->fixed),
                                  NULL, 0);
        if (tevent_req_nomem(subreq, req)) {
@@ -85,7 +85,6 @@ static void smb2cli_logoff_done(struct tevent_req *subreq)
        status = smb2cli_req_recv(subreq, state, &iov,
                                  expected, ARRAY_SIZE(expected));
        TALLOC_FREE(subreq);
-       TALLOC_FREE(state->cli->smb2.session);
        if (tevent_req_nterror(req, status)) {
                return;
        }
@@ -97,14 +96,16 @@ NTSTATUS smb2cli_logoff_recv(struct tevent_req *req)
        return tevent_req_simple_recv_ntstatus(req);
 }
 
-NTSTATUS smb2cli_logoff(struct cli_state *cli)
+NTSTATUS smb2cli_logoff(struct smbXcli_conn *conn,
+                       uint32_t timeout_msec,
+                       struct smbXcli_session *session)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct event_context *ev;
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
-       if (cli_has_async_calls(cli)) {
+       if (smbXcli_conn_has_async_calls(conn)) {
                /*
                 * Can't use sync call while an async call is in flight
                 */
@@ -115,7 +116,7 @@ NTSTATUS smb2cli_logoff(struct cli_state *cli)
        if (ev == NULL) {
                goto fail;
        }
-       req = smb2cli_logoff_send(frame, ev, cli);
+       req = smb2cli_logoff_send(frame, ev, conn, timeout_msec, session);
        if (req == NULL) {
                goto fail;
        }