resolved-manager.c revision 096b6773886bd7a0c8c97aa684b0b67dfae58355
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Tom Gundersen <teg@jklm.no>
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 <resolv.h>
#include "resolved.h"
#include "event-util.h"
#include "network-util.h"
#include "sd-dhcp-lease.h"
#include "dhcp-lease-internal.h"
#include "network-internal.h"
#include "conf-parser.h"
int r;
assert(m);
if (!address)
return -ENOMEM;
if (!addrstr)
return -ENOMEM;
if (r < 0) {
continue;
}
}
return 0;
}
int config_parse_dnsv(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
assert(m);
while ((address = m->fallback_dns)) {
}
set_fallback_dns(m, rvalue);
return 0;
}
static int manager_parse_config_file(Manager *m) {
int r;
assert(m);
false, false, m);
if (r < 0)
return r;
}
int r;
if (!m)
return -ENOMEM;
r = set_fallback_dns(m, DNS_SERVERS);
if (r < 0)
return r;
r = manager_parse_config_file(m);
if (r < 0)
return r;
r = sd_event_default(&m->event);
if (r < 0)
return r;
sd_event_set_watchdog(m->event, true);
*ret = m;
m = NULL;
return 0;
}
void manager_free(Manager *m) {
if (!m)
return;
sd_event_unref(m->event);
while ((address = m->fallback_dns)) {
}
free(m);
}
char buf[INET6_ADDRSTRLEN];
const char *address;
assert(f);
if (!address) {
log_warning("Invalid DNS address. Ignoring.");
return;
}
fputs("# Too many DNS servers configured, the following entries "
"may be ignored\n", f);
(*count) ++;
}
int manager_update_resolv_conf(Manager *m) {
const char *path = "/run/systemd/resolve/resolv.conf";
unsigned count = 0;
int n, r, i;
assert(m);
if (r < 0)
return r;
fputs("# This file is managed by systemd-resolved(8). Do not edit.\n#\n"
"# Third party programs must not access this file directly, but\n"
"# only through the symlink at /etc/resolv.conf. To manage\n"
"# resolv.conf(5) in a different way, replace the symlink by a\n"
"# static file or a different symlink.\n\n", f);
n = sd_network_get_ifindices(&indices);
if (n < 0)
n = 0;
for (i = 0; i < n; i++) {
struct in_addr *nameservers;
struct in6_addr *nameservers6;
r = sd_network_dhcp_use_dns(indices[i]);
if (r > 0) {
if (r >= 0) {
if (r >= 0) {
unsigned j;
for (j = 0; j < nameservers_size; j++)
}
}
}
if (r >= 0) {
unsigned j;
for (j = 0; j < nameservers_size; j++)
}
if (r >= 0) {
unsigned j;
for (j = 0; j < nameservers_size; j++)
}
}
fflush(f);
r = -errno;
return r;
}
return 0;
}
void *userdata) {
int r;
assert(m);
r = manager_update_resolv_conf(m);
if (r < 0)
return 0;
}
int manager_network_monitor_listen(Manager *m) {
if (r < 0)
return r;
if (fd < 0)
return fd;
if (events < 0)
return events;
if (r < 0)
return r;
m->network_monitor = monitor;
event_source = NULL;
return 0;
}