s4:lib/messaging: terminate the irpc_servers_byname() result with server_id_set_disco...
[Samba/gebeck_regimport.git] / source3 / torture / rpc_open_tcp.c
blobd29f4cfbee88b8771bece044b24515cd20adecd9
1 /*
2 * Unix SMB/CIFS implementation.
3 * test program for rpc_pipe_open_tcp().
5 * Copyright (C) Michael Adam 2008
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 3 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, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "rpc_client/cli_pipe.h"
23 #include "librpc/gen_ndr/ndr_dfs.h"
24 #include "librpc/gen_ndr/ndr_drsuapi.h"
25 #include "librpc/gen_ndr/ndr_dssetup.h"
26 #include "librpc/gen_ndr/ndr_echo.h"
27 #include "librpc/gen_ndr/ndr_epmapper.h"
28 #include "librpc/gen_ndr/ndr_eventlog.h"
29 #include "librpc/gen_ndr/ndr_initshutdown.h"
30 #include "librpc/gen_ndr/ndr_lsa.h"
31 #include "librpc/gen_ndr/ndr_netlogon.h"
32 #include "librpc/gen_ndr/ndr_ntsvcs.h"
33 #include "librpc/gen_ndr/ndr_samr.h"
34 #include "librpc/gen_ndr/ndr_srvsvc.h"
35 #include "librpc/gen_ndr/ndr_svcctl.h"
36 #include "librpc/gen_ndr/ndr_winreg.h"
37 #include "librpc/gen_ndr/ndr_wkssvc.h"
39 extern const struct ndr_interface_table ndr_table_netdfs;
40 extern const struct ndr_interface_table ndr_table_drsuapi;
41 extern const struct ndr_interface_table ndr_table_dssetup;
42 extern const struct ndr_interface_table ndr_table_rpcecho;
43 extern const struct ndr_interface_table ndr_table_epmapper;
44 extern const struct ndr_interface_table ndr_table_eventlog;
45 extern const struct ndr_interface_table ndr_table_initshutdown;
46 extern const struct ndr_interface_table ndr_table_lsarpc;
47 extern const struct ndr_interface_table ndr_table_netlogon;
48 extern const struct ndr_interface_table ndr_table_ntsvcs;
49 extern const struct ndr_interface_table ndr_table_samr;
50 extern const struct ndr_interface_table ndr_table_srvsvc;
51 extern const struct ndr_interface_table ndr_table_svcctl;
52 extern const struct ndr_interface_table ndr_table_winreg;
53 extern const struct ndr_interface_table ndr_table_wkssvc;
55 const struct ndr_interface_table *tables[] = {
56 &ndr_table_netdfs,
57 &ndr_table_drsuapi,
58 &ndr_table_dssetup,
59 &ndr_table_rpcecho,
60 &ndr_table_epmapper,
61 &ndr_table_eventlog,
62 &ndr_table_initshutdown,
63 &ndr_table_lsarpc,
64 &ndr_table_netlogon,
65 &ndr_table_ntsvcs,
66 &ndr_table_samr,
67 &ndr_table_srvsvc,
68 &ndr_table_svcctl,
69 &ndr_table_winreg,
70 &ndr_table_wkssvc,
71 NULL
74 int main(int argc, const char **argv)
76 const struct ndr_interface_table **table;
77 NTSTATUS status;
78 struct rpc_pipe_client *rpc_pipe = NULL;
79 TALLOC_CTX *mem_ctx = talloc_stackframe();
81 if (argc != 3) {
82 d_printf("USAGE: %s interface host\n", argv[0]);
83 return -1;
86 for (table = tables; *table != NULL; table++) {
87 if (strequal((*table)->name, argv[1])) {
88 break;
92 if (*table == NULL) {
93 d_printf("ERROR: unknown interface '%s' given\n", argv[1]);
94 return -1;
97 status = rpc_pipe_open_tcp(mem_ctx, argv[2], NULL,
98 &((*table)->syntax_id),
99 &rpc_pipe);
100 if (!NT_STATUS_IS_OK(status)) {
101 d_printf("ERROR calling rpc_pipe_open_tcp(): %s\n",
102 nt_errstr(status));
103 return -1;
106 TALLOC_FREE(mem_ctx);
108 return 0;