private void encodeQuestions(DnsResponse response, ByteBuf buf) throws Exception { final int count = response.count(DnsSection.QUESTION); for (int i = 0; i < count; i++) { recordEncoder.encodeQuestion((DnsQuestion) response.recordAt(DnsSection.QUESTION, i), buf); } }
private void encodeRecords(DnsQuery query, DnsSection section, ByteBuf buf) throws Exception { final int count = query.count(section); for (int i = 0; i < count; i++) { recordEncoder.encodeRecord(query.recordAt(section, i), buf); } } }
private void decodeRecords( DnsQuery query, DnsSection section, ByteBuf buf, int count) throws Exception { for (int i = count; i > 0; i--) { final DnsRecord r = recordDecoder.decodeRecord(buf); if (r == null) { // Truncated response break; } query.addRecord(section, r); } } }
private void encodeRecord0(DnsRecord record, ByteBuf out) throws Exception { encodeName(record.name(), out); out.writeShort(record.type().intValue()); out.writeShort(record.dnsClass()); out.writeInt((int) record.timeToLive()); }
@Override public final void encodeQuestion(DnsQuestion question, ByteBuf out) throws Exception { encodeName(question.name(), out); out.writeShort(question.type().intValue()); out.writeShort(question.dnsClass()); }
private void encodeRecords(DnsResponse response, DnsSection section, ByteBuf buf) throws Exception { final int count = response.count(section); for (int i = 0; i < count; i++) { recordEncoder.encodeRecord(response.recordAt(section, i), buf); } } }
@Override public final DnsQuestion decodeQuestion(ByteBuf in) throws Exception { String name = decodeName(in); DnsRecordType type = DnsRecordType.valueOf(in.readUnsignedShort()); int qClass = in.readUnsignedShort(); return new DefaultDnsQuestion(name, type, qClass); }
private void encodePtrRecord(DnsPtrRecord record, ByteBuf out) throws Exception { encodeRecord0(record, out); encodeName(record.hostname(), out); }
private void encodeQuestions(DnsQuery query, ByteBuf buf) throws Exception { final int count = query.count(DnsSection.QUESTION); for (int i = 0; i < count; i++) { recordEncoder.encodeQuestion((DnsQuestion) query.recordAt(DnsSection.QUESTION, i), buf); } }
@Override public DnsMessage addRecord(DnsSection section, int index, DnsRecord record) { addRecord(sectionOrdinal(section), index, record); return this; }
private void decodeQuestions(DnsQuery query, ByteBuf buf, int questionCount) throws Exception { for (int i = questionCount; i > 0; i--) { query.addRecord(DnsSection.QUESTION, recordDecoder.decodeQuestion(buf)); } }
private void decodeRecords( DnsResponse response, DnsSection section, ByteBuf buf, int count) throws Exception { for (int i = count; i > 0; i --) { final DnsRecord r = recordDecoder.decodeRecord(buf); if (r == null) { // Truncated response break; } response.addRecord(section, r); } } }
private void decodeQuestions(DnsResponse response, ByteBuf buf, int questionCount) throws Exception { for (int i = questionCount; i > 0; i --) { response.addRecord(DnsSection.QUESTION, recordDecoder.decodeQuestion(buf)); } }
@Override public DnsMessage clear(DnsSection section) { clear(sectionOrdinal(section)); return this; }
static StringBuilder appendQuery(StringBuilder buf, DnsQuery query) { appendQueryHeader(buf, query); appendAllRecords(buf, query); return buf; }
private static void appendAllRecords(StringBuilder buf, DnsMessage msg) { appendRecords(buf, msg, DnsSection.QUESTION); appendRecords(buf, msg, DnsSection.ANSWER); appendRecords(buf, msg, DnsSection.AUTHORITY); appendRecords(buf, msg, DnsSection.ADDITIONAL); }
private boolean isRequestedType(DnsRecordType dnsRecordType, DnsRecordType[] types) { for (DnsRecordType t : types) { if (t.equals(dnsRecordType)) { return true; } } return false; } }
@Override public DnsMessage addRecord(DnsSection section, DnsRecord record) { addRecord(sectionOrdinal(section), record); return this; }