/// <summary> /// This method writes the resource record's data (including its /// length) to the packet beginning at the offset passed. /// </summary> /// <param name="message">The DNS message being serialized.</param> /// <param name="packet">The packet buffer.</param> /// <param name="offset"> /// The offset in the packet where the data will be written. /// This parameter will return set to the offset of the first /// byte after the written data. /// </param> protected override void WriteData(DnsMessage message, byte[] packet, ref int offset) { int lenPos = offset; // Remember where the length goes offset += 2; message.WriteName(packet, ref offset, cname); Helper.WriteInt16(packet, ref lenPos, offset - lenPos - 2); // Go back and write the length }
/// <summary> /// This method writes the resource record to the packet beginning /// at the offset passed. /// </summary> /// <param name="message">The DNS message being serialized.</param> /// <param name="packet">The packet buffer.</param> /// <param name="offset"> /// The offset in the packet where the record will be written. /// This parameter will return set to the offset of the first /// byte after the written record. /// </param> public void Write(DnsMessage message, byte[] packet, ref int offset) { Assertion.Test(rrtype != DnsRRType.UNKNOWN, "RRType is not set."); message.WriteName(packet, ref offset, rname); Helper.WriteInt16(packet, ref offset, (int)rrtype); Helper.WriteInt16(packet, ref offset, (int)qclass); Helper.WriteInt32(packet, ref offset, (int)ttl); WriteData(message, packet, ref offset); }