ca8983d5e2c1c84089b03aa1e4ce3502008bfde2
[kai/samba-autobuild/.git] / source4 / smb_server / smb2 / keepalive.c
1 /* 
2    Unix SMB2 implementation.
3    
4    Copyright (C) Stefan Metzmacher      2005
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22 #include "libcli/smb2/smb2.h"
23 #include "smb_server/smb_server.h"
24 #include "smb_server/service_smb_proto.h"
25 #include "smb_server/smb2/smb2_server.h"
26
27 static NTSTATUS smb2srv_keepalive_backend(struct smb2srv_request *req)
28 {
29         /* TODO: maybe update some flags on the connection struct */
30         return NT_STATUS_OK;
31 }
32
33 static void smb2srv_keepalive_send(struct smb2srv_request *req)
34 {
35         NTSTATUS status;
36
37         if (NT_STATUS_IS_ERR(req->status)) {
38                 smb2srv_send_error(req, req->status);
39                 return;
40         }
41
42         status = smb2srv_setup_reply(req, 0x04, 0);
43         if (!NT_STATUS_IS_OK(status)) {
44                 smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
45                 talloc_free(req);
46                 return;
47         }
48
49         SSVAL(req->out.body, 0x02, 0);
50
51         smb2srv_send_reply(req);
52 }
53
54 void smb2srv_keepalive_recv(struct smb2srv_request *req)
55 {
56         uint16_t _pad;
57
58         if (req->in.body_size < 0x04) {
59                 smb2srv_send_error(req,  NT_STATUS_FOOBAR);
60                 return;
61         }
62
63         _pad    = SVAL(req->in.body, 0x02);
64
65         req->status = smb2srv_keepalive_backend(req);
66
67         if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) {
68                 talloc_free(req);
69                 return;
70         }
71         smb2srv_keepalive_send(req);
72 }