r26654: libcli/smb_composite: Rather than specifying each of the gazillion options...
[jelmer/samba4-debian.git] / source / torture / raw / openbench.c
index 3eec9fbb134af257bc7a75576f55b8cb026e25db..87b27d072837e42cd16e1b22b116adf96bcaf5a9 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "libcli/composite/composite.h"
 #include "libcli/smb_composite/smb_composite.h"
+#include "libcli/resolve/resolve.h"
 #include "param/param.h"
 
 #define BASEDIR "\\benchopen"
@@ -61,7 +62,7 @@ struct benchopen_state {
        struct timed_event *te;
 
        /* these are used for reconnections */
-       int dest_port;
+       const char **dest_ports;
        const char *dest_host;
        const char *called_name;
        const char *service_type;
@@ -123,20 +124,23 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te,
        }
 
        io->in.dest_host    = state->dest_host;
-       io->in.port         = state->dest_port;
+       io->in.dest_ports   = state->dest_ports;
        io->in.called_name  = state->called_name;
        io->in.service      = share;
        io->in.service_type = state->service_type;
        io->in.credentials  = cmdline_credentials;
        io->in.fallback_to_anonymous = false;
-       io->in.workgroup    = lp_workgroup(global_loadparm);
+       io->in.workgroup    = lp_workgroup(state->tctx->lp_ctx);
+       lp_smbcli_options(state->tctx->lp_ctx, &io->in.options);
 
        /* kill off the remnants of the old connection */
        talloc_free(state->tree);
        state->tree = NULL;
        state->fnum = -1;
 
-       ctx = smb_composite_connect_send(io, state->mem_ctx, state->ev);
+       ctx = smb_composite_connect_send(io, state->mem_ctx, 
+                                        lp_resolve_context(state->tctx->lp_ctx), 
+                                        state->ev);
        if (ctx == NULL) {
                DEBUG(0,("Failed to setup async reconnect\n"));
                exit(1);
@@ -370,7 +374,11 @@ bool torture_bench_open(struct torture_context *torture)
                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);
-               state[i].dest_port = state[i].cli->tree->session->transport->socket->port;
+               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);
+               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,