2 Unix SMB/CIFS implementation.
4 count number of calls on an interface
6 Copyright (C) Andrew Tridgell 2003
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "torture/torture.h"
25 #include "librpc/rpc/dcerpc.h"
26 #include "librpc/rpc/dcerpc_table.h"
27 #include "torture/rpc/rpc.h"
30 BOOL torture_rpc_countcalls(void)
32 const struct dcerpc_interface_table *iface;
34 struct dcerpc_pipe *p;
36 const char *iface_name;
37 DATA_BLOB stub_in, stub_out;
39 iface_name = lp_parm_string(-1, "countcalls", "interface");
40 if (iface_name == NULL) {
41 printf("You must specify an interface name with countcalls:interface\n");
45 iface = idl_iface_by_name(iface_name);
47 printf("Unknown interface '%s'\n", iface_name);
51 status = torture_rpc_connection(NULL, &p, iface);
52 if (!NT_STATUS_IS_OK(status)) {
53 printf("Failed to open '%s' - %s\n", iface->name, nt_errstr(status));
57 stub_in = data_blob_talloc(p, NULL, 0);
59 printf("\nScanning pipe '%s'\n", iface->name);
61 for (i=0;i<5000;i++) {
62 status = dcerpc_request(p, NULL, i, False, p, &stub_in, &stub_out);
63 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT) &&
64 p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) break;
65 if (NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_DISCONNECTED)) {
72 printf("no limit on calls!?\n");
76 printf("Found %d calls\n", i);