resolved-link-bus.c revision d2ec6608b93e3f74345c737637af24e9e75c209b
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2016 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 "alloc-util.h"
#include "bus-util.h"
#include "parse-util.h"
#include "resolve-util.h"
#include "resolved-bus.h"
#include "resolved-link-bus.h"
#include "strv.h"
static int property_get_dns(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
DnsServer *s;
int r;
assert(l);
if (r < 0)
return r;
r = bus_dns_server_append(reply, s, false);
if (r < 0)
return r;
}
return sd_bus_message_close_container(reply);
}
static int property_get_domains(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
DnsSearchDomain *d;
int r;
assert(l);
if (r < 0)
return r;
if (r < 0)
return r;
}
return sd_bus_message_close_container(reply);
}
static int property_get_scopes_mask(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
assert(l);
(l->llmnr_ipv4_scope ? SD_RESOLVED_LLMNR_IPV4 : 0) |
(l->llmnr_ipv6_scope ? SD_RESOLVED_LLMNR_IPV6 : 0) |
(l->mdns_ipv4_scope ? SD_RESOLVED_MDNS_IPV4 : 0) |
(l->mdns_ipv6_scope ? SD_RESOLVED_MDNS_IPV6 : 0);
}
static int property_get_ntas(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
const char *name;
Iterator i;
int r;
assert(l);
if (r < 0)
return r;
if (r < 0)
return r;
}
return sd_bus_message_close_container(reply);
}
unsigned i;
int r;
assert(l);
if (r < 0)
return r;
for (;;) {
int family;
const void *d;
if (r < 0)
return r;
if (r == 0)
break;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
return -ENOMEM;
n++;
}
if (r < 0)
return r;
for (i = 0; i < n; i++) {
DnsServer *s;
if (s)
else {
if (r < 0)
goto clear;
}
}
return r;
}
int bus_link_method_set_search_domains(sd_bus_message *message, void *userdata, sd_bus_error *error) {
char **i;
int r;
assert(l);
if (r < 0)
return r;
STRV_FOREACH(i, domains) {
r = dns_name_is_valid(*i);
if (r < 0)
return r;
if (r == 0)
if (dns_name_is_root(*i))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Root domain is not suitable as search domain");
}
STRV_FOREACH(i, domains) {
DnsSearchDomain *d;
r = dns_search_domain_find(l->search_domains, *i, &d);
if (r < 0)
goto clear;
if (r > 0)
else {
if (r < 0)
goto clear;
}
}
return r;
}
const char *llmnr;
int r;
assert(l);
if (r < 0)
return r;
else {
if (mode < 0)
}
l->llmnr_support = mode;
link_add_rrs(l, false);
}
const char *mdns;
int r;
assert(l);
if (r < 0)
return r;
else {
if (mode < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid MulticastDNS setting: %s", mdns);
}
l->mdns_support = mode;
link_add_rrs(l, false);
}
const char *dnssec;
int r;
assert(l);
if (r < 0)
return r;
else {
if (mode < 0)
}
link_set_dnssec_mode(l, mode);
}
int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, void *userdata, sd_bus_error *error) {
int r;
char **i;
assert(l);
if (r < 0)
return r;
STRV_FOREACH(i, ntas) {
r = dns_name_is_valid(*i);
if (r < 0)
return r;
if (r == 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search negative trust anchor domain: %s", *i);
}
if (!ns)
return -ENOMEM;
STRV_FOREACH(i, ntas) {
r = set_put_strdup(ns, *i);
if (r < 0)
return r;
}
}
assert(l);
link_add_rrs(l, false);
}
const sd_bus_vtable link_vtable[] = {
SD_BUS_PROPERTY("MulticastDNS", "s", property_get_resolve_support, offsetof(Link, mdns_support), 0),
SD_BUS_METHOD("SetDNSSECNegativeTrustAnchors", "as", NULL, bus_link_method_set_dnssec_negative_trust_anchors, 0),
};
int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
_cleanup_free_ char *e = NULL;
int ifindex;
int r;
assert(m);
if (r <= 0)
return 0;
r = parse_ifindex(e, &ifindex);
if (r < 0)
return 0;
if (!link)
return 0;
return 1;
}
char *p;
int r;
return NULL;
if (r < 0)
return NULL;
return p;
}
int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
Iterator i;
unsigned c = 0;
assert(m);
if (!l)
return -ENOMEM;
char *p;
p = link_bus_path(link);
if (!p)
return -ENOMEM;
l[c++] = p;
}
l[c] = NULL;
*nodes = l;
l = NULL;
return 1;
}