public void OperationWithSpecifiedCredits(ushort credits)
        {
            // define test data for this test case
            ushort receiveCreditMax = credits;
            ushort sendCreditTarget = credits;

            uint size = smbdAdapter.TestConfig.ModerateFileSizeInByte;

            string fileName = SmbdUtilities.CreateRandomFileName();

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Connect to server over RDMA.");
            NtStatus status = smbdAdapter.ConnectToServerOverRDMA();

            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "SMBD Negotiate with server.");
            SmbdNegotiateResponse response;

            status = smbdAdapter.SmbdNegotiate(sendCreditTarget, receiveCreditMax, out response);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD negotiate is {0}", status);
            BaseTestSite.Assert.IsTrue(response.MaxFragmentedSize >= SmbdConnection.FLOOR_MAX_FRAGMENTED_SIZE
                                       , "MaxFragmentedSize in negotiate response is {0}", response.MaxFragmentedSize); // check the MaxFragementSize

            // SMB2 Negotiate, Session Setup, Tree Connect and Open File
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection and open file " + fileName);
            status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 establish session and open file is {0}", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Write a moderate size of data to the file.");
            byte[]         data = new byte[size];
            WRITE_Response writeResponse;

            status = (NtStatus)smbdAdapter.Smb2Write(0, data, out writeResponse);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 write File is {0}", status);
            BaseTestSite.Assert.AreEqual <uint>(size, writeResponse.Count, "Size of written file is {0}", writeResponse.Count);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Close file and disconnect from server.");
            smbdAdapter.Smb2CloseFile();
            // disconnect
            smbdAdapter.DisconnectRdma();
        }
        /// <summary>
        /// Establish SMB2 connection over RDMA and open file
        /// 1. Connect to server over RDMA
        /// 2. SMBD Negotiation over RDMA
        /// 3. Establish SMB2 session and open file with specific dialect
        /// </summary>
        /// <param name="fileName">File name to open</param>
        /// <param name="negotiatedDialect">Optional to set the SMB2 dialect used for SMB2 connection</param>
        protected virtual void EstablishConnectionAndOpenFile(string fileName, DialectRevision negotiatedDialect = DialectRevision.Smb30)
        {
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection over RDMA and open file " + fileName);

            // Connect to server over RDMA
            NtStatus status = smbdAdapter.ConnectToServerOverRDMA();

            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status);

            // SMBD Negotiate
            status = smbdAdapter.SmbdNegotiate();
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD negotiate is {0}", status);

            status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName, negotiatedDialect);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 establish session and open file is {0}", status);
        }
        public void InitSmbdConnectionForTestCases(string fileName)
        {
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Initial SMBD connection and open file " + fileName);

            uint size = smbdAdapter.TestConfig.LargeFileSizeInByte;
            // Connect to server over RDMA
            NtStatus status = smbdAdapter.ConnectToServerOverRDMA();

            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status);

            // SMBD Negotiate
            status = smbdAdapter.SmbdNegotiate();
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD negotiate is {0}", status);


            status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 establish session and open file is {0}", status);
        }
Beispiel #4
0
        /// <summary>
        /// Establish SMB2 connection over RDMA and open file
        /// 1. Connect to server over RDMA
        /// 2. SMBD Negotiation over RDMA
        /// 3. Establish SMB2 session and open file with specific dialect
        /// </summary>
        /// <param name="fileName">File name to open</param>
        /// <param name="negotiatedDialects">Optional to set the SMB2 dialects used for SMB2 connection</param>
        protected virtual void EstablishConnectionAndOpenFile(string fileName, DialectRevision[] negotiatedDialects = null)
        {
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection over RDMA and open file " + fileName);

            // Connect to server over RDMA
            NtStatus status = smbdAdapter.ConnectToServerOverRDMA();

            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status);

            // SMBD Negotiate
            status = smbdAdapter.SmbdNegotiate();
            if (status == NtStatus.STATUS_NOT_SUPPORTED)
            {
                BaseTestSite.Assert.Inconclusive("Requested SMB dialects are not supported.");
            }
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD negotiate is {0}", status);

            status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName, negotiatedDialects);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 establish session and open file is {0}", status);
        }
Beispiel #5
0
        public void Negotiate_Version(
            SmbdVersion minVer,
            SmbdVersion maxVer)
        {
            const ushort CREDIT_REQUESTED   = 10;
            const ushort RECEIVE_CREDIT_MAX = 10;
            const uint   MAX_SEND_SIZE      = 1024;
            const uint   MAX_RECEIVE_SIZE   = 1024;
            const uint   MAX_FRAGMENT_SIZE  = 131072;

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Connect to server over RDMA");
            NtStatus status = smbdAdapter.ConnectToServerOverRDMA();

            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, string.Format("SMBD Negotiate, MinVersion: {0}; MaxVersion: {1}", minVer.ToString(), maxVer.ToString()));
            SmbdNegotiateResponse response;

            status = smbdAdapter.SmbdNegotiate(
                CREDIT_REQUESTED,
                RECEIVE_CREDIT_MAX,
                MAX_SEND_SIZE,
                MAX_RECEIVE_SIZE,
                MAX_FRAGMENT_SIZE,
                out response,
                minVer,
                maxVer
                );

            // try to negotiate on SMB2
            string fileName = SmbdUtilities.CreateRandomFileName();

            // "<3> Section 3.1.5.6:  Windows Server 2012 fails the Negotiate Request Message with STATUS_NOT_SUPPORTED if MinVersion or MaxVersion is not 0x0100"
            if (smbdAdapter.TestConfig.Platform == Platform.WindowsServer2012)
            {
                if (minVer == SmbdVersion.V1 &&
                    maxVer == SmbdVersion.V1)
                {
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_SUCCESS,
                        status,
                        "SMBD Negotiate should succeed");

                    BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection and open file " + fileName);
                    status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_SUCCESS,
                        status,
                        "Smb2EstablishSessionAndOpenFile should success");
                }
                else
                {
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_NOT_SUPPORTED,
                        status,
                        "Status of SMBD negotiate {0}", status);

                    try
                    {
                        BaseTestSite.Log.Add(LogEntryKind.TestStep, "Try to establish SMB2 connection and open file " + fileName);
                        status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
                        BaseTestSite.Assert.AreNotEqual <NtStatus>(
                            NtStatus.STATUS_SUCCESS,
                            status,
                            "Status of Smb2EstablishSessionAndOpenFile is {0}", status);
                    }
                    catch (TimeoutException e)
                    {
                        BaseTestSite.Assert.Pass("Cannot send or receive packets from peer. \nException: {0}\n{1}", e.Message, e.StackTrace);
                    }
                }
            }
            else
            {
                if (minVer <= SmbdVersion.V1 &&
                    maxVer >= SmbdVersion.V1)
                {
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_SUCCESS,
                        status,
                        "SMBD Negotiate should succeed");

                    BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection and open file " + fileName);
                    status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_SUCCESS,
                        status,
                        "Smb2EstablishSessionAndOpenFile should success");
                }
                else
                {
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_NOT_SUPPORTED,
                        status,
                        "Status of SMBD negotiate {0}", status);

                    try
                    {
                        BaseTestSite.Log.Add(LogEntryKind.TestStep, "Try to establish SMB2 connection and open file " + fileName);
                        status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
                        BaseTestSite.Assert.AreNotEqual <NtStatus>(
                            NtStatus.STATUS_SUCCESS,
                            status,
                            "Status of Smb2EstablishSessionAndOpenFile is {0}", status);
                    }
                    catch (TimeoutException e)
                    {
                        BaseTestSite.Assert.Pass("Cannot send or receive packets from peer. \nException: {0}\n{1}", e.Message, e.StackTrace);
                    }
                }
            }
        }