private void HandleRData(NetBinaryReader nbr) { long startPos = nbr.BaseStream.Position; switch (Type) { case (QType.A): case (QType.AAAA): recordValue = new IPAddress(nbr.ReadBytes(ByteCount)); break; /* case (QType.NS): case (QType.CNAME): recordValue = nbr.ReadLblOrPntString(); ReadPadOctets(nbr, startPos); break; case (QType.SOA): recordValue = new SOA(nbr); ReadPadOctets(nbr, startPos); break; */ default: recordValue = nbr.ReadBytes(ByteCount); break; } }
public IPHeader(byte[] byBuffer, int nReceived) { NetBinaryReader nbr = new NetBinaryReader(byBuffer, 0, nReceived); Version = nbr.ReadNible(); HeaderLength = nbr.ReadNible(); Precedence = (Precedence)nbr.ReadCustomAmount(3); LowDelay = nbr.ReadBit(); HighThroughput = nbr.ReadBit(); HighRelibility = nbr.ReadBit(); nbr.SkipPadBits(); TotalLength = nbr.ReadUInt16(); Identification = nbr.ReadUInt16(); nbr.ReadBit(); MayFragment = !nbr.ReadBit(); LastFragment = !nbr.ReadBit(); FragmentOffset = (nbr.ReadPadBits() << 3) + nbr.ReadByte(); TTL = nbr.ReadByte(); Protocol = (ProtocolType)nbr.ReadByte(); HeaderChecksum = IPAddress.NetworkToHostOrder(nbr.ReadInt16()); Source = new IPAddress(nbr.ReadBytes(4)); Destination = new IPAddress(nbr.ReadBytes(4)); }