public override void BodyReadFrom(byte[] aData, Stream aMainStream) { BinaryReader aSrc = new BinaryReader(new MemoryStream(aData)); this.fTargetName = DNSPacket.ParseName(aSrc, aMainStream); aSrc.Close(); }
public static DNSResource ReadFrom(BinaryReader aSrc) { DNSResource resource; string str = DNSPacket.ParseName(aSrc, aSrc.BaseStream); DNSType aType = (DNSType)DNSPacket.N2H(aSrc.ReadUInt16()); DNSClass class2 = (DNSClass)DNSPacket.N2H(aSrc.ReadUInt16()); bool flag = false; if (0 != (((ushort)class2) & 0x8000)) { flag = true; } class2 &= (DNSClass)(-32769); uint num = DNSPacket.N2H(aSrc.ReadUInt32()); ushort num2 = DNSPacket.N2H(aSrc.ReadUInt16()); byte[] aData = aSrc.ReadBytes((int)num2); DNSType type2 = aType; if (type2 == DNSType.A) { resource = new DNSARecord(); } else if (type2 == DNSType.AAAA) { resource = new DNSAAAARecord(); } else if (type2 == DNSType.PTR) { resource = new DNSPTRRecord(); } else if (type2 == DNSType.NS) { resource = new DNSNSRecord(); } else if (type2 == DNSType.TXT) { resource = new DNSTXTRecord(); } else if (type2 == DNSType.CNAME) { resource = new DNSCNameRecord(); } else if (type2 == DNSType.SRV) { resource = new DNSSRVRecord(); } else { resource = new DNSUnknownRecord(aType); } resource.fName = str; resource.fParseTime = DateTime.UtcNow; resource.fClass = class2; resource.fClearCache = flag; resource.fTTL = (ushort)num; resource.BodyReadFrom(aData, aSrc.BaseStream); return(resource); }
public override void BodyReadFrom(byte[] aData, Stream aMainStream) { BinaryReader aSrc = new BinaryReader(new MemoryStream(aData)); this.fPriority = DNSPacket.N2H(aSrc.ReadUInt16()); this.fWeight = DNSPacket.N2H(aSrc.ReadUInt16()); this.fPort = DNSPacket.N2H(aSrc.ReadUInt16()); this.fTargetName = DNSPacket.ParseName(aSrc, aMainStream); aSrc.Close(); }
public void ReadFrom(BinaryReader aSrc) { this.fName = DNSPacket.ParseName(aSrc, aSrc.BaseStream); this.fType = (DNSType)DNSPacket.N2H(aSrc.ReadUInt16()); ushort num = DNSPacket.N2H(aSrc.ReadUInt16()); if (0 != (num & 0x8000)) { this.fClearCache = true; } this.fClass = ((DNSClass)num) & ((DNSClass)(-32769)); }