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 "librpc/gen_ndr/ndr_oxidresolver.h"
24 #include "librpc/gen_ndr/ndr_remact.h"
25 #include "librpc/gen_ndr/ndr_epmapper.h"
27 #define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
29 static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t *oxid, struct GUID *oid)
31 struct RemoteActivation r;
34 uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
37 r.in.this.version.MajorVersion = 5;
38 r.in.this.version.MinorVersion = 1;
39 r.in.this.cid = GUID_random();
40 GUID_from_string(CLSID_IMAGEDOC, &r.in.Clsid);
41 r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
42 r.in.num_protseqs = 3;
43 r.in.protseq = protseq;
45 iids[0] = dcerpc_table_IUnknown.uuid;
48 status = dcerpc_RemoteActivation(p, mem_ctx, &r);
49 if(NT_STATUS_IS_ERR(status)) {
50 fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status));
54 if(!W_ERROR_IS_OK(r.out.result)) {
55 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.result));
59 if(!W_ERROR_IS_OK(r.out.hr)) {
60 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.hr));
64 if(!W_ERROR_IS_OK(r.out.results[0])) {
65 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.results[0]));
69 *oid = r.out.ipidRemUnknown;
75 static int test_SimplePing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t setid)
82 status = dcerpc_SimplePing(p, mem_ctx, &r);
83 if(NT_STATUS_IS_ERR(status)) {
84 fprintf(stderr, "SimplePing: %s\n", nt_errstr(status));
88 if(!W_ERROR_IS_OK(r.out.result)) {
89 fprintf(stderr, "SimplePing: %s\n", win_errstr(r.out.result));
96 static int test_ComplexPing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t *setid, struct GUID oid)
104 r.in.SequenceNum = 0;
107 r.in.AddToSet = &oid;
109 status = dcerpc_ComplexPing(p, mem_ctx, &r);
110 if(NT_STATUS_IS_ERR(status)) {
111 fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status));
115 if(!W_ERROR_IS_OK(r.out.result)) {
116 fprintf(stderr, "ComplexPing: %s\n", win_errstr(r.out.result));
125 static int test_ServerAlive(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
127 struct ServerAlive r;
130 status = dcerpc_ServerAlive(p, mem_ctx, &r);
131 if(NT_STATUS_IS_ERR(status)) {
132 fprintf(stderr, "ServerAlive: %s\n", nt_errstr(status));
136 if(!W_ERROR_IS_OK(r.out.result)) {
137 fprintf(stderr, "ServerAlive: %s\n", win_errstr(r.out.result));
144 static int test_ResolveOxid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t oxid)
146 struct ResolveOxid r;
148 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
151 r.in.cRequestedProtseqs = 2;
152 r.in.arRequestedProtseqs = protseq;
154 status = dcerpc_ResolveOxid(p, mem_ctx, &r);
155 if(NT_STATUS_IS_ERR(status)) {
156 fprintf(stderr, "ResolveOxid: %s\n", nt_errstr(status));
160 if(!W_ERROR_IS_OK(r.out.result)) {
161 fprintf(stderr, "ResolveOxid: %s\n", win_errstr(r.out.result));
168 static int test_ResolveOxid2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t oxid)
170 struct ResolveOxid2 r;
172 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
175 r.in.cRequestedProtseqs = 2;
176 r.in.arRequestedProtseqs = protseq;
178 status = dcerpc_ResolveOxid2(p, mem_ctx, &r);
179 if(NT_STATUS_IS_ERR(status)) {
180 fprintf(stderr, "ResolveOxid2: %s\n", nt_errstr(status));
184 if(!W_ERROR_IS_OK(r.out.result)) {
185 fprintf(stderr, "ResolveOxid2: %s\n", win_errstr(r.out.result));
189 printf("Remote server versions: %d, %d\n", r.out.ComVersion.MajorVersion, r.out.ComVersion.MinorVersion);
196 static int test_ServerAlive2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
198 struct ServerAlive2 r;
201 status = dcerpc_ServerAlive2(p, mem_ctx, &r);
202 if(NT_STATUS_IS_ERR(status)) {
203 fprintf(stderr, "ServerAlive2: %s\n", nt_errstr(status));
207 if(!W_ERROR_IS_OK(r.out.result)) {
208 fprintf(stderr, "ServerAlive2: %s\n", win_errstr(r.out.result));
215 BOOL torture_rpc_oxidresolve(void)
218 struct dcerpc_pipe *p, *premact;
225 mem_ctx = talloc_init("torture_rpc_oxidresolve");
227 status = torture_rpc_connection(mem_ctx,
229 &dcerpc_table_IRemoteActivation);
231 if (!NT_STATUS_IS_OK(status)) {
232 talloc_free(mem_ctx);
236 status = torture_rpc_connection(mem_ctx,
238 &dcerpc_table_IOXIDResolver);
240 if (!NT_STATUS_IS_OK(status)) {
241 talloc_free(mem_ctx);
245 if(!test_ServerAlive(p, mem_ctx))
248 if(!test_ServerAlive2(p, mem_ctx))
251 if(!test_RemoteActivation(premact, mem_ctx, &oxid, &oid))
254 if(!test_ComplexPing(p, mem_ctx, &setid, oid))
257 if(!test_SimplePing(p, mem_ctx, setid))
260 if(!test_ResolveOxid(p, mem_ctx, oxid))
263 if(!test_ResolveOxid2(p, mem_ctx, oxid))
266 talloc_free(mem_ctx);