public ushort this [int offset, int length] { get { ushort result = 0; for (int i = offset; i < offset + length && i < 16; ++i) result |= this[i] ? (ushort)(1 << (length - i - 1)) :(ushort)0; return result; } set { UShortT ut = new UShortT((ushort)(value << (16 - length))); for (int i = 0; i < length && i + offset < 16; ++i) { this[i + offset] = ut[i]; } } }
public DnsQuery(byte[] data, int offset) { int n = 0; qname = ParseName(data, offset, out qnameBytes, out n); qtype = UShortT.FromBytes(data, offset + n); qclass = UShortT.FromBytes(data, offset + n + 2); length = n + 4; }
public DnsHeader(byte[] data) { id = UShortT.FromBytes(data, 0); flags = UShortT.FromBytes(data, 2); qdcount = UShortT.FromBytes(data, 4); ancount = UShortT.FromBytes(data, 6); nscount = UShortT.FromBytes(data, 8); arcount = UShortT.FromBytes(data, 10); }