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.
        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[]{};
            }
        }
Beispiel #2
0
        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[] {};
            }
        }
Beispiel #3
0
 internal LocRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #4
0
 internal SoaRecord(RecordHeader dnsHeader) : base(dnsHeader) { }
Beispiel #5
0
        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);
        }
 public TSigRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
Beispiel #7
0
 internal SrvRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
        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;
        }
Beispiel #9
0
 internal RtRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #10
0
 internal X25Record(RecordHeader dnsHeader) : base(dnsHeader) { }
Beispiel #11
0
 public UnknownRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #12
0
 internal HInfoRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #13
0
 internal CNameRecord(RecordHeader dnsHeader) : base(dnsHeader) {}
Beispiel #14
0
 internal AfsdbRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #15
0
 internal PtrRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #16
0
 internal CNameRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #17
0
 internal WksRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #18
0
 internal IsdnRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #19
0
 internal DnsRecordBase(RecordHeader dnsHeader)
 {
     _dnsHeader = dnsHeader;
 }
Beispiel #20
0
 internal AfsdbRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
Beispiel #21
0
 internal PtrRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
Beispiel #22
0
 internal X25Record(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #23
0
 internal AaaaRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #24
0
 internal TxtRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
Beispiel #25
0
 public TSigRecord(RecordHeader dnsHeader) : base(dnsHeader)
 {
 }
Beispiel #26
0
 internal LocRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
Beispiel #27
0
 internal RpRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
Beispiel #28
0
 internal IsdnRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
 internal DnsRecordBase(RecordHeader dnsHeader)
 {
     _dnsHeader = dnsHeader;
 }
Beispiel #30
0
 internal WksRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
Beispiel #31
0
 internal MInfoRecord(RecordHeader dnsHeader)
     : base(dnsHeader)
 {
 }
Beispiel #32
0
 public UnknownRecord(RecordHeader dnsHeader) : base(dnsHeader) { }