s4:torture/smb2: add smb2_lease_v2_create_share() helper
authorStefan Metzmacher <metze@samba.org>
Wed, 31 Oct 2012 08:06:48 +0000 (09:06 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 18 Apr 2013 13:11:48 +0000 (15:11 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/libcli/smb2/create.c
source4/torture/smb2/util.c

index 6047a85d878d6f92b37670d2a9fb83ccb4767efe..7267f921266e49b80eea29bf92d496947662ac0c 100644 (file)
@@ -227,7 +227,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
        }
 
        if (io->in.lease_request_v2) {
-               struct smb2_lease *ls = &io->in.lease_request_v2;
+               struct smb2_lease *ls = io->in.lease_request_v2;
                uint8_t data[52];
 
                memcpy(&data[0], &ls->lease_key, 16);
index 7e882349c9226f784c79f49dc1d09dde6ed3c109..59748b7e25e7cb7bc10abd9eec0f2a6db103aa86 100644 (file)
@@ -729,6 +729,34 @@ void smb2_lease_create(struct smb2_create *io, struct smb2_lease *ls,
                                leasekey, leasestate);
 }
 
+void smb2_lease_v2_create_share(struct smb2_create *io,
+                               struct smb2_lease *ls,
+                               bool dir,
+                               const char *name,
+                               uint32_t share_access,
+                               uint64_t leasekey,
+                               const uint64_t *parentleasekey,
+                               uint32_t leasestate,
+                               uint16_t lease_epoch)
+{
+       smb2_generic_create_share(io, NULL, dir, name, NTCREATEX_DISP_OPEN_IF,
+                                 share_access, SMB2_OPLOCK_LEVEL_LEASE, 0, 0);
+
+       if (ls) {
+               ZERO_STRUCT(*ls);
+               ls->lease_key.data[0] = leasekey;
+               ls->lease_key.data[1] = ~leasekey;
+               ls->lease_state = leasestate;
+               if (parentleasekey != NULL) {
+                       ls->lease_flags |= SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET;
+                       ls->parent_lease_key.data[0] = *parentleasekey;
+                       ls->parent_lease_key.data[1] = ~(*parentleasekey);
+               }
+               ls->lease_epoch = lease_epoch;
+               io->in.lease_request_v2 = ls;
+       }
+}
+
 void smb2_oplock_create_share(struct smb2_create *io, const char *name,
                              uint32_t share_access, uint8_t oplock)
 {