Replace DnDns with HeijdenDns

HeijdenDns seems to do a better job at querying SRV records
This commit is contained in:
ORelio 2017-03-11 15:28:32 +01:00
parent a344ac4101
commit 693073edfc
112 changed files with 5491 additions and 5009 deletions

View file

@ -1,83 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
/// <summary>
/// RFC 1035:
///
/// 3.4.1. A RDATA format
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | ADDRESS |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///
/// where:
///
/// ADDRESS A 32 bit Internet address.
///
/// Hosts that have multiple Internet addresses will have multiple A
/// records.
///
/// A records cause no additional section processing. The RDATA section of
/// an A line in a master file is an Internet address expressed as four
/// decimal numbers separated by dots without any imbedded spaces (e.g.,
/// "10.2.0.52" or "192.0.5.6").
///
/// </summary>
public sealed class ARecord : DnsRecordBase, IDnsRecord
{
private string _hostAddress;
/// <summary>
/// The answer host address for the DNS A Record.
/// </summary>
public string HostAddress
{
get { return _hostAddress; }
}
internal ARecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
_hostAddress = ms.ReadByte() + "." + ms.ReadByte() + "." + ms.ReadByte() + "." + ms.ReadByte();
_answer = "Address: " + _hostAddress;
}
}
}

View file

@ -1,97 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class AaaaRecord : DnsRecordBase
{
private string m_ipAddress;
internal AaaaRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
// TODO: Test and incorporate BinToHex function below
m_ipAddress =
ms.ReadByte().ToString("x2") + ms.ReadByte().ToString("x2") + ":" + ms.ReadByte().ToString("x2") + ms.ReadByte().ToString("x2") + ":" +
ms.ReadByte().ToString("x2") + ms.ReadByte().ToString("x2") + ":" + ms.ReadByte().ToString("x2") + ms.ReadByte().ToString("x2") + ":" +
ms.ReadByte().ToString("x2") + ms.ReadByte().ToString("x2") + ":" + ms.ReadByte().ToString("x2") + ms.ReadByte().ToString("x2") + ":" +
ms.ReadByte().ToString("x2") + ms.ReadByte().ToString("x2") + ":" + ms.ReadByte().ToString("x2") + ms.ReadByte().ToString("x2");
_answer = "IPv6 Address: " + m_ipAddress;
}
// TODO: converted from VB.NET, test to make sure it works properly
private static string BinToHex(byte[] data)
{
if (data != null)
{
StringBuilder sb = new System.Text.StringBuilder(1024);
for (int i = 0; i < data.Length; i++)
{
sb.Append(data[i].ToString("X2"));
}
return sb.ToString();
}
else
{
return null;
}
}
// TODO: converted from VB.NET, test to make sure it works properly
private static byte[] HexToBin(string s)
{
int arraySize = s.Length / 2;
byte[] bytes = new byte[arraySize - 1];
int counter = 0;
for (int i = 0; i < s.Length - 1; i = 2)
{
string hexValue = s.Substring(i, 2);
// Tell convert to interpret the string as a 16 bit hex value
int intValue = Convert.ToInt32(hexValue, 16);
// Convert the integer to a byte and store it in the array
bytes[counter] = Convert.ToByte(intValue);
counter += 1;
}
return bytes;
}
}
}

View file

@ -1,78 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
namespace DnDns.Records
{
public sealed class AfsdbRecord : DnsRecordBase
{
private ushort _port;
private string _name;
private short _type;
public ushort Port
{
get { return _port; }
}
public string AfsdbName
{
get { return _name; }
}
public short Type
{
get { return _type; }
}
internal AfsdbRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
byte[] type = new byte[2];
ms.Read(type, 0, 2);
// _port = (ushort)Tools.ByteToUInt(type);
_port = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(type, 0));
_name = DnsRecordBase.ParseName(ref ms);
//_type = (short)Tools.ByteToUInt(type);
_type = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(type, 0));
_answer = "Name: " + _name + ", Port: " + _port + ", Type: " + _type;
}
}
}

View file

@ -1,74 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class AtmaRecord : DnsRecordBase
{
private string _address;
private ATMFormat _format;
public string Address
{
get { return _address; }
}
public ATMFormat Format
{
get { return _format; }
}
internal AtmaRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
byte[] address = new byte[this.DnsHeader.DataLength - 1];
_format = (ATMFormat)ms.ReadByte();
ms.Read(address, 0, this.DnsHeader.DataLength - 1);
_address = Encoding.ASCII.GetString(address);
_answer = "Address: " + _address + ", Format: " + _format;
}
public enum ATMFormat : byte
{
E164 = 0x01,
NSAP = 0x02
}
}
}

View file

@ -1,338 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Diagnostics;
namespace DnDns.Records
{
/// <summary>
/// Handles a basic Dns record
///
/// From RFC 1035:
///
/// 3.2.1. Format
///
/// All RRs have the same top level format shown below:
///
/// 1 1 1 1 1 1
/// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | |
/// / /
/// / NAME /
/// | |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | TYPE |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | CLASS |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | TTL |
/// | |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | RDLENGTH |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
/// / RDATA /
/// / /
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
///
/// where:
///
/// NAME an owner name, i.e., the name of the node to which this
/// resource record pertains.
///
/// TYPE two octets containing one of the RR TYPE codes.
///
/// CLASS two octets containing one of the RR CLASS codes.
///
/// TTL a 32 bit signed integer that specifies the time interval
/// that the resource record may be cached before the source
/// of the information should again be consulted. Zero
/// values are interpreted to mean that the RR can only be
/// used for the transaction in progress, and should not be
/// cached. For example, SOA records are always distributed
/// with a zero TTL to prohibit caching. Zero values can
/// also be used for extremely volatile data.
///
/// RDLENGTH an unsigned 16 bit integer that specifies the length in
/// octets of the RDATA field.
///
/// RDATA a variable length string of octets that describes the
/// resource. The format of this information varies
/// according to the TYPE and CLASS of the resource record.
/// </summary>
public abstract class DnsRecordBase : IDnsRecord
{
#region Fields
// NAME an owner name, i.e., the name of the node to which this
// resource record pertains.
//private string _name;
// TYPE two octets containing one of the RR TYPE codes.
//protected NsType _nsType;
// CLASS - two octets containing one of the RR CLASS codes.
//private NsClass _nsClass;
// TTL - a 32 bit signed integer that specifies the time interval
// that the resource record may be cached before the source
// of the information should again be consulted. Zero
// values are interpreted to mean that the RR can only be
// used for the transaction in progress, and should not be
// cached. For example, SOA records are always distributed
// with a zero TTL to prohibit caching. Zero values can
/// also be used for extremely volatile data.
//private int _timeToLive;
// RDLENGTH - an unsigned 16 bit integer that specifies the length in
// octets of the RDATA field.
//protected short _dataLength;
protected RecordHeader _dnsHeader;
protected string _answer;
protected string _errorMsg;
#endregion
#region Properties
/// <summary>
/// NAME - an owner name, i.e., the name of the node to which this
/// resource record pertains.
/// </summary>
//public string Name
//{
// get { return _name; }
//}
public RecordHeader DnsHeader
{
get { return _dnsHeader; }
protected set { _dnsHeader = value; }
}
public string Answer
{
get { return _answer; }
}
/// <summary>
/// TYPE two octets containing one of the RR TYPE codes.
/// </summary>
//public NsType NsType
//{
// get { return _nsType; }
//}
/// <summary>
/// CLASS - two octets containing one of the RR CLASS codes.
/// </summary>
//public NsClass NsClass
//{
// get { return _nsClass; }
//}
/// <summary>
/// TTL - a 32 bit signed integer that specifies the time interval
/// that the resource record may be cached before the source
/// of the information should again be consulted. Zero
/// values are interpreted to mean that the RR can only be
/// used for the transaction in progress, and should not be
/// cached. For example, SOA records are always distributed
/// with a zero TTL to prohibit caching. Zero values can
/// also be used for extremely volatile data.
/// </summary>
//public int TimeToLive
//{
// get { return _timeToLive; }
//}
/// <summary>
/// RDLENGTH - an unsigned 16 bit integer that specifies the length in
/// octets of the RDATA field.
/// </summary>
//public short DataLength
//{
// get { return _dataLength; }
//}
public string ErrorMsg
{
get { return _errorMsg; }
}
#endregion
internal DnsRecordBase()
{
}
public virtual void ParseRecord(ref MemoryStream ms)
{
// Default implementation - the most common.
_answer = DnsRecordBase.ParseName(ref ms);
}
internal DnsRecordBase(RecordHeader dnsHeader)
{
_dnsHeader = dnsHeader;
}
// RFC
// 4.1.4. Message compression
//
// In order to reduce the size of messages, the domain system utilizes a
// compression scheme which eliminates the repetition of domain names in a
// message. In this scheme, an entire domain name or a list of labels at
// the end of a domain name is replaced with a pointer to a prior occurance
// of the same name.
//
// The pointer takes the form of a two octet sequence:
//
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
// | 1 1| OFFSET |
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
//
// The first two bits are ones. This allows a pointer to be distinguished
// from a label, since the label must begin with two zero bits because
// labels are restricted to 63 octets or less. (The 10 and 01 combinations
// are reserved for future use.) The OFFSET field specifies an offset from
// the start of the message (i.e., the first octet of the ID field in the
// domain header). A zero offset specifies the first byte of the ID field,
// etc.
//
// The compression scheme allows a domain name in a message to be
// represented as either:
//
// - a sequence of labels ending in a zero octet
// - a pointer
// - a sequence of labels ending with a pointer
//
internal static string ParseName(ref MemoryStream ms)
{
Trace.WriteLine("Reading Name...");
StringBuilder sb = new StringBuilder();
uint next = (uint)ms.ReadByte();
Trace.WriteLine("Next is 0x" + next.ToString("x2"));
int bPointer;
while ((next != 0x00))
{
// Isolate 2 most significat bits -> e.g. 11xx xxxx
// if it's 0xc0 (11000000b} then pointer
switch (0xc0 & next)
{
// 0xc0 -> Name is a pointer.
case 0xc0:
{
// Isolate Offset
int offsetMASK = ~0xc0;
// Example on how to calculate the offset
// e.g.
//
// So if given the following 2 bytes - 0xc1 0x1c (11000001 00011100)
//
// The pointer takes the form of a two octet sequence:
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
// | 1 1| OFFSET |
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
// | 1 1| 0 0 0 0 0 1 0 0 0 1 1 1 0 0|
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
//
// A pointer is indicated by the a 1 in the two most significant bits
// The Offset is the remaining bits.
//
// The Pointer = 0xc0 (11000000 00000000)
// The offset = 0x11c (00000001 00011100)
// Move offset into the proper position
int offset = (int)(offsetMASK & next) << 8;
// extract the pointer to the data in the stream
bPointer = ms.ReadByte() + offset;
// store the position so we can resume later
long oldPtr = ms.Position;
// Move to the specified position in the stream and
// parse the name (recursive call)
ms.Position = bPointer;
sb.Append(DnsRecordBase.ParseName(ref ms));
Trace.WriteLine(sb.ToString());
// Move back to original position, and continue
ms.Position = oldPtr;
next = 0x00;
break;
}
case 0x00:
{
Debug.Assert(next < 0xc0, "Offset cannot be greater then 0xc0.");
byte[] buffer = new byte[next];
ms.Read(buffer, 0, (int)next);
sb.Append(Encoding.ASCII.GetString(buffer) + ".");
next = (uint)ms.ReadByte();
Trace.WriteLine("0x" + next.ToString("x2"));
break;
}
default:
throw new InvalidOperationException("There was a problem decompressing the DNS Message.");
}
}
return sb.ToString();
}
internal string ParseText(ref MemoryStream ms)
{
StringBuilder sb = new StringBuilder();
int len = ms.ReadByte();
byte[] buffer = new byte[len];
ms.Read(buffer, 0, len);
sb.Append(Encoding.ASCII.GetString(buffer));
return sb.ToString();
}
public override string ToString()
{
return _answer;
}
#region IDnsRecord Members
public virtual byte[] GetMessageBytes()
{
return new byte[]{};
}
#endregion
}
}

View file

@ -1,52 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class CNameRecord : DnsRecordBase
{
internal CNameRecord(RecordHeader dnsHeader) : base(dnsHeader) {}
public override void ParseRecord(ref MemoryStream ms)
{
base.ParseRecord(ref ms);
_answer = "Host: " + _answer;
}
}
}

View file

@ -1,67 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class HInfoRecord : DnsRecordBase
{
private string _cpuType;
private string _operatingSys;
public string CpuType
{
get { return _cpuType; }
}
public string OperatingSys
{
get { return _operatingSys; }
}
internal HInfoRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
_cpuType = base.ParseText(ref ms);
_operatingSys = base.ParseText(ref ms);
_answer = "CPU: " + _cpuType + ", OS: " + _operatingSys;
}
}
}

View file

@ -1,58 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public interface IDnsRecord
{
RecordHeader DnsHeader { get; }
string Answer { get; }
//short DataLength { get; }
string ErrorMsg { get; }
//string Name { get; }
//NsClass NsClass { get; }
//NsType NsType { get; }
//int TimeToLive { get; }
//void ParseRecordHeader(ref MemoryStream ms);
void ParseRecord(ref MemoryStream ms);
string ToString();
byte[] GetMessageBytes();
}
}

View file

@ -1,66 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class IsdnRecord : DnsRecordBase
{
private string _address;
private string _subAddress;
public string Address
{
get { return _address; }
}
public string SubAddress
{
get { return _subAddress; }
}
internal IsdnRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
_address = base.ParseText(ref ms);
_subAddress = base.ParseText(ref ms);
_answer = "ISDN Address: " + _address + ", SubAddress: " + _subAddress;
}
}
}

View file

@ -1,194 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
namespace DnDns.Records
{
public sealed class LocRecord : DnsRecordBase
{
// For LOC
#region Fields
private byte _version;
private byte _size;
private byte _horPrecision;
private byte _vertPrecision;
private uint _latitude;
private uint _longitude;
private uint _altitude;
#endregion
#region Properties
public byte Version
{
get { return _version; }
}
public byte Size
{
get { return _size; }
}
public byte HorPrecision
{
get { return _horPrecision; }
}
public byte VertPrecision
{
get { return _vertPrecision; }
}
public uint Latitude
{
get { return _latitude; }
}
public uint Longitude
{
get { return _longitude; }
}
public uint Altitude
{
get { return _altitude; }
}
#endregion
private char[] _latDirection = new char[2] {'N', 'S'};
private char[] _longDirection = new char[2] {'E', 'W'};
internal LocRecord(RecordHeader dnsHeader) : base(dnsHeader) {}
public override void ParseRecord(ref MemoryStream ms)
{
byte[] latitude = new Byte[4];
byte[] longitude = new Byte[4];
byte[] altitude = new Byte[4];
_version = (byte)ms.ReadByte();
_size = (byte)ms.ReadByte();
_horPrecision = (byte)ms.ReadByte();
_vertPrecision = (byte)ms.ReadByte();
ms.Read(latitude,0,latitude.Length);
// _latitude = Tools.ByteToUInt(latitude);
_latitude = (uint)IPAddress.NetworkToHostOrder((int)BitConverter.ToUInt32(latitude, 0));
ms.Read(longitude,0,longitude.Length);
// _longitude = Tools.ByteToUInt(longitude);
_longitude = (uint)IPAddress.NetworkToHostOrder((int)BitConverter.ToUInt32(longitude, 0));
ms.Read(altitude,0,altitude.Length);
// _altitude = Tools.ByteToUInt(altitude);
_altitude = (uint)IPAddress.NetworkToHostOrder((int)BitConverter.ToUInt32(altitude, 0));
StringBuilder sb = new StringBuilder();
sb.Append("Version: ");
sb.Append(_version);
sb.Append("\r\n");
sb.Append("Size: ");
sb.Append(CalcSize(_size));
sb.Append(" m\r\n");
sb.Append("Horizontal Precision: ");
sb.Append(CalcSize(_horPrecision));
sb.Append(" m\r\n");
sb.Append("Vertical Precision: ");
sb.Append(CalcSize(_vertPrecision));
sb.Append(" m\r\n");
sb.Append("Latitude: ");
sb.Append(CalcLoc(_latitude, _latDirection));
sb.Append("\r\n");
sb.Append("Longitude: ");
sb.Append(CalcLoc(_longitude, _longDirection));
sb.Append("\r\n");
sb.Append("Altitude: ");
sb.Append((_altitude - 10000000) / 100.0);
sb.Append(" m\r\n");
_answer = sb.ToString();
}
private string CalcLoc(uint angle, char[] nsew)
{
char direction;
if (angle < 0x80000000)
{
angle = 0x80000000 - angle;
direction = nsew[1];
}
else
{
angle = angle - 0x80000000;
direction = nsew[0];
}
uint tsecs = angle % 1000;
angle = angle / 1000;
uint secs = angle % 60;
angle = angle / 60;
uint minutes = angle % 60;
uint degrees = angle / 60;
return degrees + " deg, " + minutes + " min " + secs+ "." + tsecs + " sec " + direction;
}
// return size in meters
private double CalcSize(byte val)
{
double size;
int exponent;
size = (val & 0xF0) >> 4;
exponent = (val & 0x0F);
while (exponent != 0)
{
size *= 10;
exponent--;
}
return size / 100;
}
}
}

View file

@ -1,66 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class MInfoRecord : DnsRecordBase
{
private string _responsibleMb;
private string _errorMb;
public string ResponsibleMb
{
get { return _responsibleMb; }
}
public string ErrorMb
{
get { return _errorMb; }
}
internal MInfoRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
_responsibleMb = DnsRecordBase.ParseName(ref ms);
_errorMb = DnsRecordBase.ParseName(ref ms);
_answer = "Responsible MailBox: " + _responsibleMb + ", Error MailBox: " + _errorMb;
}
}
}

View file

@ -1,52 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class MbRecord : DnsRecordBase
{
internal MbRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
//public override void ParseRecord(ref MemoryStream ms)
//{
// _answer = BaseDnsRecord.ParseName(ref ms);
//}
}
}

View file

@ -1,51 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class MgRecord : DnsRecordBase
{
internal MgRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
//public override void ParseRecord(ref MemoryStream ms)
//{
// _answer = BaseDnsRecord.ParseName(ref ms);
//}
}
}

View file

@ -1,51 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class MrRecord : DnsRecordBase
{
internal MrRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
//public override void ParseRecord(ref MemoryStream ms)
//{
// _answer = BaseDnsRecord.ParseName(ref ms);
//}
}
}

View file

@ -1,75 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
namespace DnDns.Records
{
public sealed class MxRecord : DnsRecordBase
{
// For MX
private short _preference;
private string _mailExchange;
public short Preference
{
get { return _preference; }
}
public string MailExchange
{
get { return _mailExchange; }
}
internal MxRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
// Preference is a function of MX records
byte[] nsPreference = new byte[2];
ms.Read(nsPreference, 0, 2);
//_preference = (short)Tools.ByteToUInt(nsPreference);
// TODO: Should this be a UShort instead of a short?
_preference = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(nsPreference, 0));
// Parse Name
_mailExchange = DnsRecordBase.ParseName(ref ms);
_answer = "MX Preference: " + _preference + ", Mail Exchanger: " + _mailExchange;
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordA6 : Record
{
public byte[] RDATA;
public RecordA6(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordAPL : Record
{
public byte[] RDATA;
public RecordAPL(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordATMA : Record
{
public byte[] RDATA;
public RecordATMA(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordCERT : Record
{
public byte[] RDATA;
public RecordCERT(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordDHCID : Record
{
public byte[] RDATA;
public RecordDHCID(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordDNSKEY : Record
{
public byte[] RDATA;
public RecordDNSKEY(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordEID : Record
{
public byte[] RDATA;
public RecordEID(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordGID : Record
{
public byte[] RDATA;
public RecordGID(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordHIP : Record
{
public byte[] RDATA;
public RecordHIP(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordIPSECKEY : Record
{
public byte[] RDATA;
public RecordIPSECKEY(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordNIMLOC : Record
{
public byte[] RDATA;
public RecordNIMLOC(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordNSEC : Record
{
public byte[] RDATA;
public RecordNSEC(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordNSEC3 : Record
{
public byte[] RDATA;
public RecordNSEC3(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordNSEC3PARAM : Record
{
public byte[] RDATA;
public RecordNSEC3PARAM(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordOPT : Record
{
public byte[] RDATA;
public RecordOPT(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordRRSIG : Record
{
public byte[] RDATA;
public RecordRRSIG(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordSINK : Record
{
public byte[] RDATA;
public RecordSINK(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordSPF : Record
{
public byte[] RDATA;
public RecordSPF(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordSSHFP : Record
{
public byte[] RDATA;
public RecordSSHFP(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordUID : Record
{
public byte[] RDATA;
public RecordUID(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordUINFO : Record
{
public byte[] RDATA;
public RecordUINFO(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,25 @@
using System;
/*
*/
namespace Heijden.DNS
{
public class RecordUNSPEC : Record
{
public byte[] RDATA;
public RecordUNSPEC(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("not-used");
}
}
}

View file

@ -0,0 +1,15 @@
using System;
namespace Heijden.DNS
{
public class RecordUnknown : Record
{
public byte[] RDATA;
public RecordUnknown(RecordReader rr)
{
// re-read length
ushort RDLENGTH = rr.ReadUInt16(-2);
RDATA = rr.ReadBytes(RDLENGTH);
}
}
}

View file

@ -1,51 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class NsRecord : DnsRecordBase
{
internal NsRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
//public override void ParseRecord(ref MemoryStream ms)
//{
// _answer = BaseDnsRecord.ParseName(ref ms);
//}
}
}

View file

@ -0,0 +1,65 @@
using System;
/*
* http://tools.ietf.org/rfc/rfc1712.txt
*
3. RDATA Format
MSB LSB
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ LONGITUDE /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ LATITUDE /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ ALTITUDE /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
LONGITUDE The real number describing the longitude encoded as a
printable string. The precision is limited by 256 charcters
within the range -90..90 degrees. Positive numbers
indicate locations north of the equator.
LATITUDE The real number describing the latitude encoded as a
printable string. The precision is limited by 256 charcters
within the range -180..180 degrees. Positive numbers
indicate locations east of the prime meridian.
ALTITUDE The real number describing the altitude (in meters) from
mean sea-level encoded as a printable string. The precision
is limited by 256 charcters. Positive numbers indicate
locations above mean sea-level.
Latitude/Longitude/Altitude values are encoded as strings as to avoid
the precision limitations imposed by encoding as unsigned integers.
Although this might not be considered optimal, it allows for a very
high degree of precision with an acceptable average encoded record
length.
*/
namespace Heijden.DNS
{
public class RecordGPOS : Record
{
public string LONGITUDE;
public string LATITUDE;
public string ALTITUDE;
public RecordGPOS(RecordReader rr)
{
LONGITUDE = rr.ReadString();
LATITUDE = rr.ReadString();
ALTITUDE = rr.ReadString();
}
public override string ToString()
{
return string.Format("{0} {1} {2}",
LONGITUDE,
LATITUDE,
ALTITUDE);
}
}
}

View file

@ -0,0 +1,41 @@
using System;
/*
3.3.4. MD RDATA format (Obsolete)
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ MADNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
MADNAME A <domain-name> which specifies a host which has a mail
agent for the domain which should be able to deliver
mail for the domain.
MD records cause additional section processing which looks up an A type
record corresponding to MADNAME.
MD is obsolete. See the definition of MX and [RFC-974] for details of
the new scheme. The recommended policy for dealing with MD RRs found in
a master file is to reject them, or to convert them to MX RRs with a
preference of 0.
* */
namespace Heijden.DNS
{
public class RecordMD : Record
{
public string MADNAME;
public RecordMD(RecordReader rr)
{
MADNAME = rr.ReadDomainName();
}
public override string ToString()
{
return MADNAME;
}
}
}

View file

@ -0,0 +1,41 @@
using System;
/*
*
3.3.5. MF RDATA format (Obsolete)
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ MADNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
MADNAME A <domain-name> which specifies a host which has a mail
agent for the domain which will accept mail for
forwarding to the domain.
MF records cause additional section processing which looks up an A type
record corresponding to MADNAME.
MF is obsolete. See the definition of MX and [RFC-974] for details ofw
the new scheme. The recommended policy for dealing with MD RRs found in
a master file is to reject them, or to convert them to MX RRs with a
preference of 10. */
namespace Heijden.DNS
{
public class RecordMF : Record
{
public string MADNAME;
public RecordMF(RecordReader rr)
{
MADNAME = rr.ReadDomainName();
}
public override string ToString()
{
return MADNAME;
}
}
}

View file

@ -0,0 +1,57 @@
using System;
/*
* http://tools.ietf.org/rfc/rfc1348.txt
* The NSAP-PTR RR
The NSAP-PTR RR is defined with mnemonic NSAP-PTR and a type code 23
(decimal).
Its function is analogous to the PTR record used for IP addresses [4,7].
NSAP-PTR has the following format:
<NSAP-suffix> <ttl> <class> NSAP-PTR <owner>
All fields are required.
<NSAP-suffix> enumerates the actual octet values assigned by the
assigning authority for the LOCAL network. Its format in master
files is a <character-string> syntactically identical to that used in
TXT and HINFO.
The format of NSAP-PTR is class insensitive. NSAP-PTR RR causes no
additional section processing.
For example:
In net ff08000574.nsap-in-addr.arpa:
444433332222111199990123000000ff NSAP-PTR foo.bar.com.
Or in net 11110031f67293.nsap-in-addr.arpa:
67894444333322220000 NSAP-PTR host.school.de.
The RR data is the ASCII representation of the digits. It is encoded
as a <character-string>.
*/
namespace Heijden.DNS
{
public class RecordNSAPPTR : Record
{
public string OWNER;
public RecordNSAPPTR(RecordReader rr)
{
OWNER = rr.ReadString();
}
public override string ToString()
{
return string.Format("{0}",OWNER);
}
}
}

View file

@ -0,0 +1,80 @@
using System;
using System.Text;
/*
* http://tools.ietf.org/rfc/rfc2065.txt
*
5.2 NXT RDATA Format
The RDATA for an NXT RR consists simply of a domain name followed by
a bit map.
The type number for the NXT RR is 30.
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| next domain name /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| type bit map /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The NXT RR type bit map is one bit per RR type present for the owner
name similar to the WKS socket bit map. The first bit represents RR
type zero (an illegal type which should not be present.) A one bit
indicates that at least one RR of that type is present for the owner
name. A zero indicates that no such RR is present. All bits not
specified because they are beyond the end of the bit map are assumed
to be zero. Note that bit 30, for NXT, will always be on so the
minimum bit map length is actually four octets. The NXT bit map
should be printed as a list of RR type mnemonics or decimal numbers
similar to the WKS RR.
The domain name may be compressed with standard DNS name compression
when being transmitted over the network. The size of the bit map can
be inferred from the RDLENGTH and the length of the next domain name.
*/
namespace Heijden.DNS
{
public class RecordNXT : Record
{
public string NEXTDOMAINNAME;
public byte[] BITMAP;
public RecordNXT(RecordReader rr)
{
ushort length = rr.ReadUInt16(-2);
NEXTDOMAINNAME = rr.ReadDomainName();
length -= (ushort)rr.Position;
BITMAP = new byte[length];
BITMAP = rr.ReadBytes(length);
}
private bool IsSet(int bitNr)
{
int intByte = (int)(bitNr / 8);
int intOffset = (bitNr % 8);
byte b = BITMAP[intByte];
int intTest = 1 << intOffset;
if ((b & intTest) == 0)
return false;
else
return true;
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
for (int bitNr = 1; bitNr < (BITMAP.Length * 8); bitNr++)
{
if (IsSet(bitNr))
sb.Append(" " + (Type)bitNr);
}
return string.Format("{0}{1}", NEXTDOMAINNAME, sb.ToString());
}
}
}

View file

@ -1,51 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class PtrRecord : DnsRecordBase
{
internal PtrRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
//public override void ParseRecord(ref MemoryStream ms)
//{
// _answer = BaseDnsRecord.ParseName(ref ms);
//}
}
}

View file

@ -0,0 +1,12 @@
// Stuff records are made of
namespace Heijden.DNS
{
public abstract class Record
{
/// <summary>
/// The Resource Record this RDATA record belongs to
/// </summary>
public RR RR;
}
}

View file

@ -0,0 +1,38 @@
using System;
/*
3.4.1. A RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ADDRESS |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
ADDRESS A 32 bit Internet address.
Hosts that have multiple Internet addresses will have multiple A
records.
*
*/
namespace Heijden.DNS
{
public class RecordA : Record
{
public System.Net.IPAddress Address;
public RecordA(RecordReader rr)
{
System.Net.IPAddress.TryParse(string.Format("{0}.{1}.{2}.{3}",
rr.ReadByte(),
rr.ReadByte(),
rr.ReadByte(),
rr.ReadByte()), out this.Address);
}
public override string ToString()
{
return Address.ToString();
}
}
}

View file

@ -0,0 +1,38 @@
using System;
#region Rfc info
/*
2.2 AAAA data format
A 128 bit IPv6 address is encoded in the data portion of an AAAA
resource record in network byte order (high-order byte first).
*/
#endregion
namespace Heijden.DNS
{
public class RecordAAAA : Record
{
public System.Net.IPAddress Address;
public RecordAAAA(RecordReader rr)
{
System.Net.IPAddress.TryParse(
string.Format("{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
rr.ReadUInt16(),
rr.ReadUInt16(),
rr.ReadUInt16(),
rr.ReadUInt16(),
rr.ReadUInt16(),
rr.ReadUInt16(),
rr.ReadUInt16(),
rr.ReadUInt16()), out this.Address);
}
public override string ToString()
{
return Address.ToString();
}
}
}

View file

@ -0,0 +1,52 @@
using System;
/* http://tools.ietf.org/rfc/rfc1183.txt
* 1. AFS Data Base location
This section defines an extension of the DNS to locate servers both
for AFS (AFS is a registered trademark of Transarc Corporation) and
for the Open Software Foundation's (OSF) Distributed Computing
Environment (DCE) authenticated naming system using HP/Apollo's NCA,
both to be components of the OSF DCE. The discussion assumes that
the reader is familiar with AFS [5] and NCA [6].
The AFS (originally the Andrew File System) system uses the DNS to
map from a domain name to the name of an AFS cell database server.
The DCE Naming service uses the DNS for a similar function: mapping
from the domain name of a cell to authenticated name servers for that
cell. The method uses a new RR type with mnemonic AFSDB and type
code of 18 (decimal).
AFSDB has the following format:
<owner> <ttl> <class> AFSDB <subtype> <hostname>
Both RDATA fields are required in all AFSDB RRs. The <subtype> field
is a 16 bit integer. The <hostname> field is a domain name of a host
that has a server for the cell named by the owner name of the RR.
*/
namespace Heijden.DNS
{
public class RecordAFSDB : Record
{
public ushort SUBTYPE;
public string HOSTNAME;
public RecordAFSDB(RecordReader rr)
{
SUBTYPE = rr.ReadUInt16();
//HOSTNAME = rr.ReadString();
HOSTNAME = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1}",
SUBTYPE,
HOSTNAME);
}
}
}

View file

@ -0,0 +1,39 @@
using System;
/*
*
3.3.1. CNAME RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ CNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
CNAME A <domain-name> which specifies the canonical or primary
name for the owner. The owner name is an alias.
CNAME RRs cause no additional section processing, but name servers may
choose to restart the query at the canonical name in certain cases. See
the description of name server logic in [RFC-1034] for details.
*
*/
namespace Heijden.DNS
{
public class RecordCNAME : Record
{
public string CNAME;
public RecordCNAME(RecordReader rr)
{
CNAME = rr.ReadDomainName();
}
public override string ToString()
{
return CNAME;
}
}
}

View file

@ -0,0 +1,34 @@
using System;
/*
* http://tools.ietf.org/rfc/rfc2672.txt
*
3. The DNAME Resource Record
The DNAME RR has mnemonic DNAME and type code 39 (decimal).
DNAME has the following format:
<owner> <ttl> <class> DNAME <target>
The format is not class-sensitive. All fields are required. The
RDATA field <target> is a <domain-name> [DNSIS].
*
*/
namespace Heijden.DNS
{
public class RecordDNAME : Record
{
public string TARGET;
public RecordDNAME(RecordReader rr)
{
TARGET = rr.ReadDomainName();
}
public override string ToString()
{
return TARGET;
}
}
}

View file

@ -0,0 +1,64 @@
using System;
using System.Text;
/*
* http://tools.ietf.org/rfc/rfc3658.txt
*
2.4. Wire Format of the DS record
The DS (type=43) record contains these fields: key tag, algorithm,
digest type, and the digest of a public key KEY record that is
allowed and/or used to sign the child's apex KEY RRset. Other keys
MAY sign the child's apex KEY RRset.
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| key tag | algorithm | Digest type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| digest (length depends on type) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| (SHA-1 digest is 20 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
namespace Heijden.DNS
{
public class RecordDS : Record
{
public UInt16 KEYTAG;
public byte ALGORITHM;
public byte DIGESTTYPE;
public byte[] DIGEST;
public RecordDS(RecordReader rr)
{
ushort length = rr.ReadUInt16(-2);
KEYTAG = rr.ReadUInt16();
ALGORITHM = rr.ReadByte();
DIGESTTYPE = rr.ReadByte();
length -= 4;
DIGEST = new byte[length];
DIGEST = rr.ReadBytes(length);
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
for (int intI = 0; intI < DIGEST.Length; intI++)
sb.AppendFormat("{0:x2}", DIGEST[intI]);
return string.Format("{0} {1} {2} {3}",
KEYTAG,
ALGORITHM,
DIGESTTYPE,
sb.ToString());
}
}
}

View file

@ -1,191 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using DnDns.Enums;
namespace DnDns.Records
{
class RecordFactory
{
public static IDnsRecord Create(ref MemoryStream ms)
{
IDnsRecord dnsRecord;
// Have to start out with an unknown record, since we have to parse the entire
// header before we can determine the type of DNS record it is.
// TODO: Consider other options.
// start as an unknown type, then create a known type, parse the response
// and return the object.
//DnsRecordBase dr = new DnsUnknownRecord();
//dr.ParseRecordHeader(ref ms);
RecordHeader dnsHeader = new RecordHeader();
dnsHeader.ParseRecordHeader(ref ms);
switch (dnsHeader.NsType)
{
case NsType.A:
{
dnsRecord = new ARecord(dnsHeader);
break;
}
case NsType.AAAA:
{
dnsRecord = new AaaaRecord(dnsHeader);
break;
}
case NsType.MX:
{
dnsRecord = new MxRecord(dnsHeader);
break;
}
case NsType.RP:
{
dnsRecord = new RpRecord(dnsHeader);
break;
}
case NsType.MR:
{
dnsRecord = new MrRecord(dnsHeader);
break;
}
case NsType.MB:
{
dnsRecord = new MbRecord(dnsHeader);
break;
}
case NsType.MG:
{
dnsRecord = new MgRecord(dnsHeader);
break;
}
case NsType.NS:
{
dnsRecord = new NsRecord(dnsHeader);
break;
}
case NsType.CNAME:
{
dnsRecord = new CNameRecord(dnsHeader);
break;
}
case NsType.PTR:
{
dnsRecord = new PtrRecord(dnsHeader);
break;
}
case NsType.HINFO:
{
dnsRecord = new HInfoRecord(dnsHeader);
break;
}
case NsType.MINFO:
{
dnsRecord = new MInfoRecord(dnsHeader);
break;
}
case NsType.X25:
{
dnsRecord = new X25Record(dnsHeader);
break;
}
case NsType.TXT:
{
dnsRecord = new TxtRecord(dnsHeader);
break;
}
case NsType.LOC:
{
dnsRecord = new LocRecord(dnsHeader);
break;
}
case NsType.SOA:
{
dnsRecord = new SoaRecord(dnsHeader);
break;
}
case NsType.SRV:
{
dnsRecord = new SrvRecord(dnsHeader);
break;
}
case NsType.AFSDB:
{
dnsRecord = new AfsdbRecord(dnsHeader);
break;
}
case NsType.ATMA:
{
dnsRecord = new AtmaRecord(dnsHeader);
break;
}
case NsType.ISDN:
{
dnsRecord = new IsdnRecord(dnsHeader);
break;
}
case NsType.RT:
{
dnsRecord = new RtRecord(dnsHeader);
break;
}
case NsType.WKS:
{
dnsRecord = new WksRecord(dnsHeader);
break;
}
case NsType.TSIG:
{
dnsRecord = new TSigRecord(dnsHeader);
break;
}
default:
{
// Unknown type. parse and return the DnsUnknownRecord
dnsRecord = new UnknownRecord(dnsHeader);
break;
}
}
//dnsRecord.ParseRecordHeader(ref ms);
dnsRecord.ParseRecord(ref ms);
return dnsRecord;
}
}
}

View file

@ -0,0 +1,45 @@
using System;
/*
3.3.2. HINFO RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ CPU /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ OS /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
CPU A <character-string> which specifies the CPU type.
OS A <character-string> which specifies the operating
system type.
Standard values for CPU and OS can be found in [RFC-1010].
HINFO records are used to acquire general information about a host. The
main use is for protocols such as FTP that can use special procedures
when talking between machines or operating systems of the same type.
*/
namespace Heijden.DNS
{
public class RecordHINFO : Record
{
public string CPU;
public string OS;
public RecordHINFO(RecordReader rr)
{
CPU = rr.ReadString();
OS = rr.ReadString();
}
public override string ToString()
{
return string.Format("CPU={0} OS={1}",CPU,OS);
}
}
}

View file

@ -1,242 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using DnDns.Enums;
namespace DnDns.Records
{
/// <summary>
/// The DnsRecordHeader class contains fields, properties and
/// parsing cababilities within the DNS Record except the the
/// RDATA. The Name, Type, Class, TTL, and RDLength.
///
/// This class is used in the DnsRecordFactory to instantiate
/// concrete DnsRecord Classes.
///
/// RFC 1035
///
/// 3.2.1. Format
///
/// All RRs have the same top level format shown below:
///
/// 1 1 1 1 1 1
/// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | |
/// / /
/// / NAME /
/// | |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | TYPE |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | CLASS |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | TTL |
/// | |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/// | RDLENGTH |
/// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
///
/// where:
///
/// NAME an owner name, i.e., the name of the node to which this
/// resource record pertains.
///
/// TYPE two octets containing one of the RR TYPE codes.
///
/// CLASS two octets containing one of the RR CLASS codes.
///
/// TTL a 32 bit signed integer that specifies the time interval
/// that the resource record may be cached before the source
/// of the information should again be consulted. Zero
/// values are interpreted to mean that the RR can only be
/// used for the transaction in progress, and should not be
/// cached. For example, SOA records are always distributed
/// with a zero TTL to prohibit caching. Zero values can
/// also be used for extremely volatile data.
///
/// RDLENGTH an unsigned 16 bit integer that specifies the length in
/// octets of the RDATA field.
///
/// </summary>
public class RecordHeader
{
#region Fields
// NAME an owner name, i.e., the name of the node to which this
// resource record pertains.
private string _name;
// TYPE two octets containing one of the RR TYPE codes.
private NsType _nsType;
// CLASS - two octets containing one of the RR CLASS codes.
private NsClass _nsClass;
// TTL - a 32 bit signed integer that specifies the time interval
// that the resource record may be cached before the source
// of the information should again be consulted. Zero
// values are interpreted to mean that the RR can only be
// used for the transaction in progress, and should not be
// cached. For example, SOA records are always distributed
// with a zero TTL to prohibit caching. Zero values can
/// also be used for extremely volatile data.
private int _timeToLive;
// RDLENGTH - an unsigned 16 bit integer that specifies the length in
// octets of the RDATA field.
private short _dataLength;
/// <summary>
/// Initalise the <see cref="RecordHeader"/>
/// </summary>
/// <param name="name">The header name</param>
/// <param name="nsType">The resource type</param>
/// <param name="nsClass">The class type</param>
/// <param name="timeToLive">The time to live</param>
public RecordHeader(string name, NsType nsType, NsClass nsClass, int timeToLive)
{
_name = name;
_nsType = nsType;
_nsClass = nsClass;
_timeToLive = timeToLive;
}
public RecordHeader()
{
}
#endregion
#region Properties
/// <summary>
/// NAME - an owner name, i.e., the name of the node to which this
/// resource record pertains.
/// </summary>
public string Name
{
get { return _name; }
}
/// <summary>
/// TYPE two octets containing one of the RR TYPE codes.
/// </summary>
public NsType NsType
{
get { return _nsType; }
}
/// <summary>
/// CLASS - two octets containing one of the RR CLASS codes.
/// </summary>
public NsClass NsClass
{
get { return _nsClass; }
}
/// <summary>
/// TTL - a 32 bit signed integer that specifies the time interval
/// that the resource record may be cached before the source
/// of the information should again be consulted. Zero
/// values are interpreted to mean that the RR can only be
/// used for the transaction in progress, and should not be
/// cached. For example, SOA records are always distributed
/// with a zero TTL to prohibit caching. Zero values can
/// also be used for extremely volatile data.
/// </summary>
public int TimeToLive
{
get { return _timeToLive; }
}
/// <summary>
/// RDLENGTH - an unsigned 16 bit integer that specifies the length in
/// octets of the RDATA field.
/// </summary>
public short DataLength
{
get { return _dataLength; }
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="ms"></param>
public void ParseRecordHeader(ref MemoryStream ms)
{
byte[] nsType = new byte[2];
byte[] nsClass = new byte[2];
byte[] nsTTL = new byte[4];
byte[] nsDataLength = new byte[2];
// Read the name
_name = DnsRecordBase.ParseName(ref ms);
// Read the data header
ms.Read(nsType, 0, 2);
ms.Read(nsClass, 0, 2);
ms.Read(nsTTL, 0, 4);
ms.Read(nsDataLength, 0, 2);
_nsType = (NsType)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(nsType, 0));
_nsClass = (NsClass)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(nsClass, 0));
_timeToLive = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(nsTTL, 0));
_dataLength = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(nsDataLength, 0));
}
internal byte[] GetMessageBytes()
{
MemoryStream memoryStream = new MemoryStream();
byte[] data = DnsHelpers.CanonicaliseDnsName(_name, false);
memoryStream.Write(data,0,data.Length);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder((ushort)_nsType) >> 16));
memoryStream.Write(data, 0, data.Length);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder((ushort)_nsClass) >> 16));
memoryStream.Write(data, 0, data.Length);
data = BitConverter.GetBytes((uint)(IPAddress.HostToNetworkOrder((ushort)_timeToLive) >> 32));
memoryStream.Write(data, 0, data.Length);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder((ushort)_dataLength) >> 16));
memoryStream.Write(data, 0, data.Length);
return memoryStream.ToArray();
}
}
}

View file

@ -0,0 +1,91 @@
using System;
/* http://tools.ietf.org/rfc/rfc1183.txt
3.2. The ISDN RR
The ISDN RR is defined with mnemonic ISDN and type code 20 (decimal).
An ISDN (Integrated Service Digital Network) number is simply a
telephone number. The intent of the members of the CCITT is to
upgrade all telephone and data network service to a common service.
The numbering plan (E.163/E.164) is the same as the familiar
international plan for POTS (an un-official acronym, meaning Plain
Old Telephone Service). In E.166, CCITT says "An E.163/E.164
telephony subscriber may become an ISDN subscriber without a number
change."
ISDN has the following format:
<owner> <ttl> <class> ISDN <ISDN-address> <sa>
The <ISDN-address> field is required; <sa> is optional.
<ISDN-address> identifies the ISDN number of <owner> and DDI (Direct
Dial In) if any, as defined by E.164 [8] and E.163 [7], the ISDN and
PSTN (Public Switched Telephone Network) numbering plan. E.163
defines the country codes, and E.164 the form of the addresses. Its
format in master files is a <character-string> syntactically
identical to that used in TXT and HINFO.
<sa> specifies the subaddress (SA). The format of <sa> in master
files is a <character-string> syntactically identical to that used in
TXT and HINFO.
The format of ISDN is class insensitive. ISDN RRs cause no
additional section processing.
The <ISDN-address> is a string of characters, normally decimal
digits, beginning with the E.163 country code and ending with the DDI
if any. Note that ISDN, in Q.931, permits any IA5 character in the
general case.
The <sa> is a string of hexadecimal digits. For digits 0-9, the
concrete encoding in the Q.931 call setup information element is
identical to BCD.
For example:
Relay.Prime.COM. IN ISDN 150862028003217
sh.Prime.COM. IN ISDN 150862028003217 004
(Note: "1" is the country code for the North American Integrated
Numbering Area, i.e., the system of "area codes" familiar to people
in those countries.)
The RR data is the ASCII representation of the digits. It is encoded
as one or two <character-string>s, i.e., count followed by
characters.
CCITT recommendation E.166 [9] defines prefix escape codes for the
representation of ISDN (E.163/E.164) addresses in X.121, and PSDN
(X.121) addresses in E.164. It specifies that the exact codes are a
"national matter", i.e., different on different networks. A host
connected to the ISDN may be able to use both the X25 and ISDN
addresses, with the local prefix added.
*/
namespace Heijden.DNS
{
public class RecordISDN : Record
{
public string ISDNADDRESS;
public string SA;
public RecordISDN(RecordReader rr)
{
ISDNADDRESS = rr.ReadString();
SA = rr.ReadString();
}
public override string ToString()
{
return string.Format("{0} {1}",
ISDNADDRESS,
SA);
}
}
}

View file

@ -0,0 +1,65 @@
using System;
#region Rfc info
/* http://www.ietf.org/rfc/rfc2535.txt
*
3.1 KEY RDATA format
The RDATA for a KEY RR consists of flags, a protocol octet, the
algorithm number octet, and the public key itself. The format is as
follows:
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| flags | protocol | algorithm |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| /
/ public key /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
The KEY RR is not intended for storage of certificates and a separate
certificate RR has been developed for that purpose, defined in [RFC
2538].
The meaning of the KEY RR owner name, flags, and protocol octet are
described in Sections 3.1.1 through 3.1.5 below. The flags and
algorithm must be examined before any data following the algorithm
octet as they control the existence and format of any following data.
The algorithm and public key fields are described in Section 3.2.
The format of the public key is algorithm dependent.
KEY RRs do not specify their validity period but their authenticating
SIG RR(s) do as described in Section 4 below.
*/
#endregion
namespace Heijden.DNS
{
public class RecordKEY : Record
{
public UInt16 FLAGS;
public byte PROTOCOL;
public byte ALGORITHM;
public string PUBLICKEY;
public RecordKEY(RecordReader rr)
{
FLAGS = rr.ReadUInt16();
PROTOCOL = rr.ReadByte();
ALGORITHM = rr.ReadByte();
PUBLICKEY = rr.ReadString();
}
public override string ToString()
{
return string.Format("{0} {1} {2} \"{3}\"",
FLAGS,
PROTOCOL,
ALGORITHM,
PUBLICKEY);
}
}
}

View file

@ -0,0 +1,65 @@
using System;
/*
* http://tools.ietf.org/rfc/rfc2230.txt
*
* 3.1 KX RDATA format
The KX DNS record has the following RDATA format:
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| PREFERENCE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ EXCHANGER /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
PREFERENCE A 16 bit non-negative integer which specifies the
preference given to this RR among other KX records
at the same owner. Lower values are preferred.
EXCHANGER A <domain-name> which specifies a host willing to
act as a mail exchange for the owner name.
KX records MUST cause type A additional section processing for the
host specified by EXCHANGER. In the event that the host processing
the DNS transaction supports IPv6, KX records MUST also cause type
AAAA additional section processing.
The KX RDATA field MUST NOT be compressed.
*/
namespace Heijden.DNS
{
public class RecordKX : Record, IComparable
{
public ushort PREFERENCE;
public string EXCHANGER;
public RecordKX(RecordReader rr)
{
PREFERENCE = rr.ReadUInt16();
EXCHANGER = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1}", PREFERENCE, EXCHANGER);
}
public int CompareTo(object objA)
{
RecordKX recordKX = objA as RecordKX;
if (recordKX == null)
return -1;
else if (this.PREFERENCE > recordKX.PREFERENCE)
return 1;
else if (this.PREFERENCE < recordKX.PREFERENCE)
return -1;
else // they are the same, now compare case insensitive names
return string.Compare(this.EXCHANGER, recordKX.EXCHANGER, true);
}
}
}

View file

@ -0,0 +1,199 @@
using System;
using System.Text;
/*
* http://www.ietf.org/rfc/rfc1876.txt
*
2. RDATA Format
MSB LSB
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
0| VERSION | SIZE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
2| HORIZ PRE | VERT PRE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
4| LATITUDE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
6| LATITUDE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
8| LONGITUDE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
10| LONGITUDE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
12| ALTITUDE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
14| ALTITUDE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
VERSION Version number of the representation. This must be zero.
Implementations are required to check this field and make
no assumptions about the format of unrecognized versions.
SIZE The diameter of a sphere enclosing the described entity, in
centimeters, expressed as a pair of four-bit unsigned
integers, each ranging from zero to nine, with the most
significant four bits representing the base and the second
number representing the power of ten by which to multiply
the base. This allows sizes from 0e0 (<1cm) to 9e9
(90,000km) to be expressed. This representation was chosen
such that the hexadecimal representation can be read by
eye; 0x15 = 1e5. Four-bit values greater than 9 are
undefined, as are values with a base of zero and a non-zero
exponent.
Since 20000000m (represented by the value 0x29) is greater
than the equatorial diameter of the WGS 84 ellipsoid
(12756274m), it is therefore suitable for use as a
"worldwide" size.
HORIZ PRE The horizontal precision of the data, in centimeters,
expressed using the same representation as SIZE. This is
the diameter of the horizontal "circle of error", rather
than a "plus or minus" value. (This was chosen to match
the interpretation of SIZE; to get a "plus or minus" value,
divide by 2.)
VERT PRE The vertical precision of the data, in centimeters,
expressed using the sane representation as for SIZE. This
is the total potential vertical error, rather than a "plus
or minus" value. (This was chosen to match the
interpretation of SIZE; to get a "plus or minus" value,
divide by 2.) Note that if altitude above or below sea
level is used as an approximation for altitude relative to
the [WGS 84] ellipsoid, the precision value should be
adjusted.
LATITUDE The latitude of the center of the sphere described by the
SIZE field, expressed as a 32-bit integer, most significant
octet first (network standard byte order), in thousandths
of a second of arc. 2^31 represents the equator; numbers
above that are north latitude.
LONGITUDE The longitude of the center of the sphere described by the
SIZE field, expressed as a 32-bit integer, most significant
octet first (network standard byte order), in thousandths
of a second of arc, rounded away from the prime meridian.
2^31 represents the prime meridian; numbers above that are
east longitude.
ALTITUDE The altitude of the center of the sphere described by the
SIZE field, expressed as a 32-bit integer, most significant
octet first (network standard byte order), in centimeters,
from a base of 100,000m below the [WGS 84] reference
spheroid used by GPS (semimajor axis a=6378137.0,
reciprocal flattening rf=298.257223563). Altitude above
(or below) sea level may be used as an approximation of
altitude relative to the the [WGS 84] spheroid, though due
to the Earth's surface not being a perfect spheroid, there
will be differences. (For example, the geoid (which sea
level approximates) for the continental US ranges from 10
meters to 50 meters below the [WGS 84] spheroid.
Adjustments to ALTITUDE and/or VERT PRE will be necessary
in most cases. The Defense Mapping Agency publishes geoid
height values relative to the [WGS 84] ellipsoid.
*/
namespace Heijden.DNS
{
public class RecordLOC : Record
{
public byte VERSION;
public byte SIZE;
public byte HORIZPRE;
public byte VERTPRE;
public UInt32 LATITUDE;
public UInt32 LONGITUDE;
public UInt32 ALTITUDE;
private string SizeToString(byte s)
{
string strUnit = "cm";
int intBase = s >> 4;
int intPow = s & 0x0f;
if (intPow >= 2)
{
intPow -= 2;
strUnit = "m";
}
/*
if (intPow >= 3)
{
intPow -= 3;
strUnit = "km";
}
*/
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0}", intBase);
for (; intPow > 0; intPow--)
sb.Append('0');
sb.Append(strUnit);
return sb.ToString();
}
private string LonToTime(UInt32 r)
{
UInt32 Mid = 2147483648; // 2^31
char Dir = 'E';
if (r > Mid)
{
Dir = 'W';
r -= Mid;
}
double h = r / (360000.0 * 10.0);
double m = 60.0 * (h - (int)h);
double s = 60.0 * (m - (int)m);
return string.Format("{0} {1} {2:0.000} {3}", (int)h, (int)m, s, Dir);
}
private string ToTime(UInt32 r, char Below,char Above)
{
UInt32 Mid = 2147483648; // 2^31
char Dir = '?';
if (r > Mid)
{
Dir = Above;
r -= Mid;
}
else
{
Dir = Below;
r = Mid - r;
}
double h = r / (360000.0 * 10.0);
double m = 60.0 * (h - (int)h);
double s = 60.0 * (m - (int)m);
return string.Format("{0} {1} {2:0.000} {3}", (int)h, (int)m, s, Dir);
}
private string ToAlt(UInt32 a)
{
double alt = (a / 100.0) - 100000.00;
return string.Format("{0:0.00}m", alt);
}
public RecordLOC(RecordReader rr)
{
VERSION = rr.ReadByte(); // must be 0!
SIZE = rr.ReadByte();
HORIZPRE = rr.ReadByte();
VERTPRE = rr.ReadByte();
LATITUDE = rr.ReadUInt32();
LONGITUDE = rr.ReadUInt32();
ALTITUDE = rr.ReadUInt32();
}
public override string ToString()
{
return string.Format("{0} {1} {2} {3} {4} {5}",
ToTime(LATITUDE,'S','N'),
ToTime(LONGITUDE,'W','E'),
ToAlt(ALTITUDE),
SizeToString(SIZE),
SizeToString(HORIZPRE),
SizeToString(VERTPRE));
}
}
}

View file

@ -0,0 +1,35 @@
using System;
/*
3.3.3. MB RDATA format (EXPERIMENTAL)
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ MADNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
MADNAME A <domain-name> which specifies a host which has the
specified mailbox.
MB records cause additional section processing which looks up an A type
RRs corresponding to MADNAME.
*/
namespace Heijden.DNS
{
public class RecordMB : Record
{
public string MADNAME;
public RecordMB(RecordReader rr)
{
MADNAME = rr.ReadDomainName();
}
public override string ToString()
{
return MADNAME;
}
}
}

View file

@ -0,0 +1,34 @@
using System;
/*
3.3.6. MG RDATA format (EXPERIMENTAL)
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ MGMNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
MGMNAME A <domain-name> which specifies a mailbox which is a
member of the mail group specified by the domain name.
MG records cause no additional section processing.
*/
namespace Heijden.DNS
{
public class RecordMG : Record
{
public string MGMNAME;
public RecordMG(RecordReader rr)
{
MGMNAME = rr.ReadDomainName();
}
public override string ToString()
{
return MGMNAME;
}
}
}

View file

@ -0,0 +1,52 @@
using System;
/*
3.3.7. MINFO RDATA format (EXPERIMENTAL)
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ RMAILBX /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ EMAILBX /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
RMAILBX A <domain-name> which specifies a mailbox which is
responsible for the mailing list or mailbox. If this
domain name names the root, the owner of the MINFO RR is
responsible for itself. Note that many existing mailing
lists use a mailbox X-request for the RMAILBX field of
mailing list X, e.g., Msgroup-request for Msgroup. This
field provides a more general mechanism.
EMAILBX A <domain-name> which specifies a mailbox which is to
receive error messages related to the mailing list or
mailbox specified by the owner of the MINFO RR (similar
to the ERRORS-TO: field which has been proposed). If
this domain name names the root, errors should be
returned to the sender of the message.
MINFO records cause no additional section processing. Although these
records can be associated with a simple mailbox, they are usually used
with a mailing list.
*/
namespace Heijden.DNS
{
public class RecordMINFO : Record
{
public string RMAILBX;
public string EMAILBX;
public RecordMINFO(RecordReader rr)
{
RMAILBX = rr.ReadDomainName();
EMAILBX = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1}",RMAILBX,EMAILBX);
}
}
}

View file

@ -0,0 +1,36 @@
using System;
/*
3.3.8. MR RDATA format (EXPERIMENTAL)
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ NEWNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
NEWNAME A <domain-name> which specifies a mailbox which is the
proper rename of the specified mailbox.
MR records cause no additional section processing. The main use for MR
is as a forwarding entry for a user who has moved to a different
mailbox.
*/
namespace Heijden.DNS
{
public class RecordMR : Record
{
public string NEWNAME;
public RecordMR(RecordReader rr)
{
NEWNAME = rr.ReadDomainName();
}
public override string ToString()
{
return NEWNAME;
}
}
}

View file

@ -0,0 +1,59 @@
using System;
namespace Heijden.DNS
{
/*
3.3.9. MX RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| PREFERENCE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ EXCHANGE /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
PREFERENCE A 16 bit integer which specifies the preference given to
this RR among others at the same owner. Lower values
are preferred.
EXCHANGE A <domain-name> which specifies a host willing to act as
a mail exchange for the owner name.
MX records cause type A additional section processing for the host
specified by EXCHANGE. The use of MX RRs is explained in detail in
[RFC-974].
*/
public class RecordMX : Record, IComparable
{
public ushort PREFERENCE;
public string EXCHANGE;
public RecordMX(RecordReader rr)
{
PREFERENCE = rr.ReadUInt16();
EXCHANGE = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1}", PREFERENCE, EXCHANGE);
}
public int CompareTo(object objA)
{
RecordMX recordMX = objA as RecordMX;
if (recordMX == null)
return -1;
else if (this.PREFERENCE > recordMX.PREFERENCE)
return 1;
else if (this.PREFERENCE < recordMX.PREFERENCE)
return -1;
else // they are the same, now compare case insensitive names
return string.Compare(this.EXCHANGE, recordMX.EXCHANGE, true);
}
}
}

View file

@ -0,0 +1,77 @@
using System;
/*
* http://www.faqs.org/rfcs/rfc2915.html
*
8. DNS Packet Format
The packet format for the NAPTR record is:
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ORDER |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| PREFERENCE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ FLAGS /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ SERVICES /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ REGEXP /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ REPLACEMENT /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
FLAGS A <character-string> which contains various flags.
SERVICES A <character-string> which contains protocol and service
identifiers.
REGEXP A <character-string> which contains a regular expression.
REPLACEMENT A <domain-name> which specifies the new value in the
case where the regular expression is a simple replacement
operation.
<character-string> and <domain-name> as used here are defined in
RFC1035 [1].
*/
namespace Heijden.DNS
{
public class RecordNAPTR : Record
{
public ushort ORDER;
public ushort PREFERENCE;
public string FLAGS;
public string SERVICES;
public string REGEXP;
public string REPLACEMENT;
public RecordNAPTR(RecordReader rr)
{
ORDER = rr.ReadUInt16();
PREFERENCE = rr.ReadUInt16();
FLAGS = rr.ReadString();
SERVICES = rr.ReadString();
REGEXP = rr.ReadString();
REPLACEMENT = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1} \"{2}\" \"{3}\" \"{4}\" {5}",
ORDER,
PREFERENCE,
FLAGS,
SERVICES,
REGEXP,
REPLACEMENT);
}
}
}

View file

@ -0,0 +1,43 @@
using System;
/*
3.3.11. NS RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ NSDNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
NSDNAME A <domain-name> which specifies a host which should be
authoritative for the specified class and domain.
NS records cause both the usual additional section processing to locate
a type A record, and, when used in a referral, a special search of the
zone in which they reside for glue information.
The NS RR states that the named host should be expected to have a zone
starting at owner name of the specified class. Note that the class may
not indicate the protocol family which should be used to communicate
with the host, although it is typically a strong hint. For example,
hosts which are name servers for either Internet (IN) or Hesiod (HS)
class information are normally queried using IN class protocols.
*/
namespace Heijden.DNS
{
public class RecordNS : Record
{
public string NSDNAME;
public RecordNS(RecordReader rr)
{
NSDNAME = rr.ReadDomainName();
}
public override string ToString()
{
return NSDNAME;
}
}
}

View file

@ -0,0 +1,72 @@
using System;
using System.Text;
/*
* http://tools.ietf.org/rfc/rfc1348.txt
* http://tools.ietf.org/html/rfc1706
*
* |--------------|
| <-- IDP --> |
|--------------|-------------------------------------|
| AFI | IDI | <-- DSP --> |
|-----|--------|-------------------------------------|
| 47 | 0005 | DFI | AA |Rsvd | RD |Area | ID |Sel |
|-----|--------|-----|----|-----|----|-----|----|----|
octets | 1 | 2 | 1 | 3 | 2 | 2 | 2 | 6 | 1 |
|-----|--------|-----|----|-----|----|-----|----|----|
IDP Initial Domain Part
AFI Authority and Format Identifier
IDI Initial Domain Identifier
DSP Domain Specific Part
DFI DSP Format Identifier
AA Administrative Authority
Rsvd Reserved
RD Routing Domain Identifier
Area Area Identifier
ID System Identifier
SEL NSAP Selector
Figure 1: GOSIP Version 2 NSAP structure.
*/
namespace Heijden.DNS
{
public class RecordNSAP : Record
{
public ushort LENGTH;
public byte[] NSAPADDRESS;
public RecordNSAP(RecordReader rr)
{
LENGTH = rr.ReadUInt16();
NSAPADDRESS = rr.ReadBytes(LENGTH);
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0} ", LENGTH);
for (int intI = 0; intI < NSAPADDRESS.Length; intI++)
sb.AppendFormat("{0:X00}", NSAPADDRESS[intI]);
return sb.ToString();
}
public string ToGOSIPV2()
{
return string.Format("{0:X}.{1:X}.{2:X}.{3:X}.{4:X}.{5:X}.{6:X}{7:X}.{8:X}",
NSAPADDRESS[0], // AFI
NSAPADDRESS[1] << 8 | NSAPADDRESS[2], // IDI
NSAPADDRESS[3], // DFI
NSAPADDRESS[4] << 16 | NSAPADDRESS[5] << 8 | NSAPADDRESS[6], // AA
NSAPADDRESS[7] << 8 | NSAPADDRESS[8], // Rsvd
NSAPADDRESS[9] << 8 | NSAPADDRESS[10],// RD
NSAPADDRESS[11] << 8 | NSAPADDRESS[12],// Area
NSAPADDRESS[13] << 16 | NSAPADDRESS[14] << 8 | NSAPADDRESS[15], // ID-High
NSAPADDRESS[16] << 16 | NSAPADDRESS[17] << 8 | NSAPADDRESS[18], // ID-Low
NSAPADDRESS[19]);
}
}
}

View file

@ -0,0 +1,38 @@
using System;
/*
3.3.10. NULL RDATA format (EXPERIMENTAL)
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ <anything> /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Anything at all may be in the RDATA field so long as it is 65535 octets
or less.
NULL records cause no additional section processing. NULL RRs are not
allowed in master files. NULLs are used as placeholders in some
experimental extensions of the DNS.
*/
namespace Heijden.DNS
{
public class RecordNULL : Record
{
public byte[] ANYTHING;
public RecordNULL(RecordReader rr)
{
rr.Position -= 2;
// re-read length
ushort RDLENGTH = rr.ReadUInt16();
ANYTHING = new byte[RDLENGTH];
ANYTHING = rr.ReadBytes(RDLENGTH);
}
public override string ToString()
{
return string.Format("...binary data... ({0}) bytes",ANYTHING.Length);
}
}
}

View file

@ -0,0 +1,38 @@
using System;
/*
3.3.12. PTR RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ PTRDNAME /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
PTRDNAME A <domain-name> which points to some location in the
domain name space.
PTR records cause no additional section processing. These RRs are used
in special domains to point to some other location in the domain space.
These records are simple data, and don't imply any special processing
similar to that performed by CNAME, which identifies aliases. See the
description of the IN-ADDR.ARPA domain for an example.
*/
namespace Heijden.DNS
{
public class RecordPTR : Record
{
public string PTRDNAME;
public RecordPTR(RecordReader rr)
{
PTRDNAME = rr.ReadDomainName();
}
public override string ToString()
{
return PTRDNAME;
}
}
}

View file

@ -0,0 +1,97 @@
using System;
/*
* http://tools.ietf.org/rfc/rfc2163.txt
*
4. The new DNS resource record for MIXER mapping rules: PX
The specification of the Internet DNS (RFC1035) provides a number of
specific resource records (RRs) to contain specific pieces of
information. In particular they contain the Mail eXchanger (MX) RR
and the host Address (A) records which are used by the Internet SMTP
mailers. As we will store the RFC822 to X.400 mapping information in
the already existing DNS name tree, we need to define a new DNS RR in
order to avoid any possible clash or misuse of already existing data
structures. The same new RR will also be used to store the mappings
from X.400 to RFC822. More over the mapping information, i.e., the
MCGAMs, has a specific format and syntax which require an appropriate
data structure and processing. A further advantage of defining a new
RR is the ability to include flexibility for some eventual future
development.
The definition of the new 'PX' DNS resource record is:
class: IN (Internet)
name: PX (pointer to X.400/RFC822 mapping information)
value: 26
The PX RDATA format is:
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| PREFERENCE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ MAP822 /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ MAPX400 /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
PREFERENCE A 16 bit integer which specifies the preference given to
this RR among others at the same owner. Lower values
are preferred;
MAP822 A <domain-name> element containing <rfc822-domain>, the
RFC822 part of the MCGAM;
MAPX400 A <domain-name> element containing the value of
<x400-in-domain-syntax> derived from the X.400 part of
the MCGAM (see sect. 4.2);
PX records cause no additional section processing. The PX RR format
is the usual one:
<name> [<class>] [<TTL>] <type> <RDATA>
When we store in DNS a 'table1' or a 'gate1' entry, then <name> will
be an X.400 mail domain name in DNS syntax (see sect. 4.2). When we
store a 'table2' or a 'gate2' table entry, <name> will be an RFC822
mail domain name, including both fully qualified DNS domains and mail
only domains (MX-only domains). All normal DNS conventions, like
default values, wildcards, abbreviations and message compression,
apply also for all the components of the PX RR. In particular <name>,
MAP822 and MAPX400, as <domain-name> elements, must have the final
"." (root) when they are fully qualified.
*/
namespace Heijden.DNS
{
public class RecordPX : Record
{
public UInt16 PREFERENCE;
public string MAP822;
public string MAPX400;
public RecordPX(RecordReader rr)
{
PREFERENCE = rr.ReadUInt16();
MAP822 = rr.ReadDomainName();
MAPX400 = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1} {2}",
PREFERENCE,
MAP822,
MAPX400);
}
}
}

View file

@ -0,0 +1,54 @@
using System;
/* http://tools.ietf.org/rfc/rfc1183.txt
2.2. The Responsible Person RR
The method uses a new RR type with mnemonic RP and type code of 17
(decimal).
RP has the following format:
<owner> <ttl> <class> RP <mbox-dname> <txt-dname>
Both RDATA fields are required in all RP RRs.
The first field, <mbox-dname>, is a domain name that specifies the
mailbox for the responsible person. Its format in master files uses
the DNS convention for mailbox encoding, identical to that used for
the RNAME mailbox field in the SOA RR. The root domain name (just
".") may be specified for <mbox-dname> to indicate that no mailbox is
available.
The second field, <txt-dname>, is a domain name for which TXT RR's
exist. A subsequent query can be performed to retrieve the
associated TXT resource records at <txt-dname>. This provides a
level of indirection so that the entity can be referred to from
multiple places in the DNS. The root domain name (just ".") may be
specified for <txt-dname> to indicate that the TXT_DNAME is absent,
and no associated TXT RR exists.
*/
namespace Heijden.DNS
{
public class RecordRP : Record
{
public string MBOXDNAME;
public string TXTDNAME;
public RecordRP(RecordReader rr)
{
//MBOXDNAME = rr.ReadString();
MBOXDNAME = rr.ReadDomainName();
TXTDNAME = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1}",
MBOXDNAME,
TXTDNAME);
}
}
}

View file

@ -0,0 +1,76 @@
using System;
/* http://tools.ietf.org/rfc/rfc1183.txt
3.3. The Route Through RR
The Route Through RR is defined with mnemonic RT and type code 21
(decimal).
The RT resource record provides a route-through binding for hosts
that do not have their own direct wide area network addresses. It is
used in much the same way as the MX RR.
RT has the following format:
<owner> <ttl> <class> RT <preference> <intermediate-host>
Both RDATA fields are required in all RT RRs.
The first field, <preference>, is a 16 bit integer, representing the
preference of the route. Smaller numbers indicate more preferred
routes.
<intermediate-host> is the domain name of a host which will serve as
an intermediate in reaching the host specified by <owner>. The DNS
RRs associated with <intermediate-host> are expected to include at
least one A, X25, or ISDN record.
The format of the RT RR is class insensitive. RT records cause type
X25, ISDN, and A additional section processing for <intermediate-
host>.
For example,
sh.prime.com. IN RT 2 Relay.Prime.COM.
IN RT 10 NET.Prime.COM.
*.prime.com. IN RT 90 Relay.Prime.COM.
When a host is looking up DNS records to attempt to route a datagram,
it first looks for RT records for the destination host, which point
to hosts with address records (A, X25, ISDN) compatible with the wide
area networks available to the host. If it is itself in the set of
RT records, it discards any RTs with preferences higher or equal to
its own. If there are no (remaining) RTs, it can then use address
records of the destination itself.
Wild-card RTs are used exactly as are wild-card MXs. RT's do not
"chain"; that is, it is not valid to use the RT RRs found for a host
referred to by an RT.
The concrete encoding is identical to the MX RR.
*/
namespace Heijden.DNS
{
public class RecordRT : Record
{
public ushort PREFERENCE;
public string INTERMEDIATEHOST;
public RecordRT(RecordReader rr)
{
PREFERENCE = rr.ReadUInt16();
INTERMEDIATEHOST = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1}",
PREFERENCE,
INTERMEDIATEHOST);
}
}
}

View file

@ -0,0 +1,77 @@
using System;
#region Rfc info
/*
* http://www.ietf.org/rfc/rfc2535.txt
* 4.1 SIG RDATA Format
The RDATA portion of a SIG RR is as shown below. The integrity of
the RDATA information is protected by the signature field.
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| type covered | algorithm | labels |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| original TTL |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| signature expiration |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| signature inception |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| key tag | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ signer's name +
| /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-/
/ /
/ signature /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#endregion
namespace Heijden.DNS
{
public class RecordSIG : Record
{
public UInt16 TYPECOVERED;
public byte ALGORITHM;
public byte LABELS;
public UInt32 ORIGINALTTL;
public UInt32 SIGNATUREEXPIRATION;
public UInt32 SIGNATUREINCEPTION;
public UInt16 KEYTAG;
public string SIGNERSNAME;
public string SIGNATURE;
public RecordSIG(RecordReader rr)
{
TYPECOVERED = rr.ReadUInt16();
ALGORITHM = rr.ReadByte();
LABELS = rr.ReadByte();
ORIGINALTTL = rr.ReadUInt32();
SIGNATUREEXPIRATION = rr.ReadUInt32();
SIGNATUREINCEPTION = rr.ReadUInt32();
KEYTAG = rr.ReadUInt16();
SIGNERSNAME = rr.ReadDomainName();
SIGNATURE = rr.ReadString();
}
public override string ToString()
{
return string.Format("{0} {1} {2} {3} {4} {5} {6} {7} \"{8}\"",
TYPECOVERED,
ALGORITHM,
LABELS,
ORIGINALTTL,
SIGNATUREEXPIRATION,
SIGNATUREINCEPTION,
KEYTAG,
SIGNERSNAME,
SIGNATURE);
}
}
}

View file

@ -0,0 +1,105 @@
using System;
/*
3.3.13. SOA RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ MNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ RNAME /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| SERIAL |
| |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| REFRESH |
| |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| RETRY |
| |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| EXPIRE |
| |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| MINIMUM |
| |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
MNAME The <domain-name> of the name server that was the
original or primary source of data for this zone.
RNAME A <domain-name> which specifies the mailbox of the
person responsible for this zone.
SERIAL The unsigned 32 bit version number of the original copy
of the zone. Zone transfers preserve this value. This
value wraps and should be compared using sequence space
arithmetic.
REFRESH A 32 bit time interval before the zone should be
refreshed.
RETRY A 32 bit time interval that should elapse before a
failed refresh should be retried.
EXPIRE A 32 bit time value that specifies the upper limit on
the time interval that can elapse before the zone is no
longer authoritative.
MINIMUM The unsigned 32 bit minimum TTL field that should be
exported with any RR from this zone.
SOA records cause no additional section processing.
All times are in units of seconds.
Most of these fields are pertinent only for name server maintenance
operations. However, MINIMUM is used in all query operations that
retrieve RRs from a zone. Whenever a RR is sent in a response to a
query, the TTL field is set to the maximum of the TTL field from the RR
and the MINIMUM field in the appropriate SOA. Thus MINIMUM is a lower
bound on the TTL field for all RRs in a zone. Note that this use of
MINIMUM should occur when the RRs are copied into the response and not
when the zone is loaded from a master file or via a zone transfer. The
reason for this provison is to allow future dynamic update facilities to
change the SOA RR with known semantics.
*/
namespace Heijden.DNS
{
public class RecordSOA : Record
{
public string MNAME;
public string RNAME;
public uint SERIAL;
public uint REFRESH;
public uint RETRY;
public uint EXPIRE;
public uint MINIMUM;
public RecordSOA(RecordReader rr)
{
MNAME = rr.ReadDomainName();
RNAME = rr.ReadDomainName();
SERIAL = rr.ReadUInt32();
REFRESH = rr.ReadUInt32();
RETRY = rr.ReadUInt32();
EXPIRE = rr.ReadUInt32();
MINIMUM = rr.ReadUInt32();
}
public override string ToString()
{
return string.Format("{0} {1} {2} {3} {4} {5} {6}",
MNAME,
RNAME,
SERIAL,
REFRESH,
RETRY,
EXPIRE,
MINIMUM);
}
}
}

View file

@ -0,0 +1,93 @@
using System;
/*
* http://www.ietf.org/rfc/rfc2782.txt
*
Priority
The priority of this target host. A client MUST attempt to
contact the target host with the lowest-numbered priority it can
reach; target hosts with the same priority SHOULD be tried in an
order defined by the weight field. The range is 0-65535. This
is a 16 bit unsigned integer in network byte order.
Weight
A server selection mechanism. The weight field specifies a
relative weight for entries with the same priority. Larger
weights SHOULD be given a proportionately higher probability of
being selected. The range of this number is 0-65535. This is a
16 bit unsigned integer in network byte order. Domain
administrators SHOULD use Weight 0 when there isn't any server
selection to do, to make the RR easier to read for humans (less
noisy). In the presence of records containing weights greater
than 0, records with weight 0 should have a very small chance of
being selected.
In the absence of a protocol whose specification calls for the
use of other weighting information, a client arranges the SRV
RRs of the same Priority in the order in which target hosts,
specified by the SRV RRs, will be contacted. The following
algorithm SHOULD be used to order the SRV RRs of the same
priority:
To select a target to be contacted next, arrange all SRV RRs
(that have not been ordered yet) in any order, except that all
those with weight 0 are placed at the beginning of the list.
Compute the sum of the weights of those RRs, and with each RR
associate the running sum in the selected order. Then choose a
uniform random number between 0 and the sum computed
(inclusive), and select the RR whose running sum value is the
first in the selected order which is greater than or equal to
the random number selected. The target host specified in the
selected SRV RR is the next one to be contacted by the client.
Remove this SRV RR from the set of the unordered SRV RRs and
apply the described algorithm to the unordered SRV RRs to select
the next target host. Continue the ordering process until there
are no unordered SRV RRs. This process is repeated for each
Priority.
Port
The port on this target host of this service. The range is 0-
65535. This is a 16 bit unsigned integer in network byte order.
This is often as specified in Assigned Numbers but need not be.
Target
The domain name of the target host. There MUST be one or more
address records for this name, the name MUST NOT be an alias (in
the sense of RFC 1034 or RFC 2181). Implementors are urged, but
not required, to return the address record(s) in the Additional
Data section. Unless and until permitted by future standards
action, name compression is not to be used for this field.
A Target of "." means that the service is decidedly not
available at this domain.
*/
namespace Heijden.DNS
{
public class RecordSRV : Record
{
public ushort PRIORITY;
public ushort WEIGHT;
public ushort PORT;
public string TARGET;
public RecordSRV(RecordReader rr)
{
PRIORITY = rr.ReadUInt16();
WEIGHT = rr.ReadUInt16();
PORT = rr.ReadUInt16();
TARGET = rr.ReadDomainName();
}
public override string ToString()
{
return string.Format("{0} {1} {2} {3}",
PRIORITY,
WEIGHT,
PORT,
TARGET);
}
}
}

View file

@ -0,0 +1,62 @@
using System;
/*
* http://tools.ietf.org/rfc/rfc2930.txt
*
2. The TKEY Resource Record
The TKEY resource record (RR) has the structure given below. Its RR
type code is 249.
Field Type Comment
----- ---- -------
Algorithm: domain
Inception: u_int32_t
Expiration: u_int32_t
Mode: u_int16_t
Error: u_int16_t
Key Size: u_int16_t
Key Data: octet-stream
Other Size: u_int16_t
Other Data: octet-stream undefined by this specification
*/
namespace Heijden.DNS
{
public class RecordTKEY : Record
{
public string ALGORITHM;
public UInt32 INCEPTION;
public UInt32 EXPIRATION;
public UInt16 MODE;
public UInt16 ERROR;
public UInt16 KEYSIZE;
public byte[] KEYDATA;
public UInt16 OTHERSIZE;
public byte[] OTHERDATA;
public RecordTKEY(RecordReader rr)
{
ALGORITHM = rr.ReadDomainName();
INCEPTION = rr.ReadUInt32();
EXPIRATION = rr.ReadUInt32();
MODE = rr.ReadUInt16();
ERROR = rr.ReadUInt16();
KEYSIZE = rr.ReadUInt16();
KEYDATA = rr.ReadBytes(KEYSIZE);
OTHERSIZE = rr.ReadUInt16();
OTHERDATA = rr.ReadBytes(OTHERSIZE);
}
public override string ToString()
{
return string.Format("{0} {1} {2} {3} {4}",
ALGORITHM,
INCEPTION,
EXPIRATION,
MODE,
ERROR);
}
}
}

View file

@ -0,0 +1,64 @@
using System;
/*
* http://www.ietf.org/rfc/rfc2845.txt
*
* Field Name Data Type Notes
--------------------------------------------------------------
Algorithm Name domain-name Name of the algorithm
in domain name syntax.
Time Signed u_int48_t seconds since 1-Jan-70 UTC.
Fudge u_int16_t seconds of error permitted
in Time Signed.
MAC Size u_int16_t number of octets in MAC.
MAC octet stream defined by Algorithm Name.
Original ID u_int16_t original message ID
Error u_int16_t expanded RCODE covering
TSIG processing.
Other Len u_int16_t length, in octets, of
Other Data.
Other Data octet stream empty unless Error == BADTIME
*/
namespace Heijden.DNS
{
public class RecordTSIG : Record
{
public string ALGORITHMNAME;
public long TIMESIGNED;
public UInt16 FUDGE;
public UInt16 MACSIZE;
public byte[] MAC;
public UInt16 ORIGINALID;
public UInt16 ERROR;
public UInt16 OTHERLEN;
public byte[] OTHERDATA;
public RecordTSIG(RecordReader rr)
{
ALGORITHMNAME = rr.ReadDomainName();
TIMESIGNED = rr.ReadUInt32() << 32 | rr.ReadUInt32();
FUDGE = rr.ReadUInt16();
MACSIZE = rr.ReadUInt16();
MAC = rr.ReadBytes(MACSIZE);
ORIGINALID = rr.ReadUInt16();
ERROR = rr.ReadUInt16();
OTHERLEN = rr.ReadUInt16();
OTHERDATA = rr.ReadBytes(OTHERLEN);
}
public override string ToString()
{
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
dateTime = dateTime.AddSeconds(TIMESIGNED);
string printDate = dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString();
return string.Format("{0} {1} {2} {3} {4}",
ALGORITHMNAME,
printDate,
FUDGE,
ORIGINALID,
ERROR);
}
}
}

View file

@ -0,0 +1,38 @@
using System;
#region Rfc info
/*
3.3.14. TXT RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/ TXT-DATA /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
TXT-DATA One or more <character-string>s.
TXT RRs are used to hold descriptive text. The semantics of the text
depends on the domain where it is found.
*
*/
#endregion
namespace Heijden.DNS
{
public class RecordTXT : Record
{
public string TXT;
public RecordTXT(RecordReader rr)
{
TXT = rr.ReadString();
}
public override string ToString()
{
return string.Format("\"{0}\"",TXT);
}
}
}

View file

@ -0,0 +1,75 @@
using System;
/*
* 3.4.2. WKS RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ADDRESS |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| PROTOCOL | |
+--+--+--+--+--+--+--+--+ |
| |
/ <BIT MAP> /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
ADDRESS An 32 bit Internet address
PROTOCOL An 8 bit IP protocol number
<BIT MAP> A variable length bit map. The bit map must be a
multiple of 8 bits long.
The WKS record is used to describe the well known services supported by
a particular protocol on a particular internet address. The PROTOCOL
field specifies an IP protocol number, and the bit map has one bit per
port of the specified protocol. The first bit corresponds to port 0,
the second to port 1, etc. If the bit map does not include a bit for a
protocol of interest, that bit is assumed zero. The appropriate values
and mnemonics for ports and protocols are specified in [RFC-1010].
For example, if PROTOCOL=TCP (6), the 26th bit corresponds to TCP port
25 (SMTP). If this bit is set, a SMTP server should be listening on TCP
port 25; if zero, SMTP service is not supported on the specified
address.
The purpose of WKS RRs is to provide availability information for
servers for TCP and UDP. If a server supports both TCP and UDP, or has
multiple Internet addresses, then multiple WKS RRs are used.
WKS RRs cause no additional section processing.
In master files, both ports and protocols are expressed using mnemonics
or decimal numbers.
*/
namespace Heijden.DNS
{
public class RecordWKS : Record
{
public string ADDRESS;
public int PROTOCOL;
public byte[] BITMAP;
public RecordWKS(RecordReader rr)
{
ushort length = rr.ReadUInt16(-2);
ADDRESS = string.Format("{0}.{1}.{2}.{3}",
rr.ReadByte(),
rr.ReadByte(),
rr.ReadByte(),
rr.ReadByte());
PROTOCOL = (int)rr.ReadByte();
length -= 5;
BITMAP = new byte[length];
BITMAP = rr.ReadBytes(length);
}
public override string ToString()
{
return string.Format("{0} {1}",ADDRESS,PROTOCOL);
}
}
}

View file

@ -0,0 +1,51 @@
using System;
/* http://tools.ietf.org/rfc/rfc1183.txt
3.1. The X25 RR
The X25 RR is defined with mnemonic X25 and type code 19 (decimal).
X25 has the following format:
<owner> <ttl> <class> X25 <PSDN-address>
<PSDN-address> is required in all X25 RRs.
<PSDN-address> identifies the PSDN (Public Switched Data Network)
address in the X.121 [10] numbering plan associated with <owner>.
Its format in master files is a <character-string> syntactically
identical to that used in TXT and HINFO.
The format of X25 is class insensitive. X25 RRs cause no additional
section processing.
The <PSDN-address> is a string of decimal digits, beginning with the
4 digit DNIC (Data Network Identification Code), as specified in
X.121. National prefixes (such as a 0) MUST NOT be used.
For example:
Relay.Prime.COM. X25 311061700956
*/
namespace Heijden.DNS
{
public class RecordX25 : Record
{
public string PSDNADDRESS;
public RecordX25(RecordReader rr)
{
PSDNADDRESS = rr.ReadString();
}
public override string ToString()
{
return string.Format("{0}",
PSDNADDRESS);
}
}
}

View file

@ -1,68 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class RpRecord : DnsRecordBase
{
// For RP
private string _name;
private string _textLocation;
public string RpName
{
get { return _name; }
}
public string TextLocation
{
get { return _textLocation; }
}
internal RpRecord(RecordHeader dnsHeader) : base(dnsHeader) {}
public override void ParseRecord(ref MemoryStream ms)
{
_name = DnsRecordBase.ParseName(ref ms);
_textLocation = DnsRecordBase.ParseName(ref ms);
_answer = _name + ", " + _textLocation;
}
}
}

View file

@ -1,71 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
namespace DnDns.Records
{
public sealed class RtRecord : DnsRecordBase
{
private ushort _preference;
private string _intermediateHost;
public ushort Preference
{
get { return _preference; }
}
public string IntermediateHost
{
get { return _intermediateHost; }
}
internal RtRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
byte[] preference = new byte[2];
ms.Read(preference, 0, 2);
//_preference = (ushort)Tools.ByteToUInt(preference);
_preference = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(preference, 0));
_intermediateHost = DnsRecordBase.ParseName(ref ms);
_answer = "Preference: " + _preference + ", Intermediate Host: " + _intermediateHost;
}
}
}

View file

@ -1,160 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
namespace DnDns.Records
{
public sealed class SoaRecord : DnsRecordBase
{
// For SOA
#region fields
private string _primaryNameServer;
private string _responsiblePerson;
private uint _serial;
private uint _refreshInterval;
private uint _retryInterval;
private uint _expirationLimit;
// RFC 1034: TTL - only positive values of a signed 32 bit number.
private int _minimumTimeToLive;
#endregion
#region properties
public string PrimaryNameServer
{
get { return _primaryNameServer; }
}
public string ResponsiblePerson
{
get { return _responsiblePerson; }
}
public uint Serial
{
get { return _serial; }
}
public uint RefreshInterval
{
get { return _refreshInterval; }
}
public uint RetryInterval
{
get { return _retryInterval; }
}
public uint ExpirationLimit
{
get { return _expirationLimit; }
}
public int MinimumTimeToLive
{
get { return _minimumTimeToLive; }
}
#endregion
internal SoaRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
StringBuilder sb = new StringBuilder();
// Parse Name
_primaryNameServer = DnsRecordBase.ParseName(ref ms);
sb.Append("Primary NameServer: ");
sb.Append(_primaryNameServer);
sb.Append("\r\n");
// Parse Responsible Persons Mailbox (Parse Name)
_responsiblePerson = DnsRecordBase.ParseName(ref ms);
sb.Append("Responsible Person: ");
sb.Append(_responsiblePerson);
sb.Append("\r\n");
byte[] serial = new Byte[4];
byte[] refreshInterval = new Byte[4];
byte[] retryInterval = new Byte[4];
byte[] expirationLimit = new Byte[4];
byte[] minTTL = new Byte[4];
// Parse Serial (4 bytes)
ms.Read(serial, 0, 4);
//_serial = Tools.ByteToUInt(serial);
_serial = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(serial, 0));
sb.Append("Serial: ");
sb.Append(_serial);
sb.Append("\r\n");
// Parse Refresh Interval (4 bytes)
ms.Read(refreshInterval, 0, 4);
// _refreshInterval = Tools.ByteToUInt(refreshInterval);
_refreshInterval = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(refreshInterval, 0));
sb.Append("Refresh Interval: ");
sb.Append(_refreshInterval);
sb.Append("\r\n");
// Parse Retry Interval (4 bytes)
ms.Read(retryInterval, 0, 4);
//_retryInterval = Tools.ByteToUInt(retryInterval);
_retryInterval = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(retryInterval, 0));
sb.Append("Retry Interval: ");
sb.Append(_retryInterval);
sb.Append("\r\n");
// Parse Expiration limit (4 bytes)
ms.Read(expirationLimit, 0, 4);
// _expirationLimit = Tools.ByteToUInt(expirationLimit);
_expirationLimit = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(expirationLimit, 0));
sb.Append("Expire: ");
sb.Append(_expirationLimit);
sb.Append("\r\n");
// Parse Min TTL (4 bytes)
ms.Read(minTTL, 0, 4);
// _minTTL = Tools.ByteToUInt(minTTL);
_minimumTimeToLive = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(minTTL, 0));
sb.Append("TTL: ");
sb.Append(_minimumTimeToLive);
sb.Append("\r\n");
_answer = sb.ToString();
}
}
}

View file

@ -1,95 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
namespace DnDns.Records
{
public sealed class SrvRecord : DnsRecordBase
{
// For SRV
private ushort _priority;
private ushort _weight;
private ushort _port;
private string _hostName;
public ushort Priority
{
get { return _priority; }
}
public ushort Weight
{
get { return _weight; }
}
public ushort Port
{
get { return _port; }
}
public string HostName
{
get { return _hostName; }
}
internal SrvRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
byte[] priority = new byte[2];
ms.Read(priority, 0, 2);
//_priority = (ushort)Tools.ByteToUInt(Priority);
_priority = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(priority, 0));
byte[] weight = new byte[2];
ms.Read(weight, 0, 2);
// _weight = (ushort)Tools.ByteToUInt(Weight);
_weight = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(weight, 0));
byte[] port = new byte[2];
ms.Read(port, 0, 2);
//_port = (ushort)Tools.ByteToUInt(port);
_port = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(port, 0));
_hostName = DnsRecordBase.ParseName(ref ms);
_answer = "Service Location: \r\nPriority: " + _priority + "\r\nWeight: " +
_weight + "\r\nPort: " + _port + "\r\nHostName: " + _hostName + "\r\n";
}
}
}

View file

@ -1,235 +0,0 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using DnDns.Enums;
namespace DnDns.Records
{
/// <summary>
/// Implementation of a TSIG record structure as per RFC 2845
/// </summary>
public sealed class TSigRecord : DnsRecordBase
{
private string _algorithmName;
private RCode _error;
private ushort _fudge;
private ushort _originalId;
private byte[] _otherData;
private byte[] _mac;
private DateTime _timeSigned;
public string AlgorithmName
{
get { return _algorithmName; }
}
public RCode Error
{
get { return _error; }
}
public ushort Fudge
{
get { return _fudge; }
}
public ushort OriginalID
{
get { return _originalId; }
}
public byte[] OtherData
{
get { return _otherData; }
}
public byte[] Mac
{
get { return _mac; }
}
public DateTime TimeSigned
{
get { return _timeSigned; }
}
public TSigRecord(RecordHeader dnsHeader) : base(dnsHeader)
{
}
public TSigRecord(string name, string algorithmName, RCode error, ushort fudge, ushort originalId, byte[] otherData, byte[] mac, DateTime timeSigned)
{
DnsHeader = new RecordHeader(name, NsType.TSIG, NsClass.ANY, 0);
_algorithmName = algorithmName;
_error = error;
_fudge = fudge;
_originalId = originalId;
_otherData = otherData;
_mac = mac;
_timeSigned = timeSigned;
if(otherData == null)
{
_otherData = new byte[]{};
}
}
public override void ParseRecord(ref MemoryStream memoryStream)
{
Byte[] dataUInt16 = new byte[2];
Byte[] dataUInt32 = new byte[4];
_algorithmName = ParseName(ref memoryStream);
memoryStream.Read(dataUInt16, 0, dataUInt16.Length);
long timeHigh = (ushort) IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(dataUInt16, 0));
memoryStream.Read(dataUInt32, 0, dataUInt32.Length);
long timeLow = (uint) IPAddress.NetworkToHostOrder((int)BitConverter.ToUInt32(dataUInt32, 0));
_timeSigned = DnsHelpers.ConvertFromDnsTime(timeLow, timeHigh);
memoryStream.Read(dataUInt16, 0, dataUInt16.Length);
_fudge = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(dataUInt16, 0));
memoryStream.Read(dataUInt16, 0, dataUInt16.Length);
Int32 macLen = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(dataUInt16, 0));
_mac = new byte[macLen];
memoryStream.Read(_mac, 0, macLen);
memoryStream.Read(dataUInt16, 0, dataUInt16.Length);
_originalId = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(dataUInt16, 0));
memoryStream.Read(dataUInt16, 0, dataUInt16.Length);
_error = (RCode)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(dataUInt16, 0));
memoryStream.Read(dataUInt16, 0, dataUInt16.Length);
Int32 otherLen = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(dataUInt16, 0));
if(otherLen > 0)
{
_otherData = new byte[otherLen];
memoryStream.Read(_otherData, 0, otherLen);
}
else
{
_otherData = null;
}
_answer = ToString();
}
public override byte[] GetMessageBytes()
{
MemoryStream memoryStream = new MemoryStream();
byte[] data = DnsHeader.GetMessageBytes();
memoryStream.Write(data,0,data.Length);
long rLengthPosition = memoryStream.Position;
data = DnsHelpers.CanonicaliseDnsName(_algorithmName, false);
memoryStream.Write(data, 0, data.Length);
int timeHigh;
long timeLow;
DnsHelpers.ConvertToDnsTime(_timeSigned.ToUniversalTime(), out timeHigh, out timeLow);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder((ushort)timeHigh) >> 16));
memoryStream.Write(data, 0, data.Length);
data = BitConverter.GetBytes((uint)(IPAddress.HostToNetworkOrder((uint)timeLow) >> 32));
memoryStream.Write(data, 0, data.Length);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder(_fudge) >> 16));
memoryStream.Write(data, 0, data.Length);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder(_mac.Length) >> 16));
memoryStream.Write(data, 0, data.Length);
memoryStream.Write(_mac, 0, _mac.Length);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder(_originalId) >> 16));
memoryStream.Write(data, 0, data.Length);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder((ushort)_error) >> 16));
memoryStream.Write(data, 0, data.Length);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder((ushort)_otherData.Length) >> 16));
memoryStream.Write(data, 0, data.Length);
if(_otherData.Length != 0)
{
memoryStream.Write(_otherData, 0, _otherData.Length);
}
// Add the rdata lenght
long rlength = memoryStream.Position - rLengthPosition;
memoryStream.Seek(rLengthPosition - 2, SeekOrigin.Begin);
data = BitConverter.GetBytes((ushort)(IPAddress.HostToNetworkOrder((ushort)rlength) >> 16));
memoryStream.Write(data, 0, data.Length);
return memoryStream.ToArray();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append(_algorithmName);
sb.Append(" ");
sb.Append(_timeSigned);
sb.Append(" ");
sb.Append(_fudge);
sb.Append(" ");
sb.Append(_mac.Length);
sb.Append(" ");
sb.Append(Convert.ToBase64String(Mac));
sb.Append(" ");
sb.Append(_error);
sb.Append(" ");
if (_otherData == null)
{
sb.Append(0);
}
else
{
sb.Append(_otherData.Length);
sb.Append(" ");
if (_error == RCode.BADTIME)
{
if (_otherData.Length != 6)
{
sb.Append("<invalid BADTIME other data>");
}
else
{
long time = ((long)(_otherData[0] & 0xFF) << 40) +
((long)(_otherData[1] & 0xFF) << 32) +
((_otherData[2] & 0xFF) << 24) +
((_otherData[3] & 0xFF) << 16) +
((_otherData[4] & 0xFF) << 8) +
((_otherData[5] & 0xFF));
sb.Append("<server time: ");
sb.Append(DnsHelpers.ConvertFromDnsTime(time));
sb.Append(">");
}
}
else
{
sb.Append("<");
sb.Append(Convert.ToBase64String(_otherData));
sb.Append(">");
}
}
return sb.ToString();
}
}
}

View file

@ -1,63 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
/// <summary>
///
/// </summary>
public sealed class TxtRecord : DnsRecordBase
{
private string _text;
public string Text
{
get { return _text; }
}
internal TxtRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
_text = base.ParseText(ref ms);
_answer = "text: " + _text;
}
}
}

View file

@ -1,69 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
class UnknownRecord : DnsRecordBase
{
public UnknownRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
// Type not implemented so we read it into a buffer and print out the data.
StringBuilder sb = new StringBuilder(this.DnsHeader.DataLength);
byte[] b = new byte[1];
// Loop over data, if char is easily converted to ASCII, convert it.
// Otherwise print a '.'
for (int i = 0; i < this.DnsHeader.DataLength; i++)
{
ms.Read(b, 0, 1);
if ((b[0] > 0x20) && (b[0] < 0x7e))
{
sb.Append(Encoding.ASCII.GetString(b));
}
else
{
sb.Append('.');
}
}
_answer = sb.ToString();
_errorMsg = "Type " + this.DnsHeader.NsType + " not implemented.";
}
}
}

View file

@ -1,115 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace DnDns.Records
{
public sealed class WksRecord : DnsRecordBase
{
private ProtocolType _protocolType;
private IPAddress _ipAddress;
private short[] _ports;
public ProtocolType ProtocolType
{
get { return _protocolType; }
set { _protocolType = value; }
}
public IPAddress IpAddress
{
get { return _ipAddress; }
set { _ipAddress = value; }
}
public short[] Ports
{
get { return _ports; }
set { _ports = value; }
}
internal WksRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
// Bit map is the data length minus the IpAddress (4 bytes) and the Protocol (1 byte), 5 bytes total.
int bitMapLen = this.DnsHeader.DataLength - 4 - 1;
byte[] ipAddr = new byte[4];
byte[] BitMap = new byte[bitMapLen];
ms.Read(ipAddr, 0, 4);
// _ipAddress = new IPAddress(Tools.ToUInt32(ipAddr, 0));
_ipAddress = new IPAddress((uint)IPAddress.NetworkToHostOrder(BitConverter.ToUInt32(ipAddr, 0)));
_protocolType = (ProtocolType)ms.ReadByte();
ms.Read(BitMap, 0, BitMap.Length);
_ports = GetKnownServices(BitMap);
_answer = _protocolType + ": " + Tools.GetServByPort(_ports, _protocolType);
}
private short[] GetKnownServices(byte[] BitMap)
{
short[] tempPortArr = new short[1024];
int portCount = 0;
// mask to isolate left most bit
const byte mask = 0x80;
// Iterate through each byte
for (int i = 0; i < BitMap.Length; i++)
{
byte currentByte = BitMap[i];
int count = 0;
// iterate through each bit
for (byte j = 0x07; j != 0xFF; j--)
{
int port = (((i * 8) + count++) + 1);
currentByte = (byte)(currentByte << 1);
// is the flag set?
if ((mask & currentByte) == 0x80)
{
tempPortArr[portCount] = (short)port;
portCount++;
}
}
}
short[] portArr = new short[portCount];
Array.Copy(tempPortArr, 0, portArr, 0, portCount);
return portArr;
}
}
}

View file

@ -1,60 +0,0 @@
/**********************************************************************
* Copyright (c) 2010, j. montgomery *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* + Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* + Redistributions in binary form must reproduce the above copyright*
* notice, this list of conditions and the following disclaimer *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* + Neither the name of j. montgomery's employer nor the names of *
* its contributors may be used to endorse or promote products *
* derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,*
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,*
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED*
* OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DnDns.Records
{
public sealed class X25Record : DnsRecordBase
{
private string _x25Address;
public string X25Address
{
get { return _x25Address; }
}
internal X25Record(RecordHeader dnsHeader) : base(dnsHeader) { }
public override void ParseRecord(ref MemoryStream ms)
{
_x25Address = base.ParseText(ref ms);
_answer = "X.25 X.121 Address: " + _x25Address;
}
}
}

View file

@ -0,0 +1,21 @@
Record.cs
RecordA.cs
RecordAAAA.cs
RecordCNAME.cs
RecordHINFO.cs
RecordMB.cs
RecordMD.cs
RecordMF.cs
RecordMG.cs
RecordMINFO.cs
RecordMR.cs
RecordMX.cs
RecordNS.cs
RecordNULL.cs
RecordPTR.cs
RecordReader.cs
RecordSOA.cs
RecordTXT.cs
RecordUnknown.cs
RecordWKS.cs
totla.txt