summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-11-30 17:53:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:40 -0500
commit0af6dcacec1831bad1e901383a2c6458e1b0606f (patch)
treed74149f23005b6f222f3ffde33d3fcd0bbb238c3
parentd2fff52b913e9ac192163fb615a59aaa3a247afb (diff)
downloadsamba-0af6dcacec1831bad1e901383a2c6458e1b0606f.tar.gz
samba-0af6dcacec1831bad1e901383a2c6458e1b0606f.tar.bz2
samba-0af6dcacec1831bad1e901383a2c6458e1b0606f.zip
r11976: (Slightly modified) Volker fix for #3293. Use SMBecho instead of
chkpath to keep a connection alive. Jeremy. (This used to be commit f1c88de7a28942b6aaa634551dde7a8af91f4de3)
-rw-r--r--source3/client/client.c7
-rw-r--r--source3/libsmb/clientgen.c34
2 files changed, 40 insertions, 1 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 47a45b8a53..7a4f853d54 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -3088,7 +3088,12 @@ static void readline_callback(void)
goto again;
}
- cli_chkpath(cli, "\\");
+ /* Ping the server to keep the connection alive using SMBecho. */
+ {
+ unsigned char garbage[16];
+ memset(garbage, 0xf0, sizeof(garbage));
+ cli_echo(cli, garbage, sizeof(garbage));
+ }
}
/****************************************************************************
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index bc64cc919b..6dc7386c03 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -481,6 +481,7 @@ BOOL cli_set_case_sensitive(struct cli_state *cli, BOOL case_sensitive)
/****************************************************************************
Send a keepalive packet to the server
****************************************************************************/
+
BOOL cli_send_keepalive(struct cli_state *cli)
{
if (cli->fd == -1) {
@@ -495,3 +496,36 @@ BOOL cli_send_keepalive(struct cli_state *cli)
}
return True;
}
+
+/****************************************************************************
+ Send/receive a SMBecho command: ping the server
+****************************************************************************/
+
+BOOL cli_echo(struct cli_state *cli, unsigned char *data, size_t length)
+{
+ char *p;
+
+ SMB_ASSERT(length < 1024);
+
+ memset(cli->outbuf,'\0',smb_size);
+ set_message(cli->outbuf,1,length,True);
+ SCVAL(cli->outbuf,smb_com,SMBecho);
+ SSVAL(cli->outbuf,smb_tid,65535);
+ SSVAL(cli->outbuf,smb_vwv0,1);
+ cli_setup_packet(cli);
+ p = smb_buf(cli->outbuf);
+ memcpy(p, data, length);
+ p += length;
+
+ cli_setup_bcc(cli, p);
+
+ cli_send_smb(cli);
+ if (!cli_receive_smb(cli)) {
+ return False;
+ }
+
+ if (cli_is_error(cli)) {
+ return False;
+ }
+ return True;
+}