Ejemplo n.º 1
0
 //private static int ConnectPacketSize = 8;
 //public static readonly int PacketSize = BasePacketSize + ConnectPacketSize;
 public ConnectPacket(byte[] data) : base(data)
 {
     RemoteIP    = BitConverter.ToUInt32(ByteExtensions.SubBytes(data, 13, sizeof(uint)));
     RemotePort  = BitConverter.ToUInt16(ByteExtensions.SubBytes(data, 17, sizeof(ushort)));
     GotYourData = data[19];
     Finished    = data[20];
 }
Ejemplo n.º 2
0
 public InitPacket(byte[] data) : base(data)
 {
     PortType    = data[13];                                                                 //02
     ClientIndex = data[14];                                                                 //00
     UseGamePort = data[15];                                                                 //00
     LocalIp     = BitConverter.ToUInt32(ByteExtensions.SubBytes(data, 16, sizeof(uint)));   //00 - 00 - 00 - 00
     LocalPort   = BitConverter.ToUInt16(ByteExtensions.SubBytes(data, 20, sizeof(ushort))); //00 - 00
 }
Ejemplo n.º 3
0
        public ReportPacket(byte[] data) : base(data)
        {
            PortType    = data[13];
            ClientIndex = data[14];
            NegResult   = data[15];

            byte[] tempNatType = ByteExtensions.SubBytes(data, 17, sizeof(int));
            NatType = (NatType)BitConverter.ToInt32(tempNatType, 0);

            byte[] tempNatMappingScheme = ByteExtensions.SubBytes(data, 19, sizeof(int));
            NatMappingScheme = (NatMappingScheme)BitConverter.ToInt32(tempNatMappingScheme, 0);

            Array.Copy(data, 23, GameName, 0, 50);
        }
Ejemplo n.º 4
0
        public BasePacket(byte[] data)
        {
            if (data.Length < BasePacketSize)
            {
                return;
            }

            byte[] sub = ByteExtensions.SubBytes(data, 0, magicDataLen);
            //bool isEqual = Array.Equals(sub, NatNegInfo.MagicData);
            if (sub[0] != NatNegInfo.MagicData[0] || sub[1] != NatNegInfo.MagicData[1] || sub[2] != NatNegInfo.MagicData[2])
            {
                return;
            }

            if (data[magicDataLen + 2] < 0 || data[magicDataLen + 2] > (byte)NatPacketType.PreInitAck)
            {
                return;
            }

            Version    = data[magicDataLen];
            PacketType = (NatPacketType)data[magicDataLen + 1];
            Cookie     = BitConverter.ToInt32(ByteExtensions.SubBytes(data, magicDataLen + 2, 4));
        }