/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteUInt16(Priority); writer.WriteUInt16(Weight); writer.WriteUInt16(Port); writer.WriteDomainName(Target, appendSpace: false); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteByte((byte)HashAlgorithm); writer.WriteByte((byte)Flags); writer.WriteUInt16(Iterations); if (Salt == null || Salt.Length == 0) { writer.WriteString("-"); } else { writer.WriteBase16String(Salt); } writer.WriteString(Base32.ExtendedHex.Encode(NextHashedOwnerName, padding: false).ToLowerInvariant()); bool next = false; foreach (var type in Types) { if (next) { writer.WriteSpace(); } writer.WriteDnsType(type, appendSpace: false); next = true; } }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteUInt16((ushort)Flags); writer.WriteByte(Protocol); writer.WriteByte((byte)Algorithm); writer.WriteBase64String(PublicKey, appendSpace: false); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteUInt16(KeyTag); writer.WriteByte((byte)Algorithm); writer.WriteByte((byte)HashAlgorithm); writer.WriteBase16String(Digest, appendSpace: false); }
public void WriteDomainName_Escaped() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteDomainName(new DomainName(@"dr\. smith.com"), false); Assert.AreEqual(@"dr\.\032smith.com", text.ToString()); }
public void WriteDnsClass() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteDnsClass(DnsClass.IN); writer.WriteDnsClass((DnsClass)1234, appendSpace: false); Assert.AreEqual("IN CLASS1234", text.ToString()); }
public void WriteDnsType() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteDnsType(DnsType.ANY); writer.WriteDnsType((DnsType)1234, appendSpace: false); Assert.AreEqual("ANY TYPE1234", text.ToString()); }
public void WriteIPAddress() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteIPAddress(IPAddress.Loopback); writer.WriteIPAddress(IPAddress.IPv6Loopback, appendSpace: false); Assert.AreEqual("127.0.0.1 ::1", text.ToString()); }
public void WriteDateTime() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteDateTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)); writer.WriteDateTime(DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc), appendSpace: false); Assert.AreEqual("19700101000000 99991231235959", text.ToString()); }
public void WriteTimeSpan32() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteTimeSpan32(TimeSpan.FromSeconds(int.MaxValue)); writer.WriteTimeSpan32(TimeSpan.Zero, appendSpace: false); Assert.AreEqual("2147483647 0", text.ToString()); }
public void WriteByte() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteByte(byte.MaxValue); writer.WriteByte(1, appendSpace: false); Assert.AreEqual("255 1", text.ToString()); }
public void WriteTimeSpan16() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteTimeSpan16(TimeSpan.FromSeconds(ushort.MaxValue)); writer.WriteTimeSpan16(TimeSpan.Zero, appendSpace: false); Assert.AreEqual("65535 0", text.ToString()); }
public void WriteBase64String() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteBase64String(new byte[] { 1, 2, 3 }); writer.WriteBase64String(new byte[] { 1, 2, 3 }, appendSpace: false); Assert.AreEqual("AQID AQID", text.ToString()); }
public void WriteUInt16() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteUInt16(ushort.MaxValue); writer.WriteUInt16(1, appendSpace: false); Assert.AreEqual("65535 1", text.ToString()); }
public void WriteUInt32() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteUInt32(int.MaxValue); writer.WriteUInt32(1, appendSpace: false); Assert.AreEqual("2147483647 1", text.ToString()); }
public void WriteStringUnencoded() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteStringUnencoded("\\a"); writer.WriteStringUnencoded("\\b", appendSpace: false); Assert.AreEqual("\\a \\b", text.ToString()); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteDomainName(Algorithm); writer.WriteDateTime(Inception); writer.WriteDateTime(Expiration); writer.WriteUInt16((ushort)Mode); writer.WriteUInt16((ushort)Error); writer.WriteBase64String(Key); writer.WriteBase64String(OtherData ?? NoData, appendSpace: false); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteDomainName(Algorithm); writer.WriteDateTime(TimeSigned); writer.WriteTimeSpan16(Fudge); writer.WriteBase64String(MAC); writer.WriteUInt16(OriginalMessageId); writer.WriteUInt16((ushort)Error); writer.WriteBase64String(OtherData ?? NoData, appendSpace: false); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteDomainName(PrimaryName); writer.WriteDomainName(Mailbox); writer.WriteUInt32(SerialNumber); writer.WriteTimeSpan32(Refresh); writer.WriteTimeSpan32(Retry); writer.WriteTimeSpan32(Expire); writer.WriteTimeSpan32(Minimum, appendSpace: false); }
/// <inheritdoc /> public override string ToString() { using (var s = new StringWriter()) { var writer = new PresentationWriter(s); writer.WriteDomainName(Name); writer.WriteDnsClass(Class); writer.WriteDnsType(Type, appendSpace: false); return(s.ToString()); } }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteDnsType(TypeCovered); writer.WriteByte((byte)Algorithm); writer.WriteByte(Labels); writer.WriteTimeSpan32(OriginalTTL); writer.WriteDateTime(SignatureExpiration); writer.WriteDateTime(SignatureInception); writer.WriteUInt16(KeyTag); writer.WriteDomainName(SignerName); writer.WriteBase64String(Signature, appendSpace: false); }
/// <summary> /// Write the textual representation of the data that is specific to /// the resource record. /// </summary> /// <param name="writer"> /// The destination for the resource record's data. /// </param> /// <remarks> /// Derived classes should implement this method. /// <para> /// By default, this will write the hex encoding of /// the <see cref="GetData">RDATA</see> preceeded by /// "\#" and the number integer bytes. /// </para> /// </remarks> public virtual void WriteData(PresentationWriter writer) { var rdata = GetData(); var hasData = rdata.Length > 0; writer.WriteStringUnencoded("\\#"); writer.WriteUInt32((uint)rdata.Length, appendSpace: hasData); if (hasData) { writer.WriteBase16String(rdata, appendSpace: false); } }
/// <inheritdoc /> public void Write(PresentationWriter writer) { writer.WriteDomainName(Name); if (TTL != DefaultTTL) { writer.WriteTimeSpan32(TTL); } writer.WriteDnsClass(Class); writer.WriteDnsType(Type); WriteData(writer); writer.WriteEndOfLine(); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { bool next = false; foreach (var s in Strings) { if (next) { writer.WriteSpace(); } writer.WriteString(s, appendSpace: false); next = true; } }
public void WriteDomainName() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteString("alpha.com"); writer.WriteString("omega.com", appendSpace: false); Assert.AreEqual("alpha.com omega.com", text.ToString()); text = new StringWriter(); writer = new PresentationWriter(text); writer.WriteDomainName(new DomainName("alpha.com"), false); Assert.AreEqual("alpha.com", text.ToString()); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteByte((byte)HashAlgorithm); writer.WriteByte((byte)Flags); writer.WriteUInt16(Iterations); if (Salt == null || Salt.Length == 0) { writer.WriteString("-"); } else { writer.WriteBase16String(Salt, appendSpace: false); } }
public void WriteString() { var text = new StringWriter(); var writer = new PresentationWriter(text); writer.WriteString("alpha"); writer.WriteString("a b"); writer.WriteString(null); writer.WriteString(""); writer.WriteString(" "); writer.WriteString("a\\b"); writer.WriteString("a\"b"); writer.WriteString("end", appendSpace: false); Assert.AreEqual("alpha \"a b\" \"\" \"\" \" \" a\\\\b a\\\"b end", text.ToString()); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteDomainName(NextOwnerName); bool next = false; foreach (var type in Types) { if (next) { writer.WriteSpace(); } writer.WriteDnsType(type, appendSpace: false); next = true; } }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteDomainName(Mailbox); writer.WriteDomainName(TextName, appendSpace: false); }
/// <inheritdoc /> public override void WriteData(PresentationWriter writer) { writer.WriteDomainName(Authority, appendSpace: false); }