diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-07-12 14:25:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:10:06 -0500 |
commit | a8958391e8fd9ddd996d2d3aff7ddeed3243fc1f (patch) | |
tree | 617c2420c90d475b05bb3b3894feb2914fbed393 /source4/torture | |
parent | e6b29409a29bdf99c45b2c0aefecb321904f2fd3 (diff) | |
download | samba-a8958391e8fd9ddd996d2d3aff7ddeed3243fc1f.tar.gz samba-a8958391e8fd9ddd996d2d3aff7ddeed3243fc1f.tar.bz2 samba-a8958391e8fd9ddd996d2d3aff7ddeed3243fc1f.zip |
r16980: - make struct smb_notify a union and add levels RAW_NOTIFY_NTTRANS,RAW_NOTIFY_SMB2
- parse SMB2 Notify reponse
metze
(This used to be commit de50e0ccddfad16ad7b254770f4c52c1abe707b9)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/gentest.c | 52 | ||||
-rw-r--r-- | source4/torture/raw/notify.c | 289 |
2 files changed, 176 insertions, 165 deletions
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 0373dd452d..7ce27c7679 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -84,7 +84,7 @@ static struct { static struct { int notify_count; NTSTATUS status; - struct smb_notify notify; + union smb_notify notify; } notifies[NSERVERS][NINSTANCES]; /* info relevant to the current operation */ @@ -682,7 +682,7 @@ static struct ea_struct gen_ea_struct(void) */ static void async_notify(struct smbcli_request *req) { - struct smb_notify notify; + union smb_notify notify; NTSTATUS status; int i, j; uint16_t tid; @@ -690,13 +690,14 @@ static void async_notify(struct smbcli_request *req) tid = SVAL(req->in.hdr, HDR_TID); + notify.nttrans.level = RAW_NOTIFY_NTTRANS; status = smb_raw_changenotify_recv(req, current_op.mem_ctx, ¬ify); if (NT_STATUS_IS_OK(status)) { printf("notify tid=%d num_changes=%d action=%d name=%s\n", tid, - notify.out.num_changes, - notify.out.changes[0].action, - notify.out.changes[0].name.s); + notify.nttrans.out.num_changes, + notify.nttrans.out.changes[0].action, + notify.nttrans.out.changes[0].name.s); } for (i=0;i<NSERVERS;i++) { @@ -892,7 +893,7 @@ again: for (j=0;j<NINSTANCES;j++) { for (i=1;i<NSERVERS;i++) { int n; - struct smb_notify not1, not2; + union smb_notify not1, not2; if (notifies[0][j].notify_count != notifies[i][j].notify_count) { if (tries++ < 10) goto again; @@ -919,26 +920,26 @@ again: not1 = notifies[0][j].notify; not2 = notifies[i][j].notify; - for (n=0;n<not1.out.num_changes;n++) { - if (not1.out.changes[n].action != - not2.out.changes[n].action) { + for (n=0;n<not1.nttrans.out.num_changes;n++) { + if (not1.nttrans.out.changes[n].action != + not2.nttrans.out.changes[n].action) { printf("Notify action %d inconsistent %d %d\n", n, - not1.out.changes[n].action, - not2.out.changes[n].action); + not1.nttrans.out.changes[n].action, + not2.nttrans.out.changes[n].action); return False; } - if (strcmp(not1.out.changes[n].name.s, - not2.out.changes[n].name.s)) { + if (strcmp(not1.nttrans.out.changes[n].name.s, + not2.nttrans.out.changes[n].name.s)) { printf("Notify name %d inconsistent %s %s\n", n, - not1.out.changes[n].name.s, - not2.out.changes[n].name.s); + not1.nttrans.out.changes[n].name.s, + not2.nttrans.out.changes[n].name.s); return False; } - if (not1.out.changes[n].name.private_length != - not2.out.changes[n].name.private_length) { + if (not1.nttrans.out.changes[n].name.private_length != + not2.nttrans.out.changes[n].name.private_length) { printf("Notify name length %d inconsistent %d %d\n", n, - not1.out.changes[n].name.private_length, - not2.out.changes[n].name.private_length); + not1.nttrans.out.changes[n].name.private_length, + not2.nttrans.out.changes[n].name.private_length); return False; } } @@ -1820,17 +1821,18 @@ static BOOL handler_sfileinfo(int instance) */ static BOOL handler_notify(int instance) { - struct smb_notify parm[NSERVERS]; + union smb_notify parm[NSERVERS]; int n; ZERO_STRUCT(parm[0]); - parm[0].in.buffer_size = gen_io_count(); - parm[0].in.completion_filter = gen_bits_mask(0xFF); - parm[0].in.file.fnum = gen_fnum(instance); - parm[0].in.recursive = gen_bool(); + parm[0].nttrans.level = RAW_NOTIFY_NTTRANS; + parm[0].nttrans.in.buffer_size = gen_io_count(); + parm[0].nttrans.in.completion_filter = gen_bits_mask(0xFF); + parm[0].nttrans.in.file.fnum = gen_fnum(instance); + parm[0].nttrans.in.recursive = gen_bool(); GEN_COPY_PARM; - GEN_SET_FNUM(in.file.fnum); + GEN_SET_FNUM(nttrans.in.file.fnum); for (n=0;n<NSERVERS;n++) { struct smbcli_request *req; diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index 12ea821518..0f33a56ce1 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -59,7 +59,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { BOOL ret = True; NTSTATUS status; - struct smb_notify notify; + union smb_notify notify; union smb_open io; union smb_close cl; int i, count, fnum, fnum2; @@ -94,10 +94,11 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* ask for a change notify, on file or directory name changes */ - notify.in.buffer_size = 1000; - notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; - notify.in.file.fnum = fnum; - notify.in.recursive = True; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.buffer_size = 1000; + notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.nttrans.in.file.fnum = fnum; + notify.nttrans.in.recursive = True; printf("testing notify cancel\n"); @@ -114,9 +115,9 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 1); - CHECK_VAL(notify.out.changes[0].action, NOTIFY_ACTION_ADDED); - CHECK_WSTR(notify.out.changes[0].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 1); + CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); printf("testing notify rmdir\n"); @@ -125,9 +126,9 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 1); - CHECK_VAL(notify.out.changes[0].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[0].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 1); + CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); printf("testing notify mkdir - rmdir - mkdir - rmdir\n"); @@ -138,15 +139,15 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) req = smb_raw_changenotify_send(cli->tree, ¬ify); status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 4); - CHECK_VAL(notify.out.changes[0].action, NOTIFY_ACTION_ADDED); - CHECK_WSTR(notify.out.changes[0].name, "subdir-name", STR_UNICODE); - CHECK_VAL(notify.out.changes[1].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[1].name, "subdir-name", STR_UNICODE); - CHECK_VAL(notify.out.changes[2].action, NOTIFY_ACTION_ADDED); - CHECK_WSTR(notify.out.changes[2].name, "subdir-name", STR_UNICODE); - CHECK_VAL(notify.out.changes[3].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[3].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 4); + CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[1].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[2].action, NOTIFY_ACTION_ADDED); + CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[3].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name", STR_UNICODE); count = torture_numops; printf("testing buffered notify on create of %d files\n", count); @@ -165,12 +166,12 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* (1st notify) setup a new notify on a different directory handle. This new notify won't see the events above. */ - notify.in.file.fnum = fnum2; + notify.nttrans.in.file.fnum = fnum2; req2 = smb_raw_changenotify_send(cli->tree, ¬ify); /* (2nd notify) whereas this notify will see the above buffered events, and it directly returns the buffered events */ - notify.in.file.fnum = fnum; + notify.nttrans.in.file.fnum = fnum; req = smb_raw_changenotify_send(cli->tree, ¬ify); /* (1st unlink) as the 2nd notify directly returns, @@ -184,18 +185,18 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, count); - for (i=1;i<notify.out.num_changes;i++) { - CHECK_VAL(notify.out.changes[i].action, NOTIFY_ACTION_ADDED); + CHECK_VAL(notify.nttrans.out.num_changes, count); + for (i=1;i<notify.nttrans.out.num_changes;i++) { + CHECK_VAL(notify.nttrans.out.changes[i].action, NOTIFY_ACTION_ADDED); } - CHECK_WSTR(notify.out.changes[0].name, "test0.txt", STR_UNICODE); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE); /* and now from the 1st notify */ status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 1); - CHECK_VAL(notify.out.changes[0].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[0].name, "test0.txt", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 1); + CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE); /* (3rd notify) this notify will only see the 1st unlink */ req = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -208,32 +209,32 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* receive the 3rd notify */ status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 1); - CHECK_VAL(notify.out.changes[0].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[0].name, "test0.txt", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 1); + CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE); /* and we now see the rest of the unlink calls on both directory handles */ - notify.in.file.fnum = fnum; + notify.nttrans.in.file.fnum = fnum; sleep(1); req = smb_raw_changenotify_send(cli->tree, ¬ify); status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, count-1); - for (i=0;i<notify.out.num_changes;i++) { - CHECK_VAL(notify.out.changes[i].action, NOTIFY_ACTION_REMOVED); + CHECK_VAL(notify.nttrans.out.num_changes, count-1); + for (i=0;i<notify.nttrans.out.num_changes;i++) { + CHECK_VAL(notify.nttrans.out.changes[i].action, NOTIFY_ACTION_REMOVED); } - notify.in.file.fnum = fnum2; + notify.nttrans.in.file.fnum = fnum2; req = smb_raw_changenotify_send(cli->tree, ¬ify); status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, count-1); - for (i=0;i<notify.out.num_changes;i++) { - CHECK_VAL(notify.out.changes[i].action, NOTIFY_ACTION_REMOVED); + CHECK_VAL(notify.nttrans.out.num_changes, count-1); + for (i=0;i<notify.nttrans.out.num_changes;i++) { + CHECK_VAL(notify.nttrans.out.changes[i].action, NOTIFY_ACTION_REMOVED); } printf("testing if a close() on the dir handle triggers the notify reply\n"); - notify.in.file.fnum = fnum; + notify.nttrans.in.file.fnum = fnum; req = smb_raw_changenotify_send(cli->tree, ¬ify); cl.close.level = RAW_CLOSE_CLOSE; @@ -244,7 +245,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 0); + CHECK_VAL(notify.nttrans.out.num_changes, 0); done: smb_raw_exit(cli->session); @@ -259,7 +260,7 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { BOOL ret = True; NTSTATUS status; - struct smb_notify notify; + union smb_notify notify; union smb_open io; int fnum; struct smbcli_request *req1, *req2; @@ -288,14 +289,15 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* ask for a change notify, on file or directory name changes. Setup both with and without recursion */ - notify.in.buffer_size = 1000; - notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_CREATION; - notify.in.file.fnum = fnum; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.buffer_size = 1000; + notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_CREATION; + notify.nttrans.in.file.fnum = fnum; - notify.in.recursive = True; + notify.nttrans.in.recursive = True; req1 = smb_raw_changenotify_send(cli->tree, ¬ify); - notify.in.recursive = False; + notify.nttrans.in.recursive = False; req2 = smb_raw_changenotify_send(cli->tree, ¬ify); /* cancel initial requests so the buffer is setup */ @@ -315,8 +317,8 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_rename(cli->tree, BASEDIR "\\subdir-name\\subname2", BASEDIR "\\subname2-r"); smbcli_rename(cli->tree, BASEDIR "\\subname2-r", BASEDIR "\\subname3-r"); - notify.in.completion_filter = 0; - notify.in.recursive = True; + notify.nttrans.in.completion_filter = 0; + notify.nttrans.in.recursive = True; msleep(10); req1 = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -324,57 +326,57 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name"); smbcli_unlink(cli->tree, BASEDIR "\\subname3-r"); - notify.in.recursive = False; + notify.nttrans.in.recursive = False; req2 = smb_raw_changenotify_send(cli->tree, ¬ify); status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 11); - CHECK_VAL(notify.out.changes[0].action, NOTIFY_ACTION_ADDED); - CHECK_WSTR(notify.out.changes[0].name, "subdir-name", STR_UNICODE); - CHECK_VAL(notify.out.changes[1].action, NOTIFY_ACTION_ADDED); - CHECK_WSTR(notify.out.changes[1].name, "subdir-name\\subname1", STR_UNICODE); - CHECK_VAL(notify.out.changes[2].action, NOTIFY_ACTION_ADDED); - CHECK_WSTR(notify.out.changes[2].name, "subdir-name\\subname2", STR_UNICODE); - CHECK_VAL(notify.out.changes[3].action, NOTIFY_ACTION_OLD_NAME); - CHECK_WSTR(notify.out.changes[3].name, "subdir-name\\subname1", STR_UNICODE); - CHECK_VAL(notify.out.changes[4].action, NOTIFY_ACTION_NEW_NAME); - CHECK_WSTR(notify.out.changes[4].name, "subdir-name\\subname1-r", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 11); + CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[1].action, NOTIFY_ACTION_ADDED); + CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name\\subname1", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[2].action, NOTIFY_ACTION_ADDED); + CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name\\subname2", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[3].action, NOTIFY_ACTION_OLD_NAME); + CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name\\subname1", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[4].action, NOTIFY_ACTION_NEW_NAME); + CHECK_WSTR(notify.nttrans.out.changes[4].name, "subdir-name\\subname1-r", STR_UNICODE); /* the remove/add between directories is acceptable in either order */ - if (notify.out.changes[5].action == NOTIFY_ACTION_ADDED) { - CHECK_VAL(notify.out.changes[6].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[6].name, "subdir-name\\subname2", STR_UNICODE); - CHECK_VAL(notify.out.changes[5].action, NOTIFY_ACTION_ADDED); - CHECK_WSTR(notify.out.changes[5].name, "subname2-r", STR_UNICODE); + if (notify.nttrans.out.changes[5].action == NOTIFY_ACTION_ADDED) { + CHECK_VAL(notify.nttrans.out.changes[6].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[6].name, "subdir-name\\subname2", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[5].action, NOTIFY_ACTION_ADDED); + CHECK_WSTR(notify.nttrans.out.changes[5].name, "subname2-r", STR_UNICODE); } else { - CHECK_VAL(notify.out.changes[5].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[5].name, "subdir-name\\subname2", STR_UNICODE); - CHECK_VAL(notify.out.changes[6].action, NOTIFY_ACTION_ADDED); - CHECK_WSTR(notify.out.changes[6].name, "subname2-r", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[5].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[5].name, "subdir-name\\subname2", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[6].action, NOTIFY_ACTION_ADDED); + CHECK_WSTR(notify.nttrans.out.changes[6].name, "subname2-r", STR_UNICODE); } - CHECK_VAL(notify.out.changes[7].action, NOTIFY_ACTION_MODIFIED); - CHECK_WSTR(notify.out.changes[7].name, "subname2-r", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[7].action, NOTIFY_ACTION_MODIFIED); + CHECK_WSTR(notify.nttrans.out.changes[7].name, "subname2-r", STR_UNICODE); - CHECK_VAL(notify.out.changes[8].action, NOTIFY_ACTION_OLD_NAME); - CHECK_WSTR(notify.out.changes[8].name, "subname2-r", STR_UNICODE); - CHECK_VAL(notify.out.changes[9].action, NOTIFY_ACTION_NEW_NAME); - CHECK_WSTR(notify.out.changes[9].name, "subname3-r", STR_UNICODE); - CHECK_VAL(notify.out.changes[10].action, NOTIFY_ACTION_MODIFIED); - CHECK_WSTR(notify.out.changes[10].name, "subname3-r", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[8].action, NOTIFY_ACTION_OLD_NAME); + CHECK_WSTR(notify.nttrans.out.changes[8].name, "subname2-r", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[9].action, NOTIFY_ACTION_NEW_NAME); + CHECK_WSTR(notify.nttrans.out.changes[9].name, "subname3-r", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[10].action, NOTIFY_ACTION_MODIFIED); + CHECK_WSTR(notify.nttrans.out.changes[10].name, "subname3-r", STR_UNICODE); status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 3); - CHECK_VAL(notify.out.changes[0].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[0].name, "subdir-name\\subname1-r", STR_UNICODE); - CHECK_VAL(notify.out.changes[1].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[1].name, "subdir-name", STR_UNICODE); - CHECK_VAL(notify.out.changes[2].action, NOTIFY_ACTION_REMOVED); - CHECK_WSTR(notify.out.changes[2].name, "subname3-r", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 3); + CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name\\subname1-r", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[1].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.changes[2].action, NOTIFY_ACTION_REMOVED); + CHECK_WSTR(notify.nttrans.out.changes[2].name, "subname3-r", STR_UNICODE); done: smb_raw_exit(cli->session); @@ -389,7 +391,7 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { BOOL ret = True; NTSTATUS status; - struct smb_notify notify; + union smb_notify notify; union smb_open io; int fnum, fnum2; uint32_t mask; @@ -419,8 +421,9 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = BASEDIR; - notify.in.buffer_size = 1000; - notify.in.recursive = True; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.buffer_size = 1000; + notify.nttrans.in.recursive = True; #define NOTIFY_MASK_TEST(setup, op, cleanup, Action, expected, nchanges) \ do { for (mask=i=0;i<32;i++) { \ @@ -429,8 +432,8 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); \ fnum = io.ntcreatex.out.file.fnum; \ setup \ - notify.in.file.fnum = fnum; \ - notify.in.completion_filter = (1<<i); \ + notify.nttrans.in.file.fnum = fnum; \ + notify.nttrans.in.completion_filter = (1<<i); \ req = smb_raw_changenotify_send(cli->tree, ¬ify); \ op \ msleep(10); smb_raw_ntcancel(req); \ @@ -440,18 +443,18 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (NT_STATUS_EQUAL(status, NT_STATUS_CANCELLED)) continue; \ CHECK_STATUS(status, NT_STATUS_OK); \ /* special case to cope with file rename behaviour */ \ - if (nchanges == 2 && notify.out.num_changes == 1 && \ - notify.out.changes[0].action == NOTIFY_ACTION_MODIFIED && \ + if (nchanges == 2 && notify.nttrans.out.num_changes == 1 && \ + notify.nttrans.out.changes[0].action == NOTIFY_ACTION_MODIFIED && \ ((expected) & FILE_NOTIFY_CHANGE_ATTRIBUTES) && \ Action == NOTIFY_ACTION_OLD_NAME) { \ printf("(rename file special handling OK)\n"); \ - } else if (nchanges != notify.out.num_changes || \ - notify.out.changes[0].action != Action || \ - strcmp(notify.out.changes[0].name.s, "tname1") != 0) { \ + } else if (nchanges != notify.nttrans.out.num_changes || \ + notify.nttrans.out.changes[0].action != Action || \ + strcmp(notify.nttrans.out.changes[0].name.s, "tname1") != 0) { \ printf("ERROR: nchanges=%d action=%d filter=0x%08x\n", \ - notify.out.num_changes, \ - notify.out.changes[0].action, \ - notify.in.completion_filter); \ + notify.nttrans.out.num_changes, \ + notify.nttrans.out.changes[0].action, \ + notify.nttrans.in.completion_filter); \ ret = False; \ } \ mask |= (1<<i); \ @@ -601,7 +604,7 @@ static BOOL test_notify_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) BOOL ret = True; union smb_open io; union smb_close cl; - struct smb_notify notify; + union smb_notify notify; struct smbcli_request *req; int fnum; const char *fname = BASEDIR "\\file.txt"; @@ -626,10 +629,11 @@ static BOOL test_notify_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* ask for a change notify, on file or directory name changes */ - notify.in.file.fnum = fnum; - notify.in.buffer_size = 1000; - notify.in.completion_filter = FILE_NOTIFY_CHANGE_STREAM_NAME; - notify.in.recursive = False; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.file.fnum = fnum; + notify.nttrans.in.buffer_size = 1000; + notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_STREAM_NAME; + notify.nttrans.in.recursive = False; printf("testing if notifies on file handles are invalid (should be)\n"); @@ -658,7 +662,7 @@ static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx) { BOOL ret = True; NTSTATUS status; - struct smb_notify notify; + union smb_notify notify; union smb_open io; int fnum; struct smbcli_request *req; @@ -692,10 +696,11 @@ static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx) /* ask for a change notify, on file or directory name changes */ - notify.in.buffer_size = 1000; - notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; - notify.in.file.fnum = fnum; - notify.in.recursive = True; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.buffer_size = 1000; + notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.nttrans.in.file.fnum = fnum; + notify.nttrans.in.recursive = True; req = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -704,7 +709,7 @@ static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx) status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 0); + CHECK_VAL(notify.nttrans.out.num_changes, 0); done: torture_close_connection(cli); @@ -718,7 +723,7 @@ static BOOL test_notify_exit(TALLOC_CTX *mem_ctx) { BOOL ret = True; NTSTATUS status; - struct smb_notify notify; + union smb_notify notify; union smb_open io; int fnum; struct smbcli_request *req; @@ -752,10 +757,11 @@ static BOOL test_notify_exit(TALLOC_CTX *mem_ctx) /* ask for a change notify, on file or directory name changes */ - notify.in.buffer_size = 1000; - notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; - notify.in.file.fnum = fnum; - notify.in.recursive = True; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.buffer_size = 1000; + notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.nttrans.in.file.fnum = fnum; + notify.nttrans.in.recursive = True; req = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -764,7 +770,7 @@ static BOOL test_notify_exit(TALLOC_CTX *mem_ctx) status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 0); + CHECK_VAL(notify.nttrans.out.num_changes, 0); done: torture_close_connection(cli); @@ -778,7 +784,7 @@ static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx) { BOOL ret = True; NTSTATUS status; - struct smb_notify notify; + union smb_notify notify; union smb_open io; int fnum; struct smbcli_request *req; @@ -812,10 +818,11 @@ static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx) /* ask for a change notify, on file or directory name changes */ - notify.in.buffer_size = 1000; - notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; - notify.in.file.fnum = fnum; - notify.in.recursive = True; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.buffer_size = 1000; + notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.nttrans.in.file.fnum = fnum; + notify.nttrans.in.recursive = True; req = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -824,7 +831,7 @@ static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx) status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 0); + CHECK_VAL(notify.nttrans.out.num_changes, 0); done: torture_close_connection(cli); @@ -839,7 +846,7 @@ static BOOL test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { BOOL ret = True; NTSTATUS status; - struct smb_notify notify; + union smb_notify notify; union smb_open io; int fnum; struct smbcli_request *req1, *req2; @@ -868,10 +875,11 @@ static BOOL test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* ask for a change notify, on file or directory name changes */ - notify.in.buffer_size = 1000; - notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; - notify.in.file.fnum = fnum; - notify.in.recursive = True; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.buffer_size = 1000; + notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.nttrans.in.file.fnum = fnum; + notify.nttrans.in.recursive = True; req1 = smb_raw_changenotify_send(cli->tree, ¬ify); req2 = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -880,15 +888,15 @@ static BOOL test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 1); - CHECK_WSTR(notify.out.changes[0].name, "subdir-name", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 1); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name2"); status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(notify.out.num_changes, 1); - CHECK_WSTR(notify.out.changes[0].name, "subdir-name2", STR_UNICODE); + CHECK_VAL(notify.nttrans.out.num_changes, 1); + CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name2", STR_UNICODE); done: smb_raw_exit(cli->session); @@ -902,7 +910,7 @@ done: static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { BOOL ret = True; - struct smb_notify notify; + union smb_notify notify; union smb_open io; struct smbcli_request *req; struct { @@ -950,7 +958,8 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; io.ntcreatex.in.security_flags = 0; - notify.in.buffer_size = 20000; + notify.nttrans.level = RAW_NOTIFY_NTTRANS; + notify.nttrans.in.buffer_size = 20000; /* setup the directory tree, and the notify buffer on each directory @@ -961,9 +970,9 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); dirs[i].fnum = io.ntcreatex.out.file.fnum; - notify.in.completion_filter = dirs[i].filter; - notify.in.file.fnum = dirs[i].fnum; - notify.in.recursive = dirs[i].recursive; + notify.nttrans.in.completion_filter = dirs[i].filter; + notify.nttrans.in.file.fnum = dirs[i].fnum; + notify.nttrans.in.recursive = dirs[i].recursive; req = smb_raw_changenotify_send(cli->tree, ¬ify); smb_raw_ntcancel(req); status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); @@ -983,14 +992,14 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* count events that have happened in each dir */ for (i=0;i<ARRAY_SIZE(dirs);i++) { - notify.in.file.fnum = dirs[i].fnum; + notify.nttrans.in.file.fnum = dirs[i].fnum; req = smb_raw_changenotify_send(cli->tree, ¬ify); smb_raw_ntcancel(req); - notify.out.num_changes = 0; + notify.nttrans.out.num_changes = 0; status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); - if (notify.out.num_changes != dirs[i].expected) { + if (notify.nttrans.out.num_changes != dirs[i].expected) { printf("ERROR: i=%d expected %d got %d for '%s'\n", - i, dirs[i].expected, notify.out.num_changes, + i, dirs[i].expected, notify.nttrans.out.num_changes, dirs[i].path); ret = False; } |