/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_TXT Parse(byte[] reply, ref int offset, int rdLength, int ttl) { // TXT RR string text = Dns_Client.ReadCharacterString(reply, ref offset); return(new DNS_rr_TXT(text, ttl)); }
/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_NAPTR Parse(byte[] reply, ref int offset, int rdLength, int ttl) { /* RFC 3403. * The packet format for the NAPTR record is as follows * 1 1 1 1 1 1 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ORDER | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | PREFERENCE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / FLAGS / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / SERVICES / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / REGEXP / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / REPLACEMENT / | / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ */ int order = reply[offset++] << 8 | reply[offset++]; int preference = reply[offset++] << 8 | reply[offset++]; string flags = Dns_Client.ReadCharacterString(reply, ref offset); string services = Dns_Client.ReadCharacterString(reply, ref offset); string regexp = Dns_Client.ReadCharacterString(reply, ref offset); string replacement = ""; Dns_Client.GetQName(reply, ref offset, ref replacement); return(new DNS_rr_NAPTR(order, preference, flags, services, regexp, replacement, ttl)); }