private static DNSRRBase ReadResourceRecord(byte[] data, DataReader reader) { DNSRRBase rr = null; string name = ReadString(data, reader); DNSType type = (DNSType)reader.ReadUInt16(false); DNSClass cls = (DNSClass)reader.ReadUInt16(false); uint ttl = reader.ReadUInt32(false); ushort rlen = reader.ReadUInt16(false); byte[] rdata = reader.ReadBytes(rlen); switch (type) { case DNSType.CNAME: { CNameDNSRR newRec = new CNameDNSRR(data, rdata); rr = newRec; } break; case DNSType.A: { ADNSRR aRec = new ADNSRR(rdata); rr = aRec; } break; case DNSType.AAAA: { AAAADNSRR aRec = new AAAADNSRR(rdata); rr = aRec; } break; case DNSType.PTR: { PTRDNSRR aRec = new PTRDNSRR(data, rdata); rr = aRec; } break; default: { UnknownDNSRR newRec = new UnknownDNSRR(); newRec.RData = rdata; rr = newRec; } break; } rr.Name = name; rr.Class = cls; rr.Type = type; rr.TimeToLive = ttl; return(rr); }
private static DNSRRBase[] ReadResourceRecords(byte[] data, DataReader reader, int count) { DNSRRBase[] records = new DNSRRBase[count]; for (int i = 0; i < count; ++i) { records[i] = ReadResourceRecord(data, reader); } return(records); }
private static DNSRRBase[] ReadResourceRecords(byte[] data, DataReader reader, int count) { DNSRRBase[] records = new DNSRRBase[count]; for (int i = 0; i < count; ++i) { records[i] = ReadResourceRecord(data, reader); } return records; }