* changed the way strings are handled in pidl to a much more general
[nivanova/samba-autobuild/.git] / source4 / torture / rpc / epmapper.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for epmapper rpc operations
4
5    Copyright (C) Andrew Tridgell 2003
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
24
25 static BOOL test_Lookup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
26 {
27         NTSTATUS status;
28         struct epm_Lookup r;
29         struct GUID uuid;
30         struct rpc_if_id_t iface;
31         struct policy_handle handle;
32
33         ZERO_STRUCT(uuid);
34         ZERO_STRUCT(iface);
35         ZERO_STRUCT(handle);
36
37         r.in.inquiry_type = 0;
38         r.in.object = &uuid;
39         r.in.interface_id = &iface;
40         r.in.vers_option = 0;
41         r.in.entry_handle = &handle;
42         r.out.entry_handle = &handle;
43         r.in.max_ents = 1;
44
45         do {
46                 status = dcerpc_epm_Lookup(p, mem_ctx, &r);
47                 if (NT_STATUS_IS_OK(status) && r.out.status == 0) {
48                         printf("Found '%s'\n", r.out.entries[0].annotation);
49                 }
50         } while (NT_STATUS_IS_OK(status) && r.out.status == 0);
51
52         if (!NT_STATUS_IS_OK(status)) {
53                 printf("Lookup failed - %s\n", nt_errstr(status));
54                 return False;
55         }
56
57
58         return True;
59 }
60
61 BOOL torture_rpc_epmapper(int dummy)
62 {
63         NTSTATUS status;
64         struct dcerpc_pipe *p;
65         TALLOC_CTX *mem_ctx;
66         BOOL ret = True;
67
68         mem_ctx = talloc_init("torture_rpc_epmapper");
69
70         status = torture_rpc_connection(&p, 
71                                         DCERPC_EPMAPPER_NAME,
72                                         DCERPC_EPMAPPER_UUID,
73                                         DCERPC_EPMAPPER_VERSION);
74         if (!NT_STATUS_IS_OK(status)) {
75                 return False;
76         }
77         
78         p->flags |= DCERPC_DEBUG_PRINT_BOTH;
79
80         if (!test_Lookup(p, mem_ctx)) {
81                 ret = False;
82         }
83
84         torture_rpc_close(p);
85
86         return ret;
87 }