LCOV - code coverage report
Current view: top level - source4/libcli/smb2 - lease_break.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 24 25 96.0 %
Date: 2024-04-21 15:09:00 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    SMB2 client oplock break handling
       5             : 
       6             :    Copyright (C) Zachary Loafman 2009
       7             : 
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "libcli/smb2/smb2.h"
      24             : #include "libcli/smb2/smb2_calls.h"
      25             : 
      26             : /*
      27             :   Send a Lease Break Acknowledgement
      28             : */
      29         146 : struct smb2_request *smb2_lease_break_ack_send(struct smb2_tree *tree,
      30             :                                                struct smb2_lease_break_ack *io)
      31             : {
      32           0 :         struct smb2_request *req;
      33             : 
      34         146 :         req = smb2_request_init_tree(tree, SMB2_OP_BREAK, 0x24, false, 0);
      35         146 :         if (req == NULL) return NULL;
      36             : 
      37         146 :         SIVAL(req->out.body, 0x02, io->in.reserved);
      38         146 :         SIVAL(req->out.body, 0x04, io->in.lease.lease_flags);
      39         146 :         memcpy(req->out.body+0x8, &io->in.lease.lease_key,
      40             :             sizeof(struct smb2_lease_key));
      41         146 :         SIVAL(req->out.body, 0x18, io->in.lease.lease_state);
      42         146 :         SBVAL(req->out.body, 0x1C, io->in.lease.lease_duration);
      43             : 
      44         146 :         smb2_transport_send(req);
      45             : 
      46         146 :         return req;
      47             : }
      48             : 
      49             : 
      50             : /*
      51             :   Receive a Lease Break Response
      52             : */
      53         146 : NTSTATUS smb2_lease_break_ack_recv(struct smb2_request *req,
      54             :                                    struct smb2_lease_break_ack *io)
      55             : {
      56         146 :         if (!smb2_request_receive(req) ||
      57         146 :             !smb2_request_is_ok(req)) {
      58          26 :                 return smb2_request_destroy(req);
      59             :         }
      60             : 
      61         120 :         SMB2_CHECK_PACKET_RECV(req, 0x24, false);
      62             : 
      63         120 :         io->out.reserved             = IVAL(req->in.body, 0x02);
      64         120 :         io->out.lease.lease_flags    = IVAL(req->in.body, 0x04);
      65         120 :         memcpy(&io->out.lease.lease_key, req->in.body+0x8,
      66             :             sizeof(struct smb2_lease_key));
      67         120 :         io->out.lease.lease_state    = IVAL(req->in.body, 0x18);
      68         120 :         io->out.lease.lease_duration = IVAL(req->in.body, 0x1C);
      69             : 
      70         120 :         return smb2_request_destroy(req);
      71             : }
      72             : 
      73             : /*
      74             :   sync flush request
      75             : */
      76          48 : NTSTATUS smb2_lease_break_ack(struct smb2_tree *tree,
      77             :                               struct smb2_lease_break_ack *io)
      78             : {
      79          48 :         struct smb2_request *req = smb2_lease_break_ack_send(tree, io);
      80          48 :         return smb2_lease_break_ack_recv(req, io);
      81             : }

Generated by: LCOV version 1.14