internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            if (length < ConstantPartLength)
            {
                return(null);
            }

            DnsType      typeCovered         = (DnsType)dns.ReadUShort(offsetInDns + Offset.TypeCovered, Endianity.Big);
            DnsAlgorithm algorithm           = (DnsAlgorithm)dns[offsetInDns + Offset.Algorithm];
            byte         labels              = dns[offsetInDns + Offset.Labels];
            uint         originalTtl         = dns.ReadUInt(offsetInDns + Offset.OriginalTtl, Endianity.Big);
            uint         signatureExpiration = dns.ReadUInt(offsetInDns + Offset.SignatureExpiration, Endianity.Big);
            uint         signatureInception  = dns.ReadUInt(offsetInDns + Offset.SignatureInception, Endianity.Big);
            ushort       keyTag              = dns.ReadUShort(offsetInDns + Offset.KeyTag, Endianity.Big);

            offsetInDns += ConstantPartLength;
            length      -= ConstantPartLength;

            DnsDomainName signersName;
            int           signersNameLength;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length, out signersName, out signersNameLength))
            {
                return(null);
            }
            offsetInDns += signersNameLength;
            length      -= signersNameLength;

            DataSegment signature = dns.Subsegment(offsetInDns, length);

            return(new DnsResourceDataSignature(typeCovered, algorithm, labels, originalTtl, signatureExpiration, signatureInception, keyTag, signersName, signature));
        }
        internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            DnsDomainName mainNameServer;
            int           domainNameLength;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length, out mainNameServer, out domainNameLength))
            {
                return(null);
            }
            offsetInDns += domainNameLength;
            length      -= domainNameLength;

            DnsDomainName responsibleMailbox;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length, out responsibleMailbox, out domainNameLength))
            {
                return(null);
            }
            offsetInDns += domainNameLength;
            length      -= domainNameLength;

            if (length != ConstantPartLength)
            {
                return(null);
            }

            uint serial     = dns.ReadUInt(offsetInDns + Offset.Serial, Endianity.Big);;
            uint refresh    = dns.ReadUInt(offsetInDns + Offset.Refresh, Endianity.Big);;
            uint retry      = dns.ReadUInt(offsetInDns + Offset.Retry, Endianity.Big);;
            uint expire     = dns.ReadUInt(offsetInDns + Offset.Expire, Endianity.Big);;
            uint minimumTtl = dns.ReadUInt(offsetInDns + Offset.MinimumTtl, Endianity.Big);;

            return(new DnsResourceDataStartOfAuthority(mainNameServer, responsibleMailbox, serial, refresh, retry, expire, minimumTtl));
        }
Beispiel #3
0
        internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            DnsDomainName domainName1;
            int           numBytesRead;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length, out domainName1, out numBytesRead))
            {
                return((DnsResourceData)null);
            }
            offsetInDns += numBytesRead;
            length      -= numBytesRead;
            DnsDomainName domainName2;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length, out domainName2, out numBytesRead))
            {
                return((DnsResourceData)null);
            }
            offsetInDns += numBytesRead;
            length      -= numBytesRead;
            if (length != 20)
            {
                return((DnsResourceData)null);
            }
            uint num        = dns.ReadUInt(offsetInDns, Endianity.Big);
            uint refresh    = dns.ReadUInt(offsetInDns + 4, Endianity.Big);
            uint retry      = dns.ReadUInt(offsetInDns + 8, Endianity.Big);
            uint expire     = dns.ReadUInt(offsetInDns + 12, Endianity.Big);
            uint minimumTtl = dns.ReadUInt(offsetInDns + 16, Endianity.Big);

            return((DnsResourceData) new DnsResourceDataStartOfAuthority(domainName1, domainName2, (SerialNumber32)num, refresh, retry, expire, minimumTtl));
        }
        internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            if (length < 18)
            {
                return((DnsResourceData)null);
            }
            DnsType      typeCovered = (DnsType)dns.ReadUShort(offsetInDns, Endianity.Big);
            DnsAlgorithm algorithm   = (DnsAlgorithm)dns[offsetInDns + 2];
            byte         labels      = dns[offsetInDns + 3];
            uint         originalTtl = dns.ReadUInt(offsetInDns + 4, Endianity.Big);
            uint         num1        = dns.ReadUInt(offsetInDns + 8, Endianity.Big);
            uint         num2        = dns.ReadUInt(offsetInDns + 12, Endianity.Big);
            ushort       keyTag      = dns.ReadUShort(offsetInDns + 16, Endianity.Big);

            offsetInDns += 18;
            length      -= 18;
            DnsDomainName domainName;
            int           numBytesRead;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length, out domainName, out numBytesRead))
            {
                return((DnsResourceData)null);
            }
            offsetInDns += numBytesRead;
            length      -= numBytesRead;
            DataSegment signature = dns.Subsegment(offsetInDns, length);

            return((DnsResourceData) new DnsResourceDataSignature(typeCovered, algorithm, labels, originalTtl, (SerialNumber32)num1, (SerialNumber32)num2, keyTag, domainName, signature));
        }
        internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            if (length < ConstantPartLength + DnsDomainName.RootLength)
            {
                return(null);
            }

            DnsDomainName algorithm;
            int           algorithmLength;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length - ConstantPartLength, out algorithm, out algorithmLength))
            {
                return(null);
            }
            offsetInDns += algorithmLength;
            length      -= algorithmLength;

            if (length < ConstantPartLength)
            {
                return(null);
            }

            uint inception              = dns.ReadUInt(offsetInDns + OffsetAfterAlgorithm.Inception, Endianity.Big);
            uint expiration             = dns.ReadUInt(offsetInDns + OffsetAfterAlgorithm.Expiration, Endianity.Big);
            DnsTransactionKeyMode mode  = (DnsTransactionKeyMode)dns.ReadUShort(offsetInDns + OffsetAfterAlgorithm.Mode, Endianity.Big);
            DnsResponseCode       error = (DnsResponseCode)dns.ReadUShort(offsetInDns + OffsetAfterAlgorithm.Error, Endianity.Big);

            int keySize = dns.ReadUShort(offsetInDns + OffsetAfterAlgorithm.KeySize, Endianity.Big);

            if (length < ConstantPartLength + keySize)
            {
                return(null);
            }
            DataSegment key = dns.Subsegment(offsetInDns + OffsetAfterAlgorithm.KeyData, keySize);

            int totalReadAfterAlgorithm = OffsetAfterAlgorithm.KeyData + keySize;

            offsetInDns += totalReadAfterAlgorithm;
            length      -= totalReadAfterAlgorithm;
            int otherSize = dns.ReadUShort(offsetInDns, Endianity.Big);

            if (length != sizeof(ushort) + otherSize)
            {
                return(null);
            }
            DataSegment other = dns.Subsegment(offsetInDns + sizeof(ushort), otherSize);

            return(new DnsResourceDataTransactionKey(algorithm, inception, expiration, mode, error, key, other));
        }
Beispiel #6
0
        internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            if (length < 17)
            {
                return((DnsResourceData)null);
            }
            DnsDomainName domainName;
            int           numBytesRead;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length - 16, out domainName, out numBytesRead))
            {
                return((DnsResourceData)null);
            }
            offsetInDns += numBytesRead;
            length      -= numBytesRead;
            if (length < 16)
            {
                return((DnsResourceData)null);
            }
            uint num1 = dns.ReadUInt(offsetInDns, Endianity.Big);
            uint num2 = dns.ReadUInt(offsetInDns + 4, Endianity.Big);
            DnsTransactionKeyMode mode  = (DnsTransactionKeyMode)dns.ReadUShort(offsetInDns + 8, Endianity.Big);
            DnsResponseCode       error = (DnsResponseCode)dns.ReadUShort(offsetInDns + 10, Endianity.Big);
            int length1 = (int)dns.ReadUShort(offsetInDns + 12, Endianity.Big);

            if (length < 16 + length1)
            {
                return((DnsResourceData)null);
            }
            DataSegment key  = dns.Subsegment(offsetInDns + 14, length1);
            int         num3 = 14 + length1;

            offsetInDns += num3;
            length      -= num3;
            int length2 = (int)dns.ReadUShort(offsetInDns, Endianity.Big);

            if (length != 2 + length2)
            {
                return((DnsResourceData)null);
            }
            DataSegment other = dns.Subsegment(offsetInDns + 2, length2);

            return((DnsResourceData) new DnsResourceDataTransactionKey(domainName, (SerialNumber32)num1, (SerialNumber32)num2, mode, error, key, other));
        }