Пример #1
0
        private void ParseAdditionals()
        {
            int nextOffset = 0;

            if (!this.ParseRecords <DnsDataResourceRecord>(this.AdditionalsOffset, (Func <ushort>)(() => this.AdditionalCount), new DnsDatagram.ParseRecord <DnsDataResourceRecord>(DnsDataResourceRecord.Parse), ref this._additionals, ref nextOffset) || this._additionals == null)
            {
                return;
            }
            this._options = (DnsOptResourceRecord)Enumerable.FirstOrDefault <DnsDataResourceRecord>((IEnumerable <DnsDataResourceRecord>) this._additionals, (Func <DnsDataResourceRecord, bool>)(additional => additional.DnsType == DnsType.Opt));
        }
Пример #2
0
        public void DnsOptResourceRecordTest()
        {
            Random random = new Random();
            for (int i = 0; i != 100; ++i)
            {
                DnsDomainName domainName = random.NextDnsDomainName();
                ushort sendersUdpPayloadSize = random.NextUShort();
                byte extendedRcode = random.NextByte();
                DnsOptVersion version = (DnsOptVersion)random.NextByte();
                DnsOptFlags flags = (DnsOptFlags)random.NextUShort();
                DnsResourceDataOptions data = (DnsResourceDataOptions)random.NextDnsResourceData(DnsType.Opt);

                DnsOptResourceRecord record = new DnsOptResourceRecord(domainName, sendersUdpPayloadSize, extendedRcode, version, flags, data);
                
                Assert.AreEqual(domainName, record.DomainName);
                Assert.AreEqual(sendersUdpPayloadSize, record.SendersUdpPayloadSize);
                Assert.AreEqual(extendedRcode, record.ExtendedReturnCode);
                Assert.AreEqual(version, record.Version);
                Assert.AreEqual(flags, record.Flags);
                Assert.AreEqual(data, record.Data);
            }
        }