struct nbt_name called, calling;
const char *server_name;
struct smbcli_state *cli;
+ bool ok;
make_nbt_name_client(&calling, netbios_name);
server_name = destip ? destip : desthost;
- if (!(cli = smbcli_state_init(NULL)) ||
- !smbcli_socket_connect(cli, server_name, destports,
- ev_ctx, resolve_ctx, options,
- socket_options)) {
- d_printf("Connection to %s failed\n", server_name);
+ cli = smbcli_state_init(NULL);
+ if (cli == NULL) {
+ d_printf("smbcli_state_init() failed\n");
return 1;
}
- if (!smbcli_transport_establish(cli, &calling, &called)) {
- d_printf("session request failed\n");
- talloc_free(cli);
+ ok = smbcli_socket_connect(cli, server_name, destports,
+ ev_ctx, resolve_ctx, options,
+ socket_options,
+ &calling, &called);
+ if (!ok) {
+ d_printf("Connection to %s failed\n", server_name);
return 1;
}
struct tevent_context *ev_ctx,
struct resolve_context *resolve_ctx,
struct smbcli_options *options,
- const char *socket_options)
+ const char *socket_options,
+ struct nbt_name *calling,
+ struct nbt_name *called)
{
struct smbcli_socket *sock;
+ uint32_t timeout_msec = options->request_timeout * 1000;
+ NTSTATUS status;
sock = smbcli_sock_connect_byname(server, ports, NULL,
resolve_ctx, ev_ctx,
socket_options);
if (sock == NULL) return false;
-
- cli->transport = smbcli_transport_init(sock, cli, true, options);
- if (!cli->transport) {
- return false;
- }
-
- return true;
-}
-/* wrapper around smbcli_transport_connect() */
-bool smbcli_transport_establish(struct smbcli_state *cli,
- struct nbt_name *calling,
- struct nbt_name *called)
-{
- uint32_t timeout_msec = cli->transport->options.request_timeout * 1000;
- NTSTATUS status;
-
- status = smbcli_transport_connect(cli->transport->socket,
+ status = smbcli_transport_connect(sock,
timeout_msec,
calling, called);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
+ cli->transport = smbcli_transport_init(sock, cli, true, options);
+ if (!cli->transport) {
+ return false;
+ }
+
return true;
}
struct tevent_context *ev_ctx,
struct resolve_context *resolve_ctx,
struct smbcli_options *options,
- const char *socket_options);
-bool smbcli_transport_establish(struct smbcli_state *cli,
- struct nbt_name *calling,
- struct nbt_name *called);
+ const char *socket_options,
+ struct nbt_name *calling,
+ struct nbt_name *called);
NTSTATUS smbcli_negprot(struct smbcli_state *cli, bool unicode, int maxprotocol);
NTSTATUS smbcli_session_setup(struct smbcli_state *cli,
struct cli_credentials *credentials,
struct smbcli_state *cli;
const char *host = torture_setting_string(tctx, "host", NULL);
struct smbcli_options options;
+ bool ok;
make_nbt_name_client(&calling, lpcfg_netbios_name(tctx->lp_ctx));
lpcfg_smbcli_options(tctx->lp_ctx, &options);
- if (!smbcli_socket_connect(cli, host, lpcfg_smb_ports(tctx->lp_ctx), tctx->ev,
- lpcfg_resolve_context(tctx->lp_ctx), &options,
- lpcfg_socket_options(tctx->lp_ctx))) {
+ ok = smbcli_socket_connect(cli, host, lpcfg_smb_ports(tctx->lp_ctx),
+ tctx->ev,
+ lpcfg_resolve_context(tctx->lp_ctx),
+ &options,
+ lpcfg_socket_options(tctx->lp_ctx),
+ &calling, &called);
+ if (!ok) {
torture_comment(tctx, "Failed to connect with %s\n", host);
goto failed;
}
- if (!smbcli_transport_establish(cli, &calling, &called)) {
- torture_comment(tctx, "%s rejected the session\n",host);
- goto failed;
- }
-
return cli;
failed: