static int do_message_op(struct cli_credentials *creds)
{
NTSTATUS status;
+ struct smb_transports ts =
+ smbsock_transports_from_port(port ? port : NBT_SMB_PORT);
if (lp_disable_netbios()) {
d_printf("NetBIOS over TCP disabled.\n");
status = cli_connect_nb(talloc_tos(),
desthost, have_ip ? &dest_ss : NULL,
- port ? port : NBT_SMB_PORT, name_type,
+ &ts,
+ name_type,
lp_netbios_name(),
SMB_SIGNING_OFF,
0,
NTSTATUS cli_connect_nb(TALLOC_CTX *mem_ctx,
const char *host,
const struct sockaddr_storage *dest_ss,
- uint16_t port,
+ const struct smb_transports *transports,
int name_type,
const char *myname,
enum smb_signing_setting signing_state,
struct tevent_context *ev;
struct tevent_req *req;
NTSTATUS status = NT_STATUS_NO_MEMORY;
- struct smb_transports ts = smbsock_transports_from_port(port);
ev = samba_tevent_context_init(mem_ctx);
if (ev == NULL) {
goto fail;
}
- req = cli_connect_nb_send(ev, ev, host, dest_ss, &ts, name_type,
+ req = cli_connect_nb_send(ev, ev, host, dest_ss, transports, name_type,
myname, signing_state, flags);
if (req == NULL) {
goto fail;
cli_credentials_get_smb_encryption(creds);
struct smb2_negotiate_contexts *in_contexts = NULL;
struct smb2_negotiate_contexts *out_contexts = NULL;
+ struct smb_transports ts = smbsock_transports_from_port(port);
if (encryption_state >= SMB_ENCRYPTION_DESIRED) {
signing_state = SMB_SIGNING_REQUIRED;
status = cli_connect_nb(NULL,
server,
dest_ss,
- port,
+ &ts,
name_type,
NULL,
signing_state,
struct smbXcli_tcon *tcon = NULL;
int signing_state = SMB_SIGNING_DEFAULT;
struct cli_credentials *creds = NULL;
+ struct smb_transports ats = smbsock_transports_from_port(port);
+ uint8_t ati;
+ const struct smb_transports *ts = &ats;
+ struct smb_transports ots = { .num_transports = 0, };
+ struct smb_transports nts = { .num_transports = 0, };
*in_cache = false;
return NULL;
}
+ for (ati = 0; ati < ats.num_transports; ati++) {
+ const struct smb_transport *at =
+ &ats.transports[ati];
+
+ if (at->type == SMB_TRANSPORT_TYPE_NBT) {
+ struct smb_transport *nt =
+ &nts.transports[nts.num_transports];
+ *nt = *at;
+ nts.num_transports += 1;
+ } else {
+ struct smb_transport *ot =
+ &ots.transports[ots.num_transports];
+ *ot = *at;
+ ots.num_transports += 1;
+ }
+ }
+
/* Look for a cached connection */
srv = SMBC_find_server(ctx, context, server, share,
pp_workgroup, pp_username, pp_password);
signing_state = SMB_SIGNING_REQUIRED;
}
- if (port == 0) {
+ if (nts.num_transports != 0 && ots.num_transports != 0) {
if (share == NULL || *share == '\0' || is_ipc) {
/*
* Try 139 first for IPC$
*/
+ ts = &ots;
+
status = cli_connect_nb(NULL,
server_n,
NULL,
- NBT_SMB_PORT,
+ &nts,
0x20,
smbc_getNetbiosName(context),
signing_state,
status = cli_connect_nb(NULL,
server_n,
NULL,
- port,
+ ts,
0x20,
smbc_getNetbiosName(context),
signing_state,
NTSTATUS status;
NTSTATUS result;
bool pass_must_change = False;
+ struct smb_transports ts =
+ smb_transports_parse("client smb transports",
+ lp_client_smb_transports());
*err_str = NULL;
result = cli_connect_nb(talloc_tos(),
remote_machine,
NULL,
- 0,
+ &ts,
0x20,
NULL,
SMB_SIGNING_IPC_DEFAULT,
NTSTATUS cli_connect_nb(TALLOC_CTX *mem_ctx,
const char *host,
const struct sockaddr_storage *dest_ss,
- uint16_t port,
+ const struct smb_transports *transports,
int name_type,
const char *myname,
enum smb_signing_setting signing_state,
int flags,
- struct cli_state **pcli);
+ struct cli_state **pcli)
+ NONNULL(4) NONNULL(9);
NTSTATUS cli_start_connection(TALLOC_CTX *mem_ctx,
struct cli_state **output_cli,
const char *my_name,
struct cli_state *cli;
uint32_t local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
struct sockaddr_storage ss;
+ const char *nbt[] = { "nbt", NULL, };
+ struct smb_transports ts = smb_transports_parse("forced-nbt", nbt);
NTSTATUS status;
/* W2K DMB's return empty browse lists on port 445. Use 139.
status = cli_connect_nb(talloc_tos(),
name,
&ss,
- NBT_SMB_PORT,
+ &ts,
nm_type,
get_local_machine_name(),
SMB_SIGNING_DEFAULT,
struct cli_state *c;
NTSTATUS status;
int flags = 0;
+ struct smb_transports ts =
+ smb_transports_parse("client smb transports",
+ lp_client_smb_transports());
if (disable_spnego) {
flags |= CLI_FULL_CONNECTION_DONT_SPNEGO;
status = cli_connect_nb(NULL,
host,
NULL,
- port_to_use,
+ &ts,
0x20,
myname,
signing_state,
switch (opt) {
case 'p':
port_to_use = atoi(optarg);
+ lpcfg_set_cmdline(lp_ctx, "client smb transports", optarg);
break;
case 's':
seed = atoi(optarg);
bool ret = false;
struct sockaddr_storage server_ss;
char *server_name = NULL;
+ struct smb_transports ts =
+ smb_transports_parse("client smb transports",
+ lp_client_smb_transports());
NTSTATUS status;
/* flags (i.e. server type) may depend on command */
status = cli_connect_nb(c,
server_name,
&server_ss,
- 0,
+ &ts,
0x20,
lp_netbios_name(),
SMB_SIGNING_IPC_DEFAULT,
{
time_t ret = 0;
struct cli_state *cli = NULL;
+ struct smb_transports ts =
+ smb_transports_parse("client smb transports",
+ lp_client_smb_transports());
NTSTATUS status;
status = cli_connect_nb(talloc_tos(),
host,
dest_ss,
- 0,
+ &ts,
0x20,
lp_netbios_name(),
SMB_SIGNING_DEFAULT,