2 Unix SMB/CIFS implementation.
3 test suite for oxidresolve operations
5 Copyright (C) Jelmer Vernooij 2004
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "torture/torture.h"
24 #include "librpc/gen_ndr/ndr_oxidresolver_c.h"
25 #include "librpc/gen_ndr/ndr_remact_c.h"
26 #include "librpc/gen_ndr/epmapper.h"
27 #include "torture/rpc/rpc.h"
28 #include "librpc/gen_ndr/ndr_dcom.h"
30 #define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
32 static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t *oxid, struct GUID *oid)
34 struct RemoteActivation r;
37 uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
40 r.in.this.version.MajorVersion = 5;
41 r.in.this.version.MinorVersion = 1;
42 r.in.this.cid = GUID_random();
43 GUID_from_string(CLSID_IMAGEDOC, &r.in.Clsid);
44 r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
45 r.in.num_protseqs = 3;
46 r.in.protseq = protseq;
48 iids[0] = dcerpc_table_IUnknown.uuid;
51 status = dcerpc_RemoteActivation(p, mem_ctx, &r);
52 if(NT_STATUS_IS_ERR(status)) {
53 fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status));
57 if(!W_ERROR_IS_OK(r.out.result)) {
58 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.result));
62 if(!W_ERROR_IS_OK(r.out.hr)) {
63 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.hr));
67 if(!W_ERROR_IS_OK(r.out.results[0])) {
68 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.results[0]));
72 *oid = r.out.ipidRemUnknown;
78 static int test_SimplePing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t setid)
85 status = dcerpc_SimplePing(p, mem_ctx, &r);
86 if(NT_STATUS_IS_ERR(status)) {
87 fprintf(stderr, "SimplePing: %s\n", nt_errstr(status));
91 if(!W_ERROR_IS_OK(r.out.result)) {
92 fprintf(stderr, "SimplePing: %s\n", win_errstr(r.out.result));
99 static int test_ComplexPing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t *setid, struct GUID oid)
101 struct ComplexPing r;
107 r.in.SequenceNum = 0;
110 r.in.AddToSet = &oid;
112 status = dcerpc_ComplexPing(p, mem_ctx, &r);
113 if(NT_STATUS_IS_ERR(status)) {
114 fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status));
118 if(!W_ERROR_IS_OK(r.out.result)) {
119 fprintf(stderr, "ComplexPing: %s\n", win_errstr(r.out.result));
128 static int test_ServerAlive(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
130 struct ServerAlive r;
133 status = dcerpc_ServerAlive(p, mem_ctx, &r);
134 if(NT_STATUS_IS_ERR(status)) {
135 fprintf(stderr, "ServerAlive: %s\n", nt_errstr(status));
139 if(!W_ERROR_IS_OK(r.out.result)) {
140 fprintf(stderr, "ServerAlive: %s\n", win_errstr(r.out.result));
147 static int test_ResolveOxid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t oxid)
149 struct ResolveOxid r;
151 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
154 r.in.cRequestedProtseqs = 2;
155 r.in.arRequestedProtseqs = protseq;
157 status = dcerpc_ResolveOxid(p, mem_ctx, &r);
158 if(NT_STATUS_IS_ERR(status)) {
159 fprintf(stderr, "ResolveOxid: %s\n", nt_errstr(status));
163 if(!W_ERROR_IS_OK(r.out.result)) {
164 fprintf(stderr, "ResolveOxid: %s\n", win_errstr(r.out.result));
171 static int test_ResolveOxid2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t oxid)
173 struct ResolveOxid2 r;
175 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
178 r.in.cRequestedProtseqs = 2;
179 r.in.arRequestedProtseqs = protseq;
181 status = dcerpc_ResolveOxid2(p, mem_ctx, &r);
182 if(NT_STATUS_IS_ERR(status)) {
183 fprintf(stderr, "ResolveOxid2: %s\n", nt_errstr(status));
187 if(!W_ERROR_IS_OK(r.out.result)) {
188 fprintf(stderr, "ResolveOxid2: %s\n", win_errstr(r.out.result));
192 printf("Remote server versions: %d, %d\n", r.out.ComVersion.MajorVersion, r.out.ComVersion.MinorVersion);
199 static int test_ServerAlive2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
201 struct ServerAlive2 r;
204 status = dcerpc_ServerAlive2(p, mem_ctx, &r);
205 if(NT_STATUS_IS_ERR(status)) {
206 fprintf(stderr, "ServerAlive2: %s\n", nt_errstr(status));
210 if(!W_ERROR_IS_OK(r.out.result)) {
211 fprintf(stderr, "ServerAlive2: %s\n", win_errstr(r.out.result));
218 BOOL torture_rpc_oxidresolve(struct torture_context *torture)
221 struct dcerpc_pipe *p, *premact;
228 mem_ctx = talloc_init("torture_rpc_oxidresolve");
230 status = torture_rpc_connection(mem_ctx,
232 &dcerpc_table_IRemoteActivation);
234 if (!NT_STATUS_IS_OK(status)) {
235 talloc_free(mem_ctx);
239 status = torture_rpc_connection(mem_ctx,
241 &dcerpc_table_IOXIDResolver);
243 if (!NT_STATUS_IS_OK(status)) {
244 talloc_free(mem_ctx);
248 if(!test_ServerAlive(p, mem_ctx))
251 if(!test_ServerAlive2(p, mem_ctx))
254 if(!test_RemoteActivation(premact, mem_ctx, &oxid, &oid))
257 if(!test_ComplexPing(p, mem_ctx, &setid, oid))
260 if(!test_SimplePing(p, mem_ctx, setid))
263 if(!test_ResolveOxid(p, mem_ctx, oxid))
266 if(!test_ResolveOxid2(p, mem_ctx, oxid))
269 talloc_free(mem_ctx);