/// <summary>
        /// Send a Dfs request to server
        /// </summary>
        /// <param name="payload">REQ_GET_DFS_REFERRAL structure in byte array</param>
        /// <param name="isEX">
        /// Boolean which indicates whether payload contains DFS_GET_REFERRAL_EX message
        /// MUST be false for SMB transport.
        /// </param>>
        /// <exception cref="System.ArgumentNullException">the payload to be sent is null.</exception>
        /// <exception cref="ArgumentException">extended request packet cannot be in payload</exception>
        /// <exception cref="System.InvalidOperationException">The transport is not connected</exception>
        public override void SendDfscPayload(byte[] payload, bool isEX)
        {
            if (isEX)
            {
                throw new ArgumentException("REQ_DFS_GET_REFERRAL_EX message not supported over SMB transport");
            }
            if (this.smbClient == null)
            {
                throw new InvalidOperationException("The transport is not connected.");
            }

            if (payload == null)
            {
                throw new ArgumentNullException("payload");
            }
            REQ_GET_DFS_REFERRAL referral = new REQ_GET_DFS_REFERRAL();

            // Put payload[0] into the lower byte of MaxReferralLevel
            // Put payload[1] into the upper byte of MaxReferralLevel
            // Sample: payload[0] = 0x0B; payload[1] = 0x0A
            // MaxReferralLevel = 0x0A0B;
            referral.MaxReferralLevel = (ushort)(payload[1] << 8 | payload[0]);
            referral.RequestFileName  = new byte[payload.Length - sizeofMaxReferralLevel];

            Array.Copy(payload, sizeofMaxReferralLevel, referral.RequestFileName, 0, referral.RequestFileName.Length);
            SmbTrans2GetDfsReferralRequestPacket request = this.smbClient.CreateTrans2GetDFSReferralRequest(
                this.treeId, Trans2SmbParametersFlags.NONE, "", referral);

            if (this.isSignRequired)
            {
                request.Sign(this.NextSequenceNumber, this.sessionKey);
            }
            this.smbClient.SendPacket(request);
        }
Esempio n. 2
0
        /// <summary>
        /// find the transaction2 packet.
        /// </summary>
        /// <param name="command">the command of transaction2 packet.</param>
        /// <returns>the target transaction2 packet</returns>
        private static SmbPacket FindTheTrans2Packet(Trans2SubCommand command)
        {
            SmbPacket smbPacket = null;

            switch ((Trans2SubCommand)command)
            {
            case Trans2SubCommand.TRANS2_FIND_FIRST2:
                smbPacket = new SmbTrans2FindFirst2RequestPacket();
                break;

            case Trans2SubCommand.TRANS2_FIND_NEXT2:
                smbPacket = new SmbTrans2FindNext2RequestPacket();
                break;

            case Trans2SubCommand.TRANS2_QUERY_FS_INFORMATION:
                smbPacket = new SmbTrans2QueryFsInformationRequestPacket();
                break;

            case Trans2SubCommand.TRANS2_SET_FS_INFORMATION:
                smbPacket = new SmbTrans2SetFsInformationRequestPacket();
                break;

            case Trans2SubCommand.TRANS2_QUERY_PATH_INFORMATION:
                smbPacket = new SmbTrans2QueryPathInformationRequestPacket();
                break;

            case Trans2SubCommand.TRANS2_SET_PATH_INFORMATION:
                smbPacket = new SmbTrans2SetPathInformationRequestPacket();
                break;

            case Trans2SubCommand.TRANS2_QUERY_FILE_INFORMATION:
                smbPacket = new SmbTrans2QueryFileInformationRequestPacket();
                break;

            case Trans2SubCommand.TRANS2_SET_FILE_INFORMATION:
                smbPacket = new SmbTrans2SetFileInformationRequestPacket();
                break;

            case Trans2SubCommand.TRANS2_GET_DFS_REFERRAL:
                smbPacket = new SmbTrans2GetDfsReferralRequestPacket();
                break;

            default:
                break;
            }
            return(smbPacket);
        }
Esempio n. 3
0
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbTrans2GetDfsReferralRequestPacket(SmbTrans2GetDfsReferralRequestPacket packet)
     : base(packet)
 {
 }
 /// <summary>
 /// Deep copy constructor. 
 /// </summary>
 public SmbTrans2GetDfsReferralRequestPacket(SmbTrans2GetDfsReferralRequestPacket packet)
     : base(packet)
 {
 }
        /// <summary>
        /// find the transaction2 packet.
        /// </summary>
        /// <param name="command">the command of transaction2 packet.</param>
        /// <returns>the target transaction2 packet</returns>
        private static SmbPacket FindTheTrans2Packet(Trans2SubCommand command)
        {
            SmbPacket smbPacket = null;
            switch ((Trans2SubCommand)command)
            {
                case Trans2SubCommand.TRANS2_FIND_FIRST2:
                    smbPacket = new SmbTrans2FindFirst2RequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_FIND_NEXT2:
                    smbPacket = new SmbTrans2FindNext2RequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_QUERY_FS_INFORMATION:
                    smbPacket = new SmbTrans2QueryFsInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_SET_FS_INFORMATION:
                    smbPacket = new SmbTrans2SetFsInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_QUERY_PATH_INFORMATION:
                    smbPacket = new SmbTrans2QueryPathInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_SET_PATH_INFORMATION:
                    smbPacket = new SmbTrans2SetPathInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_QUERY_FILE_INFORMATION:
                    smbPacket = new SmbTrans2QueryFileInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_SET_FILE_INFORMATION:
                    smbPacket = new SmbTrans2SetFileInformationRequestPacket();
                    break;

                case Trans2SubCommand.TRANS2_GET_DFS_REFERRAL:
                    smbPacket = new SmbTrans2GetDfsReferralRequestPacket();
                    break;

                default:
                    break;
            }
            return smbPacket;
        }