Пример #1
0
        internal override void Load(DnsRecordHeader header, IntPtr dataPointer)
        {
            base.Load(header, dataPointer);

            Win32DnsTxtRecord record = Marshal.PtrToStructure <Win32DnsTxtRecord>(dataPointer);

            if (record.StringCount > 0)
            {
                var txtRecords   = new List <string>((int)record.StringCount);
                var stringPtrs   = new IntPtr[record.StringCount];
                var txtArrayAddr = new IntPtr(dataPointer.ToInt64() + Marshal.OffsetOf <Win32DnsTxtRecord>("StringArray").ToInt64());

                using (var txtBuffer = new SafeDnsTxtBuffer(txtArrayAddr))
                {
                    txtBuffer.Initialize <IntPtr>(record.StringCount);
                    txtBuffer.ReadArray(0, stringPtrs, 0, stringPtrs.Length);
                }

                for (int i = 0; i < stringPtrs.Length; i++)
                {
                    txtRecords.Add(Marshal.PtrToStringUni(stringPtrs[i]));
                }

                this.txtEntries = new ReadOnlyCollection <string>(txtRecords);
            }
            else
            {
                this.txtEntries = Empty;
            }
        }
Пример #2
0
        internal override void Load(DnsRecordHeader header, IntPtr dataPointer)
        {
            base.Load(header, dataPointer);

            Win32DnsPtrRecord record = Marshal.PtrToStructure <Win32DnsPtrRecord>(dataPointer);

            this.nameHost = record.NameHost;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DnsARecord"/> class.
        /// </summary>
        /// <param name="header">DNS record header.</param>
        /// <param name="dataPointer">Pointer to the data portion of the DNS record.</param>
        internal override void Load(DnsRecordHeader header, IntPtr dataPointer)
        {
            base.Load(header, dataPointer);

            Win32DnsARecord record = Marshal.PtrToStructure <Win32DnsARecord>(dataPointer);

            this.numericIpAddress = record.IpAddress;
            this.ipAddress        = new IPAddress((long)record.IpAddress);
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the DnsSrvRecord class.
        /// </summary>
        /// <param name="header">Dns dnsRecord header</param>
        /// <param name="dataPointer">Pointer to the data portion of the dnsRecord</param>
        internal override void Load(DnsRecordHeader header, IntPtr dataPointer)
        {
            base.Load(header, dataPointer);

            Win32DnsSrvRecord record = Marshal.PtrToStructure <Win32DnsSrvRecord>(dataPointer);

            this.target   = record.NameTarget;
            this.priority = record.Priority;
            this.weight   = record.Weight;
            this.port     = record.Port;
        }
Пример #5
0
        internal override void Load(DnsRecordHeader header, IntPtr dataPointer)
        {
            base.Load(header, dataPointer);

            Win32DnsSoaRecord record = Marshal.PtrToStructure <Win32DnsSoaRecord>(dataPointer);

            this.primaryNameServer = record.NamePrimaryServer;
            this.administratorName = record.NameAdministrator;
            this.serialNumber      = record.SerialNo;
            this.refresh           = record.Refresh;
            this.retry             = record.Retry;
            this.expire            = record.Expire;
            this.defaultTtl        = record.DefaultTtl;
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DnsAAAARecord"/> class.
        /// </summary>
        /// <param name="header">DNS record header.</param>
        /// <param name="dataPointer">Pointer to the data portion of the DNS record.</param>
        internal override void Load(DnsRecordHeader header, IntPtr dataPointer)
        {
            base.Load(header, dataPointer);

            Win32DnsAAAARecord record = Marshal.PtrToStructure <Win32DnsAAAARecord>(dataPointer);

            unsafe
            {
                using (var aaaaBuffer = new SafeDnsAAAABuffer(new IntPtr(&record.Ip6Address)))
                {
                    aaaaBuffer.Initialize(IP6_ADDRESS.Size);
                    byte[] ipv6AddressBytes = new byte[IP6_ADDRESS.Size];
                    aaaaBuffer.ReadArray <byte>(0, ipv6AddressBytes, 0, IP6_ADDRESS.Size);
                    this.ipAddress         = new IPAddress(ipv6AddressBytes);
                    this.numericIp6Address = new BigInteger(ipv6AddressBytes);
                }
            }
        }
Пример #7
0
 /// <summary>
 /// Loads the DNS dnsRecord.
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="dataPointer">The data pointer.</param>
 internal virtual void Load(DnsRecordHeader header, IntPtr dataPointer)
 {
     this.name       = header.Name;
     this.timeToLive = Math.Max(1, header.Ttl);
 }