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