resolved-dns-rr.c revision f91dc2400dc33e9a0745ecaaef7489af116dca38
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2014 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceKey* dns_resource_key_new(uint16_t class, uint16_t type, const char *name) {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering k = malloc0(sizeof(DnsResourceKey) + l + 1);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering strcpy((char*) k + sizeof(DnsResourceKey), name);
7c1ff6ac3d9e3acae1d601d40728cf7ccc9a7730Tom GundersenDnsResourceKey* dns_resource_key_new_cname(const DnsResourceKey *key) {
7c1ff6ac3d9e3acae1d601d40728cf7ccc9a7730Tom Gundersen return dns_resource_key_new(key->class, DNS_TYPE_CNAME, DNS_RESOURCE_KEY_NAME(key));
36d9205d669bcdcb04fa730d1f3549a9fc9a9001Tom GundersenDnsResourceKey* dns_resource_key_new_redirect(const DnsResourceKey *key, const DnsResourceRecord *cname) {
58db254ade4fb2ef77de68f28c4f13814819f6a1Lennart Poettering assert(IN_SET(cname->key->type, DNS_TYPE_CNAME, DNS_TYPE_DNAME));
58db254ade4fb2ef77de68f28c4f13814819f6a1Lennart Poettering return dns_resource_key_new(key->class, key->type, cname->cname.name);
58db254ade4fb2ef77de68f28c4f13814819f6a1Lennart Poettering r = dns_name_change_suffix(DNS_RESOURCE_KEY_NAME(key), DNS_RESOURCE_KEY_NAME(cname->key), cname->dname.name, &destination);
58db254ade4fb2ef77de68f28c4f13814819f6a1Lennart Poettering return dns_resource_key_ref((DnsResourceKey*) key);
58db254ade4fb2ef77de68f28c4f13814819f6a1Lennart Poettering k = dns_resource_key_new_consume(key->class, key->type, destination);
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poetteringint dns_resource_key_new_append_suffix(DnsResourceKey **ret, DnsResourceKey *key, char *name) {
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering r = dns_name_concat(DNS_RESOURCE_KEY_NAME(key), name, &joined);
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering new_key = dns_resource_key_new_consume(key->class, key->type, joined);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceKey* dns_resource_key_new_consume(uint16_t class, uint16_t type, char *name) {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceKey* dns_resource_key_ref(DnsResourceKey *k) {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceKey* dns_resource_key_unref(DnsResourceKey *k) {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint dns_resource_key_equal(const DnsResourceKey *a, const DnsResourceKey *b) {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering r = dns_name_equal(DNS_RESOURCE_KEY_NAME(a), DNS_RESOURCE_KEY_NAME(b));
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poetteringint dns_resource_key_match_rr(const DnsResourceKey *key, const DnsResourceRecord *rr, const char *search_domain) {
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering /* Checks if an rr matches the specified key. If a search
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering * domain is specified, it will also be checked if the key
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering * with the search domain suffixed might match the RR. */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering if (rr->key->class != key->class && key->class != DNS_CLASS_ANY)
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering if (rr->key->type != key->type && key->type != DNS_TYPE_ANY)
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering r = dns_name_equal(DNS_RESOURCE_KEY_NAME(rr->key), DNS_RESOURCE_KEY_NAME(key));
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering r = dns_name_concat(DNS_RESOURCE_KEY_NAME(key), search_domain, &joined);
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering return dns_name_equal(DNS_RESOURCE_KEY_NAME(rr->key), joined);
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poetteringint dns_resource_key_match_cname(const DnsResourceKey *key, const DnsResourceRecord *rr, const char *search_domain) {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering if (rr->key->class != key->class && key->class != DNS_CLASS_ANY)
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering r = dns_name_equal(DNS_RESOURCE_KEY_NAME(key), DNS_RESOURCE_KEY_NAME(rr->key));
58db254ade4fb2ef77de68f28c4f13814819f6a1Lennart Poettering else if (rr->key->type == DNS_TYPE_DNAME)
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering r = dns_name_endswith(DNS_RESOURCE_KEY_NAME(key), DNS_RESOURCE_KEY_NAME(rr->key));
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering r = dns_name_concat(DNS_RESOURCE_KEY_NAME(key), search_domain, &joined);
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering return dns_name_equal(joined, DNS_RESOURCE_KEY_NAME(rr->key));
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering else if (rr->key->type == DNS_TYPE_DNAME)
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering return dns_name_endswith(joined, DNS_RESOURCE_KEY_NAME(rr->key));
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersenstatic void dns_resource_key_hash_func(const void *i, struct siphash *state) {
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen dns_name_hash_func(DNS_RESOURCE_KEY_NAME(k), state);
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen siphash24_compress(&k->class, sizeof(k->class), state);
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen siphash24_compress(&k->type, sizeof(k->type), state);
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidtstatic int dns_resource_key_compare_func(const void *a, const void *b) {
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering const DnsResourceKey *x = a, *y = b;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering ret = dns_name_compare_func(DNS_RESOURCE_KEY_NAME(x), DNS_RESOURCE_KEY_NAME(y));
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidtconst struct hash_ops dns_resource_key_hash_ops = {
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringint dns_resource_key_to_string(const DnsResourceKey *key, char **ret) {
d23a27a964748967e1ad20e86de869a753af555bTom Gundersen char cbuf[strlen("CLASS") + DECIMAL_STR_MAX(uint16_t)], tbuf[strlen("TYPE") + DECIMAL_STR_MAX(uint16_t)];
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering const char *c, *t;
23432a1c249b9c513e438bffe9778a7ce2ee74feZbigniew Jędrzejewski-Szmek if (asprintf(&s, "%s %s %-5s", DNS_RESOURCE_KEY_NAME(key), c, t) < 0)
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceRecord* dns_resource_record_new(DnsResourceKey *key) {
8bf52d3d17d364438191077d0750b8b80b5dc53aLennart PoetteringDnsResourceRecord* dns_resource_record_new_full(uint16_t class, uint16_t type, const char *name) {
8bf52d3d17d364438191077d0750b8b80b5dc53aLennart Poettering _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
8bf52d3d17d364438191077d0750b8b80b5dc53aLennart Poettering key = dns_resource_key_new(class, type, name);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart PoetteringDnsResourceRecord* dns_resource_record_ref(DnsResourceRecord *rr) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart PoetteringDnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) {
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poetteringint dns_resource_record_new_reverse(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *hostname) {
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering r = dns_name_reverse(family, address, &ptr);
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering key = dns_resource_key_new_consume(DNS_CLASS_IN, DNS_TYPE_PTR, ptr);
78c6a153c47f8d597c827bdcaf8c4e42ac87f738Lennart Poetteringint dns_resource_record_new_address(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name) {
78c6a153c47f8d597c827bdcaf8c4e42ac87f738Lennart Poettering rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_A, name);
78c6a153c47f8d597c827bdcaf8c4e42ac87f738Lennart Poettering rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_AAAA, name);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringint dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecord *b) {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering r = dns_resource_key_equal(a->key, b->key);
fd0b4602f6332c3f1660eb208c8f5c719709a009Lennart Poettering switch (a->unparseable ? _DNS_TYPE_INVALID : a->key->type) {
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering r = dns_name_equal(a->srv.name, b->srv.name);
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering return a->srv.priority == b->srv.priority &&
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering return dns_name_equal(a->ptr.name, b->ptr.name);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering return strcaseeq(a->hinfo.cpu, b->hinfo.cpu) &&
9de3e3294065e8697ff10130b53f274319cdcf6fZbigniew Jędrzejewski-Szmek case DNS_TYPE_SPF: /* exactly the same as TXT */
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering return dns_txt_item_equal(a->txt.items, b->txt.items);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering return memcmp(&a->a.in_addr, &b->a.in_addr, sizeof(struct in_addr)) == 0;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering return memcmp(&a->aaaa.in6_addr, &b->aaaa.in6_addr, sizeof(struct in6_addr)) == 0;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering r = dns_name_equal(a->soa.mname, b->soa.mname);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering r = dns_name_equal(a->soa.rname, b->soa.rname);
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek if (a->mx.priority != b->mx.priority)
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek return dns_name_equal(a->mx.exchange, b->mx.exchange);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek assert(a->loc.version == b->loc.version);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek return a->loc.size == b->loc.size &&
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek a->loc.horiz_pre == b->loc.horiz_pre &&
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek a->loc.vert_pre == b->loc.vert_pre &&
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek a->loc.latitude == b->loc.latitude &&
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek a->loc.longitude == b->loc.longitude &&
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek a->loc.altitude == b->loc.altitude;
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen memcmp(a->ds.digest, b->ds.digest, a->ds.digest_size) == 0;
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering return a->sshfp.algorithm == b->sshfp.algorithm &&
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen a->sshfp.fingerprint_size == b->sshfp.fingerprint_size &&
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen memcmp(a->sshfp.fingerprint, b->sshfp.fingerprint, a->sshfp.fingerprint_size) == 0;
f91dc2400dc33e9a0745ecaaef7489af116dca38Lennart Poettering return a->dnskey.flags == b->dnskey.flags &&
f91dc2400dc33e9a0745ecaaef7489af116dca38Lennart Poettering a->dnskey.protocol == b->dnskey.protocol &&
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek a->dnskey.algorithm == b->dnskey.algorithm &&
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek a->dnskey.key_size == b->dnskey.key_size &&
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek memcmp(a->dnskey.key, b->dnskey.key, a->dnskey.key_size) == 0;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek /* do the fast comparisons first */
03664a62914782dbd8f069bbcf8a0c8ca1df7010Lukas Nykryn if (a->rrsig.type_covered != b->rrsig.type_covered ||
03664a62914782dbd8f069bbcf8a0c8ca1df7010Lukas Nykryn a->rrsig.original_ttl != b->rrsig.original_ttl ||
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek a->rrsig.signature_size != b->rrsig.signature_size ||
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek memcmp(a->rrsig.signature, b->rrsig.signature, a->rrsig.signature_size) != 0)
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek return dns_name_equal(a->rrsig.signer, b->rrsig.signer);
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen return dns_name_equal(a->nsec.next_domain_name, b->nsec.next_domain_name) &&
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen return a->nsec3.algorithm == b->nsec3.algorithm &&
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen memcmp(a->nsec3.salt, b->nsec3.salt, a->nsec3.salt_size) == 0 &&
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen memcmp(a->nsec3.next_hashed_name, b->nsec3.next_hashed_name, a->nsec3.next_hashed_name_size) == 0 &&
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering return a->generic.size == b->generic.size &&
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering memcmp(a->generic.data, b->generic.data, a->generic.size) == 0;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmekstatic char* format_location(uint32_t latitude, uint32_t longitude, uint32_t altitude,
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek uint8_t size, uint8_t horiz_pre, uint8_t vert_pre) {
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek char NS = latitude >= 1U<<31 ? 'N' : 'S';
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek char EW = longitude >= 1U<<31 ? 'E' : 'W';
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek int lat = latitude >= 1U<<31 ? (int) (latitude - (1U<<31)) : (int) ((1U<<31) - latitude);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek int lon = longitude >= 1U<<31 ? (int) (longitude - (1U<<31)) : (int) ((1U<<31) - longitude);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek double alt = altitude >= 10000000u ? altitude - 10000000u : -(double)(10000000u - altitude);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek double siz = (size >> 4) * exp10((double) (size & 0xF));
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek double hor = (horiz_pre >> 4) * exp10((double) (horiz_pre & 0xF));
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek double ver = (vert_pre >> 4) * exp10((double) (vert_pre & 0xF));
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek if (asprintf(&s, "%d %d %.3f %c %d %d %.3f %c %.2fm %.2fm %.2fm %.2fm",
7c6423e19136a7b7b6ef3fe06b94822e582dda27Tom Gundersenstatic int format_timestamp_dns(char *buf, size_t l, time_t sec) {
7c6423e19136a7b7b6ef3fe06b94822e582dda27Tom Gundersen if (strftime(buf, l, "%Y%m%d%H%M%S", &tm) <= 0)
2c1fb4f71206bf970d493294208c5d7597194856Lennart Poettering r = strv_extend(&strv, dns_type_to_string(type));
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poetteringstatic char *format_txt(DnsTxtItem *first) {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering p = s = new(char, c);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering for (j = 0; j < i->length; j++) {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering if (i->data[j] < ' ' || i->data[j] == '"' || i->data[j] >= 127) {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering *(p++) = '\\';
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering *(p++) = i->data[j];
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringint dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret) {
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek _cleanup_free_ char *k = NULL, *t = NULL;
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering r = dns_resource_key_to_string(rr->key, &k);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek switch (rr->unparseable ? _DNS_TYPE_INVALID : rr->key->type) {
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering s = strjoin(k, " ", rr->hinfo.cpu, " ", rr->hinfo.os, NULL);
9de3e3294065e8697ff10130b53f274319cdcf6fZbigniew Jędrzejewski-Szmek case DNS_TYPE_SPF: /* exactly the same as TXT */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering r = in_addr_to_string(AF_INET, (const union in_addr_union*) &rr->a.in_addr, &x);
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek r = in_addr_to_string(AF_INET6, (const union in_addr_union*) &rr->aaaa.in6_addr, &t);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering r = asprintf(&s, "%s %s %s %u %u %u %u %u",
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek t = format_location(rr->loc.latitude,
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen t = hexmem(rr->ds.digest, rr->ds.digest_size);
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen t = hexmem(rr->sshfp.fingerprint, rr->sshfp.fingerprint_size);
ff3d6560bead6879a2fed1bf99bfe8273b3723f1Zbigniew Jędrzejewski-Szmek alg = dnssec_algorithm_to_string(rr->dnskey.algorithm);
1bf968f36393666f2c57953b1748e6219c027deeTom Gundersen t = base64mem(rr->dnskey.key, rr->dnskey.key_size);
ff3d6560bead6879a2fed1bf99bfe8273b3723f1Zbigniew Jędrzejewski-Szmek alg ? 0 : 1, alg ? 0u : (unsigned) rr->dnskey.algorithm,
7c6423e19136a7b7b6ef3fe06b94822e582dda27Tom Gundersen char expiration[strlen("YYYYMMDDHHmmSS") + 1], inception[strlen("YYYYMMDDHHmmSS") + 1];
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek type = dns_type_to_string(rr->rrsig.type_covered);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek alg = dnssec_algorithm_to_string(rr->rrsig.algorithm);
1bf968f36393666f2c57953b1748e6219c027deeTom Gundersen t = base64mem(rr->rrsig.signature, rr->rrsig.signature_size);
7c6423e19136a7b7b6ef3fe06b94822e582dda27Tom Gundersen r = format_timestamp_dns(expiration, sizeof(expiration), rr->rrsig.expiration);
7c6423e19136a7b7b6ef3fe06b94822e582dda27Tom Gundersen r = format_timestamp_dns(inception, sizeof(inception), rr->rrsig.inception);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek /* TYPE?? follows
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek * http://tools.ietf.org/html/rfc3597#section-5 */
7c6423e19136a7b7b6ef3fe06b94822e582dda27Tom Gundersen r = asprintf(&s, "%s %s%.*u %.*s%.*u %u %u %s %s %u %s %s",
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek type ? 0 : 1, type ? 0u : (unsigned) rr->rrsig.type_covered,
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek alg ? 0 : 1, alg ? 0u : (unsigned) rr->rrsig.algorithm,
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen _cleanup_free_ char *salt = NULL, *hash = NULL;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen salt = hexmem(rr->nsec3.salt, rr->nsec3.salt_size);
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen hash = base32hexmem(rr->nsec3.next_hashed_name, rr->nsec3.next_hashed_name_size, false);
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen r = asprintf(&s, "%s %"PRIu8" %"PRIu8" %"PRIu16" %s %s %s",
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek t = hexmem(rr->generic.data, rr->generic.size);
f5430a3ef308f3a102899fcaf7fbece757082f2aLennart Poettering r = asprintf(&s, "%s \\# %zu %s", k, rr->generic.size, t);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringconst char *dns_class_to_string(uint16_t class) {
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringint dns_class_from_string(const char *s, uint16_t *class) {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart PoetteringDnsTxtItem *dns_txt_item_free_all(DnsTxtItem *i) {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poetteringbool dns_txt_item_equal(DnsTxtItem *a, DnsTxtItem *b) {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering if (memcmp(a->data, b->data, a->length) != 0)