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.h"
25 #include "librpc/gen_ndr/ndr_oxidresolver_c.h"
26 #include "librpc/gen_ndr/ndr_remact.h"
27 #include "librpc/gen_ndr/ndr_remact_c.h"
28 #include "librpc/gen_ndr/epmapper.h"
29 #include "torture/rpc/rpc.h"
30 #include "librpc/gen_ndr/ndr_dcom.h"
32 #define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
34 static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t *oxid, struct GUID *oid)
36 struct RemoteActivation r;
39 uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
42 r.in.this.version.MajorVersion = 5;
43 r.in.this.version.MinorVersion = 1;
44 r.in.this.cid = GUID_random();
45 GUID_from_string(CLSID_IMAGEDOC, &r.in.Clsid);
46 r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
47 r.in.num_protseqs = 3;
48 r.in.protseq = protseq;
50 iids[0] = dcerpc_table_IUnknown.uuid;
53 status = dcerpc_RemoteActivation(p, mem_ctx, &r);
54 if(NT_STATUS_IS_ERR(status)) {
55 fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status));
59 if(!W_ERROR_IS_OK(r.out.result)) {
60 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.result));
64 if(!W_ERROR_IS_OK(r.out.hr)) {
65 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.hr));
69 if(!W_ERROR_IS_OK(r.out.results[0])) {
70 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.results[0]));
74 *oid = r.out.ipidRemUnknown;
80 static int test_SimplePing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t setid)
87 status = dcerpc_SimplePing(p, mem_ctx, &r);
88 if(NT_STATUS_IS_ERR(status)) {
89 fprintf(stderr, "SimplePing: %s\n", nt_errstr(status));
93 if(!W_ERROR_IS_OK(r.out.result)) {
94 fprintf(stderr, "SimplePing: %s\n", win_errstr(r.out.result));
101 static int test_ComplexPing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t *setid, struct GUID oid)
103 struct ComplexPing r;
109 r.in.SequenceNum = 0;
112 r.in.AddToSet = &oid;
114 status = dcerpc_ComplexPing(p, mem_ctx, &r);
115 if(NT_STATUS_IS_ERR(status)) {
116 fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status));
120 if(!W_ERROR_IS_OK(r.out.result)) {
121 fprintf(stderr, "ComplexPing: %s\n", win_errstr(r.out.result));
130 static int test_ServerAlive(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
132 struct ServerAlive r;
135 status = dcerpc_ServerAlive(p, mem_ctx, &r);
136 if(NT_STATUS_IS_ERR(status)) {
137 fprintf(stderr, "ServerAlive: %s\n", nt_errstr(status));
141 if(!W_ERROR_IS_OK(r.out.result)) {
142 fprintf(stderr, "ServerAlive: %s\n", win_errstr(r.out.result));
149 static int test_ResolveOxid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t oxid)
151 struct ResolveOxid r;
153 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
156 r.in.cRequestedProtseqs = 2;
157 r.in.arRequestedProtseqs = protseq;
159 status = dcerpc_ResolveOxid(p, mem_ctx, &r);
160 if(NT_STATUS_IS_ERR(status)) {
161 fprintf(stderr, "ResolveOxid: %s\n", nt_errstr(status));
165 if(!W_ERROR_IS_OK(r.out.result)) {
166 fprintf(stderr, "ResolveOxid: %s\n", win_errstr(r.out.result));
173 static int test_ResolveOxid2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t oxid)
175 struct ResolveOxid2 r;
177 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
180 r.in.cRequestedProtseqs = 2;
181 r.in.arRequestedProtseqs = protseq;
183 status = dcerpc_ResolveOxid2(p, mem_ctx, &r);
184 if(NT_STATUS_IS_ERR(status)) {
185 fprintf(stderr, "ResolveOxid2: %s\n", nt_errstr(status));
189 if(!W_ERROR_IS_OK(r.out.result)) {
190 fprintf(stderr, "ResolveOxid2: %s\n", win_errstr(r.out.result));
194 printf("Remote server versions: %d, %d\n", r.out.ComVersion.MajorVersion, r.out.ComVersion.MinorVersion);
201 static int test_ServerAlive2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
203 struct ServerAlive2 r;
206 status = dcerpc_ServerAlive2(p, mem_ctx, &r);
207 if(NT_STATUS_IS_ERR(status)) {
208 fprintf(stderr, "ServerAlive2: %s\n", nt_errstr(status));
212 if(!W_ERROR_IS_OK(r.out.result)) {
213 fprintf(stderr, "ServerAlive2: %s\n", win_errstr(r.out.result));
220 BOOL torture_rpc_oxidresolve(void)
223 struct dcerpc_pipe *p, *premact;
230 mem_ctx = talloc_init("torture_rpc_oxidresolve");
232 status = torture_rpc_connection(mem_ctx,
234 &dcerpc_table_IRemoteActivation);
236 if (!NT_STATUS_IS_OK(status)) {
237 talloc_free(mem_ctx);
241 status = torture_rpc_connection(mem_ctx,
243 &dcerpc_table_IOXIDResolver);
245 if (!NT_STATUS_IS_OK(status)) {
246 talloc_free(mem_ctx);
250 if(!test_ServerAlive(p, mem_ctx))
253 if(!test_ServerAlive2(p, mem_ctx))
256 if(!test_RemoteActivation(premact, mem_ctx, &oxid, &oid))
259 if(!test_ComplexPing(p, mem_ctx, &setid, oid))
262 if(!test_SimplePing(p, mem_ctx, setid))
265 if(!test_ResolveOxid(p, mem_ctx, oxid))
268 if(!test_ResolveOxid2(p, mem_ctx, oxid))
271 talloc_free(mem_ctx);