s4:torture:smb2: extract map_lease() to util.c as smb2_util_lease_state().
authorMichael Adam <obnox@samba.org>
Tue, 8 Nov 2011 07:04:28 +0000 (08:04 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 9 Nov 2011 00:02:08 +0000 (01:02 +0100)
source4/torture/smb2/durable_open.c
source4/torture/smb2/util.c

index ea0fbfade480b79e4721eaffdf44ef95d1fc1e30..19b9e1d88a88568fa807026bc9da60b94a8ac809 100644 (file)
        } while(0)
 
 
-static inline uint32_t map_lease(const char *ls)
-{
-       uint32_t val = 0;
-       int i;
-
-       for (i = 0; i < strlen(ls); i++) {
-               switch (ls[i]) {
-               case 'R':
-                       val |= SMB2_LEASE_READ;
-                       break;
-               case 'H':
-                       val |= SMB2_LEASE_HANDLE;
-                       break;
-               case 'W':
-                       val |= SMB2_LEASE_WRITE;
-                       break;
-               }
-       }
-
-       return val;
-}
-
 static inline uint32_t map_sharemode(const char *sharemode)
 {
        uint32_t val = NTCREATEX_SHARE_ACCESS_NONE; /* 0 */
@@ -324,7 +302,7 @@ static bool test_one_durable_open_open2(struct torture_context *tctx,
        ZERO_STRUCT(ls);
        ls.lease_key.data[0] = lease;
        ls.lease_key.data[1] = ~lease;
-       ls.lease_state = map_lease(test.type);
+       ls.lease_state = smb2_util_lease_state(test.type);
        io.in.lease_request = &ls;
 
        status = smb2_create(tree, mem_ctx, &io);
@@ -336,7 +314,8 @@ static bool test_one_durable_open_open2(struct torture_context *tctx,
        CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_LEASE);
        CHECK_VAL(io.out.lease_response.lease_key.data[0], lease);
        CHECK_VAL(io.out.lease_response.lease_key.data[1], ~lease);
-       CHECK_VAL(io.out.lease_response.lease_state, map_lease(test.type));
+       CHECK_VAL(io.out.lease_response.lease_state,
+                 smb2_util_lease_state(test.type));
 done:
        if (h != NULL) {
                smb2_util_close(tree, *h);
index caa7fd4be59a79af892fcf23dcdd9834aecf2730..49ffccda143cde228feac0dbb60e1f303cc858a1 100644 (file)
@@ -499,3 +499,25 @@ bool smb2_util_verify_attrib(TALLOC_CTX *tctx, struct smb2_tree *tree,
 }
 
 
+uint32_t smb2_util_lease_state(const char *ls)
+{
+       uint32_t val = 0;
+       int i;
+
+       for (i = 0; i < strlen(ls); i++) {
+               switch (ls[i]) {
+               case 'R':
+                       val |= SMB2_LEASE_READ;
+                       break;
+               case 'H':
+                       val |= SMB2_LEASE_HANDLE;
+                       break;
+               case 'W':
+                       val |= SMB2_LEASE_WRITE;
+                       break;
+               }
+       }
+
+       return val;
+}
+