summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/client/client.c5
-rw-r--r--source/include/client.h1
-rw-r--r--source/libsmb/clientgen.c15
3 files changed, 18 insertions, 3 deletions
diff --git a/source/client/client.c b/source/client/client.c
index ae2f19c36ea..c8d3a8a755c 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -29,6 +29,7 @@
struct cli_state *cli;
extern BOOL in_client;
+static int port = SMB_PORT;
pstring cur_dir = "\\";
pstring cd_path = "";
static pstring service;
@@ -1647,7 +1648,8 @@ struct cli_state *do_connect(char *server, char *share)
if (have_ip) ip = dest_ip;
/* have to open a new connection */
- if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, &ip)) {
+ if (!(c=cli_initialise(NULL)) || (cli_set_port(c, port) == 0) ||
+ !cli_connect(c, server_n, &ip)) {
DEBUG(0,("Connection to %s failed\n", server_n));
return NULL;
}
@@ -1909,7 +1911,6 @@ static int do_message_op(void)
{
fstring base_directory;
char *pname = argv[0];
- int port = SMB_PORT;
int opt;
extern FILE *dbf;
extern char *optarg;
diff --git a/source/include/client.h b/source/include/client.h
index 458c50d87ba..f5226e32e8e 100644
--- a/source/include/client.h
+++ b/source/include/client.h
@@ -72,6 +72,7 @@ struct pwd_info
};
struct cli_state {
+ int port;
int fd;
uint16 cnum;
uint16 pid;
diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c
index d0ddfa87bef..92a90d2ccf8 100644
--- a/source/libsmb/clientgen.c
+++ b/source/libsmb/clientgen.c
@@ -28,6 +28,17 @@
extern int DEBUGLEVEL;
extern pstring user_socket_options;
+/*
+ * Change the port number used to call on
+ */
+int cli_set_port(struct cli_state *cli, int port)
+{
+ if (port > 0)
+ cli -> port = port;
+
+ return cli -> port;
+}
+
/****************************************************************************
recv an smb
****************************************************************************/
@@ -2377,9 +2388,10 @@ BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
cli->dest_ip = *ip;
}
+ if (cli -> port == 0) cli -> port = 139; /* Set to default */
cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip,
- 139, cli->timeout);
+ cli -> port, cli->timeout);
if (cli->fd == -1)
return False;
@@ -2405,6 +2417,7 @@ struct cli_state *cli_initialise(struct cli_state *cli)
ZERO_STRUCTP(cli);
+ cli->port = 0;
cli->fd = -1;
cli->cnum = -1;
cli->pid = (uint16)getpid();