added a simple test for the old SMBtcon interface
authorAndrew Tridgell <tridge@samba.org>
Sat, 29 Mar 2003 12:44:42 +0000 (12:44 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 29 Mar 2003 12:44:42 +0000 (12:44 +0000)
(This used to be commit c95ae394c5dfe5e0fcc658119213b17bcb95fab5)

source3/libsmb/cliconnect.c
source3/torture/torture.c

index 763878f9b38307d81b66e91f8334c8585d83edf8..75dcd62c2f37e88a62689a86c3b31bba49d9265a 100644 (file)
@@ -750,7 +750,6 @@ BOOL cli_ulogoff(struct cli_state *cli)
 /****************************************************************************
  Send a tconX.
 ****************************************************************************/
-
 BOOL cli_send_tconX(struct cli_state *cli, 
                    const char *share, const char *dev, const char *pass, int passlen)
 {
@@ -1343,3 +1342,45 @@ name *SMBSERVER with error %s\n", desthost, cli_errstr(cli) ));
 
        return True;
 }
+
+
+
+
+
+/****************************************************************************
+ Send an old style tcon.
+****************************************************************************/
+NTSTATUS cli_raw_tcon(struct cli_state *cli, 
+                     const char *service, const char *pass, const char *dev,
+                     uint16 *max_xmit, uint16 *tid)
+{
+       char *p;
+
+       memset(cli->outbuf,'\0',smb_size);
+       memset(cli->inbuf,'\0',smb_size);
+
+       set_message(cli->outbuf, 0, 0, True);
+       SCVAL(cli->outbuf,smb_com,SMBtcon);
+       cli_setup_packet(cli);
+
+       p = smb_buf(cli->outbuf);
+       *p++ = 4; p += clistr_push(cli, p, service, -1, STR_TERMINATE | STR_NOALIGN);
+       *p++ = 4; p += clistr_push(cli, p, pass, -1, STR_TERMINATE | STR_NOALIGN);
+       *p++ = 4; p += clistr_push(cli, p, dev, -1, STR_TERMINATE | STR_NOALIGN);
+
+       cli_setup_bcc(cli, p);
+
+       cli_send_smb(cli);
+       if (!cli_receive_smb(cli)) {
+               return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
+       }
+
+       if (cli_is_error(cli)) {
+               return cli_nt_error(cli);
+       }
+
+       *max_xmit = SVAL(cli->inbuf, smb_vwv0);
+       *tid = SVAL(cli->inbuf, smb_vwv1);
+
+       return NT_STATUS_OK;
+}
index 327212c6be2b425db0236db28ee638e46713a36a..6ab5bf6dbb235b138910650abe6d2d45fdf50093 100644 (file)
@@ -976,6 +976,43 @@ static BOOL run_tcon_test(int dummy)
 }
 
 
+/*
+ checks for old style tcon support
+ */
+static BOOL run_tcon2_test(int dummy)
+{
+       static struct cli_state *cli;
+       uint16 cnum, max_xmit;
+       char *service;
+       NTSTATUS status;
+
+       if (!torture_open_connection(&cli)) {
+               return False;
+       }
+       cli_sockopt(cli, sockops);
+
+       printf("starting tcon2 test\n");
+
+       asprintf(&service, "\\\\%s\\%s", host, share);
+
+       status = cli_raw_tcon(cli, service, password, "?????", &max_xmit, &cnum);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("tcon2 failed : %s\n", cli_errstr(cli));
+       } else {
+               printf("tcon OK : max_xmit=%d cnum=%d tid=%d\n", 
+                      (int)max_xmit, (int)cnum, SVAL(cli->inbuf, smb_tid));
+       }
+
+       if (!torture_close_connection(cli)) {
+               return False;
+       }
+
+       printf("Passed tcon2 test\n");
+       return True;
+}
+
+
 /*
   This test checks that 
 
@@ -4137,6 +4174,7 @@ static struct {
        {"CASETABLE", torture_casetable, 0},
        {"ERRMAPEXTRACT", run_error_map_extract, 0},
        {"PIPE_NUMBER", run_pipe_number, 0},
+       {"TCON2",  run_tcon2_test, 0},
        {NULL, NULL, 0}};