2 Unix SMB/CIFS implementation.
3 test suite for epmapper rpc operations
5 Copyright (C) Andrew Tridgell 2003
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.
26 display any protocol tower
28 static void display_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr)
33 for (i=0;i<twr->num_floors;i++) {
34 struct epm_lhs *lhs = &twr->floors[i].lhs;
35 struct epm_rhs *rhs = &twr->floors[i].rhs;
36 switch (lhs->protocol) {
38 uuid = GUID_string(mem_ctx, &lhs->info.uuid.uuid);
39 if (strcasecmp(uuid, NDR_GUID) == 0) {
42 printf(" uuid %s/0x%02x", uuid, lhs->info.uuid.version);
51 if (rhs->rhs_data.length == 4) {
53 in.s_addr = IVAL(rhs->rhs_data.data, 0);
54 printf("%s", inet_ntoa(in));
59 printf(" PIPE:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
63 printf(" SMB:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
67 printf(" NetBIOS:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
71 printf(" UNK(1):%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
76 if (rhs->rhs_data.length == 2) {
77 printf("%d", RSVAL(rhs->rhs_data.data, 0));
82 printf(" UNK(%02x):", lhs->protocol);
83 if (rhs->rhs_data.length == 2) {
84 printf("%d", RSVAL(rhs->rhs_data.data, 0));
93 static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
94 struct epm_twr_t *twr)
99 struct policy_handle handle;
106 r.in.map_tower = twr;
107 r.in.entry_handle = &handle;
108 r.out.entry_handle = &handle;
109 r.in.max_towers = 100;
111 status = dcerpc_epm_Map(p, mem_ctx, &r);
112 if (!NT_STATUS_IS_OK(status) || r.out.status != 0) {
113 printf("epm_Map failed - %s/0x%x\n",
114 nt_errstr(status), r.out.status);
118 printf("epm_Map results:\n");
120 for (i=0;i<r.out.num_towers;i++) {
121 if (r.out.towers[i].twr) {
122 display_tower(mem_ctx, &r.out.towers[i].twr->towers);
129 static BOOL test_Lookup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
134 struct rpc_if_id_t iface;
135 struct policy_handle handle;
141 r.in.inquiry_type = 0;
143 r.in.interface_id = &iface;
144 r.in.vers_option = 0;
145 r.in.entry_handle = &handle;
146 r.out.entry_handle = &handle;
151 status = dcerpc_epm_Lookup(p, mem_ctx, &r);
152 if (!NT_STATUS_IS_OK(status) || r.out.status != 0) {
155 for (i=0;i<r.out.num_ents;i++) {
156 printf("\nFound '%s'\n", r.out.entries[i].annotation);
157 display_tower(mem_ctx, &r.out.entries[i].tower->towers);
158 test_Map(p, mem_ctx, r.out.entries[i].tower);
160 } while (NT_STATUS_IS_OK(status) &&
162 r.out.num_ents == r.in.max_ents);
164 if (!NT_STATUS_IS_OK(status)) {
165 printf("Lookup failed - %s\n", nt_errstr(status));
173 BOOL torture_rpc_epmapper(int dummy)
176 struct dcerpc_pipe *p;
180 mem_ctx = talloc_init("torture_rpc_epmapper");
182 status = torture_rpc_connection(&p,
183 DCERPC_EPMAPPER_NAME,
184 DCERPC_EPMAPPER_UUID,
185 DCERPC_EPMAPPER_VERSION);
186 if (!NT_STATUS_IS_OK(status)) {
190 p->flags |= DCERPC_DEBUG_PRINT_BOTH;
192 if (!test_Lookup(p, mem_ctx)) {
196 talloc_destroy(mem_ctx);
198 torture_rpc_close(p);