예제 #1
0
        public TCPPacket(IPv4Packet Packet) : base(Packet)
        {
            SourcePort = (payload[0] << 8) | payload[1];
            DestPort   = (payload[2] << 8) | payload[3];
            SeqNumber  = (payload[4] << 24) | (payload[5] << 16)
                         | (payload[6] << 8) | payload[7];
            AckNumber = (payload[8] << 24) | (payload[9] << 16)
                        | (payload[10] << 8) | payload[11];
            DataOffset    = (payload[12] & 0xF0) >> 4;
            NS            = (payload[12] & 0x01) == 1;
            CWR           = (payload[13] & 0x80) == 1;
            ECE           = (payload[13] & 0x40) == 1;
            URG           = (payload[13] & 0x20) == 1;
            ACK           = (payload[13] & 0x10) == 1;
            PSH           = (payload[13] & 0x08) == 1;
            RST           = (payload[13] & 0x04) == 1;
            SYN           = (payload[13] & 0x02) == 1;
            FIN           = (payload[13] & 0x01) == 1;
            WindowSize    = (payload[14] << 8) | payload[15];
            Checksum      = (payload[16] << 8) | payload[17];
            UrgentPointer = (payload[18] << 8) | payload[19];

            if (DataOffset > 5)
            {
                Options = new byte[(DataOffset - 5) * 4];
                Buffer.BlockCopy(payload, 20, Options, 0, (DataOffset - 5) * 4);
            }

            Data = new byte[Header.TotalLength - Header.IHL * 4 - DataOffset * 4];
            Buffer.BlockCopy(payload, DataOffset * 4, Data, 0, Header.TotalLength - Header.IHL * 4 - DataOffset * 4);
        }
예제 #2
0
 public UDPPacket(IPv4Packet Packet) : base(Packet)
 {
     SourcePort = (payload[0] << 8) | payload[1];
     DestPort   = (payload[2] << 8) | payload[3];
     Length     = (payload[4] << 8) | payload[5];
     Checksum   = (payload[6] << 8) | payload[7];
     Data       = new byte[Length - 8];
     Buffer.BlockCopy(payload, 8, Data, 0, Length - 8);
 }
예제 #3
0
 public ICMPPacket(IPv4Packet Packet) : base(Packet)
 {
     Type     = payload[0];
     Code     = payload[1];
     Checksum = (payload[2] << 8) | payload[3];
     PingId   = (payload[4] << 8) | payload[5];
     PingSeq  = (payload[6] << 8) | payload[7];
     Data     = new byte[payload.Length - 8];
     Buffer.BlockCopy(payload, 8, Data, 0, payload.Length - 8);
 }
예제 #4
0
 public IPv4Packet(IPv4Packet Packet) : this(Packet.Header, Packet.payload)
 {
 }