Beispiel #1
0
        public Command12(CommandBuilder command)
        {
            if (command == null)
                throw new ArgumentNullException("command");

            m_Command = command;
            m_Keys.BlockSize = m_Command.ReadUInt16();
            m_Keys.FeedbackSize = m_Command.ReadUInt16();
            m_Keys.KeySize = m_Command.ReadUInt16();
            m_Keys.Mode = (CipherMode)m_Command.ReadByte();
            m_Keys.Padding = (PaddingMode)m_Command.ReadByte();
            m_Keys.IV = m_Command.ReadBytes(m_Command.ReadByte());
            m_Keys.Key = m_Command.ReadBytes(m_Command.ReadByte());
        }
Beispiel #2
0
        public Command12(CommandBuilder command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            m_Command           = command;
            m_Keys.BlockSize    = m_Command.ReadUInt16();
            m_Keys.FeedbackSize = m_Command.ReadUInt16();
            m_Keys.KeySize      = m_Command.ReadUInt16();
            m_Keys.Mode         = (CipherMode)m_Command.ReadByte();
            m_Keys.Padding      = (PaddingMode)m_Command.ReadByte();
            m_Keys.IV           = m_Command.ReadBytes(m_Command.ReadByte());
            m_Keys.Key          = m_Command.ReadBytes(m_Command.ReadByte());
        }
Beispiel #3
0
        public Command54(CommandBuilder command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            m_Command        = command;
            m_CommandID      = m_Command.ReadBytes(48);
            m_SenderPeerID   = m_Command.ReadBytes(48);
            m_ReceiverPeerID = m_Command.ReadBytes(48);
            m_SourceSearchID = m_Command.ReadBytes(48);
            m_FileSize       = m_Command.ReadUInt32();
            m_FileName       = m_Command.ReadString();
            m_MetaData       = new RIndexedHashtable <string, string>();
            ushort metaDataCount = m_Command.ReadUInt16();

            for (int n = 0; n < metaDataCount; n++)
            {
                m_MetaData.Add(m_Command.ReadString(), m_Command.ReadString());
            }
            m_Comment    = m_Command.ReadString();
            m_Rating     = m_Command.ReadByte();
            m_SectorsMap = m_Command.ReadBytes(m_Command.ReadUInt16());
        }
Beispiel #4
0
        public Command53(CommandBuilder command)
        {
            if (command == null)
                throw new ArgumentNullException("command");

            m_Command = command;
            m_CommandID = m_Command.ReadBytes(48);
            m_SenderPeerID = m_Command.ReadBytes(48);
            m_ReceiverPeerID = m_Command.ReadBytes(48);
            m_SourceSearchID = m_Command.ReadBytes(48);
            m_FileSize = m_Command.ReadUInt32();
            m_FileName = m_Command.ReadString();
            m_MetaData = new RIndexedHashtable<string, string>();
            ushort metaDataCount = m_Command.ReadUInt16();
            for (int n = 0; n < metaDataCount; n++)
                m_MetaData.Add(m_Command.ReadString(), m_Command.ReadString());
            m_Comment = m_Command.ReadString();
            m_Rating = m_Command.ReadByte();
        }
Beispiel #5
0
        public Command23(CommandBuilder command)
        {
            if (command == null)
                throw new ArgumentNullException("command");

            m_Command = command;
            m_CommandID = m_Command.ReadBytes(48);
            m_SenderPeerID = m_Command.ReadBytes(48);
            m_ReceiverPeerID = m_Command.ReadBytes(48);
            m_SearchID = m_Command.ReadBytes(48);
            m_SearchResults = new RList<SearchResult>();
            ushort searchResultsCount = m_Command.ReadUInt16();
            for (int n = 0; n < searchResultsCount; n++)
            {
                byte[] fileHash = m_Command.ReadBytes(64);
                uint fileSize = m_Command.ReadUInt32();
                string fileName = m_Command.ReadString();
                RIndexedHashtable<string, string> metaData = new RIndexedHashtable<string, string>();
                ushort metaDataCount = m_Command.ReadUInt16();
                for (int m = 0; m < metaDataCount; m++)
                    metaData.Add(m_Command.ReadString(), m_Command.ReadString());
                m_SearchResults.Add(new SearchResult(fileHash, fileSize, fileName, metaData, m_Command.ReadString(), m_Command.ReadByte()));
            }
        }
Beispiel #6
0
        public Command23(CommandBuilder command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            m_Command        = command;
            m_CommandID      = m_Command.ReadBytes(48);
            m_SenderPeerID   = m_Command.ReadBytes(48);
            m_ReceiverPeerID = m_Command.ReadBytes(48);
            m_SearchID       = m_Command.ReadBytes(48);
            m_SearchResults  = new RList <SearchResult>();
            ushort searchResultsCount = m_Command.ReadUInt16();

            for (int n = 0; n < searchResultsCount; n++)
            {
                byte[] fileHash = m_Command.ReadBytes(64);
                uint   fileSize = m_Command.ReadUInt32();
                string fileName = m_Command.ReadString();
                RIndexedHashtable <string, string> metaData = new RIndexedHashtable <string, string>();
                ushort metaDataCount = m_Command.ReadUInt16();
                for (int m = 0; m < metaDataCount; m++)
                {
                    metaData.Add(m_Command.ReadString(), m_Command.ReadString());
                }
                m_SearchResults.Add(new SearchResult(fileHash, fileSize, fileName, metaData, m_Command.ReadString(), m_Command.ReadByte()));
            }
        }
        public static Command Receive(Connection connection, byte[] receivedBuffer)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");
            if (receivedBuffer == null)
                throw new ArgumentNullException("buffer");
            if (receivedBuffer.Length < 10)
                throw new ArgumentException();

            CommandBuilder command = new CommandBuilder(connection, receivedBuffer);
            byte code = command.ReadByte();
            command.SetCommandCode(code);
            switch (code)
            {
                case 0x10:
                    return new Command10(command);
                case 0x11:
                    return new Command11(command);
                case 0x12:
                    return new Command12(command);
                case 0x13:
                    return new Command13(command);
                case 0x20:
                    return new Command20(command);
                case 0x21:
                    return new Command21(command);
                case 0x22:
                    return new Command22(command);
                case 0x23:
                    return new Command23(command);
                case 0x40:
                    return new Command40(command);
                case 0x41:
                    return new Command41(command);
                case 0x42:
                    return new Command42(command);
                case 0x43:
                    return new Command43(command);
                case 0x44:
                    return new Command44(command);
                case 0x45:
                    return new Command45(command);
                case 0x46:
                    return new Command46(command);
                case 0x50:
                    return new Command50(command);
                case 0x51:
                    return new Command51(command);
                case 0x52:
                    return new Command52(command);
                case 0x53:
                    return new Command53(command);
                case 0x54:
                    return new Command54(command);
                case 0x60:
                    return new Command60(command);
                case 0x61:
                    return new Command61(command);
                case 0x62:
                    return new Command62(command);
                case 0x63:
                    return new Command63(command);
                case 0x64:
                    return new Command64(command);
                case 0x70:
                    return new Command70(command);
                case 0x71:
                    return new Command71(command);
                case 0x72:
                    return new Command72(command);
                case 0x74:
                    return new Command74(command);
                case 0x75:
                    return new Command75(command);
                case 0x76:
                    return new Command76(command);
                case 0x78:
                    return new Command78(command);
                case 0x79:
                    return new Command79(command);
                case 0x7A:
                    return new Command7A(command);
                default:
                    throw new InvalidDataException();
            }
        }
Beispiel #8
0
        public static Command Receive(Connection connection, byte[] receivedBuffer)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (receivedBuffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (receivedBuffer.Length < 10)
            {
                throw new ArgumentException();
            }

            CommandBuilder command = new CommandBuilder(connection, receivedBuffer);
            byte           code    = command.ReadByte();

            command.SetCommandCode(code);
            switch (code)
            {
            case 0x10:
                return(new Command10(command));

            case 0x11:
                return(new Command11(command));

            case 0x12:
                return(new Command12(command));

            case 0x13:
                return(new Command13(command));

            case 0x20:
                return(new Command20(command));

            case 0x21:
                return(new Command21(command));

            case 0x22:
                return(new Command22(command));

            case 0x23:
                return(new Command23(command));

            case 0x40:
                return(new Command40(command));

            case 0x41:
                return(new Command41(command));

            case 0x42:
                return(new Command42(command));

            case 0x43:
                return(new Command43(command));

            case 0x44:
                return(new Command44(command));

            case 0x45:
                return(new Command45(command));

            case 0x46:
                return(new Command46(command));

            case 0x50:
                return(new Command50(command));

            case 0x51:
                return(new Command51(command));

            case 0x52:
                return(new Command52(command));

            case 0x53:
                return(new Command53(command));

            case 0x54:
                return(new Command54(command));

            case 0x60:
                return(new Command60(command));

            case 0x61:
                return(new Command61(command));

            case 0x62:
                return(new Command62(command));

            case 0x63:
                return(new Command63(command));

            case 0x64:
                return(new Command64(command));

            case 0x70:
                return(new Command70(command));

            case 0x71:
                return(new Command71(command));

            case 0x72:
                return(new Command72(command));

            case 0x74:
                return(new Command74(command));

            case 0x75:
                return(new Command75(command));

            case 0x76:
                return(new Command76(command));

            case 0x78:
                return(new Command78(command));

            case 0x79:
                return(new Command79(command));

            case 0x7A:
                return(new Command7A(command));

            default:
                throw new InvalidDataException();
            }
        }