resolved-dns-rr.c revision 2d4c5cbc0ed3ccb09dc086a040088b454c22c644
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "resolved-dns-domain.h"
#include "resolved-dns-rr.h"
DnsResourceKey *k;
size_t l;
if (!k)
return NULL;
k->n_ref = 1;
return k;
}
DnsResourceKey *k;
if (!k)
return NULL;
k->n_ref = 1;
return k;
}
if (!k)
return NULL;
k->n_ref++;
return k;
}
if (!k)
return NULL;
if (k->n_ref == 1) {
free(k);
} else
k->n_ref--;
return NULL;
}
int r;
if (r <= 0)
return r;
return 0;
return 0;
return 1;
}
return 0;
return 0;
}
return 0;
return 0;
}
const DnsResourceKey *k = i;
unsigned long ul;
return ul;
}
int dns_resource_key_compare_func(const void *a, const void *b) {
const DnsResourceKey *x = a, *y = b;
int ret;
if (ret != 0)
return ret;
return -1;
return 1;
return -1;
return 1;
return 0;
}
const char *c, *t;
char *s;
if (!c) {
c = cbuf;
}
if (!t){
t = tbuf;
}
if (!s)
return -ENOMEM;
*ret = s;
return 0;
}
if (!rr)
return NULL;
return rr;
}
if (!key)
return NULL;
return dns_resource_record_new(key);
}
if (!rr)
return NULL;
return rr;
}
if (!rr)
return NULL;
return NULL;
}
}
return NULL;
}
int dns_resource_record_new_reverse(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *hostname) {
int r;
if (r < 0)
return r;
if (!key)
return -ENOMEM;
if (!rr)
return -ENOMEM;
return -ENOMEM;
return 0;
}
int r;
assert(a);
assert(b);
if (r <= 0)
return r;
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
case DNS_TYPE_HINFO:
case DNS_TYPE_A:
case DNS_TYPE_AAAA:
case DNS_TYPE_SOA:
if (r <= 0)
return r;
if (r <= 0)
return r;
default:
}
}
_cleanup_free_ char *k = NULL;
char *s;
int r;
if (r < 0)
return r;
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
if (!s)
return -ENOMEM;
break;
case DNS_TYPE_HINFO:
if (!s)
return -ENOMEM;
break;
case DNS_TYPE_A: {
_cleanup_free_ char *x = NULL;
if (r < 0)
return r;
if (!s)
return -ENOMEM;
break;
}
case DNS_TYPE_AAAA: {
_cleanup_free_ char *x = NULL;
if (r < 0)
return r;
if (!s)
return -ENOMEM;
break;
}
case DNS_TYPE_SOA:
r = asprintf(&s, "%s %s %s %u %u %u %u %u",
k,
if (r < 0)
return -ENOMEM;
break;
default: {
_cleanup_free_ char *x = NULL;
if (!x)
return -ENOMEM;
if (!s)
return -ENOMEM;
break;
}}
*ret = s;
return 0;
}
switch (class) {
case DNS_CLASS_IN:
return "IN";
case DNS_CLASS_ANY:
return "ANY";
}
return NULL;
}
assert(s);
if (strcaseeq(s, "IN"))
*class = DNS_CLASS_IN;
else if (strcaseeq(s, "ANY"))
*class = DNS_TYPE_ANY;
else
return -EINVAL;
return 0;
}
static const struct {
const char *name;
} dns_types[] = {
{ DNS_TYPE_A, "A" },
{ DNS_TYPE_NS, "NS" },
{ DNS_TYPE_CNAME, "CNAME" },
{ DNS_TYPE_SOA, "SOA" },
{ DNS_TYPE_PTR, "PTR" },
{ DNS_TYPE_HINFO, "HINFO" },
{ DNS_TYPE_MX, "MX" },
{ DNS_TYPE_TXT, "TXT" },
{ DNS_TYPE_AAAA, "AAAA" },
{ DNS_TYPE_SRV, "SRV" },
{ DNS_TYPE_SSHFP, "SSHFP" },
{ DNS_TYPE_DNAME, "DNAME" },
{ DNS_TYPE_ANY, "ANY" },
{ DNS_TYPE_OPT, "OPT" },
{ DNS_TYPE_TKEY, "TKEY" },
{ DNS_TYPE_TSIG, "TSIG" },
{ DNS_TYPE_IXFR, "IXFR" },
{ DNS_TYPE_AXFR, "AXFR" },
};
unsigned i;
for (i = 0; i < ELEMENTSOF(dns_types); i++)
return NULL;
}
unsigned i;
assert(s);
for (i = 0; i < ELEMENTSOF(dns_types); i++)
return 0;
}
return -EINVAL;
}