DnsRecord
Description
One decoded resource record.
Fields
| Name | Description |
|---|---|
name |
decoded label string (e.g. “example.com.”) |
type |
record type |
rclass |
record class (typically 1 = IN) |
ttl |
seconds the record may be cached |
ipv4 |
valid when type == DNS_TYPE_A; otherwise zero |
ipv6 |
valid when type == DNS_TYPE_AAAA; otherwise zero |
target |
valid when type is CNAME / NS / PTR; otherwise empty |
rdata |
raw rdata bytes; always populated regardless of type |
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Dns.h:79:
Str target;
DnsWireBuf rdata;
} DnsRecord;
typedef Vec(DnsRecord) DnsRecords;- In
Dns.h:81:
} DnsRecord;
typedef Vec(DnsRecord) DnsRecords;
///
- In
Dns.h:168:
/// TAGS: Dns, Parser, Deinit, Lifecycle
///
void DnsRecordDeinit(DnsRecord *self);
#ifdef __cplusplus- In
Dns.c:176:
// Decode one resource record. Advances the iter past the record.
static bool decode_record(BufIter *it, DnsRecord *rec, Allocator *alloc) {
rec->name = StrInit(alloc);
rec->target = StrInit(alloc);- In
Dns.c:255:
static bool decode_record_list(BufIter *it, u16 count, DnsRecords *out, Allocator *alloc) {
for (u16 i = 0; i < count; ++i) {
DnsRecord rec = {0};
if (!decode_record(it, &rec, alloc)) {
DnsRecordDeinit(&rec);- In
Dns.c:320:
// ---------------------------------------------------------------------------
void DnsRecordDeinit(DnsRecord *self) {
if (!self) {
return;- In
Dns.c:161:
if (match) {
DnsRecord *r0 = VecPtrAt(&resp.answers, 0);
match = r0->type == DNS_TYPE_A && r0->ttl == 300 && r0->ipv4[0] == 93 && r0->ipv4[1] == 184 &&
r0->ipv4[2] == 216 && r0->ipv4[3] == 34 && ZstrCompare(StrBegin(&r0->name), "example.com") == 0;- In
Dns.c:166:
}
if (match) {
DnsRecord *r1 = VecPtrAt(&resp.answers, 1);
match = r1->type == DNS_TYPE_AAAA && r1->ipv6[0] == 0x26 && r1->ipv6[1] == 0x06 && r1->ipv6[14] == 0x19 &&
r1->ipv6[15] == 0x46;- In
Dns.c:295:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_CNAME && ZstrCompare(StrBegin(&r->target), "example.com") == 0;
}- In
Dns.c:566:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_A && r->ttl == 300 && r->ipv4[0] == 0x0a && r->ipv4[1] == 0x0b &&
r->ipv4[2] == 0x0c && r->ipv4[3] == 0x0d && ZstrCompare(StrBegin(&r->name), "www.example.com") == 0;- In
Dns.c:741:
bool match = ok && q2_off == 256 && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_A && ZstrCompare(StrBegin(&r->name), "zz") == 0;
}- In
Dns.c:808:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match =
r->type == DNS_TYPE_A && r->ttl == 2 && ZstrCompare(StrBegin(&r->name), "abc.de") == 0 && r->ipv4[0] == 9;- In
Dns.c:1082:
bool match = ok && VecLen(&resp.answers) == 2;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_A && r->rclass == 1 && r->ttl == 0x01020304u && r->ipv4[0] == 8 &&
r->ipv4[1] == 8 && r->ipv4[2] == 4 && r->ipv4[3] == 4 && r->ipv6[0] == 0 &&- In
Dns.c:1110:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->rclass == 0x00FE;
}- In
Dns.c:1135:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->ttl == 0x80112233u;
}- In
Dns.c:1221:
bool match = ok && VecLen(&resp.answers) == 2;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_AAAA && r->ttl == 10 && VecLen(&r->target) == 0;
static const u8 ip6[] =- In
Dns.c:1306:
bool match = ok && VecLen(&resp.answers) == 2;
if (match) {
DnsRecord *r0 = VecPtrAt(&resp.answers, 0);
DnsRecord *r1 = VecPtrAt(&resp.answers, 1);
match = ZstrCompare(StrBegin(&r0->name), "x") == 0 && r0->ttl == 1 && r0->ipv4[0] == 1 && r0->ipv4[3] == 4 &&- In
Dns.c:1307:
if (match) {
DnsRecord *r0 = VecPtrAt(&resp.answers, 0);
DnsRecord *r1 = VecPtrAt(&resp.answers, 1);
match = ZstrCompare(StrBegin(&r0->name), "x") == 0 && r0->ttl == 1 && r0->ipv4[0] == 1 && r0->ipv4[3] == 4 &&
ZstrCompare(StrBegin(&r1->name), "y") == 0 && r1->ttl == 2 && r1->ipv4[0] == 5 && r1->ipv4[3] == 8;- In
Dns.c:1402:
bool match = ok && VecLen(&resp.answers) == 1 && VecLen(&resp.authority) == 1 && VecLen(&resp.additional) == 1;
if (match) {
DnsRecord *an = VecPtrAt(&resp.answers, 0);
DnsRecord *ns = VecPtrAt(&resp.authority, 0);
DnsRecord *ar = VecPtrAt(&resp.additional, 0);- In
Dns.c:1403:
if (match) {
DnsRecord *an = VecPtrAt(&resp.answers, 0);
DnsRecord *ns = VecPtrAt(&resp.authority, 0);
DnsRecord *ar = VecPtrAt(&resp.additional, 0);
match = ZstrCompare(StrBegin(&an->name), "an") == 0 && an->ipv4[0] == 11 &&- In
Dns.c:1404:
DnsRecord *an = VecPtrAt(&resp.answers, 0);
DnsRecord *ns = VecPtrAt(&resp.authority, 0);
DnsRecord *ar = VecPtrAt(&resp.additional, 0);
match = ZstrCompare(StrBegin(&an->name), "an") == 0 && an->ipv4[0] == 11 &&
ZstrCompare(StrBegin(&ns->name), "ns") == 0 && ns->ipv4[0] == 22 &&- In
Dns.c:1469:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = ZstrCompare(StrBegin(&r->name), "q") == 0 && r->ipv4[0] == 9 && r->ttl == 5;
}- In
Dns.c:1521:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_CNAME && ZstrCompare(StrBegin(&r->target), "to") == 0;
}- In
Dns.c:1828:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_A && r->ipv4[0] == 1 && r->ipv4[3] == 4;
}- In
Dns.c:2048:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_A && r->ttl == 7 && ZstrCompare(StrBegin(&r->name), "zz") == 0;
}- In
Dns.c:2084:
bool ok = DnsParseResponse(&resp, wire, sizeof(wire), adbg);
ok = ok && (VecLen(&resp.answers) == 1);
DnsRecord *r = ok ? VecPtrAt(&resp.answers, 0) : NULL;
ok = ok && (r->type == DNS_TYPE_CNAME);
// Heap-backed target ("example.com") -- the Str the dropped StrDeinit leaks.
Last updated on