resolved-dns-rr.c revision 7263f72499e962b3fd54cdb7c79d49ca72121ede
/*-*- 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 <math.h>
#include "strv.h"
#include "resolved-dns-domain.h"
#include "resolved-dns-rr.h"
#include "dns-type.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;
}
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;
}
case DNS_TYPE_SRV:
break;
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
case DNS_TYPE_DNAME:
break;
case DNS_TYPE_HINFO:
break;
case DNS_TYPE_TXT:
case DNS_TYPE_SPF:
break;
case DNS_TYPE_SOA:
break;
case DNS_TYPE_MX:
break;
case DNS_TYPE_SSHFP:
break;
case DNS_TYPE_LOC:
case DNS_TYPE_A:
case DNS_TYPE_AAAA:
break;
default:
}
}
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;
if (a->unparseable != b->unparseable)
return 0;
case DNS_TYPE_SRV:
if (r <= 0)
return r;
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
case DNS_TYPE_DNAME:
case DNS_TYPE_HINFO:
case DNS_TYPE_SPF: /* exactly the same as TXT */
case DNS_TYPE_TXT: {
int i;
return false;
return true;
}
case DNS_TYPE_A:
case DNS_TYPE_AAAA:
case DNS_TYPE_SOA:
if (r <= 0)
return r;
if (r <= 0)
return r;
case DNS_TYPE_MX:
return 0;
case DNS_TYPE_LOC:
case DNS_TYPE_SSHFP:
default:
}
}
char *s;
if (asprintf(&s, "%d %d %.3f %c %d %d %.3f %c %.2fm %.2fm %.2fm %.2fm",
NS,
EW,
alt / 100.,
siz / 100.,
hor / 100.,
ver / 100.) < 0)
return NULL;
return s;
}
_cleanup_free_ char *k = NULL;
char *s;
int r;
if (r < 0)
return r;
case DNS_TYPE_SRV:
r = asprintf(&s, "%s %u %u %u %s",
k,
if (r < 0)
return -ENOMEM;
break;
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
case DNS_TYPE_DNAME:
if (!s)
return -ENOMEM;
break;
case DNS_TYPE_HINFO:
if (!s)
return -ENOMEM;
break;
case DNS_TYPE_SPF: /* exactly the same as TXT */
case DNS_TYPE_TXT: {
_cleanup_free_ char *t;
if (!t)
return -ENOMEM;
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;
case DNS_TYPE_MX:
r = asprintf(&s, "%s %u %s",
k,
if (r < 0)
return -ENOMEM;
break;
case DNS_TYPE_LOC: {
_cleanup_free_ char *loc;
if (!loc)
return -ENOMEM;
if (!s)
return -ENOMEM;
break;
}
case DNS_TYPE_SSHFP: {
_cleanup_free_ char *x = NULL;
if (!x)
return -ENOMEM;
r = asprintf(&s, "%s %u %u %s",
k,
x);
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;
}