/// <summary> /// Implementation Reference RFC 3658 /// </summary> /// <param name="buffer"></param> public DSRecord(DataBuffer buffer, int length) { key = buffer.ReadShortInt(); algorithm = buffer.ReadByte(); digestType = buffer.ReadByte(); digest = buffer.ReadBytes(length - 4); }
public KeyRecord(DataBuffer buffer, int length) { flags = buffer.ReadShortInt(); protocol = buffer.ReadByte(); algorithm = buffer.ReadByte(); publicKey = buffer.ReadBytes(length - 4); }
/// <summary> /// Implementation Reference RFC 2782 /// </summary> /// <param name="buffer"></param> public SrvRecord(DataBuffer buffer) { priority = buffer.ReadShortInt(); weight = buffer.ReadShortUInt(); port = buffer.ReadShortUInt(); domain = buffer.ReadDomainName(); }
/// <summary> /// Create a Question record for Dns Answer /// </summary> /// <param name="buffer"></param> public Question(DataBuffer buffer) { domain = buffer.ReadDomainName(); recType = (RecordType)buffer.ReadBEShortInt(); classType = buffer.ReadBEShortInt(); }
/// <summary> /// WKS Record Type Consructor /// </summary> /// <param name="buffer"></param> /// <param name="length"></param> public WksRecord(DataBuffer buffer, int length) { ipAddress = buffer.ReadIPAddress(); protocol = buffer.ReadByte(); services = new Byte[length - 5]; for(int i = 0; i < (length - 5); i++) services[i] = buffer.ReadByte(); }
/// <summary> /// Implementation Reference RFC 3403 /// </summary> /// <param name="buffer"></param> public NaptrRecord(DataBuffer buffer) { order = buffer.ReadShortUInt(); priority = buffer.ReadShortUInt(); flags = buffer.ReadCharString(); services = buffer.ReadCharString(); regexp = buffer.ReadCharString(); replacement = buffer.ReadCharString(); }
/// <summary> /// Create a DNSEntry record and dispatch to data constructor /// for thast record type /// </summary> /// <param name="buffer"></param> public DnsEntry(DataBuffer buffer) { try { domain = buffer.ReadDomainName(); buffer.ReadByte(); recType = (RecordType)buffer.ReadShortInt(); classType = buffer.ReadShortInt(); ttl = buffer.ReadInt(); int length = buffer.ReadByte(); switch (recType) { case RecordType.A: data = new ARecord(buffer); break; case RecordType.NS: data = new NSRecord(buffer); break; case RecordType.CNAME: data = new CNameRecord(buffer); break; case RecordType.SOA: data = new SoaRecord(buffer); break; case RecordType.MB: data = new MBRecord(buffer); break; case RecordType.MG: data = new MGRecord(buffer); break; case RecordType.MR: data = new MRRecord(buffer); break; case RecordType.NULL: data = new NullRecord(buffer, length); break; case RecordType.WKS: data = new WksRecord(buffer, length); break; case RecordType.PTR: data = new PtrRecord(buffer); break; case RecordType.HINFO: data = new HInfoRecord(buffer, length); break; case RecordType.MINFO: data = new MInfoRecord(buffer); break; case RecordType.MX: data = new MXRecord(buffer); break; case RecordType.TXT: data = new TxtRecord(buffer, length); break; case RecordType.RP: data = new RPRecord(buffer); break; case RecordType.AFSDB: data = new AfsdbRecord(buffer); break; case RecordType.X25: data = new X25Record(buffer); break; case RecordType.ISDN: data = new IsdnRecord(buffer); break; case RecordType.RT: data = new RTRecord(buffer); break; case RecordType.NSAP: data = new NsapRecord(buffer, length); break; case RecordType.SIG: data = new SigRecord(buffer, length); break; case RecordType.KEY: data = new KeyRecord(buffer, length); break; case RecordType.PX: data = new PXRecord(buffer); break; case RecordType.AAAA: data = new AAAARecord(buffer); break; case RecordType.LOC: data = new LocRecord(buffer); break; case RecordType.SRV: data = new SrvRecord(buffer); break; case RecordType.NAPTR: data = new NaptrRecord(buffer); break; case RecordType.KX: data = new KXRecord(buffer); break; case RecordType.A6: data = new A6Record(buffer); break; case RecordType.DNAME: data = new DNameRecord(buffer); break; case RecordType.DS: data = new DSRecord(buffer, length); break; case RecordType.TKEY: data = new TKeyRecord(buffer); break; case RecordType.TSIG: data = new TSigRecord(buffer); break; default: throw new DnsQueryException("Invalid DNS Record Type in DNS Response", null); } } catch (Exception ex) { data = new ExceptionRecord(ex.Message); throw ex; } }
public SoaRecord(DataBuffer buffer) { primaryNameServer = buffer.ReadDomainName(); responsibleMailAddress = buffer.ReadDomainName(); serial = buffer.ReadInt(); refresh = buffer.ReadInt(); retry = buffer.ReadInt(); expire = buffer.ReadInt(); defaultTtl = buffer.ReadInt(); }
/// <summary> /// Create Location Record from Data Buffer /// </summary> /// <param name="buffer"></param> public LocRecord(DataBuffer buffer) { version = buffer.ReadShortInt(); size = buffer.ReadShortInt(); horzPrecision = buffer.ReadShortInt(); vertPrecision = buffer.ReadShortInt(); lattitude = buffer.ReadInt(); longitude = buffer.ReadInt(); altitude = buffer.ReadInt(); }
public TSigRecord(DataBuffer buffer) { algorithm = buffer.ReadDomainName(); timeSigned = buffer.ReadLongInt(); fudge = buffer.ReadShortUInt(); macSize = buffer.ReadShortUInt(); mac = buffer.ReadBytes(macSize); originalId = buffer.ReadShortUInt(); error = buffer.ReadShortUInt(); otherLen = buffer.ReadShortUInt(); otherData = buffer.ReadBytes(otherLen); }
/// <summary> /// Implementation Reference RFC 2535 /// </summary> /// <param name="buffer"></param> /// <param name="length"></param> public SigRecord(DataBuffer buffer, int length) { int pos = buffer.Position; coveredType = buffer.ReadShortInt(); algorithm = buffer.ReadByte(); numLabels = buffer.ReadByte(); expiration = buffer.ReadUInt(); inception = buffer.ReadUInt(); keyTag = buffer.ReadShortInt(); signer = buffer.ReadDomainName(); buffer.Position = pos - length; }
/// <summary> /// Implementation References RFC 2930 /// </summary> /// <param name="buffer"></param> public TKeyRecord(DataBuffer buffer) { algorithm = buffer.ReadDomainName(); inception = buffer.ReadUInt(); expiration = buffer.ReadUInt(); mode = buffer.ReadShortUInt(); error = buffer.ReadShortUInt(); keySize = buffer.ReadShortUInt(); keyData = buffer.ReadBytes(keySize); otherSize = buffer.ReadShortUInt(); otherData = buffer.ReadBytes(otherSize); }
/// <summary> /// Implementation Reference RFC 3363 /// </summary> /// <param name="buffer"></param> public A6Record(DataBuffer buffer) { prefixLength = buffer.ReadByte(); if(prefixLength == 0) //Only Address Present { ipAddress = buffer.ReadIPv6Address(); } else if (prefixLength == 128) //Only Domain Name Present { domain = buffer.ReadDomainName(); } else //Address and Domain Name Present { ipAddress = buffer.ReadIPv6Address(); domain = buffer.ReadDomainName(); } }
/// <summary> /// create a text array from record bytes /// </summary> /// <param name="buffer"> buffer of bytes </param> /// <param name="length"> length of bytes to use</param> public TextOnly(DataBuffer buffer, int length) { int len = length; int pos = buffer.Position; text = new List<string>(); byte next = buffer.Next; while (length > 0) { text.Add(buffer.ReadCharString()); length -= next + 1; if (length < 0) { buffer.Position = pos - len; //Reset current Pointer of Buffer to end of this record throw new DnsQueryException("Buffer Over Run in TextOnly Record Data Type", null); } next = buffer.Next; } if (length > 0) { buffer.Position = pos - len; //Reset current Pointer of Buffer to end of this record throw new DnsQueryException("Buffer Under Run in TextOnly Record Data Type", null); } }
public PXRecord(DataBuffer buffer) : base(buffer) { x400Domain = buffer.ReadDomainName(); }
/// <summary> /// Create data record for AFSDB type from data buffer /// </summary> /// <param name="buffer"></param> public AfsdbRecord(DataBuffer buffer) { subType = buffer.ReadShortInt(); domain = buffer.ReadDomainName(); }
/// <summary> /// Common class for all record types that contain a preference and a domain name /// </summary> /// <param name="buffer"></param> public PrefAndDomain(DataBuffer buffer) { preference = buffer.ReadBEShortInt(); domain = buffer.ReadDomainName(); }
public Answer(DataBuffer buffer) : base(buffer) {}
/// <summary> /// Create A Record from Data Buffer /// </summary> /// <param name="buffer"></param> public ARecord(DataBuffer buffer) { byte[] ipaddress = buffer.ReadBytes(4); ipAddress = new IPAddress(ipaddress); }
/// <summary> /// Implementation Rference RFC 1706 /// RFC is unclear and self-contradictory record type not implemented /// </summary> /// <param name="buffer"></param> public NsapRecord(DataBuffer buffer, int length) { buffer.Position += length; throw new NotImplementedException("Experimental Record Type Unable to Implement"); }
/// <summary> /// Implementation Reference RFC 3596 /// </summary> /// <param name="buffer"></param> public AAAARecord(DataBuffer buffer) { ipAddress = buffer.ReadIPv6Address(); }
/// <summary> /// Text Record Type /// </summary> /// <param name="buffer"></param> /// <param name="length"></param> public TxtRecord(DataBuffer buffer, int length) : base(buffer, length) { }
/// <summary> /// Base class for all Record Types that have RDATA consisting of a single domain name /// </summary> /// <param name="buffer"></param> public DomainNameOnly(DataBuffer buffer) { domain = buffer.ReadDomainName(); }
/// <summary> /// Implementation Reference RFC 1035 /// </summary> /// <param name="buffer"></param> public NSRecord(DataBuffer buffer) : base(buffer){}
/// <summary> /// Ceate A server Record for server section of Dns Response /// </summary> /// <param name="buffer"></param> public Server(DataBuffer buffer) : base(buffer) {}
/// <summary> /// Implementation Reference RFC 1183 /// </summary> /// <param name="buffer"></param> public RPRecord(DataBuffer buffer) { responsibleMailbox = buffer.ReadDomainName(); textDomain = buffer.ReadDomainName(); }
/// <summary> /// Implementation Reference RFC 1183 /// </summary> /// <param name="buffer"></param> public RTRecord(DataBuffer buffer) : base(buffer){}
/// <summary> /// Implementation Reference RFC 1035 /// </summary> /// <param name="buffer"></param> /// <param name="length"></param> public HInfoRecord(DataBuffer buffer, int length) : base(buffer, length){}
/// <summary> /// Implementation Reference RFC 1183 /// </summary> /// <param name="buffer"></param> public IsdnRecord(DataBuffer buffer) { isdnAddress = buffer.ReadCharString(); subAddress = buffer.ReadCharString(); }
/// <summary> /// Create X25 Record Type /// </summary> /// <param name="buffer"></param> public X25Record(DataBuffer buffer) : base(buffer){}
/// <summary> /// Given a byte array interpret them as a DnsEntry /// </summary> /// <param name="response"></param> public DnsAnswer(byte[] response) { questions = new List<Question>(); answers = new List<Answer>(); servers = new List<Server>(); additional = new List<Record>(); exceptions = new List<Exception>(); DataBuffer buffer = new DataBuffer(response, 2); byte bits1 = buffer.ReadByte(); byte bits2 = buffer.ReadByte(); //Mask off return code int returnCode = bits2 & 15; if (returnCode > 6) returnCode = 6; this.returnCode = (ReturnCode)returnCode; //Get Additional Flags authoritative = TestBit(bits1, 2); recursive = TestBit(bits2, 8); truncated = TestBit(bits1, 1); int nQuestions = buffer.ReadBEShortInt(); int nAnswers = buffer.ReadBEShortInt(); int nServers = buffer.ReadBEShortInt(); int nAdditional = buffer.ReadBEShortInt(); //read in questions for(int i = 0; i < nQuestions; i++) { try { questions.Add(new Question(buffer)); } catch (Exception ex) { exceptions.Add(ex); } } //read in answers for(int i = 0; i < nAnswers; i++) { try { answers.Add(new Answer(buffer)); } catch (Exception ex) { exceptions.Add(ex); } } //read in servers for(int i = 0; i < nServers; i++) { try { servers.Add(new Server(buffer)); } catch (Exception ex) { exceptions.Add(ex); } } //read in additional records for(int i = 0; i < nAdditional; i++) { try { additional.Add(new Record(buffer)); } catch (Exception ex) { exceptions.Add(ex); } } }
/// <summary> /// Given a byte array interpret them as a DnsEntry /// </summary> /// <param name="response"></param> public DnsAnswer(byte[] response) { questions = new List <Question>(); answers = new List <Answer>(); servers = new List <Server>(); additional = new List <Record>(); exceptions = new List <Exception>(); DataBuffer buffer = new DataBuffer(response, 2); byte bits1 = buffer.ReadByte(); byte bits2 = buffer.ReadByte(); //Mask off return code int returnCode = bits2 & 15; if (returnCode > 6) { returnCode = 6; } this.returnCode = (ReturnCode)returnCode; //Get Additional Flags authoritative = TestBit(bits1, 2); recursive = TestBit(bits2, 8); truncated = TestBit(bits1, 1); int nQuestions = buffer.ReadBEShortInt(); int nAnswers = buffer.ReadBEShortInt(); int nServers = buffer.ReadBEShortInt(); int nAdditional = buffer.ReadBEShortInt(); //read in questions for (int i = 0; i < nQuestions; i++) { try { questions.Add(new Question(buffer)); } catch (Exception ex) { exceptions.Add(ex); } } //read in answers for (int i = 0; i < nAnswers; i++) { try { answers.Add(new Answer(buffer)); } catch (Exception ex) { exceptions.Add(ex); } } //read in servers for (int i = 0; i < nServers; i++) { try { servers.Add(new Server(buffer)); } catch (Exception ex) { exceptions.Add(ex); } } //read in additional records for (int i = 0; i < nAdditional; i++) { try { additional.Add(new Record(buffer)); } catch (Exception ex) { exceptions.Add(ex); } } }
/// <summary> /// Implementation Reference RFC 2672 /// </summary> /// <param name="buffer"></param> public DNameRecord(DataBuffer buffer) : base(buffer){}
public PtrRecord(DataBuffer buffer):base(buffer){}
/// <summary> /// Text Record Type /// </summary> /// <param name="buffer"></param> /// <param name="length"></param> public TxtRecord(DataBuffer buffer, int length) : base(buffer, length){}
/// <summary> /// Create X25 Record Type /// </summary> /// <param name="buffer"></param> public X25Record(DataBuffer buffer) : base(buffer) { }