Ejemplo n.º 1
0
        internal static DnsOptions Read(DataSegment data)
        {
            List <DnsOption> options = new List <DnsOption>();

            while (data.Length != 0)
            {
                if (data.Length < DnsOption.MinimumLength)
                {
                    return(null);
                }
                DnsOptionCode code             = (DnsOptionCode)data.ReadUShort(0, Endianity.Big);
                ushort        optionDataLength = data.ReadUShort(sizeof(ushort), Endianity.Big);

                int optionLength = DnsOption.MinimumLength + optionDataLength;
                if (data.Length < optionLength)
                {
                    return(null);
                }
                DnsOption option = DnsOption.CreateInstance(code, data.Subsegment(DnsOption.MinimumLength, optionDataLength));
                if (option == null)
                {
                    return(null);
                }
                options.Add(option);

                data = data.Subsegment(optionLength, data.Length - optionLength);
            }

            return(new DnsOptions(options));
        }
Ejemplo n.º 2
0
        internal override bool EqualsData(DnsOption other)
        {
            DnsOptionLongLivedQuery castedOther = (DnsOptionLongLivedQuery)other;

            return(Version.Equals(castedOther.Version) &&
                   OpCode.Equals(castedOther.OpCode) &&
                   ErrorCode.Equals(castedOther.ErrorCode) &&
                   Id.Equals(castedOther.Id) &&
                   LeaseLife.Equals(castedOther.LeaseLife));
        }
Ejemplo n.º 3
0
 internal override bool EqualsData(DnsOption other)
 {
     return(EqualsData(other as DnsOptionClientSubnet));
 }