mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
converted the rpcecho pipe to use IDL
(This used to be commit 1b7a7bc464
)
This commit is contained in:
parent
b7a6971ce1
commit
adf6142953
@ -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;
|
||||
|
@ -102,6 +102,20 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n)
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
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
|
||||
*/
|
||||
@ -179,6 +193,15 @@ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32 n)
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
@ -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));
|
||||
NDR_CHECK(ndr_push_uint32(ndr, *r->in.v));
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
push a addone
|
||||
*/
|
||||
NTSTATUS ndr_push_rpcecho_addone(struct ndr_push *ndr,
|
||||
struct rpcecho_addone *r)
|
||||
NTSTATUS ndr_pull_echo_AddOne(struct ndr_pull *ndr, struct echo_AddOne *r)
|
||||
{
|
||||
NDR_CHECK(ndr_push_uint32(ndr, r->in.data));
|
||||
NDR_CHECK(ndr_pull_uint32(ndr, r->out.v));
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
parse a echodata
|
||||
*/
|
||||
NTSTATUS ndr_pull_rpcecho_echodata(struct ndr_pull *ndr,
|
||||
struct rpcecho_echodata *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 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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
/* SourceData interface */
|
||||
struct rpcecho_sourcedata {
|
||||
struct {
|
||||
int len;
|
||||
} in;
|
||||
struct {
|
||||
int len;
|
||||
char *data;
|
||||
} out;
|
||||
|
||||
};
|
||||
|
||||
/* define the command codes */
|
||||
enum {
|
||||
RPCECHO_CALL_ADDONE=0,
|
||||
RPCECHO_CALL_ECHODATA,
|
||||
RPCECHO_CALL_SINKDATA,
|
||||
RPCECHO_CALL_SOURCEDATA
|
||||
struct echo_SourceData {
|
||||
struct {
|
||||
uint32 len;
|
||||
} in;
|
||||
|
||||
struct {
|
||||
uint8 *data;
|
||||
} out;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#define DCERPC_ECHO_ADDONE 0
|
||||
#define DCERPC_ECHO_ECHODATA 1
|
||||
#define DCERPC_ECHO_SINKDATA 2
|
||||
#define DCERPC_ECHO_SOURCEDATA 3
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -33,13 +33,16 @@ static BOOL test_addone(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
|
||||
printf("\nTesting AddOne\n");
|
||||
|
||||
for (i=0;i<10;i++) {
|
||||
int n;
|
||||
status = dcerpc_rpcecho_addone(p, i, &n);
|
||||
uint32 n = i;
|
||||
struct echo_AddOne r;
|
||||
r.in.v = &n;
|
||||
r.out.v = &n;
|
||||
status = dcerpc_echo_AddOne(p, mem_ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
printf("AddOne(%d) failed - %s\n", i, nt_errstr(status));
|
||||
return False;
|
||||
}
|
||||
printf("%d + 1 = %d\n", i, n);
|
||||
printf("%d + 1 = %u\n", i, n);
|
||||
}
|
||||
|
||||
return True;
|
||||
@ -54,28 +57,28 @@ static BOOL test_echodata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
|
||||
NTSTATUS status;
|
||||
char *data_in, *data_out;
|
||||
int len = 1 + (random() % 5000);
|
||||
int len_out;
|
||||
struct echo_EchoData r;
|
||||
|
||||
printf("\nTesting EchoData\n");
|
||||
|
||||
data_in = talloc(mem_ctx, len);
|
||||
data_out = talloc(mem_ctx, len);
|
||||
for (i=0;i<len;i++) {
|
||||
data_in[i] = i+1;
|
||||
data_in[i] = i;
|
||||
}
|
||||
|
||||
r.in.len = len;
|
||||
r.in.data = data_in;
|
||||
r.out.data = data_out;
|
||||
|
||||
status = dcerpc_rpcecho_echodata(p, mem_ctx,
|
||||
len,
|
||||
data_in,
|
||||
&len_out,
|
||||
&data_out);
|
||||
status = dcerpc_echo_EchoData(p, mem_ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
printf("EchoData(%d) failed - %s\n", len, nt_errstr(status));
|
||||
return False;
|
||||
}
|
||||
printf("EchoData(%d) returned %d bytes\n", len, len_out);
|
||||
|
||||
if (memcmp(data_in, data_out, len) != 0) {
|
||||
printf("Bad data returned!\n");
|
||||
printf("Bad data returned for len %d!\n", len);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -91,26 +94,27 @@ static BOOL test_sourcedata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
int i;
|
||||
NTSTATUS status;
|
||||
char *data_out;
|
||||
int len = 200000 + (random() % 5000);
|
||||
int len_out;
|
||||
char *data_out;
|
||||
struct echo_SourceData r;
|
||||
|
||||
printf("\nTesting SourceData\n");
|
||||
|
||||
status = dcerpc_rpcecho_sourcedata(p, mem_ctx,
|
||||
len,
|
||||
&len_out,
|
||||
&data_out);
|
||||
data_out = talloc(mem_ctx, len);
|
||||
|
||||
r.in.len = len;
|
||||
r.out.data = data_out;
|
||||
|
||||
status = dcerpc_echo_SourceData(p, mem_ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
printf("SourceData(%d) failed - %s\n", len, nt_errstr(status));
|
||||
return False;
|
||||
}
|
||||
printf("SourceData(%d) returned %d bytes\n", len, len_out);
|
||||
|
||||
for (i=0;i<len;i++) {
|
||||
unsigned char *v = (unsigned char *)data_out;
|
||||
if (v[i] != (i & 0xFF)) {
|
||||
printf("bad data 0x%x at %d\n", data_out[i], i);
|
||||
printf("bad data 0x%x at %d\n", (unsigned char)data_out[i], i);
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -127,6 +131,7 @@ static BOOL test_sinkdata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
|
||||
NTSTATUS status;
|
||||
char *data_in;
|
||||
int len = 200000 + (random() % 5000);
|
||||
struct echo_SinkData r;
|
||||
|
||||
printf("\nTesting SinkData\n");
|
||||
|
||||
@ -135,9 +140,10 @@ static BOOL test_sinkdata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
|
||||
data_in[i] = i+1;
|
||||
}
|
||||
|
||||
status = dcerpc_rpcecho_sinkdata(p, mem_ctx,
|
||||
len,
|
||||
data_in);
|
||||
r.in.len = len;
|
||||
r.in.data = data_in;
|
||||
|
||||
status = dcerpc_echo_SinkData(p, mem_ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
printf("SinkData(%d) failed - %s\n", len, nt_errstr(status));
|
||||
return False;
|
||||
|
Loading…
Reference in New Issue
Block a user