private uint SessionSetup(
            Packet_Header_Flags_Values headerFlags,
            SESSION_SETUP_Request_Flags sessionSetupFlags,
            SESSION_SETUP_Request_SecurityMode_Values securityMode,
            SESSION_SETUP_Request_Capabilities_Values capabilities,
            ulong previousSessionId,
            SecurityPackageType securityPackageType,
            string serverName,
            byte[] token,
            out byte[] serverGssToken,
            ushort creditRequest = 64)
        {
            Packet_Header          header;
            SESSION_SETUP_Response sessionSetupResponse;

            uint status;

            status = client.SessionSetup(
                1,
                creditRequest,
                headerFlags,
                messageId++,
                sessionId,
                sessionSetupFlags,
                securityMode,
                capabilities,
                previousSessionId,
                token,
                out sessionId,
                out serverGssToken,
                out header,
                out sessionSetupResponse);

            return(status);
        }
Esempio n. 2
0
        /// <summary>
        /// Send an SMB2 SESSION_SETUP request with specified parameters
        /// </summary>
        /// <param name="headerFlags">A Flags field indicates how to process the operation.</param>
        /// <param name="sessionSetupFlags">To bind an existing session to a new connection,set to SMB2_SESSION_FLAG_BINDING to bind; otherwise set it to NONE.</param>
        /// <param name="securityMode">The security mode field specifies whether SMB signing is enabled, required at the server, or both</param>
        /// <param name="capabilities">Specifies protocol capabilities for the client.</param>
        /// <param name="token">Gss token to send</param>
        /// <param name="serverToken">GssToken returned from server</param>
        /// <param name="isResponseEncryptedSessionFlag">check if SESSION_FLAG_ENCRYPT_DATA returned from server</param>
        /// <param name="creditRequest">The number of credits the client is requesting. Default value is 64.</param>
        /// <param name="previousSessionId">For reconnect, set it to previous sessionId, otherwise set it to 0. Default value is 0.</param>
        /// <returns>The status code for SESSION_SETUP Response.</returns>
        public uint SessionSetup(
            Packet_Header_Flags_Values headerFlags,
            SESSION_SETUP_Request_Flags sessionSetupFlags,
            SESSION_SETUP_Request_SecurityMode_Values securityMode,
            SESSION_SETUP_Request_Capabilities_Values capabilities,
            byte[] token,
            out byte[] serverToken,
            out bool isResponseEncryptedSessionFlag,
            ushort creditRequest    = 64,
            ulong previousSessionId = 0)
        {
            Packet_Header          header;
            SESSION_SETUP_Response sessionSetupResponse;

            ulong  messageId    = generateMessageId(sequenceWindow);
            ushort creditCharge = generateCreditCharge(1);

            // Need to consume credit from sequence window first according to TD
            ConsumeCredit(messageId, creditCharge);

            uint status = Smb2Client.SessionSetup(
                1,
                creditRequest,
                headerFlags,
                messageId,
                sessionId,
                sessionSetupFlags,
                securityMode,
                capabilities,
                previousSessionId,
                token,
                out sessionId,
                out serverToken,
                out header,
                out sessionSetupResponse);

            isResponseEncryptedSessionFlag = sessionSetupResponse.SessionFlags.HasFlag(SessionFlags_Values.SESSION_FLAG_ENCRYPT_DATA);

            ProduceCredit(messageId, header);

            return(status);
        }
        /// <summary>
        /// Send an SMB2 SESSION_SETUP request with specified parameters
        /// </summary>
        /// <param name="headerFlags">A Flags field indicates how to process the operation.</param>
        /// <param name="sessionSetupFlags">To bind an existing session to a new connection,set to SMB2_SESSION_FLAG_BINDING to bind; otherwise set it to NONE.</param>
        /// <param name="securityMode">The security mode field specifies whether SMB signing is enabled, required at the server, or both</param>
        /// <param name="capabilities">Specifies protocol capabilities for the client.</param>
        /// <param name="token">Gss token to send</param>
        /// <param name="serverToken">GssToken returned from server</param>
        /// <param name="creditRequest">The number of credits the client is requesting. Default value is 64.</param>
        /// <param name="previousSessionId">For reconnect, set it to previous sessionId, otherwise set it to 0. Default value is 0.</param>
        /// <returns>The status code for SESSION_SETUP Response.</returns>
        public uint SessionSetup(
            Packet_Header_Flags_Values headerFlags,
            SESSION_SETUP_Request_Flags sessionSetupFlags,
            SESSION_SETUP_Request_SecurityMode_Values securityMode,
            SESSION_SETUP_Request_Capabilities_Values capabilities,
            byte[] token,
            out byte[] serverToken,
            ushort creditRequest = 64,
            ulong previousSessionId = 0)
        {
            Packet_Header header;
            SESSION_SETUP_Response sessionSetupResponse;

            ulong messageId = generateMessageId(sequenceWindow);
            ushort creditCharge = generateCreditCharge(1);

            // Need to consume credit from sequence window first according to TD
            ConsumeCredit(messageId, creditCharge);

            uint status = Smb2Client.SessionSetup(
                1,
                creditRequest,
                headerFlags,
                messageId,
                sessionId,
                sessionSetupFlags,
                securityMode,
                capabilities,
                previousSessionId,
                token,
                out sessionId,
                out serverToken,
                out header,
                out sessionSetupResponse);

            ProduceCredit(messageId, header);

            return status;
        }