r3428: switched to using minimal includes for the auto-generated RPC code.
[samba.git] / source4 / torture / rpc / oxidresolve.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for oxidresolve 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_oxidresolver.h"
24
25 static int test_SimplePing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, HYPER_T setid)
26 {
27         struct SimplePing r;
28         NTSTATUS status;
29
30         r.in.SetId = &setid;
31
32         status = dcerpc_SimplePing(p, mem_ctx, &r);
33         if(NT_STATUS_IS_ERR(status)) {
34                 fprintf(stderr, "SimplePing: %s\n", nt_errstr(status));
35                 return 0;
36         }
37
38         if(!W_ERROR_IS_OK(r.out.result)) {
39                 fprintf(stderr, "SimplePing: %s\n", win_errstr(r.out.result));
40                 return 0;
41         }
42
43         return 1;
44 }
45
46 static int test_ComplexPing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, HYPER_T *setid)
47 {
48         struct ComplexPing r;
49         NTSTATUS status;
50
51         *setid = 0;
52         ZERO_STRUCT(r.in);
53
54         r.in.SequenceNum = 0;
55         r.in.SetId = setid;
56         r.out.SetId = setid;
57
58         status = dcerpc_ComplexPing(p, mem_ctx, &r);
59         if(NT_STATUS_IS_ERR(status)) {
60                 fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status));
61                 return 0;
62         }
63
64         if(!W_ERROR_IS_OK(r.out.result)) {
65                 fprintf(stderr, "ComplexPing: %s\n", win_errstr(r.out.result));
66                 return 0;
67         }
68
69         
70
71         return 1;
72 }
73
74 static int test_ServerAlive(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
75 {
76         struct ServerAlive r;
77         NTSTATUS status;
78
79         status = dcerpc_ServerAlive(p, mem_ctx, &r);
80         if(NT_STATUS_IS_ERR(status)) {
81                 fprintf(stderr, "ServerAlive: %s\n", nt_errstr(status));
82                 return 0;
83         }
84
85         if(!W_ERROR_IS_OK(r.out.result)) {
86                 fprintf(stderr, "ServerAlive: %s\n", win_errstr(r.out.result));
87                 return 0;
88         }
89
90         return 1;
91 }
92
93
94 static int test_ServerAlive2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
95 {
96         struct ServerAlive2 r;
97         NTSTATUS status;
98
99         status = dcerpc_ServerAlive2(p, mem_ctx, &r);
100         if(NT_STATUS_IS_ERR(status)) {
101                 fprintf(stderr, "ServerAlive2: %s\n", nt_errstr(status));
102                 return 0;
103         }
104
105         if(!W_ERROR_IS_OK(r.out.result)) {
106                 fprintf(stderr, "ServerAlive2: %s\n", win_errstr(r.out.result));
107                 return 0;
108         }
109
110         return 1;
111 }
112
113 BOOL torture_rpc_oxidresolve(void)
114 {
115         NTSTATUS status;
116        struct dcerpc_pipe *p;
117         TALLOC_CTX *mem_ctx;
118         BOOL ret = True;
119         HYPER_T setid;
120
121         mem_ctx = talloc_init("torture_rpc_oxidresolve");
122
123         status = torture_rpc_connection(&p, 
124                                         DCERPC_IOXIDRESOLVER_NAME, 
125                                         DCERPC_IOXIDRESOLVER_UUID, 
126                                         DCERPC_IOXIDRESOLVER_VERSION);
127
128         if (!NT_STATUS_IS_OK(status)) {
129                 return False;
130         }
131
132         if(!test_ServerAlive(p, mem_ctx))
133                 ret = False;
134
135         if(!test_ComplexPing(p, mem_ctx, &setid))
136                 ret = False;
137
138         if(!test_SimplePing(p, mem_ctx, setid))
139                 ret = False;
140
141         if(!test_ServerAlive2(p, mem_ctx))
142                 ret = False;
143
144         talloc_destroy(mem_ctx);
145
146         torture_rpc_close(p);
147
148         return ret;
149 }