r5775: Remove some unused functions (unions are no longer as special as they used...
[samba.git] / source4 / torture / rpc / remact.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for remoteactivation operations
4
5    Copyright (C) Jelmer Vernooij 2004
6    
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.
11    
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.
16    
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.
20 */
21
22 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_remact.h"
24 #include "librpc/gen_ndr/ndr_epmapper.h"
25 #include "librpc/gen_ndr/com_dcom.h"
26
27 static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
28 {
29         struct RemoteActivation r;
30         NTSTATUS status;
31         struct GUID iids[2];
32         uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
33
34         ZERO_STRUCT(r.in);
35         r.in.this.version.MajorVersion = 5;
36         r.in.this.version.MinorVersion = 1;
37         r.in.this.cid = GUID_random();
38         GUID_from_string(CLSID_SIMPLE, &r.in.Clsid);
39         r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
40         r.in.num_protseqs = 3;
41         r.in.protseq = protseq;
42         r.in.Interfaces = 2;
43         GUID_from_string(DCERPC_IUNKNOWN_UUID, &iids[0]);
44         GUID_from_string(DCERPC_ISTREAM_UUID, &iids[1]);
45         r.in.pIIDs = iids;
46
47         status = dcerpc_RemoteActivation(p, mem_ctx, &r);
48         if(NT_STATUS_IS_ERR(status)) {
49                 printf("RemoteActivation: %s\n", nt_errstr(status));
50                 return 0;
51         }
52
53         if(!W_ERROR_IS_OK(r.out.result)) {
54                 printf("RemoteActivation: %s\n", win_errstr(r.out.result));
55                 return 0;
56         }
57
58         if(!W_ERROR_IS_OK(r.out.hr)) {
59                 printf("RemoteActivation: %s\n", win_errstr(r.out.hr));
60                 return 0;
61         }
62
63         if(!W_ERROR_IS_OK(r.out.results[0])) {
64                 printf("RemoteActivation: %s\n", win_errstr(r.out.results[0]));
65                 return 0;
66         }
67
68         GUID_from_string(DCERPC_ICLASSFACTORY_UUID, &iids[0]);
69         r.in.Interfaces = 1;
70         r.in.Mode = MODE_GET_CLASS_OBJECT;
71
72         status = dcerpc_RemoteActivation(p, mem_ctx, &r);
73         if(NT_STATUS_IS_ERR(status)) {
74                 printf("RemoteActivation(GetClassObject): %s\n", nt_errstr(status));
75                 return 0;
76         }
77
78         if(!W_ERROR_IS_OK(r.out.result)) {
79                 printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.result));
80                 return 0;
81         }
82
83         if(!W_ERROR_IS_OK(r.out.hr)) {
84                 printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.hr));
85                 return 0;
86         }
87
88         if(!W_ERROR_IS_OK(r.out.results[0])) {
89                 printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.results[0]));
90                 return 0;
91         }
92
93         return 1;
94 }
95
96 BOOL torture_rpc_remact(void)
97 {
98      NTSTATUS status;
99      struct dcerpc_pipe *p;
100         TALLOC_CTX *mem_ctx;
101         BOOL ret = True;
102
103         mem_ctx = talloc_init("torture_rpc_remact");
104
105         status = torture_rpc_connection(&p, 
106                                         DCERPC_IREMOTEACTIVATION_NAME,
107                                         DCERPC_IREMOTEACTIVATION_UUID, 
108                                         DCERPC_IREMOTEACTIVATION_VERSION);
109
110         if (!NT_STATUS_IS_OK(status)) {
111                 return False;
112         }
113
114         if(!test_RemoteActivation(p, mem_ctx))
115                 ret = False;
116
117         talloc_free(mem_ctx);
118
119     torture_rpc_close(p);
120
121         return ret;
122 }