From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/rpc_client/ndr.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 source3/rpc_client/ndr.c (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c new file mode 100644 index 0000000000..985490f71c --- /dev/null +++ b/source3/rpc_client/ndr.c @@ -0,0 +1,90 @@ +/* + Unix SMB/CIFS implementation. + + libndr interface + + Copyright (C) Jelmer Vernooij 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" + + +NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + int p_idx, int opnum, void *data, + ndr_pull_flags_fn_t pull_fn, ndr_push_flags_fn_t push_fn) +{ + prs_struct q_ps, r_ps; + struct ndr_pull *pull; + DATA_BLOB blob; + struct ndr_push *push; + NTSTATUS status; + + SMB_ASSERT(cli->pipe_idx == p_idx); + + push = ndr_push_init_ctx(mem_ctx); + if (!push) { + return NT_STATUS_NO_MEMORY; + } + + status = push_fn(push, NDR_IN, data); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + blob = ndr_push_blob(push); + + if (!prs_init_data_blob(&q_ps, &blob, mem_ctx)) { + return NT_STATUS_NO_MEMORY; + } + + talloc_free(push); + + if (!prs_init( &r_ps, 0, mem_ctx, UNMARSHALL )) { + prs_mem_free( &q_ps ); + return NT_STATUS_NO_MEMORY; + } + + status = rpc_api_pipe_req(cli, opnum, &q_ps, &r_ps); + + prs_mem_free( &q_ps ); + + if (!NT_STATUS_IS_OK(status)) { + prs_mem_free( &r_ps ); + return status; + } + + if (!prs_data_blob(&r_ps, &blob, mem_ctx)) { + prs_mem_free( &r_ps ); + return NT_STATUS_NO_MEMORY; + } + + prs_mem_free( &r_ps ); + + pull = ndr_pull_init_blob(&blob, mem_ctx); + if (pull == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = pull_fn(pull, NDR_OUT, data); + talloc_free(pull); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + return NT_STATUS_OK; +} -- cgit From 4f024ad3d1fa697bac3db05c27f355dff0941636 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 11 Sep 2006 20:00:00 +0000 Subject: r18395: have the ndr layer alloc outgoing structure members for us (This used to be commit 4fb35eeb44d434b04282c41e98c4a5767e1a8647) --- source3/rpc_client/ndr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index 985490f71c..82b9079a28 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -79,6 +79,8 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } + /* have the ndr parser alloc memory for us */ + pull->flags |= LIBNDR_FLAG_REF_ALLOC; status = pull_fn(pull, NDR_OUT, data); talloc_free(pull); -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/rpc_client/ndr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index 82b9079a28..616c621baf 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/rpc_client/ndr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index 616c621baf..86d75ab024 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -16,8 +16,7 @@ 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. + along with this program. If not, see . */ #include "includes.h" -- cgit From 18a48df488f5fcf9b55abf61b09778bdc15373d7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Aug 2007 12:20:33 +0000 Subject: r24594: pass down the ndr_interface_table in the samba3 client bindings instead of the pull and push functions metze (This used to be commit 5e3d4df9bca069708d72f548dc5ddfc7708ac122) --- source3/rpc_client/ndr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index 86d75ab024..c7044aa7d9 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -22,24 +22,29 @@ #include "includes.h" -NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - int p_idx, int opnum, void *data, - ndr_pull_flags_fn_t pull_fn, ndr_push_flags_fn_t push_fn) +NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int p_idx, + const struct ndr_interface_table *table, + uint32 opnum, void *r) { prs_struct q_ps, r_ps; + const struct ndr_interface_call *call; struct ndr_pull *pull; DATA_BLOB blob; struct ndr_push *push; NTSTATUS status; SMB_ASSERT(cli->pipe_idx == p_idx); + SMB_ASSERT(table->num_calls > opnum); + + call = &table->calls[opnum]; push = ndr_push_init_ctx(mem_ctx); if (!push) { return NT_STATUS_NO_MEMORY; } - status = push_fn(push, NDR_IN, data); + status = call->ndr_push(push, NDR_IN, r); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -80,7 +85,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, /* have the ndr parser alloc memory for us */ pull->flags |= LIBNDR_FLAG_REF_ALLOC; - status = pull_fn(pull, NDR_OUT, data); + status = call->ndr_pull(pull, NDR_OUT, r); talloc_free(pull); if (!NT_STATUS_IS_OK(status)) { -- cgit From f9578af966c1c1b5b5df4acac9977472d2896bea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 14:39:45 +0100 Subject: ndr: change NTSTAUS into enum ndr_err_code (samba3 callers) lib/messages_local.c rpc_client/ndr.c smbd/notify_internal.c utils/net_rpc_registry.c metze (This used to be commit c2645d2164c05976a98bafed980b6029baf89977) --- source3/rpc_client/ndr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index c7044aa7d9..a64ead809a 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -33,6 +33,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, DATA_BLOB blob; struct ndr_push *push; NTSTATUS status; + enum ndr_err_code ndr_err; SMB_ASSERT(cli->pipe_idx == p_idx); SMB_ASSERT(table->num_calls > opnum); @@ -44,9 +45,9 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, return NT_STATUS_NO_MEMORY; } - status = call->ndr_push(push, NDR_IN, r); - if (!NT_STATUS_IS_OK(status)) { - return status; + ndr_err = call->ndr_push(push, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); } blob = ndr_push_blob(push); @@ -85,11 +86,11 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, /* have the ndr parser alloc memory for us */ pull->flags |= LIBNDR_FLAG_REF_ALLOC; - status = call->ndr_pull(pull, NDR_OUT, r); + ndr_err = call->ndr_pull(pull, NDR_OUT, r); talloc_free(pull); - if (!NT_STATUS_IS_OK(status)) { - return status; + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); } return NT_STATUS_OK; -- cgit From e06aa46b9fab1e107fea8f6453fb13deffa91e96 Mon Sep 17 00:00:00 2001 From: Marc VanHeyningen Date: Fri, 14 Mar 2008 14:26:28 -0800 Subject: Coverity fixes (This used to be commit 3fc85d22590550f0539215d020e4411bf5b14363) --- source3/rpc_client/ndr.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index a64ead809a..ae705b313b 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -58,10 +58,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, talloc_free(push); - if (!prs_init( &r_ps, 0, mem_ctx, UNMARSHALL )) { - prs_mem_free( &q_ps ); - return NT_STATUS_NO_MEMORY; - } + prs_init_empty( &r_ps, mem_ctx, UNMARSHALL ); status = rpc_api_pipe_req(cli, opnum, &q_ps, &r_ps); -- cgit From f56eedb95c64593ceff0ef91b99729c5071aa7ac Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Apr 2008 11:45:41 +0200 Subject: Remove the pipe_idx variable from rpc_pipe_client (This used to be commit 4840febcd481563c3d9b2fabc1fe1b2ae5a76cf6) --- source3/rpc_client/ndr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index ae705b313b..91751a2d71 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -35,7 +35,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, NTSTATUS status; enum ndr_err_code ndr_err; - SMB_ASSERT(cli->pipe_idx == p_idx); + SMB_ASSERT(rpccli_is_pipe_idx(cli, p_idx)); SMB_ASSERT(table->num_calls > opnum); call = &table->calls[opnum]; -- cgit From bd479ced46af51d7661b5015821f5237779c4366 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jul 2008 12:49:50 +0200 Subject: Remove a reference to pipe_idx (This used to be commit e949b9d11f439c32c85a3cd9ae4c1a859a4c284a) --- source3/rpc_client/ndr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index 91751a2d71..4f1ef029c8 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -35,7 +35,8 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, NTSTATUS status; enum ndr_err_code ndr_err; - SMB_ASSERT(rpccli_is_pipe_idx(cli, p_idx)); + SMB_ASSERT(ndr_syntax_id_equal(&table->syntax_id, + &cli->abstract_syntax)); SMB_ASSERT(table->num_calls > opnum); call = &table->calls[opnum]; -- cgit From da6e4248eedfcf420797f42f589fff4875161303 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jul 2008 13:04:41 +0200 Subject: Make idl: cli_do_rpc_ndr does not use pipe_idx anymore (This used to be commit ffd2ff5325ef24f08dcb63e4561f5f62bffef6d3) --- source3/rpc_client/ndr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index 4f1ef029c8..c494cce848 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -23,7 +23,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int p_idx, + TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32 opnum, void *r) { -- cgit From 767130ebec474f16e951d1c450cca27e434e9b47 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 1 Sep 2008 21:28:57 +0200 Subject: Fix some nonempty blank lines (This used to be commit 9336cd1c5e5b5d113cd4912d4479dfe609fe261e) --- source3/rpc_client/ndr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_client/ndr.c') diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index c494cce848..72a33137a6 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -60,7 +60,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, talloc_free(push); prs_init_empty( &r_ps, mem_ctx, UNMARSHALL ); - + status = rpc_api_pipe_req(cli, opnum, &q_ps, &r_ps); prs_mem_free( &q_ps ); -- cgit