Coverage Report

Created: 2025-12-31 06:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/samba/source4/libcli/smb2/lease_break.c
Line
Count
Source
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
struct smb2_request *smb2_lease_break_ack_send(struct smb2_tree *tree,
30
                                               struct smb2_lease_break_ack *io)
31
0
{
32
0
  struct smb2_request *req;
33
34
0
  req = smb2_request_init_tree(tree, SMB2_OP_BREAK, 0x24, false, 0);
35
0
  if (req == NULL) return NULL;
36
37
0
  SIVAL(req->out.body, 0x02, io->in.reserved);
38
0
  SIVAL(req->out.body, 0x04, io->in.lease.lease_flags);
39
0
  memcpy(req->out.body+0x8, &io->in.lease.lease_key,
40
0
      sizeof(struct smb2_lease_key));
41
0
  SIVAL(req->out.body, 0x18, io->in.lease.lease_state);
42
0
  SBVAL(req->out.body, 0x1C, io->in.lease.lease_duration);
43
44
0
  smb2_transport_send(req);
45
46
0
  return req;
47
0
}
48
49
50
/*
51
  Receive a Lease Break Response
52
*/
53
NTSTATUS smb2_lease_break_ack_recv(struct smb2_request *req,
54
                                   struct smb2_lease_break_ack *io)
55
0
{
56
0
  if (!smb2_request_receive(req) ||
57
0
      !smb2_request_is_ok(req)) {
58
0
    return smb2_request_destroy(req);
59
0
  }
60
61
0
  SMB2_CHECK_PACKET_RECV(req, 0x24, false);
62
63
0
  io->out.reserved    = IVAL(req->in.body, 0x02);
64
0
  io->out.lease.lease_flags = IVAL(req->in.body, 0x04);
65
0
  memcpy(&io->out.lease.lease_key, req->in.body+0x8,
66
0
      sizeof(struct smb2_lease_key));
67
0
  io->out.lease.lease_state = IVAL(req->in.body, 0x18);
68
0
  io->out.lease.lease_duration  = IVAL(req->in.body, 0x1C);
69
70
0
  return smb2_request_destroy(req);
71
0
}
72
73
/*
74
  sync flush request
75
*/
76
NTSTATUS smb2_lease_break_ack(struct smb2_tree *tree,
77
                              struct smb2_lease_break_ack *io)
78
0
{
79
0
  struct smb2_request *req = smb2_lease_break_ack_send(tree, io);
80
0
  return smb2_lease_break_ack_recv(req, io);
81
0
}