Ejemplo n.º 1
0
        internal Lease(BinaryReader bR)
        {
            switch (bR.ReadByte())
            {
            case 1:
                _type             = (LeaseType)bR.ReadByte();
                _clientIdentifier = DhcpOption.Parse(bR.BaseStream) as ClientIdentifierOption;
                _clientIdentifier.ParseOptionValue();

                _hostName = bR.ReadShortString();
                if (_hostName == "")
                {
                    _hostName = null;
                }

                _hardwareAddress = bR.ReadBuffer();
                _address         = IPAddressExtension.Parse(bR);
                _leaseObtained   = bR.ReadDate();
                _leaseExpires    = bR.ReadDate();
                break;

            default:
                throw new InvalidDataException("Lease data format version not supported.");
            }
        }
Ejemplo n.º 2
0
        internal Lease(BinaryReader bR)
        {
            byte version = bR.ReadByte();

            switch (version)
            {
            case 1:
            case 2:
                _type             = (LeaseType)bR.ReadByte();
                _clientIdentifier = DhcpOption.Parse(bR.BaseStream) as ClientIdentifierOption;
                _clientIdentifier.ParseOptionValue();

                _hostName = bR.ReadShortString();
                if (string.IsNullOrWhiteSpace(_hostName))
                {
                    _hostName = null;
                }

                _hardwareAddress = bR.ReadBuffer();
                _address         = IPAddressExtension.Parse(bR);

                if (version >= 2)
                {
                    _comments = bR.ReadShortString();
                    if (string.IsNullOrWhiteSpace(_comments))
                    {
                        _comments = null;
                    }
                }

                _leaseObtained = bR.ReadDateTime();
                _leaseExpires  = bR.ReadDateTime();
                break;

            default:
                throw new InvalidDataException("Lease data format version not supported.");
            }
        }