diff options
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/ndr/ndr.c | 7 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 23 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_echo.c | 115 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_echo.h | 81 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_lsa.c | 12 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_lsa.h | 5 | ||||
-rw-r--r-- | source4/librpc/rpc/rpc_echo.c | 129 |
7 files changed, 130 insertions, 242 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 2413e7322d..2ab78d3d09 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -215,15 +215,14 @@ done: /* pull a generic array */ -NTSTATUS ndr_pull_array(struct ndr_pull *ndr, int ndr_flags, void **base, +NTSTATUS ndr_pull_array(struct ndr_pull *ndr, int ndr_flags, void *base, size_t elsize, uint32 count, NTSTATUS (*pull_fn)(struct ndr_pull *, int, void *)) { int i; uint32 max_count; char *p; - NDR_ALLOC_N_SIZE(ndr, *base, count, elsize); - p = *base; + p = base; NDR_CHECK(ndr_pull_uint32(ndr, &max_count)); if (max_count != count) { /* maybe we can cope with this? */ @@ -236,7 +235,7 @@ NTSTATUS ndr_pull_array(struct ndr_pull *ndr, int ndr_flags, void **base, } if (!(ndr_flags & NDR_BUFFERS)) goto done; buffers: - p = *base; + p = base; for (i=0;i<count;i++) { NDR_CHECK(pull_fn(ndr, NDR_BUFFERS, p)); p += elsize; diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 6ada49997f..b8c0cffd6d 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -103,6 +103,20 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n) } /* + pull an array of uint8 +*/ +NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, char *data, uint32 n) +{ + uint32 len; + NDR_CHECK(ndr_pull_uint32(ndr, &len)); + if (len != n) { + return NT_STATUS_INVALID_PARAMETER; + } + return ndr_pull_bytes(ndr, data, len); +} + + +/* parse a GUID */ NTSTATUS ndr_pull_guid(struct ndr_pull *ndr, GUID *guid) @@ -180,6 +194,15 @@ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32 n) } /* + push an array of uint8 +*/ +NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, const char *data, uint32 n) +{ + NDR_CHECK(ndr_push_uint32(ndr, n)); + return ndr_push_bytes(ndr, data, n); +} + +/* save the current position */ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save) diff --git a/source4/librpc/ndr/ndr_echo.c b/source4/librpc/ndr/ndr_echo.c index e2bb062d2e..afe7f0c873 100644 --- a/source4/librpc/ndr/ndr_echo.c +++ b/source4/librpc/ndr/ndr_echo.c @@ -1,114 +1,69 @@ -/* - Unix SMB/CIFS implementation. - - routines for marshalling/unmarshalling rpcecho pipe - - Copyright (C) Andrew Tridgell 2003 - - 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. -*/ - +/* parser auto-generated by pidl */ #include "includes.h" - -/* - parse a addone -*/ -NTSTATUS ndr_pull_rpcecho_addone(struct ndr_pull *ndr, - struct rpcecho_addone *r) +NTSTATUS ndr_push_echo_AddOne(struct ndr_push *ndr, struct echo_AddOne *r) { - NDR_CHECK(ndr_pull_uint32(ndr, &r->out.data)); - return NT_STATUS_OK; -} - + NDR_CHECK(ndr_push_uint32(ndr, *r->in.v)); -/* - push a addone -*/ -NTSTATUS ndr_push_rpcecho_addone(struct ndr_push *ndr, - struct rpcecho_addone *r) -{ - NDR_CHECK(ndr_push_uint32(ndr, r->in.data)); return NT_STATUS_OK; } - -/* - parse a echodata -*/ -NTSTATUS ndr_pull_rpcecho_echodata(struct ndr_pull *ndr, - struct rpcecho_echodata *r) +NTSTATUS ndr_pull_echo_AddOne(struct ndr_pull *ndr, struct echo_AddOne *r) { - NDR_CHECK(ndr_pull_uint32(ndr, &r->out.len)); - NDR_ALLOC_N(ndr, r->out.data, r->out.len); - NDR_CHECK(ndr_pull_bytes(ndr, r->out.data, r->out.len)); + NDR_CHECK(ndr_pull_uint32(ndr, r->out.v)); + return NT_STATUS_OK; } -/* - push a echodata -*/ -NTSTATUS ndr_push_rpcecho_echodata(struct ndr_push *ndr, - struct rpcecho_echodata *r) +NTSTATUS ndr_push_echo_EchoData(struct ndr_push *ndr, struct echo_EchoData *r) { NDR_CHECK(ndr_push_uint32(ndr, r->in.len)); - NDR_CHECK(ndr_push_uint32(ndr, r->in.len)); - NDR_CHECK(ndr_push_bytes(ndr, r->in.data, r->in.len)); + if (r->in.data) { + NDR_CHECK(ndr_push_array_uint8(ndr, r->in.data, r->in.len)); + } + return NT_STATUS_OK; } -/* - parse a sinkdata -*/ -NTSTATUS ndr_pull_rpcecho_sinkdata(struct ndr_pull *ndr, - struct rpcecho_sinkdata *r) +NTSTATUS ndr_pull_echo_EchoData(struct ndr_pull *ndr, struct echo_EchoData *r) { + if (r->out.data) { + NDR_CHECK(ndr_pull_array_uint8(ndr, r->out.data, r->in.len)); + } + return NT_STATUS_OK; } -/* - push a sinkdata -*/ -NTSTATUS ndr_push_rpcecho_sinkdata(struct ndr_push *ndr, - struct rpcecho_sinkdata *r) +NTSTATUS ndr_push_echo_SinkData(struct ndr_push *ndr, struct echo_SinkData *r) { NDR_CHECK(ndr_push_uint32(ndr, r->in.len)); - NDR_CHECK(ndr_push_uint32(ndr, r->in.len)); - NDR_CHECK(ndr_push_bytes(ndr, r->in.data, r->in.len)); + if (r->in.data) { + NDR_CHECK(ndr_push_array_uint8(ndr, r->in.data, r->in.len)); + } + return NT_STATUS_OK; } -/* - parse a sourcedata -*/ -NTSTATUS ndr_pull_rpcecho_sourcedata(struct ndr_pull *ndr, - struct rpcecho_sourcedata *r) +NTSTATUS ndr_pull_echo_SinkData(struct ndr_pull *ndr, struct echo_SinkData *r) { - NDR_CHECK(ndr_pull_uint32(ndr, &r->out.len)); - NDR_ALLOC_N(ndr, r->out.data, r->out.len); - NDR_CHECK(ndr_pull_bytes(ndr, r->out.data, r->out.len)); + return NT_STATUS_OK; } -/* - push a sourcedata -*/ -NTSTATUS ndr_push_rpcecho_sourcedata(struct ndr_push *ndr, - struct rpcecho_sourcedata *r) +NTSTATUS ndr_push_echo_SourceData(struct ndr_push *ndr, struct echo_SourceData *r) { NDR_CHECK(ndr_push_uint32(ndr, r->in.len)); + + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_echo_SourceData(struct ndr_pull *ndr, struct echo_SourceData *r) +{ + if (r->out.data) { + NDR_CHECK(ndr_pull_array_uint8(ndr, r->out.data, r->in.len)); + } + return NT_STATUS_OK; } + diff --git a/source4/librpc/ndr/ndr_echo.h b/source4/librpc/ndr/ndr_echo.h index aecf68c4c0..ed187fd4d6 100644 --- a/source4/librpc/ndr/ndr_echo.h +++ b/source4/librpc/ndr/ndr_echo.h @@ -1,76 +1,51 @@ -/* - Unix SMB/CIFS implementation. +/* header auto-generated by pidl */ - definitions for marshalling/unmarshalling the rpcecho pipe - - Copyright (C) Andrew Tridgell 2003 - - 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. -*/ - -/* - see http://samba.org/ftp/unpacked/junkcode/rpcecho-win32/ for the - definition of this pipe -*/ - -/* AddOne interface */ -struct rpcecho_addone { +struct echo_AddOne { struct { - int data; + uint32 *v; } in; + struct { - int data; + uint32 *v; } out; + }; -/* EchoData interface */ -struct rpcecho_echodata { +struct echo_EchoData { struct { - int len; - const char *data; + uint32 len; + uint8 *data; } in; + struct { - int len; - char *data; + uint8 *data; } out; + }; -/* SinkData interface */ -struct rpcecho_sinkdata { +struct echo_SinkData { struct { - int len; - char *data; + uint32 len; + uint8 *data; } in; + + struct { + } out; + }; -/* SourceData interface */ -struct rpcecho_sourcedata { +struct echo_SourceData { struct { - int len; + uint32 len; } in; + struct { - int len; - char *data; + uint8 *data; } out; -}; -/* define the command codes */ -enum { - RPCECHO_CALL_ADDONE=0, - RPCECHO_CALL_ECHODATA, - RPCECHO_CALL_SINKDATA, - RPCECHO_CALL_SOURCEDATA }; - + +#define DCERPC_ECHO_ADDONE 0 +#define DCERPC_ECHO_ECHODATA 1 +#define DCERPC_ECHO_SINKDATA 2 +#define DCERPC_ECHO_SOURCEDATA 3 diff --git a/source4/librpc/ndr/ndr_lsa.c b/source4/librpc/ndr/ndr_lsa.c index 12b981c1e7..651ba9de08 100644 --- a/source4/librpc/ndr/ndr_lsa.c +++ b/source4/librpc/ndr/ndr_lsa.c @@ -234,7 +234,8 @@ static NTSTATUS ndr_pull_lsa_SidArray(struct ndr_pull *ndr, int ndr_flags, struc buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sids) { - NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)&r->sids, sizeof(r->sids[0]), r->num_sids, (ndr_pull_flags_fn_t)ndr_pull_lsa_SidPtr)); + NDR_ALLOC_N_SIZE(ndr, r->sids, r->num_sids, sizeof(r->sids[0])); + NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)r->sids, sizeof(r->sids[0]), r->num_sids, (ndr_pull_flags_fn_t)ndr_pull_lsa_SidPtr)); } done: return NT_STATUS_OK; @@ -348,7 +349,8 @@ static NTSTATUS ndr_pull_lsa_TransNameArray(struct ndr_pull *ndr, int ndr_flags, buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->names) { - NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)&r->names, sizeof(r->names[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TranslatedName)); + NDR_ALLOC_N_SIZE(ndr, r->names, r->count, sizeof(r->names[0])); + NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)r->names, sizeof(r->names[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TranslatedName)); } done: return NT_STATUS_OK; @@ -420,7 +422,8 @@ static NTSTATUS ndr_pull_lsa_RefDomainList(struct ndr_pull *ndr, int ndr_flags, buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->domains) { - NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)&r->domains, sizeof(r->domains[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TrustInformation)); + NDR_ALLOC_N_SIZE(ndr, r->domains, r->count, sizeof(r->domains[0])); + NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)r->domains, sizeof(r->domains[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TrustInformation)); } done: return NT_STATUS_OK; @@ -509,7 +512,8 @@ static NTSTATUS ndr_pull_lsa_TransSidArray(struct ndr_pull *ndr, int ndr_flags, buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sids) { - NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)&r->sids, sizeof(r->sids[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TranslatedSid)); + NDR_ALLOC_N_SIZE(ndr, r->sids, r->count, sizeof(r->sids[0])); + NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)r->sids, sizeof(r->sids[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TranslatedSid)); } done: return NT_STATUS_OK; diff --git a/source4/librpc/ndr/ndr_lsa.h b/source4/librpc/ndr/ndr_lsa.h index 770138f349..ddb0eed323 100644 --- a/source4/librpc/ndr/ndr_lsa.h +++ b/source4/librpc/ndr/ndr_lsa.h @@ -142,3 +142,8 @@ struct lsa_LookupNames { }; +#define DCERPC_LSA_OPENPOLICY 0 +#define DCERPC_LSA_OPENPOLICY2 1 +#define DCERPC_LSA_ENUMSIDS 2 +#define DCERPC_LSA_LOOKUPSIDS 3 +#define DCERPC_LSA_LOOKUPNAMES 4 diff --git a/source4/librpc/rpc/rpc_echo.c b/source4/librpc/rpc/rpc_echo.c index d73f9bda9c..9cf81a23ac 100644 --- a/source4/librpc/rpc/rpc_echo.c +++ b/source4/librpc/rpc/rpc_echo.c @@ -22,116 +22,43 @@ #include "includes.h" -/* - addone interface -*/ -NTSTATUS dcerpc_rpcecho_addone(struct dcerpc_pipe *p, - int in_data, int *out_data) +NTSTATUS dcerpc_echo_AddOne(struct dcerpc_pipe *p, + TALLOC_CTX *mem_ctx, + struct echo_AddOne *r) { - struct rpcecho_addone r; - NTSTATUS status; - TALLOC_CTX *mem_ctx; - - mem_ctx = talloc_init("dcerpc_rpcecho_addone"); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - /* fill the .in side of the call */ - r.in.data = in_data; - - /* make the call */ - status = dcerpc_ndr_request(p, RPCECHO_CALL_ADDONE, mem_ctx, - (ndr_push_fn_t) ndr_push_rpcecho_addone, - (ndr_pull_fn_t) ndr_pull_rpcecho_addone, - &r); - - /* and extract the .out parameters */ - *out_data = r.out.data; - - talloc_destroy(mem_ctx); - return status; + return dcerpc_ndr_request(p, DCERPC_ECHO_ADDONE, mem_ctx, + (ndr_push_fn_t) ndr_push_echo_AddOne, + (ndr_pull_fn_t) ndr_pull_echo_AddOne, + r); } -/* - echodata interface -*/ -NTSTATUS dcerpc_rpcecho_echodata(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx, - int len, - const char *in_data, - int *out_len, - char **out_data) +NTSTATUS dcerpc_echo_EchoData(struct dcerpc_pipe *p, + TALLOC_CTX *mem_ctx, + struct echo_EchoData *r) { - struct rpcecho_echodata r; - NTSTATUS status; - - /* fill the .in side of the call */ - r.in.len = len; - r.in.data = in_data; - - /* make the call */ - status = dcerpc_ndr_request(p, RPCECHO_CALL_ECHODATA, mem_ctx, - (ndr_push_fn_t) ndr_push_rpcecho_echodata, - (ndr_pull_fn_t) ndr_pull_rpcecho_echodata, - &r); - - /* and extract the .out parameters */ - *out_len = r.out.len; - *out_data = r.out.data; - - return status; + return dcerpc_ndr_request(p, DCERPC_ECHO_ECHODATA, mem_ctx, + (ndr_push_fn_t) ndr_push_echo_EchoData, + (ndr_pull_fn_t) ndr_pull_echo_EchoData, + r); } -/* - sourcedata interface -*/ -NTSTATUS dcerpc_rpcecho_sourcedata(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx, - int len, - int *out_len, - char **out_data) +NTSTATUS dcerpc_echo_SinkData(struct dcerpc_pipe *p, + TALLOC_CTX *mem_ctx, + struct echo_SinkData *r) { - struct rpcecho_sourcedata r; - NTSTATUS status; - - /* fill the .in side of the call */ - r.in.len = len; - - /* make the call */ - status = dcerpc_ndr_request(p, RPCECHO_CALL_SOURCEDATA, mem_ctx, - (ndr_push_fn_t) ndr_push_rpcecho_sourcedata, - (ndr_pull_fn_t) ndr_pull_rpcecho_sourcedata, - &r); - - /* and extract the .out parameters */ - *out_len = r.out.len; - *out_data = r.out.data; - - return status; + return dcerpc_ndr_request(p, DCERPC_ECHO_SINKDATA, mem_ctx, + (ndr_push_fn_t) ndr_push_echo_SinkData, + (ndr_pull_fn_t) ndr_pull_echo_SinkData, + r); } -/* - sinkdata interface -*/ -NTSTATUS dcerpc_rpcecho_sinkdata(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx, - int len, - char *data) +NTSTATUS dcerpc_echo_SourceData(struct dcerpc_pipe *p, + TALLOC_CTX *mem_ctx, + struct echo_SourceData *r) { - struct rpcecho_sinkdata r; - NTSTATUS status; - - /* fill the .in side of the call */ - r.in.len = len; - r.in.data = data; - - /* make the call */ - status = dcerpc_ndr_request(p, RPCECHO_CALL_SINKDATA, mem_ctx, - (ndr_push_fn_t) ndr_push_rpcecho_sinkdata, - (ndr_pull_fn_t) ndr_pull_rpcecho_sinkdata, - &r); - - return status; + return dcerpc_ndr_request(p, DCERPC_ECHO_SOURCEDATA, mem_ctx, + (ndr_push_fn_t) ndr_push_echo_SourceData, + (ndr_pull_fn_t) ndr_pull_echo_SourceData, + r); } |