internal DnsResourceRecordIPAddress (DnsResourceRecord rr, int address_size)
		{
			CopyFrom (rr);
			ArraySegment<byte> segment = rr.Data;
			byte [] bytes = new byte [address_size];
			Buffer.BlockCopy (segment.Array, segment.Offset, bytes, 0, address_size);
			address = new IPAddress (bytes);
		}
Beispiel #2
0
		internal void CopyFrom(DnsResourceRecord rr) {
			name = rr.name;
			type = rr.type;
			klass = rr.klass;
			ttl = rr.ttl;
			rdlength = rr.rdlength;
			m_rdata = rr.m_rdata;
		}
Beispiel #3
0
		static internal DnsResourceRecord CreateFromBuffer(DnsPacket packet, int size, ref int offset) {
			string pname = packet.ReadName(ref offset);
			DnsType ptype = (DnsType)packet.ReadUInt16(ref offset);
			DnsClass pclass = (DnsClass)packet.ReadUInt16(ref offset);
			int pttl = packet.ReadInt32(ref offset);
			ushort prdlength = packet.ReadUInt16(ref offset);
			DnsResourceRecord rr = new DnsResourceRecord();
			rr.name = pname;
			rr.type = ptype;
			rr.klass = pclass;
			rr.ttl = pttl;
			rr.rdlength = prdlength;
			rr.m_rdata = new ArraySegment<byte>(packet.Packet, offset, prdlength);
			offset += prdlength;

			switch(pclass) {
			case DnsClass.IN:
				switch(ptype) {
				case DnsType.A:
					rr = new DnsResourceRecordA(rr);
					break;
				case DnsType.AAAA:
					rr = new DnsResourceRecordAAAA(rr);
					break;
				case DnsType.CNAME:
					rr = new DnsResourceRecordCName(rr);
					break;
				case DnsType.PTR:
					rr = new DnsResourceRecordPTR(rr);
					break;
				default:
					break;
					}
				break;
			default:
				break;
			}
			return rr;
		}
Beispiel #4
0
		internal DnsResourceRecordAAAA (DnsResourceRecord rr)
			: base (rr, 16)
		{
		}
		internal DnsResourceRecordCName (DnsResourceRecord rr)
		{
			CopyFrom (rr);
			int offset = rr.Data.Offset;
			cname = DnsPacket.ReadName (rr.Data.Array, ref offset);
		}
Beispiel #6
0
		internal DnsResourceRecordA (DnsResourceRecord rr)
			: base (rr, 4)
		{
		}