Пример #1
0
        /// <summary>
        /// Write the response data
        /// </summary>
        /// <param name="array"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        protected override int WriteResponseData(byte[] array, int offset)
        {
            int bytesWritten = DnsUtil.WriteHostnameLabel(array, offset, this.MasterHostname);

            bytesWritten += DnsUtil.WriteHostnameLabel(array, offset + bytesWritten, this.ResponsibleMailboxHostname);

            bytesWritten += DnsEncoder.WriteUint32(array, this.SerialNumber, offset + bytesWritten);
            bytesWritten += DnsEncoder.WriteInt32(array, this.RefreshInterval, offset + bytesWritten);
            bytesWritten += DnsEncoder.WriteInt32(array, this.RetryInterval, offset + bytesWritten);
            bytesWritten += DnsEncoder.WriteInt32(array, this.ExpirationLimit, offset + bytesWritten);
            bytesWritten += DnsEncoder.WriteInt32(array, this.MinimumTTL, offset + bytesWritten);

            return(bytesWritten);
        }
Пример #2
0
        /// <summary>
        /// Write the record data into the given byte array and return the number of bytes written
        /// </summary>
        /// <param name="array">Array.</param>
        /// <param name="offset">Offset.</param>
        public virtual int WriteRecord(byte[] array, int offset)
        {
            int startingOffset = offset;

            // 2 bytes - TYPE
            offset += DnsEncoder.WriteUint16(array, (uint)this.Type, offset);
            // 2 bytes - CLASS We just use the default one here
            offset += DnsEncoder.WriteUint16(array, (uint)1, offset);
            // 4 bytes - TTL
            offset += DnsEncoder.WriteInt32(array, this.TTL, offset);
            // 2 bytes - RDLENGTH the length of the response data for this response
            // This is actually written later, after we write the data with a negative offset

            // X bytes - Response data
            var dataLength = this.WriteResponseData(array, offset + 2);

            // Write the RDLENGTH
            offset += DnsEncoder.WriteUint16(array, (uint)dataLength, offset);
            offset += dataLength;

            return(offset - startingOffset);
        }