public BulletinBoardSendPostSummaryPacket(BulletinBoard Board, BulletinBoardPost Post) : base(0x71) { // Set the maximum size EnsureCapacity(1024); // Fill the packet data UnderlyingStream.Write((byte)BulletinPacket.PacketSubType.SendPostSummary); int BoardSerial = Board.Serial; if ((Post.RootParent != null) && (Post.RootParent is BulletinBoard)) { BoardSerial = (((Item)(Post.RootParent)).Serial); } UnderlyingStream.Write((int)BoardSerial); // Bulletin Board Serial UnderlyingStream.Write((int)Post.Serial); // Post Serial int ParentSerial = Board.Serial; if ((Post.Parent != null) && ((Post.Parent is BulletinBoard) || (Post.Parent is BulletinBoardPost))) { ParentSerial = (((Item)(Post.Parent)).Serial); } UnderlyingStream.Write((int)(ParentSerial == BoardSerial ? 0 : ParentSerial)); // Parent Serial (if it is a reply) UnderlyingStream.Write((byte)(Post.Author.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Author); UnderlyingStream.Write((byte)(Post.Subject.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Subject); UnderlyingStream.Write((byte)(Post.Date.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Date); // Log the raw packet info BulletinPacket.LogPacket("BulletinBoardSendPostSummaryPacket", UnderlyingStream.ToArray()); }
public BulletinBoardOpenPacket(BulletinBoard Board) : base(0x71) { // Don't need much room here (just enough to take into account a // non-default bulletin board name) EnsureCapacity(256); // Get the name of the bulletin board string BoardName = Board.Name == null ? "Bulletin Board" : Board.Name; // Fill the packet data UnderlyingStream.Write((byte)BulletinPacket.PacketSubType.DisplayBoard); UnderlyingStream.Write((int)Board.Serial); UnderlyingStream.WriteAsciiNull(BoardName); // Log the raw packet info BulletinPacket.LogPacket("BulletinBoardOpenPacket", UnderlyingStream.ToArray()); }
public AddPostReplyItemPacket(BulletinBoardPost Post) : base(0x25, 21) { // Add the post to the bulletin board UnderlyingStream.Write((int)Post.Serial); UnderlyingStream.Write((byte)0x0e); // Model High UnderlyingStream.Write((byte)0xb0); // Model Low UnderlyingStream.Write((byte)0x00); // Unknown UnderlyingStream.Write((byte)0x00); // Item Count High UnderlyingStream.Write((byte)0x00); // Item Count Low UnderlyingStream.Write((byte)0x00); // X Location High UnderlyingStream.Write((byte)0x00); // X Location Low UnderlyingStream.Write((byte)0x00); // Y Location High UnderlyingStream.Write((byte)0x00); // Y Location Low UnderlyingStream.Write((byte)0x00); UnderlyingStream.Write((int)(((Item)(Post.RootParent)).Serial)); // Parent item serial number UnderlyingStream.Write((byte)0x00); // Colour High UnderlyingStream.Write((byte)0x00); // Colour Low BulletinPacket.LogPacket("AddPostReplyItemPacket", UnderlyingStream.ToArray()); }
private void EncryptAndAddHash(INetState ns) { byte[] bufferUnencrypted = UnderlyingStream.ToArray(); // this is where we would add postfix padding if we were using a block cipher if (!Cryptor.CreateMAC(ns.Https.CipherSuite, ns.Https.EnMAC, ns.Https.SequenceNumberSent, RecordType, bufferUnencrypted, 5, out byte[] mac))
public BulletinBoardPostPacket(BulletinBoardPost Post) : base(0x71) { // Set the maximum size EnsureCapacity(65535); // Fill the packet data UnderlyingStream.Write((byte)BulletinPacket.PacketSubType.SendPostMessage); int BoardSerial = 0; if ((Post.RootParent != null) && (Post.RootParent is BulletinBoard)) { BoardSerial = (((Item)(Post.RootParent)).Serial); } UnderlyingStream.Write((int)BoardSerial); // Bulletin Board Serial UnderlyingStream.Write((int)Post.Serial); // Post Serial UnderlyingStream.Write((byte)(Post.Author.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Author); UnderlyingStream.Write((byte)(Post.Subject.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Subject); UnderlyingStream.Write((byte)(Post.Date.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Date); #region Unknown Constant // Some constant that is needed (DON'T Change Anything in here unless // you've figured out what the contents of the packet do) //"\x01\x90\x83\xea\x06\x15\x2e\x07\x1d\x17\x0f\x07\x37\x1f\x7b // \x05\xeb\x20\x3d\x04\x66\x20\x4d\x04\x66\x0e\x75\x00\x00" UnderlyingStream.Write((byte)0x01); UnderlyingStream.Write((byte)0x90); UnderlyingStream.Write((byte)0x83); UnderlyingStream.Write((byte)0xEA); UnderlyingStream.Write((byte)0x06); UnderlyingStream.Write((byte)0x15); UnderlyingStream.Write((byte)0x2E); UnderlyingStream.Write((byte)0x07); UnderlyingStream.Write((byte)0x1D); UnderlyingStream.Write((byte)0x17); UnderlyingStream.Write((byte)0x0F); UnderlyingStream.Write((byte)0x07); UnderlyingStream.Write((byte)0x37); UnderlyingStream.Write((byte)0x1F); UnderlyingStream.Write((byte)0x7B); UnderlyingStream.Write((byte)0x05); UnderlyingStream.Write((byte)0xEB); UnderlyingStream.Write((byte)0x20); UnderlyingStream.Write((byte)0x3D); UnderlyingStream.Write((byte)0x04); UnderlyingStream.Write((byte)0x66); UnderlyingStream.Write((byte)0x20); UnderlyingStream.Write((byte)0x4D); UnderlyingStream.Write((byte)0x04); UnderlyingStream.Write((byte)0x66); UnderlyingStream.Write((byte)0x0E); UnderlyingStream.Write((byte)0x75); UnderlyingStream.Write((byte)0x00); UnderlyingStream.Write((byte)0x00); #endregion // Lets assume that all of the previous data that is of varying size // was completely full (255 characters for Author, Subject, and Date) // The total size of the packet so far would then be (in bytes): // 1+2+1+4+4+1+255+1+255+1+255+29 = 809 Bytes // That leaves 65535-809 = 64726 Bytes for the remaining lines of the // message. Each line can contain a maximum of 255 characters (including the terminating null) // And there can only be a total of 255 lines so, to be safe we are only // going to allow 250 lines max! That will result in a total of // 250x256 = 64000 Bytes total for a complete message (way under the 64766 limit) // Set the maximum number of lines int MaxLines = (Post.Message.Length < 250 ? Post.Message.Length : 250); UnderlyingStream.Write((byte)MaxLines); // Add each line (up to the maximum number of lines) for (int x = 0; ((x < Post.Message.Length) && (x < 250)); x++) { UnderlyingStream.Write((byte)(Post.Message[x].Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Message[x]); } // Log the raw packet info BulletinPacket.LogPacket("BulletinBoardPostPacket", UnderlyingStream.ToArray()); }
public BulletinBoardFillItemsPacket(BulletinBoard Board) : base(0x3c) { // Since the maximum size of a packet is 65535 and the overhead of the // segment is 19 characters, lets ensure the maximum capacity is available EnsureCapacity(65535); // There will be a check to allow only a maximum of 3072 posts to be shown // on a single bulletin board // 3072x19 bytes for an item segment = 58368 bytes (should be very safe) // Get all of the items associated with this bulletin board //ArrayList OriginalPosts = Board.Items; //List<Item> OriginalPosts = Board.Items; List <Item> OriginalPosts = new List <Item>(); foreach (Item item in World.Items.Values) { // Add each global post to the global post list if (item is BulletinBoardPost) { //all posts go on every messagebaord //if (item.Parent == Board) OriginalPosts.Add(item); } } // Do a deep copy of each post on the board (need to do this so that // the replies can be added to the outgoing message without modifiying // the original array list) List <Item> AllPosts = new List <Item>(); //ArrayList AllPosts = new ArrayList(OriginalPosts.Count); foreach (BulletinBoardPost OriginalPost in OriginalPosts) { AllPosts.Add(OriginalPost); } // Add any global posts to the top of the new list. // Global posts can not be replied to since they don't belong to // a specific bulletin board. if (BulletinBoardGlobalPostList.m_GlobalPostList.Count > 0) { AllPosts.InsertRange(0, BulletinBoardGlobalPostList.m_GlobalPostList); } // Collect any replies to posts and insert them into the array list // as long as the array list contains less than 3072 items for (int x = 0; x < AllPosts.Count; x++) { // Get the current post object in the list BulletinBoardPost Post = AllPosts[x] as BulletinBoardPost; // Check if the object retrieved from the list was a post if (Post != null) { // Check to see if this post item has any child posts if (Post.Items.Count > 0) { // Collect all child posts (replies) and insert them // into the original array list after the current posts // position. foreach (BulletinBoardPost Reply in Post.Items) { AllPosts.Add(Reply); // Add the reply posts to the end } } } } // Fill in the mandatory pieces of the packet UnderlyingStream.Write((short)AllPosts.Count); // Check each root item for any children foreach (BulletinBoardPost Post in AllPosts) { UnderlyingStream.Write((int)Post.Serial); UnderlyingStream.Write((byte)0x0E); // Model High UnderlyingStream.Write((byte)0xB0); // Model Low UnderlyingStream.Write((byte)0x00); // Unknown UnderlyingStream.Write((byte)0x00); // Items In Stack High UnderlyingStream.Write((byte)0x00); // Items In Stack Low UnderlyingStream.Write((byte)0x00); // X Position High UnderlyingStream.Write((byte)0x3A); // X Position Low UnderlyingStream.Write((byte)0x00); // Y Position High UnderlyingStream.Write((byte)0x3A); // Y Position Low UnderlyingStream.Write((byte)0x00); UnderlyingStream.Write((int)Board.Serial); UnderlyingStream.Write((byte)0x00); // Colour High UnderlyingStream.Write((byte)0x00); // Colour Low } // Log the raw packet info BulletinPacket.LogPacket("BulletinBoardFillItemsPacket", UnderlyingStream.ToArray()); }