Exemple #1
0
        public ICMPPacket(uint aSrcIP, uint aDestIP, ICMPType aType, byte[] aData, byte aCode)
        {
            mICMPHead = base.Initialize(
                aData,      //Data in ICMP body
                8,          //Size of ICMP header
                0x01,       //ICMP
                aSrcIP,
                aDestIP
                );

            this.Type = aType;
            this.Code = aCode;
        }
        public ICMPPacket(uint aSrcIP, uint aDestIP, ICMPType aType, byte[] aData, byte aCode)
        {
            mICMPHead = base.Initialize(
                    aData,  //Data in ICMP body
                    8,      //Size of ICMP header
                    0x01,   //ICMP
                    aSrcIP, 
                    aDestIP
                    );

            this.Type = aType;
            this.Code = aCode;
        }
Exemple #3
0
        public ICMPPacket(int startIndex, byte[] bytes)
            : base(startIndex, bytes)
        {
            _type = (ICMPType)bytes[startIndex];
            _code = bytes[startIndex + 1];
            _checksum = (ushort)IPAddress.HostToNetworkOrder(BitConverter.ToInt16(bytes, startIndex + 2));

            bytes[startIndex + 2] = 0;
            bytes[startIndex + 3] = 0;

            _identifier = (ushort)IPAddress.HostToNetworkOrder(BitConverter.ToInt16(bytes, startIndex + 4));
            _sequenceNumber = (ushort)IPAddress.HostToNetworkOrder(BitConverter.ToInt16(bytes, startIndex + 6));

            int dataStartIndex = startIndex + 8;
            int dataLength = bytes.Length - dataStartIndex;

            _data = new byte[dataLength];

            for (int i = dataStartIndex; i < bytes.Length; i++)
            {
                _data[i - dataStartIndex] = bytes[i];
            }
        }
Exemple #4
0
 public ICMPMessage(ICMPType type, IPAddress destination)
 {
     this.Type = type;
     this.Destination = destination;
 }