示例#1
0
        public IPHeaderV4(BinaryReader binaryReader, IP2Location.Component ip2l)
        {
            try
            {
                _headerLength   = binaryReader.ReadByte();
                _headerLength <<= 4;
                _headerLength >>= 4;
                _headerLength  *= 4;

                _differentiatedServices = binaryReader.ReadByte();

                _totalLength = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());

                _identification = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());

                _flagsAndOffset = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());

                _timeToLive = binaryReader.ReadByte();

                _protocol = binaryReader.ReadByte();

                _checksum = IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());

                SourceAddress = new ExtendedIpAddress((uint)(binaryReader.ReadInt32()), ip2l);

                DestinationAddress = new ExtendedIpAddress((uint)(binaryReader.ReadInt32()), ip2l);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PraisedSniffer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        public IPHeaderV6(BinaryReader binaryReader, IP2Location.Component ip2l)
        {
            _versionTrafficClassAndFlowLabel = (uint)IPAddress.NetworkToHostOrder(binaryReader.ReadInt32());

            _payloadLength = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());

            _nextHeader = binaryReader.ReadByte();

            _hopLimit = binaryReader.ReadByte();

            for (int i = 0; i < 16; i++)
            {
                _sourceAddress[i] = binaryReader.ReadByte();
            }

            SourceAddress = new ExtendedIpAddress(_sourceAddress, ip2l);
            SourceAddress.ToString();

            for (int i = 0; i < 16; i++)
            {
                _destinationAddress[i] = binaryReader.ReadByte();
            }

            DestinationAddress = new ExtendedIpAddress(_destinationAddress, ip2l);
        }