diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-07-12 07:33:25 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:10:04 -0500 |
commit | 86c3e628e0c912b486b406d47b20b1940fa81449 (patch) | |
tree | f6f112f30bb28ba702a4313391f386e1c7cac376 | |
parent | 32ab51876728577375b954a04103f71ddd4d93dc (diff) | |
download | samba-86c3e628e0c912b486b406d47b20b1940fa81449.tar.gz samba-86c3e628e0c912b486b406d47b20b1940fa81449.tar.bz2 samba-86c3e628e0c912b486b406d47b20b1940fa81449.zip |
r16975: implement SMB2 Notify call in the client lib
metze
(This used to be commit a455dc7a8392230395c0e444f76a4ca13192f871)
-rw-r--r-- | source4/libcli/smb2/config.mk | 1 | ||||
-rw-r--r-- | source4/libcli/smb2/notify.c | 83 | ||||
-rw-r--r-- | source4/libcli/smb2/smb2_calls.h | 22 |
3 files changed, 106 insertions, 0 deletions
diff --git a/source4/libcli/smb2/config.mk b/source4/libcli/smb2/config.mk index 33ef633e1f..9dba94f506 100644 --- a/source4/libcli/smb2/config.mk +++ b/source4/libcli/smb2/config.mk @@ -19,5 +19,6 @@ OBJ_FILES = \ tdis.o \ flush.o \ lock.o \ + notify.o \ keepalive.o PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBPACKET gensec diff --git a/source4/libcli/smb2/notify.c b/source4/libcli/smb2/notify.c new file mode 100644 index 0000000000..0e61293495 --- /dev/null +++ b/source4/libcli/smb2/notify.c @@ -0,0 +1,83 @@ +/* + Unix SMB/CIFS implementation. + + SMB2 client notify calls + + Copyright (C) Stefan Metzmacher 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "libcli/raw/libcliraw.h" +#include "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" + +/* + send a notify request +*/ +struct smb2_request *smb2_notify_send(struct smb2_tree *tree, struct smb2_notify *io) +{ + struct smb2_request *req; + + req = smb2_request_init_tree(tree, SMB2_OP_NOTIFY, 0x20, False, 0); + if (req == NULL) return NULL; + + SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0030); + + SSVAL(req->out.body, 0x02, io->in.recursive); + SIVAL(req->out.body, 0x04, io->in.buffer_size); + smb2_push_handle(req->out.body+0x08, &io->in.file.handle); + SIVAL(req->out.body, 0x18, io->in.completion_filter); + SIVAL(req->out.body, 0x1C, io->in.unknown); + + smb2_transport_send(req); + + return req; +} + + +/* + recv a notify reply +*/ +NTSTATUS smb2_notify_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, + struct smb2_notify *io) +{ + NTSTATUS status; + + if (!smb2_request_receive(req) || + smb2_request_is_error(req)) { + return smb2_request_destroy(req); + } + + SMB2_CHECK_PACKET_RECV(req, 0x08, True); + + status = smb2_pull_o16s32_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.blob); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + return smb2_request_destroy(req); +} + +/* + sync notify request +*/ +NTSTATUS smb2_notify(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, + struct smb2_notify *io) +{ + struct smb2_request *req = smb2_notify_send(tree, io); + return smb2_notify_recv(req, mem_ctx, io); +} diff --git a/source4/libcli/smb2/smb2_calls.h b/source4/libcli/smb2/smb2_calls.h index abb7f88ee2..c3dc629430 100644 --- a/source4/libcli/smb2/smb2_calls.h +++ b/source4/libcli/smb2/smb2_calls.h @@ -94,6 +94,28 @@ struct smb2_setinfo { } in; }; +struct smb2_notify { + struct { + /* static body buffer 32 (0x20) bytes */ + /* uint16_t buffer_code; 0x32 */ + uint16_t recursive; + uint32_t buffer_size; + union smb_handle file; + uint32_t completion_filter; + uint32_t unknown; + } in; + + struct { + /* static body buffer 8 (0x08) bytes */ + /* uint16_t buffer_code; 0x09 = 0x08 + 1 */ + /* uint16_t blob_ofs; */ + /* uint16_t blob_size; */ + + /* dynamic body */ + DATA_BLOB blob; + } out; +}; + struct cli_credentials; struct event_context; #include "libcli/smb2/smb2_proto.h" |