-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecordKX.cs
65 lines (53 loc) · 1.81 KB
/
RecordKX.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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);
}
}
}