Lines Matching defs:rr
28 #include "resolved-dns-rr.h"
187 int dns_resource_key_match_rr(const DnsResourceKey *key, DnsResourceRecord *rr, const char *search_domain) {
191 assert(rr);
193 if (key == rr->key)
196 /* Checks if an rr matches the specified key. If a search
200 if (rr->key->class != key->class && key->class != DNS_CLASS_ANY)
203 if (rr->key->type != key->type && key->type != DNS_TYPE_ANY)
206 r = dns_name_equal(DNS_RESOURCE_KEY_NAME(rr->key), DNS_RESOURCE_KEY_NAME(key));
217 return dns_name_equal(DNS_RESOURCE_KEY_NAME(rr->key), joined);
378 DnsResourceRecord *rr;
380 rr = new0(DnsResourceRecord, 1);
381 if (!rr)
384 rr->n_ref = 1;
385 rr->key = dns_resource_key_ref(key);
386 rr->expiry = USEC_INFINITY;
387 rr->n_skip_labels_signer = rr->n_skip_labels_source = (unsigned) -1;
389 return rr;
402 DnsResourceRecord* dns_resource_record_ref(DnsResourceRecord *rr) {
403 if (!rr)
406 assert(rr->n_ref > 0);
407 rr->n_ref++;
409 return rr;
412 DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) {
413 if (!rr)
416 assert(rr->n_ref > 0);
418 if (rr->n_ref > 1) {
419 rr->n_ref--;
423 if (rr->key) {
424 switch(rr->key->type) {
427 free(rr->srv.name);
434 free(rr->ptr.name);
438 free(rr->hinfo.cpu);
439 free(rr->hinfo.os);
444 dns_txt_item_free_all(rr->txt.items);
448 free(rr->soa.mname);
449 free(rr->soa.rname);
453 free(rr->mx.exchange);
457 free(rr->ds.digest);
461 free(rr->sshfp.fingerprint);
465 free(rr->dnskey.key);
469 free(rr->rrsig.signer);
470 free(rr->rrsig.signature);
474 free(rr->nsec.next_domain_name);
475 bitmap_free(rr->nsec.types);
479 free(rr->nsec3.next_hashed_name);
480 free(rr->nsec3.salt);
481 bitmap_free(rr->nsec3.types);
490 free(rr->tlsa.data);
495 free(rr->generic.data);
498 free(rr->wire_format);
499 dns_resource_key_unref(rr->key);
502 free(rr->to_string);
503 free(rr);
510 _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
528 rr = dns_resource_record_new(key);
529 if (!rr)
532 rr->ptr.name = strdup(hostname);
533 if (!rr->ptr.name)
536 *ret = rr;
537 rr = NULL;
543 DnsResourceRecord *rr;
551 rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_A, name);
552 if (!rr)
555 rr->a.in_addr = address->in;
559 rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_AAAA, name);
560 if (!rr)
563 rr->aaaa.in6_addr = address->in6;
567 *ret = rr;
820 const char *dns_resource_record_to_string(DnsResourceRecord *rr) {
825 assert(rr);
827 if (rr->to_string)
828 return rr->to_string;
830 r = dns_resource_key_to_string(rr->key, &k);
834 switch (rr->unparseable ? _DNS_TYPE_INVALID : rr->key->type) {
839 rr->srv.priority,
840 rr->srv.weight,
841 rr->srv.port,
842 strna(rr->srv.name));
851 s = strjoin(k, " ", rr->ptr.name, NULL);
858 s = strjoin(k, " ", rr->hinfo.cpu, " ", rr->hinfo.os, NULL);
865 t = format_txt(rr->txt.items);
877 r = in_addr_to_string(AF_INET, (const union in_addr_union*) &rr->a.in_addr, &x);
888 r = in_addr_to_string(AF_INET6, (const union in_addr_union*) &rr->aaaa.in6_addr, &t);
900 strna(rr->soa.mname),
901 strna(rr->soa.rname),
902 rr->soa.serial,
903 rr->soa.refresh,
904 rr->soa.retry,
905 rr->soa.expire,
906 rr->soa.minimum);
914 rr->mx.priority,
915 rr->mx.exchange);
921 assert(rr->loc.version == 0);
923 t = format_location(rr->loc.latitude,
924 rr->loc.longitude,
925 rr->loc.altitude,
926 rr->loc.size,
927 rr->loc.horiz_pre,
928 rr->loc.vert_pre);
938 t = hexmem(rr->ds.digest, rr->ds.digest_size);
944 rr->ds.key_tag,
945 rr->ds.algorithm,
946 rr->ds.digest_type,
953 t = hexmem(rr->sshfp.fingerprint, rr->sshfp.fingerprint_size);
959 rr->sshfp.algorithm,
960 rr->sshfp.fptype,
972 key_tag = dnssec_keytag(rr, true);
974 r = dnssec_algorithm_to_string_alloc(rr->dnskey.algorithm, &alg);
981 rr->dnskey.flags,
982 rr->dnskey.protocol,
989 rr->dnskey.key, rr->dnskey.key_size,
999 rr->dnskey.flags & DNSKEY_FLAG_SEP ? " SEP" : "",
1000 rr->dnskey.flags & DNSKEY_FLAG_REVOKE ? " REVOKE" : "",
1001 rr->dnskey.flags & DNSKEY_FLAG_ZONE_KEY ? " ZONE_KEY" : "",
1018 type = dns_type_to_string(rr->rrsig.type_covered);
1020 r = dnssec_algorithm_to_string_alloc(rr->rrsig.algorithm, &alg);
1024 r = format_timestamp_dns(expiration, sizeof(expiration), rr->rrsig.expiration);
1028 r = format_timestamp_dns(inception, sizeof(inception), rr->rrsig.inception);
1038 type ? 0 : 1, type ? 0u : (unsigned) rr->rrsig.type_covered,
1040 rr->rrsig.labels,
1041 rr->rrsig.original_ttl,
1044 rr->rrsig.key_tag,
1045 rr->rrsig.signer,
1051 rr->rrsig.signature, rr->rrsig.signature_size,
1060 t = format_types(rr->nsec.types);
1066 rr->nsec.next_domain_name,
1075 if (rr->nsec3.salt_size > 0) {
1076 salt = hexmem(rr->nsec3.salt, rr->nsec3.salt_size);
1081 hash = base32hexmem(rr->nsec3.next_hashed_name, rr->nsec3.next_hashed_name_size, false);
1085 t = format_types(rr->nsec3.types);
1091 rr->nsec3.algorithm,
1092 rr->nsec3.flags,
1093 rr->nsec3.iterations,
1094 rr->nsec3.salt_size > 0 ? salt : "-",
1108 cert_usage = tlsa_cert_usage_to_string(rr->tlsa.cert_usage);
1109 selector = tlsa_selector_to_string(rr->tlsa.selector);
1110 matching_type = tlsa_matching_type_to_string(rr->tlsa.matching_type);
1114 rr->tlsa.cert_usage,
1115 rr->tlsa.selector,
1116 rr->tlsa.matching_type,
1122 rr->tlsa.data, rr->tlsa.data_size,
1153 rr->generic.data, rr->generic.data_size,
1161 t = hexmem(rr->generic.data, rr->generic.data_size);
1166 r = asprintf(&s, "%s \\# %zu %s", k, rr->generic.data_size, t);
1172 rr->to_string = s;
1176 int dns_resource_record_to_wire_format(DnsResourceRecord *rr, bool canonical) {
1189 assert(rr);
1199 if (rr->wire_format && rr->wire_format_canonical == canonical)
1202 r = dns_packet_append_rr(&packet, rr, &start, &rds);
1209 free(rr->wire_format);
1210 rr->wire_format = packet._data;
1211 rr->wire_format_size = packet.size;
1212 rr->wire_format_rdata_offset = rds;
1213 rr->wire_format_canonical = canonical;
1221 int dns_resource_record_signer(DnsResourceRecord *rr, const char **ret) {
1225 assert(rr);
1230 if (rr->n_skip_labels_signer == (unsigned) -1)
1233 n = DNS_RESOURCE_KEY_NAME(rr->key);
1234 r = dns_name_skip(n, rr->n_skip_labels_signer, &n);
1244 int dns_resource_record_source(DnsResourceRecord *rr, const char **ret) {
1248 assert(rr);
1253 if (rr->n_skip_labels_source == (unsigned) -1)
1256 n = DNS_RESOURCE_KEY_NAME(rr->key);
1257 r = dns_name_skip(n, rr->n_skip_labels_source, &n);
1267 int dns_resource_record_is_signer(DnsResourceRecord *rr, const char *zone) {
1271 assert(rr);
1273 r = dns_resource_record_signer(rr, &signer);
1280 int dns_resource_record_is_synthetic(DnsResourceRecord *rr) {
1283 assert(rr);
1287 if (rr->n_skip_labels_source == (unsigned) -1)
1290 if (rr->n_skip_labels_source == 0)
1293 if (rr->n_skip_labels_source > 1)
1296 r = dns_name_startswith(DNS_RESOURCE_KEY_NAME(rr->key), "*");
1304 const DnsResourceRecord *rr = i;
1306 assert(rr);
1308 dns_resource_key_hash_func(rr->key, state);
1310 switch (rr->unparseable ? _DNS_TYPE_INVALID : rr->key->type) {
1313 siphash24_compress(&rr->srv.priority, sizeof(rr->srv.priority), state);
1314 siphash24_compress(&rr->srv.weight, sizeof(rr->srv.weight), state);
1315 siphash24_compress(&rr->srv.port, sizeof(rr->srv.port), state);
1316 dns_name_hash_func(rr->srv.name, state);
1323 dns_name_hash_func(rr->ptr.name, state);
1327 string_hash_func(rr->hinfo.cpu, state);
1328 string_hash_func(rr->hinfo.os, state);
1335 LIST_FOREACH(items, j, rr->txt.items) {
1346 siphash24_compress(&rr->a.in_addr, sizeof(rr->a.in_addr), state);
1350 siphash24_compress(&rr->aaaa.in6_addr, sizeof(rr->aaaa.in6_addr), state);
1354 dns_name_hash_func(rr->soa.mname, state);
1355 dns_name_hash_func(rr->soa.rname, state);
1356 siphash24_compress(&rr->soa.serial, sizeof(rr->soa.serial), state);
1357 siphash24_compress(&rr->soa.refresh, sizeof(rr->soa.refresh), state);
1358 siphash24_compress(&rr->soa.retry, sizeof(rr->soa.retry), state);
1359 siphash24_compress(&rr->soa.expire, sizeof(rr->soa.expire), state);
1360 siphash24_compress(&rr->soa.minimum, sizeof(rr->soa.minimum), state);
1364 siphash24_compress(&rr->mx.priority, sizeof(rr->mx.priority), state);
1365 dns_name_hash_func(rr->mx.exchange, state);
1369 siphash24_compress(&rr->loc.version, sizeof(rr->loc.version), state);
1370 siphash24_compress(&rr->loc.size, sizeof(rr->loc.size), state);
1371 siphash24_compress(&rr->loc.horiz_pre, sizeof(rr->loc.horiz_pre), state);
1372 siphash24_compress(&rr->loc.vert_pre, sizeof(rr->loc.vert_pre), state);
1373 siphash24_compress(&rr->loc.latitude, sizeof(rr->loc.latitude), state);
1374 siphash24_compress(&rr->loc.longitude, sizeof(rr->loc.longitude), state);
1375 siphash24_compress(&rr->loc.altitude, sizeof(rr->loc.altitude), state);
1379 siphash24_compress(&rr->sshfp.algorithm, sizeof(rr->sshfp.algorithm), state);
1380 siphash24_compress(&rr->sshfp.fptype, sizeof(rr->sshfp.fptype), state);
1381 siphash24_compress(rr->sshfp.fingerprint, rr->sshfp.fingerprint_size, state);
1385 siphash24_compress(&rr->dnskey.flags, sizeof(rr->dnskey.flags), state);
1386 siphash24_compress(&rr->dnskey.protocol, sizeof(rr->dnskey.protocol), state);
1387 siphash24_compress(&rr->dnskey.algorithm, sizeof(rr->dnskey.algorithm), state);
1388 siphash24_compress(rr->dnskey.key, rr->dnskey.key_size, state);
1392 siphash24_compress(&rr->rrsig.type_covered, sizeof(rr->rrsig.type_covered), state);
1393 siphash24_compress(&rr->rrsig.algorithm, sizeof(rr->rrsig.algorithm), state);
1394 siphash24_compress(&rr->rrsig.labels, sizeof(rr->rrsig.labels), state);
1395 siphash24_compress(&rr->rrsig.original_ttl, sizeof(rr->rrsig.original_ttl), state);
1396 siphash24_compress(&rr->rrsig.expiration, sizeof(rr->rrsig.expiration), state);
1397 siphash24_compress(&rr->rrsig.inception, sizeof(rr->rrsig.inception), state);
1398 siphash24_compress(&rr->rrsig.key_tag, sizeof(rr->rrsig.key_tag), state);
1399 dns_name_hash_func(rr->rrsig.signer, state);
1400 siphash24_compress(rr->rrsig.signature, rr->rrsig.signature_size, state);
1404 dns_name_hash_func(rr->nsec.next_domain_name, state);
1411 siphash24_compress(&rr->ds.key_tag, sizeof(rr->ds.key_tag), state);
1412 siphash24_compress(&rr->ds.algorithm, sizeof(rr->ds.algorithm), state);
1413 siphash24_compress(&rr->ds.digest_type, sizeof(rr->ds.digest_type), state);
1414 siphash24_compress(rr->ds.digest, rr->ds.digest_size, state);
1418 siphash24_compress(&rr->nsec3.algorithm, sizeof(rr->nsec3.algorithm), state);
1419 siphash24_compress(&rr->nsec3.flags, sizeof(rr->nsec3.flags), state);
1420 siphash24_compress(&rr->nsec3.iterations, sizeof(rr->nsec3.iterations), state);
1421 siphash24_compress(rr->nsec3.salt, rr->nsec3.salt_size, state);
1422 siphash24_compress(rr->nsec3.next_hashed_name, rr->nsec3.next_hashed_name_size, state);
1427 siphash24_compress(&rr->tlsa.cert_usage, sizeof(rr->tlsa.cert_usage), state);
1428 siphash24_compress(&rr->tlsa.selector, sizeof(rr->tlsa.selector), state);
1429 siphash24_compress(&rr->tlsa.matching_type, sizeof(rr->tlsa.matching_type), state);
1430 siphash24_compress(&rr->tlsa.data, rr->tlsa.data_size, state);
1435 siphash24_compress(rr->generic.data, rr->generic.data_size, state);
1515 /* Names as listed on https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml */