[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-test-2367-gbc1df53

Günther Deschner gd at samba.org
Sun Feb 17 23:32:35 GMT 2008


The branch, v3-2-test has been updated
       via  bc1df536fa04e004ccf177e0f3ba56f3c47709aa (commit)
       via  da6636577dbbdabd248ea87a07819c5e63577f86 (commit)
       via  9bc5068cc387cd02e53db6146db9b4ed0af3160d (commit)
       via  c7c89317db3774e75013dec67e44100d7276c939 (commit)
       via  9d7699cbe4ba3536d7acf8e06374e33c036a2d2a (commit)
      from  8971afaf744e5124d4b82cad76e368ccd05be394 (commit)

http://gitweb.samba.org/?samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit bc1df536fa04e004ccf177e0f3ba56f3c47709aa
Author: Günther Deschner <gd at samba.org>
Date:   Mon Feb 18 00:24:57 2008 +0100

    Remove unused marshalling for NTSVCS_GET_DEVICE_LIST_SIZE.
    
    Guenther

commit da6636577dbbdabd248ea87a07819c5e63577f86
Author: Günther Deschner <gd at samba.org>
Date:   Mon Feb 18 00:21:56 2008 +0100

    Use pidl for _PNP_GetDeviceListSize().
    
    Guenther

commit 9bc5068cc387cd02e53db6146db9b4ed0af3160d
Author: Günther Deschner <gd at samba.org>
Date:   Mon Feb 18 00:23:25 2008 +0100

    Add ntsvcs_getdevlistsize command to rpcclient.
    
    Guenther

commit c7c89317db3774e75013dec67e44100d7276c939
Author: Günther Deschner <gd at samba.org>
Date:   Mon Feb 18 00:26:10 2008 +0100

    Re-run make idl.
    
    Guenther

commit 9d7699cbe4ba3536d7acf8e06374e33c036a2d2a
Author: Günther Deschner <gd at samba.org>
Date:   Mon Feb 18 00:22:45 2008 +0100

    Fill in IDL PNP_GetDeviceListSize() based on samba3.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source/include/rpc_ntsvcs.h        |   13 --------
 source/librpc/gen_ndr/cli_ntsvcs.c |    6 ++++
 source/librpc/gen_ndr/cli_ntsvcs.h |    3 ++
 source/librpc/gen_ndr/ndr_ntsvcs.c |   56 ++++++++++++++++++++++++++++++++++++
 source/librpc/gen_ndr/ntsvcs.h     |    6 ++++
 source/librpc/gen_ndr/srv_ntsvcs.c |    7 ++++
 source/librpc/idl/ntsvcs.idl       |    6 +++-
 source/rpc_parse/parse_ntsvcs.c    |   53 ----------------------------------
 source/rpc_server/srv_ntsvcs.c     |   18 +-----------
 source/rpc_server/srv_ntsvcs_nt.c  |   23 ++++-----------
 source/rpcclient/cmd_ntsvcs.c      |   40 +++++++++++++++++++++++++
 11 files changed, 130 insertions(+), 101 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/rpc_ntsvcs.h b/source/include/rpc_ntsvcs.h
index 12224fe..55f3662 100644
--- a/source/include/rpc_ntsvcs.h
+++ b/source/include/rpc_ntsvcs.h
@@ -37,19 +37,6 @@
 
 typedef struct {
 	UNISTR2 *devicename;
-	uint32 flags;
-} NTSVCS_Q_GET_DEVICE_LIST_SIZE;
-
-typedef struct {
-	uint32 size;
-	WERROR status;
-} NTSVCS_R_GET_DEVICE_LIST_SIZE;
-
-
-/**************************/
-
-typedef struct {
-	UNISTR2 *devicename;
 	uint32 buffer_size;
 	uint32 flags;
 } NTSVCS_Q_GET_DEVICE_LIST;
diff --git a/source/librpc/gen_ndr/cli_ntsvcs.c b/source/librpc/gen_ndr/cli_ntsvcs.c
index c21910c..7f27580 100644
--- a/source/librpc/gen_ndr/cli_ntsvcs.c
+++ b/source/librpc/gen_ndr/cli_ntsvcs.c
@@ -476,12 +476,17 @@ NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli,
 
 NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli,
 				      TALLOC_CTX *mem_ctx,
+				      const char *devicename,
+				      uint32_t *size,
+				      uint32_t flags,
 				      WERROR *werror)
 {
 	struct PNP_GetDeviceListSize r;
 	NTSTATUS status;
 
 	/* In parameters */
+	r.in.devicename = devicename;
+	r.in.flags = flags;
 
 	if (DEBUGLEVEL >= 10) {
 		NDR_PRINT_IN_DEBUG(PNP_GetDeviceListSize, &r);
@@ -507,6 +512,7 @@ NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli,
 	}
 
 	/* Return variables */
+	*size = *r.out.size;
 
 	/* Return result */
 	if (werror) {
diff --git a/source/librpc/gen_ndr/cli_ntsvcs.h b/source/librpc/gen_ndr/cli_ntsvcs.h
index 666ea9b..9112000 100644
--- a/source/librpc/gen_ndr/cli_ntsvcs.h
+++ b/source/librpc/gen_ndr/cli_ntsvcs.h
@@ -39,6 +39,9 @@ NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli,
 				  WERROR *werror);
 NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli,
 				      TALLOC_CTX *mem_ctx,
+				      const char *devicename,
+				      uint32_t *size,
+				      uint32_t flags,
 				      WERROR *werror);
 NTSTATUS rpccli_PNP_GetDepth(struct rpc_pipe_client *cli,
 			     TALLOC_CTX *mem_ctx,
diff --git a/source/librpc/gen_ndr/ndr_ntsvcs.c b/source/librpc/gen_ndr/ndr_ntsvcs.c
index be55319..c66ec2a 100644
--- a/source/librpc/gen_ndr/ndr_ntsvcs.c
+++ b/source/librpc/gen_ndr/ndr_ntsvcs.c
@@ -498,8 +498,20 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceList(struct ndr_print *ndr, const char *nam
 static enum ndr_err_code ndr_push_PNP_GetDeviceListSize(struct ndr_push *ndr, int flags, const struct PNP_GetDeviceListSize *r)
 {
 	if (flags & NDR_IN) {
+		NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.devicename));
+		if (r->in.devicename) {
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicename, CH_UTF16)));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicename, CH_UTF16)));
+			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.devicename, ndr_charset_length(r->in.devicename, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+		}
+		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.flags));
 	}
 	if (flags & NDR_OUT) {
+		if (r->out.size == NULL) {
+			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+		}
+		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.size));
 		NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result));
 	}
 	return NDR_ERR_SUCCESS;
@@ -507,9 +519,42 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceListSize(struct ndr_push *ndr, in
 
 static enum ndr_err_code ndr_pull_PNP_GetDeviceListSize(struct ndr_pull *ndr, int flags, struct PNP_GetDeviceListSize *r)
 {
+	uint32_t _ptr_devicename;
+	TALLOC_CTX *_mem_save_devicename_0;
+	TALLOC_CTX *_mem_save_size_0;
 	if (flags & NDR_IN) {
+		ZERO_STRUCT(r->out);
+
+		NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devicename));
+		if (_ptr_devicename) {
+			NDR_PULL_ALLOC(ndr, r->in.devicename);
+		} else {
+			r->in.devicename = NULL;
+		}
+		if (r->in.devicename) {
+			_mem_save_devicename_0 = NDR_PULL_GET_MEM_CTX(ndr);
+			NDR_PULL_SET_MEM_CTX(ndr, r->in.devicename, 0);
+			NDR_CHECK(ndr_pull_array_size(ndr, &r->in.devicename));
+			NDR_CHECK(ndr_pull_array_length(ndr, &r->in.devicename));
+			if (ndr_get_array_length(ndr, &r->in.devicename) > ndr_get_array_size(ndr, &r->in.devicename)) {
+				return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.devicename), ndr_get_array_length(ndr, &r->in.devicename));
+			}
+			NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.devicename), sizeof(uint16_t)));
+			NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.devicename, ndr_get_array_length(ndr, &r->in.devicename), sizeof(uint16_t), CH_UTF16));
+			NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devicename_0, 0);
+		}
+		NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags));
+		NDR_PULL_ALLOC(ndr, r->out.size);
+		ZERO_STRUCTP(r->out.size);
 	}
 	if (flags & NDR_OUT) {
+		if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+			NDR_PULL_ALLOC(ndr, r->out.size);
+		}
+		_mem_save_size_0 = NDR_PULL_GET_MEM_CTX(ndr);
+		NDR_PULL_SET_MEM_CTX(ndr, r->out.size, LIBNDR_FLAG_REF_ALLOC);
+		NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.size));
+		NDR_PULL_SET_MEM_CTX(ndr, _mem_save_size_0, LIBNDR_FLAG_REF_ALLOC);
 		NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result));
 	}
 	return NDR_ERR_SUCCESS;
@@ -525,11 +570,22 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceListSize(struct ndr_print *ndr, const char
 	if (flags & NDR_IN) {
 		ndr_print_struct(ndr, "in", "PNP_GetDeviceListSize");
 		ndr->depth++;
+		ndr_print_ptr(ndr, "devicename", r->in.devicename);
+		ndr->depth++;
+		if (r->in.devicename) {
+			ndr_print_string(ndr, "devicename", r->in.devicename);
+		}
+		ndr->depth--;
+		ndr_print_uint32(ndr, "flags", r->in.flags);
 		ndr->depth--;
 	}
 	if (flags & NDR_OUT) {
 		ndr_print_struct(ndr, "out", "PNP_GetDeviceListSize");
 		ndr->depth++;
+		ndr_print_ptr(ndr, "size", r->out.size);
+		ndr->depth++;
+		ndr_print_uint32(ndr, "size", *r->out.size);
+		ndr->depth--;
 		ndr_print_WERROR(ndr, "result", r->out.result);
 		ndr->depth--;
 	}
diff --git a/source/librpc/gen_ndr/ntsvcs.h b/source/librpc/gen_ndr/ntsvcs.h
index 477d6ad..2384011 100644
--- a/source/librpc/gen_ndr/ntsvcs.h
+++ b/source/librpc/gen_ndr/ntsvcs.h
@@ -102,6 +102,12 @@ struct PNP_GetDeviceList {
 
 struct PNP_GetDeviceListSize {
 	struct {
+		const char *devicename;/* [unique,charset(UTF16)] */
+		uint32_t flags;
+	} in;
+
+	struct {
+		uint32_t *size;/* [ref] */
 		WERROR result;
 	} out;
 
diff --git a/source/librpc/gen_ndr/srv_ntsvcs.c b/source/librpc/gen_ndr/srv_ntsvcs.c
index 7bbf9d1..608353c 100644
--- a/source/librpc/gen_ndr/srv_ntsvcs.c
+++ b/source/librpc/gen_ndr/srv_ntsvcs.c
@@ -854,6 +854,13 @@ static bool api_PNP_GetDeviceListSize(pipes_struct *p)
 		NDR_PRINT_IN_DEBUG(PNP_GetDeviceListSize, r);
 	}
 
+	ZERO_STRUCT(r->out);
+	r->out.size = talloc_zero(r, uint32_t);
+	if (r->out.size == NULL) {
+		talloc_free(r);
+		return false;
+	}
+
 	r->out.result = _PNP_GetDeviceListSize(p, r);
 
 	if (p->rng_fault_state) {
diff --git a/source/librpc/idl/ntsvcs.idl b/source/librpc/idl/ntsvcs.idl
index a9c41cc..78ac307 100644
--- a/source/librpc/idl/ntsvcs.idl
+++ b/source/librpc/idl/ntsvcs.idl
@@ -72,7 +72,11 @@ interface ntsvcs
 	/******************/
 	/* Function: 0x0b */
 
-	WERROR PNP_GetDeviceListSize();
+	WERROR PNP_GetDeviceListSize(
+		[in,unique] [string,charset(UTF16)] uint16 *devicename,
+		[out,ref] uint32 *size,
+		[in] uint32 flags
+		);
 
 	/******************/
 	/* Function: 0x0c */
diff --git a/source/rpc_parse/parse_ntsvcs.c b/source/rpc_parse/parse_ntsvcs.c
index 86e8d9d..faa7f8d 100644
--- a/source/rpc_parse/parse_ntsvcs.c
+++ b/source/rpc_parse/parse_ntsvcs.c
@@ -25,59 +25,6 @@
 /*******************************************************************
 ********************************************************************/
 
-/*******************************************************************
-********************************************************************/
-
-bool ntsvcs_io_q_get_device_list_size(const char *desc, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, prs_struct *ps, int depth)
-{
-	if (q_u == NULL)
-		return False;
-
-	prs_debug(ps, depth, desc, "ntsvcs_io_q_get_device_list_size");
-	depth++;
-	
-	if(!prs_align(ps))
-		return False;
-
-	if ( !prs_pointer("devicename", ps, depth, (void*)&q_u->devicename, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2) )
-		return False;
-	if ( !prs_align(ps) )
-		return False;
-		
-	if ( !prs_uint32("flags", ps, depth, &q_u->flags) )
-		return False;
-	
-	return True;
-
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool ntsvcs_io_r_get_device_list_size(const char *desc, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u, prs_struct *ps, int depth)
-{
-	if ( !r_u )
-		return False;
-
-	prs_debug(ps, depth, desc, "ntsvcs_io_r_get_device_list_size");
-	depth++;
-
-	if(!prs_align(ps))
-		return False;
-		
-	if(!prs_uint32("size", ps, depth, &r_u->size))
-		return False;
-		
-	if(!prs_werror("status", ps, depth, &r_u->status))
-		return False;
-
-	return True;
-}
-
-
-/*******************************************************************
-********************************************************************/
-
 bool ntsvcs_io_q_get_device_list(const char *desc, NTSVCS_Q_GET_DEVICE_LIST *q_u, prs_struct *ps, int depth)
 {
 	if (q_u == NULL)
diff --git a/source/rpc_server/srv_ntsvcs.c b/source/rpc_server/srv_ntsvcs.c
index cd22489..73d4b4f 100644
--- a/source/rpc_server/srv_ntsvcs.c
+++ b/source/rpc_server/srv_ntsvcs.c
@@ -56,23 +56,7 @@ static bool api_ntsvcs_get_version(pipes_struct *p)
 
 static bool api_ntsvcs_get_device_list_size(pipes_struct *p)
 {
-	NTSVCS_Q_GET_DEVICE_LIST_SIZE q_u;
-	NTSVCS_R_GET_DEVICE_LIST_SIZE r_u;
-	prs_struct *data = &p->in_data.data;
-	prs_struct *rdata = &p->out_data.rdata;
-
-	ZERO_STRUCT(q_u);
-	ZERO_STRUCT(r_u);
-
-	if(!ntsvcs_io_q_get_device_list_size("", &q_u, data, 0))
-		return False;
-
-	r_u.status = _ntsvcs_get_device_list_size(p, &q_u, &r_u);
-
-	if(!ntsvcs_io_r_get_device_list_size("", &r_u, rdata, 0))
-		return False;
-
-	return True;
+	return proxy_ntsvcs_call(p, NDR_PNP_GETDEVICELISTSIZE);
 }
 
 /*******************************************************************
diff --git a/source/rpc_server/srv_ntsvcs_nt.c b/source/rpc_server/srv_ntsvcs_nt.c
index b6e0126..76bc24e 100644
--- a/source/rpc_server/srv_ntsvcs_nt.c
+++ b/source/rpc_server/srv_ntsvcs_nt.c
@@ -45,21 +45,20 @@ WERROR _PNP_GetVersion(pipes_struct *p,
 /********************************************************************
 ********************************************************************/
 
-WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u )
+WERROR _PNP_GetDeviceListSize(pipes_struct *p,
+			      struct PNP_GetDeviceListSize *r)
 {
-	fstring device;
 	char *devicepath;
 
-	if ( !q_u->devicename )
+	if (!r->in.devicename) {
 		return WERR_ACCESS_DENIED;
+	}
 
-	rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
-
-	if (!(devicepath = get_device_path(p->mem_ctx, device))) {
+	if (!(devicepath = get_device_path(p->mem_ctx, r->in.devicename))) {
 		return WERR_NOMEM;
 	}
 
-	r_u->size = strlen(devicepath) + 2;
+	*r->out.size = strlen(devicepath) + 2;
 
 	TALLOC_FREE(devicepath);
 
@@ -269,16 +268,6 @@ WERROR _PNP_GetDeviceList(pipes_struct *p,
 /****************************************************************
 ****************************************************************/
 
-WERROR _PNP_GetDeviceListSize(pipes_struct *p,
-			      struct PNP_GetDeviceListSize *r)
-{
-	p->rng_fault_state = true;
-	return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
 WERROR _PNP_GetDepth(pipes_struct *p,
 		     struct PNP_GetDepth *r)
 {
diff --git a/source/rpcclient/cmd_ntsvcs.c b/source/rpcclient/cmd_ntsvcs.c
index f764806..04e367a 100644
--- a/source/rpcclient/cmd_ntsvcs.c
+++ b/source/rpcclient/cmd_ntsvcs.c
@@ -75,10 +75,50 @@ static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli,
 	return werr;
 }
 
+static WERROR cmd_ntsvcs_get_device_list_size(struct rpc_pipe_client *cli,
+					      TALLOC_CTX *mem_ctx,
+					      int argc,
+					      const char **argv)
+{
+	NTSTATUS status;
+	WERROR werr;
+	const char *devicename = NULL;
+	uint32_t flags = 0;
+	uint32_t size = 0;
+
+	if (argc < 2 || argc > 4) {
+		printf("usage: %s [devicename] <flags>\n", argv[0]);
+		return WERR_OK;
+	}
+
+	devicename = argv[1];
+
+	if (argc >= 3) {
+		flags = atoi(argv[2]);
+	}
+
+	status = rpccli_PNP_GetDeviceListSize(cli, mem_ctx,
+					      devicename,
+					      &size,
+					      flags,
+					      &werr);
+	if (!NT_STATUS_IS_OK(status)) {
+		return ntstatus_to_werror(status);
+	}
+
+	if (W_ERROR_IS_OK(werr)) {
+		printf("size: %d\n", size);
+	}
+
+	return werr;
+}
+
+
 struct cmd_set ntsvcs_commands[] = {
 
 	{ "NTSVCS" },
 	{ "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" },
 	{ "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" },
+	{ "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_device_list_size, PI_NTSVCS, NULL, "Query NTSVCS get device list", "" },
 	{ NULL }
 };


-- 
Samba Shared Repository


More information about the samba-cvs mailing list