public Command52(byte[] commandID, byte[] senderPeerID, byte[] sourceSearchID, byte[] hashedFileHash) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (sourceSearchID == null) throw new ArgumentNullException("sourceSearchID"); if (sourceSearchID.Length != 48) throw new ArgumentException(); if (hashedFileHash == null) throw new ArgumentNullException("hashedFileHash"); if (hashedFileHash.Length != 64) throw new ArgumentException(); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_SourceSearchID = sourceSearchID; m_HashedFileHash = hashedFileHash; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x52); m_Command.Write(0x52); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_SourceSearchID); m_Command.Write(m_HashedFileHash); }
public Command71(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] feedbackID, uint queueLength) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (receiverPeerID == null) throw new ArgumentNullException("receiverPeerID"); if (receiverPeerID.Length != 48) throw new ArgumentException(); if (feedbackID == null) throw new ArgumentNullException("feedbackID"); if (feedbackID.Length != 48) throw new ArgumentException(); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_FeedbackID = feedbackID; m_QueueLength = queueLength; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x71); m_Command.Write((byte)0x71); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_FeedbackID); m_Command.Write(m_QueueLength); }
public Command22(byte[] commandID, byte[] senderPeerID, byte[] searchID, string searchPattern) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (searchID == null) throw new ArgumentNullException("searchID"); if (searchID.Length != 48) throw new ArgumentException(); if (searchPattern == null) throw new ArgumentNullException("searchPattern"); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_SearchID = searchID; m_SearchPattern = searchPattern; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x22); m_Command.Write(0x22); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_SearchID); m_Command.Write(m_SearchPattern); }
public Command63(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] sourceSearchID) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (receiverPeerID == null) throw new ArgumentNullException("receiverPeerID"); if (receiverPeerID.Length != 48) throw new ArgumentException(); if (sourceSearchID == null) throw new ArgumentNullException("sourceSearchID"); if (sourceSearchID.Length != 48) throw new ArgumentException(); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_SourceSearchID = sourceSearchID; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x63); m_Command.Write(0x63); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_SourceSearchID); }
public Command61(byte[] commandID, ushort reserved, ushort hopCount, byte[] senderPeerID, byte[] sourceSearchID, byte[] hashedFileHash) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (sourceSearchID == null) throw new ArgumentNullException("sourceSearchID"); if (sourceSearchID.Length != 48) throw new ArgumentException(); if (hashedFileHash == null) throw new ArgumentNullException("hashedFileHash"); if (hashedFileHash.Length != 64) throw new ArgumentException(); m_CommandID = commandID; m_Reserved = reserved; m_HopCount = hopCount; m_SenderPeerID = senderPeerID; m_SourceSearchID = sourceSearchID; m_HashedFileHash = hashedFileHash; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x61); m_Command.Write(0x61); m_Command.Write(m_CommandID); m_Command.Write(m_Reserved); m_Command.Write(m_HopCount); m_Command.Write(m_SenderPeerID); m_Command.Write(m_SourceSearchID); m_Command.Write(m_HashedFileHash); }
public Command21(byte[] commandID, ushort reserved, ushort hopCount, byte[] senderPeerID, byte[] searchID, string searchPattern) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (searchID == null) throw new ArgumentNullException("searchID"); if (searchID.Length != 48) throw new ArgumentException(); if (searchPattern == null) throw new ArgumentNullException("searchPattern"); m_CommandID = commandID; m_Reserved = reserved; m_HopCount = hopCount; m_SenderPeerID = senderPeerID; m_SearchID = searchID; m_SearchPattern = searchPattern; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x21); m_Command.Write(0x21); m_Command.Write(m_CommandID); m_Command.Write(m_Reserved); m_Command.Write(m_HopCount); m_Command.Write(m_SenderPeerID); m_Command.Write(m_SearchID); m_Command.Write(m_SearchPattern); }
public Command44(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] downloadID) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (receiverPeerID == null) throw new ArgumentNullException("receiverPeerID"); if (receiverPeerID.Length != 48) throw new ArgumentException(); if (downloadID == null) throw new ArgumentNullException("downloadID"); if (downloadID.Length != 48) throw new ArgumentException(); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_DownloadID = downloadID; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x44); m_Command.Write((byte)0x44); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_DownloadID); }
public Command10(CommandBuilder command) { if (command == null) throw new ArgumentNullException("command"); m_Command = command; m_Keys.Modulus = m_Command.ReadBytes(command.ReadUInt16()); m_Keys.Exponent = m_Command.ReadBytes(command.ReadUInt16()); }
public Command10(RSAParameters keys) { m_Keys = keys; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.None, 0x10); m_Command.Write((byte)0x10); m_Command.Write((ushort)keys.Modulus.Length); m_Command.Write(keys.Modulus); m_Command.Write((ushort)keys.Exponent.Length); m_Command.Write(keys.Exponent); }
public Command44(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_DownloadID = m_Command.ReadBytes(48); }
public Command22(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_SearchID = m_Command.ReadBytes(48); m_SearchPattern = m_Command.ReadString(); }
public Command52(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_SourceSearchID = m_Command.ReadBytes(48); m_HashedFileHash = m_Command.ReadBytes(64); }
public Command71(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_FeedbackID = m_Command.ReadBytes(48); m_QueueLength = m_Command.ReadUInt32(); }
public Command64(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_SectorsMap = m_Command.ReadBytes(m_Command.ReadUInt16()); }
public Command7A(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_DownloadID = m_Command.ReadBytes(48); m_FileHashCodeResult = m_Command.ReadBytes(64); }
public Command61(CommandBuilder command) { if (command == null) throw new ArgumentNullException("command"); m_Command = command; m_CommandID = m_Command.ReadBytes(48); m_Reserved = m_Command.ReadUInt16(); m_HopCount = m_Command.ReadUInt16(); m_SenderPeerID = m_Command.ReadBytes(48); m_SourceSearchID = m_Command.ReadBytes(48); m_HashedFileHash = m_Command.ReadBytes(64); }
public Command79(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_DownloadID = m_Command.ReadBytes(48); m_Sector = m_Command.ReadUInt32(); m_SectorData = m_Command.ReadBytes(m_Command.ReadUInt16()); m_SectorHashCodeResult = m_Command.ReadBytes(64); }
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()); }
public Command12(RijndaelParameters keys) { m_Keys = keys; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.RSA, 0x12); m_Command.Write((byte)0x12); m_Command.Write((ushort)m_Keys.BlockSize); m_Command.Write((ushort)m_Keys.FeedbackSize); m_Command.Write((ushort)m_Keys.KeySize); m_Command.Write((byte)m_Keys.Mode); m_Command.Write((byte)m_Keys.Padding); m_Command.Write((byte)m_Keys.IV.Length); m_Command.Write(m_Keys.IV); m_Command.Write((byte)m_Keys.Key.Length); m_Command.Write(m_Keys.Key); }
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(); }
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 Command7A(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] downloadID, byte[] fileHashCodeResult) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (receiverPeerID == null) throw new ArgumentNullException("receiverPeerID"); if (receiverPeerID.Length != 48) throw new ArgumentException(); if (downloadID == null) throw new ArgumentNullException("downloadID"); if (downloadID.Length != 48) throw new ArgumentException(); if (fileHashCodeResult == null) throw new ArgumentNullException("fileHashCodeResult"); if (fileHashCodeResult.Length != 64) throw new ArgumentException(); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_DownloadID = downloadID; m_FileHashCodeResult = fileHashCodeResult; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x7A); m_Command.Write((byte)0x7A); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_DownloadID); m_Command.Write(m_FileHashCodeResult); }
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(); } }
public Command53(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] sourceSearchID, uint fileSize, string fileName, RIndexedHashtable <string, string> metaData, string comment, byte rating) { if (commandID == null) { throw new ArgumentNullException("commandID"); } if (commandID.Length != 48) { throw new ArgumentException(); } if (senderPeerID == null) { throw new ArgumentNullException("senderPeerID"); } if (senderPeerID.Length != 48) { throw new ArgumentException(); } if (receiverPeerID == null) { throw new ArgumentNullException("receiverPeerID"); } if (receiverPeerID.Length != 48) { throw new ArgumentException(); } if (sourceSearchID == null) { throw new ArgumentNullException("sourceSearchID"); } if (sourceSearchID.Length != 48) { throw new ArgumentException(); } if (fileName == null) { throw new ArgumentNullException("fileName"); } if (metaData == null) { throw new ArgumentNullException("metaData"); } if (comment == null) { throw new ArgumentNullException("comment"); } m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_SourceSearchID = sourceSearchID; m_FileSize = fileSize; m_FileName = fileName; m_MetaData = metaData; m_Rating = rating; m_Comment = comment; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x53); m_Command.Write(0x53); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_SourceSearchID); m_Command.Write(m_FileSize); m_Command.Write(m_FileName); m_Command.Write((ushort)m_MetaData.Count); foreach (KeyValuePair <string, string> metaDataItem in metaData) { m_Command.Write(metaDataItem.Key); m_Command.Write(metaDataItem.Value); } m_Command.Write(m_Comment); m_Command.Write(m_Rating); }
public Command46(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] downloadID, uint sector, byte[] sectorData, byte[] sectorHashCodeResult) { if (commandID == null) { throw new ArgumentNullException("commandID"); } if (commandID.Length != 48) { throw new ArgumentException(); } if (senderPeerID == null) { throw new ArgumentNullException("senderPeerID"); } if (senderPeerID.Length != 48) { throw new ArgumentException(); } if (receiverPeerID == null) { throw new ArgumentNullException("receiverPeerID"); } if (receiverPeerID.Length != 48) { throw new ArgumentException(); } if (downloadID == null) { throw new ArgumentNullException("downloadID"); } if (downloadID.Length != 48) { throw new ArgumentException(); } if (sectorData == null) { throw new ArgumentNullException("sectorData"); } if (sectorHashCodeResult == null) { throw new ArgumentNullException("sectorHashCodeResult"); } if (sectorHashCodeResult.Length != 64) { throw new ArgumentException(); } m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_DownloadID = downloadID; m_Sector = sector; m_SectorData = sectorData; m_SectorHashCodeResult = sectorHashCodeResult; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x46); m_Command.Write((byte)0x46); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_DownloadID); m_Command.Write(m_Sector); m_Command.Write((ushort)m_SectorData.Length); m_Command.Write(m_SectorData); m_Command.Write(m_SectorHashCodeResult); }
public Command53(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] sourceSearchID, uint fileSize, string fileName, RIndexedHashtable<string, string> metaData, string comment, byte rating) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (receiverPeerID == null) throw new ArgumentNullException("receiverPeerID"); if (receiverPeerID.Length != 48) throw new ArgumentException(); if (sourceSearchID == null) throw new ArgumentNullException("sourceSearchID"); if (sourceSearchID.Length != 48) throw new ArgumentException(); if (fileName == null) throw new ArgumentNullException("fileName"); if (metaData == null) throw new ArgumentNullException("metaData"); if (comment == null) throw new ArgumentNullException("comment"); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_SourceSearchID = sourceSearchID; m_FileSize = fileSize; m_FileName = fileName; m_MetaData = metaData; m_Rating = rating; m_Comment = comment; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x53); m_Command.Write(0x53); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_SourceSearchID); m_Command.Write(m_FileSize); m_Command.Write(m_FileName); m_Command.Write((ushort)m_MetaData.Count); foreach (KeyValuePair<string, string> metaDataItem in metaData) { m_Command.Write(metaDataItem.Key); m_Command.Write(metaDataItem.Value); } m_Command.Write(m_Comment); m_Command.Write(m_Rating); }
public Command79(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] downloadID, uint sector, byte[] sectorData, byte[] sectorHashCodeResult) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (receiverPeerID == null) throw new ArgumentNullException("receiverPeerID"); if (receiverPeerID.Length != 48) throw new ArgumentException(); if (downloadID == null) throw new ArgumentNullException("downloadID"); if (downloadID.Length != 48) throw new ArgumentException(); if (sectorData == null) throw new ArgumentNullException("sectorData"); if (sectorHashCodeResult == null) throw new ArgumentNullException("sectorHashCodeResult"); if (sectorHashCodeResult.Length != 64) throw new ArgumentException(); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_DownloadID = downloadID; m_Sector = sector; m_SectorData = sectorData; m_SectorHashCodeResult = sectorHashCodeResult; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x79); m_Command.Write((byte)0x79); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_DownloadID); m_Command.Write(m_Sector); m_Command.Write((ushort)m_SectorData.Length); m_Command.Write(m_SectorData); m_Command.Write(m_SectorHashCodeResult); }
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(); } }
public Command23(byte[] commandID, byte[] senderPeerID, byte[] receiverPeerID, byte[] searchID, RList<SearchResult> searchResults) { if (commandID == null) throw new ArgumentNullException("commandID"); if (commandID.Length != 48) throw new ArgumentException(); if (senderPeerID == null) throw new ArgumentNullException("senderPeerID"); if (senderPeerID.Length != 48) throw new ArgumentException(); if (receiverPeerID == null) throw new ArgumentNullException("receiverPeerID"); if (receiverPeerID.Length != 48) throw new ArgumentException(); if (searchID == null) throw new ArgumentNullException("searchID"); if (searchID.Length != 48) throw new ArgumentException(); if (searchResults == null) throw new ArgumentNullException("searchResults"); m_CommandID = commandID; m_SenderPeerID = senderPeerID; m_ReceiverPeerID = receiverPeerID; m_SearchID = searchID; m_SearchResults = searchResults; m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.Rijndael, 0x23); m_Command.Write(0x23); m_Command.Write(m_CommandID); m_Command.Write(m_SenderPeerID); m_Command.Write(m_ReceiverPeerID); m_Command.Write(m_SearchID); m_Command.Write((ushort)m_SearchResults.Count); foreach (SearchResult searchResult in searchResults) { m_Command.Write(searchResult.FileHash); m_Command.Write(searchResult.FileSize); m_Command.Write(searchResult.FileName); m_Command.Write((ushort)searchResult.MetaData.Count); foreach (KeyValuePair<string, string> metaData in searchResult.MetaData) { m_Command.Write(metaData.Key); m_Command.Write(metaData.Value); } m_Command.Write(searchResult.Comment); m_Command.Write(searchResult.Rating); } }