summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-09-23 08:35:17 +0200
committerStefan Metzmacher <metze@samba.org>2011-11-30 15:13:36 +0100
commit4afbda221c20ffa36a1d1e37ef11f86073a49da6 (patch)
tree8d9cc7d03f5bb4ea4ffa761dfee0ba7e9cdc005c /source4/torture
parent99ef6a4bec1058b3649e5e72f8ea85f6df93a154 (diff)
downloadsamba-4afbda221c20ffa36a1d1e37ef11f86073a49da6.tar.gz
samba-4afbda221c20ffa36a1d1e37ef11f86073a49da6.tar.bz2
samba-4afbda221c20ffa36a1d1e37ef11f86073a49da6.zip
s4:libcli/raw: implement on top of smbXcli_conn/req
metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Wed Nov 30 15:13:36 CET 2011 on sn-devel-104
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/basic/base.c26
-rw-r--r--source4/torture/raw/lockbench.c26
-rw-r--r--source4/torture/raw/openbench.c25
3 files changed, 57 insertions, 20 deletions
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index d1005d0bdc..56461005e8 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -65,6 +65,14 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
goto failed;
}
+ cli->transport = smbcli_transport_init(cli->sock, cli,
+ true, &cli->options);
+ cli->sock = NULL;
+ if (!cli->transport) {
+ torture_comment(tctx, "smbcli_transport_init failed\n");
+ goto failed;
+ }
+
return cli;
failed:
@@ -360,15 +368,23 @@ static bool run_negprot_nowait(struct torture_context *tctx)
torture_comment(tctx, "Filling send buffer\n");
for (i=0;i<100;i++) {
- struct smbcli_request *req;
- req = smb_raw_negotiate_send(cli->transport, lpcfg_unicode(tctx->lp_ctx), PROTOCOL_NT1);
+ struct tevent_req *req;
+ req = smb_raw_negotiate_send(cli, tctx->ev,
+ cli->transport,
+ PROTOCOL_NT1);
tevent_loop_once(tctx->ev);
- if (req->state == SMBCLI_REQUEST_ERROR) {
+ if (!tevent_req_is_in_progress(req)) {
+ NTSTATUS status;
+
+ status = smb_raw_negotiate_recv(req);
+ TALLOC_FREE(req);
if (i > 0) {
- torture_comment(tctx, "Failed to fill pipe packet[%d] - %s (ignored)\n", i+1, nt_errstr(req->status));
+ torture_comment(tctx, "Failed to fill pipe packet[%d] - %s (ignored)\n",
+ i+1, nt_errstr(status));
break;
} else {
- torture_comment(tctx, "Failed to fill pipe - %s \n", nt_errstr(req->status));
+ torture_comment(tctx, "Failed to fill pipe - %s \n",
+ nt_errstr(status));
torture_close_connection(cli);
return false;
}
diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c
index 0a4faface8..1f016f0ee0 100644
--- a/source4/torture/raw/lockbench.c
+++ b/source4/torture/raw/lockbench.c
@@ -33,6 +33,8 @@
#include "libcli/resolve/resolve.h"
#include "param/param.h"
#include "torture/raw/proto.h"
+#include "libcli/smb/smbXcli_base.h"
+#include "../lib/util/util_net.h"
#define BASEDIR "\\benchlock"
#define FNAME BASEDIR "\\lock.dat"
@@ -336,6 +338,11 @@ bool torture_bench_lock(struct torture_context *torture)
printf("Opening %d connections\n", nprocs);
for (i=0;i<nprocs;i++) {
+ const struct sockaddr_storage *dest_ss;
+ char addrstr[INET6_ADDRSTRLEN];
+ const char *dest_str;
+ uint16_t dest_port;
+
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
state[i].client_num = i;
@@ -343,20 +350,23 @@ bool torture_bench_lock(struct torture_context *torture)
if (!torture_open_connection_ev(&cli, i, torture, torture->ev)) {
return false;
}
- talloc_steal(mem_ctx, state);
+ talloc_steal(state[i].mem_ctx, cli);
state[i].tree = cli->tree;
- state[i].dest_host = talloc_strdup(state[i].mem_ctx,
- cli->tree->session->transport->socket->hostname);
+
+ dest_ss = smbXcli_conn_remote_sockaddr(
+ state[i].tree->session->transport->conn);
+ dest_str = print_sockaddr(addrstr, sizeof(addrstr), dest_ss);
+ dest_port = get_sockaddr_port(dest_ss);
+
+ state[i].dest_host = talloc_strdup(state[i].mem_ctx, dest_str);
state[i].dest_ports = talloc_array(state[i].mem_ctx,
const char *, 2);
state[i].dest_ports[0] = talloc_asprintf(state[i].dest_ports,
- "%u",
- cli->tree->session->transport->socket->port);
+ "%u", dest_port);
state[i].dest_ports[1] = NULL;
state[i].called_name = talloc_strdup(state[i].mem_ctx,
- cli->tree->session->transport->called.name);
- state[i].service_type = talloc_strdup(state[i].mem_ctx,
- cli->tree->device);
+ smbXcli_conn_remote_name(cli->tree->session->transport->conn));
+ state[i].service_type = talloc_strdup(state[i].mem_ctx, "?????");
}
num_connected = i;
diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c
index 9543eea1b1..7533c4fb65 100644
--- a/source4/torture/raw/openbench.c
+++ b/source4/torture/raw/openbench.c
@@ -34,6 +34,8 @@
#include "libcli/resolve/resolve.h"
#include "param/param.h"
#include "torture/raw/proto.h"
+#include "libcli/smb/smbXcli_base.h"
+#include "../lib/util/util_net.h"
#define BASEDIR "\\benchopen"
@@ -390,6 +392,11 @@ bool torture_bench_open(struct torture_context *torture)
printf("Opening %d connections\n", nprocs);
for (i=0;i<nprocs;i++) {
+ const struct sockaddr_storage *dest_ss;
+ char addrstr[INET6_ADDRSTRLEN];
+ const char *dest_str;
+ uint16_t dest_port;
+
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
state[i].client_num = i;
@@ -397,19 +404,23 @@ bool torture_bench_open(struct torture_context *torture)
if (!torture_open_connection_ev(&state[i].cli, i, torture, torture->ev)) {
return false;
}
- talloc_steal(mem_ctx, state);
+ talloc_steal(state[i].mem_ctx, state[i].cli);
state[i].tree = state[i].cli->tree;
- state[i].dest_host = talloc_strdup(state[i].mem_ctx,
- state[i].cli->tree->session->transport->socket->hostname);
+
+ dest_ss = smbXcli_conn_remote_sockaddr(
+ state[i].tree->session->transport->conn);
+ dest_str = print_sockaddr(addrstr, sizeof(addrstr), dest_ss);
+ dest_port = get_sockaddr_port(dest_ss);
+
+ state[i].dest_host = talloc_strdup(state[i].mem_ctx, dest_str);
state[i].dest_ports = talloc_array(state[i].mem_ctx,
const char *, 2);
state[i].dest_ports[0] = talloc_asprintf(state[i].dest_ports,
- "%u", state[i].cli->tree->session->transport->socket->port);
+ "%u", dest_port);
state[i].dest_ports[1] = NULL;
state[i].called_name = talloc_strdup(state[i].mem_ctx,
- state[i].cli->tree->session->transport->called.name);
- state[i].service_type = talloc_strdup(state[i].mem_ctx,
- state[i].cli->tree->device);
+ smbXcli_conn_remote_name(state[i].tree->session->transport->conn));
+ state[i].service_type = talloc_strdup(state[i].mem_ctx, "?????");
}
num_connected = i;