/// <inheritdoc /> public override void Write(WireWriter writer) { writer.WriteUInt16(Id); var flags = (Convert.ToInt32(QR) << 15) | (((ushort)Opcode & 0xf) << 11) | ((Z & 0x7F) << 4) | ((ushort)Status & 0xf); writer.WriteUInt16((ushort)flags); writer.WriteUInt16((ushort)1); writer.WriteUInt16((ushort)Prerequisites.Count); writer.WriteUInt16((ushort)Updates.Count); writer.WriteUInt16((ushort)AdditionalResources.Count); Zone.Write(writer); foreach (var r in Prerequisites) { r.Write(writer); } foreach (var r in Updates) { r.Write(writer); } foreach (var r in AdditionalResources) { r.Write(writer); } }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteUInt16(KeyTag); writer.WriteByte((byte)Algorithm); writer.WriteByte((byte)HashAlgorithm); writer.WriteBytes(Digest); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { foreach (var algorithm in Algorithms) { writer.WriteByte((byte)algorithm); } }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteUInt16((ushort)Flags); writer.WriteByte(Protocol); writer.WriteByte((byte)Algorithm); writer.WriteBytes(PublicKey); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteByte((byte)HashAlgorithm); writer.WriteByte(Flags); writer.WriteUInt16(Iterations); writer.WriteByteLengthPrefixedBytes(Salt); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { if (Timeout.HasValue) { writer.WriteUInt16((ushort)(Timeout.Value.TotalMilliseconds / 100)); } }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { foreach (var s in Strings) { writer.WriteString(s); } }
/// <summary> /// Length in bytes of the object when serialised. /// </summary> /// <returns> /// Numbers of bytes when serialised. /// </returns> public int Length() { var writer = new WireWriter(Stream.Null); Write(writer); return(writer.Position); }
/// <summary> /// The resource specific data. /// </summary> /// <returns> /// A byte array, never <b>null</b>. /// </returns> /// <remarks> /// This is referred to as the <c>RDATA</c> in the DNS spec. /// </remarks> public byte[] GetData() { using (var ms = new MemoryStream()) { var writer = new WireWriter(ms); this.WriteData(writer); return(ms.ToArray()); } }
/// <summary> /// The length of the resource specific data. /// </summary> /// <returns> /// Number of bytes to represent the resource specific data. /// </returns> /// <remarks> /// This is referred to as the <c>RDLENGTH</c> in the DNS spec. /// </remarks> public int GetDataLength() { using (var ms = new MemoryStream()) { var writer = new WireWriter(ms); this.WriteData(writer); return((int)ms.Length); } }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteByte((byte)HashAlgorithm); writer.WriteByte((byte)Flags); writer.WriteUInt16(Iterations); writer.WriteByteLengthPrefixedBytes(Salt); writer.WriteByteLengthPrefixedBytes(NextHashedOwnerName); writer.WriteBitmap(Types.Select(t => (ushort)t)); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteDomainName(PrimaryName); writer.WriteDomainName(Mailbox); writer.WriteUInt32(SerialNumber); writer.WriteTimeSpan32(Refresh); writer.WriteTimeSpan32(Retry); writer.WriteTimeSpan32(Expire); writer.WriteTimeSpan32(Minimum); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteDomainName(Algorithm); writer.WriteDateTime32(Inception); writer.WriteDateTime32(Expiration); writer.WriteUInt16((ushort)Mode); writer.WriteUInt16((ushort)Error); writer.WriteUint16LengthPrefixedBytes(Key); writer.WriteUint16LengthPrefixedBytes(OtherData); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteDomainName(Algorithm); writer.WriteDateTime48(TimeSigned); writer.WriteTimeSpan16(Fudge); writer.WriteUint16LengthPrefixedBytes(MAC); writer.WriteUInt16(OriginalMessageId); writer.WriteUInt16((ushort)Error); writer.WriteUint16LengthPrefixedBytes(OtherData); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { foreach (var option in Options) { writer.WriteUInt16((ushort)option.Type); writer.PushLengthPrefixedScope(); option.WriteData(writer); writer.PopLengthPrefixedScope(); } }
/// <inheritdoc /> public override void Write(WireWriter writer) { writer.WriteDomainName(Name); writer.WriteUInt16((ushort)Type); writer.WriteUInt16((ushort)Class); writer.WriteTimeSpan32(TTL); writer.PushLengthPrefixedScope(); WriteData(writer); writer.PopLengthPrefixedScope(); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteUInt16((ushort)TypeCovered); writer.WriteByte((byte)Algorithm); writer.WriteByte(Labels); writer.WriteTimeSpan32(OriginalTTL); writer.WriteDateTime32(SignatureExpiration); writer.WriteDateTime32(SignatureInception); writer.WriteUInt16(KeyTag); writer.WriteDomainName(SignerName, uncompressed: true); writer.WriteBytes(Signature); }
/// <inheritdoc /> public override void Write(WireWriter writer) { writer.WriteDomainName(Name); writer.WriteUInt16((ushort)Type); var classValue = (ushort)Class; if (QU) { classValue = (ushort)(classValue | 0x01 << 15); } writer.WriteUInt16((ushort)classValue); }
/// <inheritdoc /> public override void Write(WireWriter writer) { writer.WriteUInt16(Id); var flags = (Convert.ToInt32(QR) << 15) | (((ushort)opcode4 & 0xf) << 11) | (Convert.ToInt32(AA) << 10) | (Convert.ToInt32(TC) << 9) | (Convert.ToInt32(RD) << 8) | (Convert.ToInt32(RA) << 7) | ((Z & 0x1) << 6) | (Convert.ToInt32(AD) << 5) | (Convert.ToInt32(CD) << 4) | ((ushort)Status & 0xf); writer.WriteUInt16((ushort)flags); writer.WriteUInt16((ushort)Questions.Count); writer.WriteUInt16((ushort)Answers.Count); writer.WriteUInt16((ushort)AuthorityRecords.Count); writer.WriteUInt16((ushort)AdditionalRecords.Count); foreach (var r in Questions) { r.Write(writer); } foreach (var r in Answers) { r.Write(writer); } foreach (var r in AuthorityRecords) { r.Write(writer); } foreach (var r in AdditionalRecords) { r.Write(writer); } }
/// <summary> /// Creates a new instance of the <see cref="DSRecord"/> class /// from the specified <see cref="DNSKEYRecord"/>. /// </summary> /// <param name="key"> /// The dns key to use. /// </param> /// <param name="force"> /// If <b>true</b>, key usage checks are ignored. /// </param> /// <exception cref="ArgumentException"> /// Both <see cref="DNSKEYFlags.ZoneKey"/> and <see cref="DNSKEYFlags.SecureEntryPoint"/> /// must be set. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The <see cref="ResourceRecord.Name"/> of the <paramref name="key"/> is missing. /// </exception> public DSRecord(DNSKEYRecord key, bool force = false) : this() { // Check the key. if (!force) { if ((key.Flags & DNSKEYFlags.ZoneKey) == DNSKEYFlags.None) { throw new ArgumentException("ZoneKey must be set.", "key"); } if ((key.Flags & DNSKEYFlags.SecureEntryPoint) == DNSKEYFlags.None) { throw new ArgumentException("SecureEntryPoint must be set.", "key"); } } byte[] digest; using (var ms = new MemoryStream()) using (var hasher = DigestRegistry.Create(key.Algorithm)) { var writer = new WireWriter(ms) { CanonicalForm = true }; writer.WriteDomainName(key.Name); key.WriteData(writer); ms.Position = 0; digest = hasher.ComputeHash(ms); } Algorithm = key.Algorithm; Class = key.Class; KeyTag = key.KeyTag(); Name = key.Name; TTL = key.TTL; Digest = digest; HashAlgorithm = DigestType.Sha1; }
/// <inheritdoc /> public abstract void Write(WireWriter writer);
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteIPAddress(Address); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteBytes(Data); }
/// <inheritdoc /> public override void WriteData(WireWriter writer) { writer.WriteDomainName(NextOwnerName, uncompressed: true); writer.WriteBitmap(Types.Select(t => (ushort)t)); }
/// <summary> /// Write the data that is specific to the resource record <see cref="System.Type"/>. /// </summary> /// <param name="writer"> /// The destination for the DNS object's data. /// </param> /// <remarks> /// Derived classes must implement this method. /// </remarks> public virtual void WriteData(WireWriter writer) { }