svn commit: samba r16975 - in branches/SAMBA_4_0/source/libcli/smb2: .

metze at samba.org metze at samba.org
Wed Jul 12 07:33:25 GMT 2006


Author: metze
Date: 2006-07-12 07:33:25 +0000 (Wed, 12 Jul 2006)
New Revision: 16975

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16975

Log:
implement SMB2 Notify call in the client lib

metze
Added:
   branches/SAMBA_4_0/source/libcli/smb2/notify.c
Modified:
   branches/SAMBA_4_0/source/libcli/smb2/config.mk
   branches/SAMBA_4_0/source/libcli/smb2/smb2_calls.h


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/smb2/config.mk
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/config.mk	2006-07-12 06:56:47 UTC (rev 16974)
+++ branches/SAMBA_4_0/source/libcli/smb2/config.mk	2006-07-12 07:33:25 UTC (rev 16975)
@@ -19,5 +19,6 @@
 	tdis.o \
 	flush.o \
 	lock.o \
+	notify.o \
 	keepalive.o
 PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBPACKET gensec

Added: branches/SAMBA_4_0/source/libcli/smb2/notify.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/notify.c	2006-07-12 06:56:47 UTC (rev 16974)
+++ branches/SAMBA_4_0/source/libcli/smb2/notify.c	2006-07-12 07:33:25 UTC (rev 16975)
@@ -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);
+}

Modified: branches/SAMBA_4_0/source/libcli/smb2/smb2_calls.h
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/smb2_calls.h	2006-07-12 06:56:47 UTC (rev 16974)
+++ branches/SAMBA_4_0/source/libcli/smb2/smb2_calls.h	2006-07-12 07:33:25 UTC (rev 16975)
@@ -94,6 +94,28 @@
 	} 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"



More information about the samba-cvs mailing list