resolved-link.c revision 0dd25fb9f005d8ab7ac4bc10a609d00569f8c56a
/*-*- 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 "sd-network.h"
#include "dhcp-lease-internal.h"
#include "strv.h"
#include "resolved-link.h"
int r;
assert(m);
if (r < 0)
return r;
if (!l)
return -ENOMEM;
if (r < 0)
return r;
l->manager = m;
if (ret)
*ret = l;
l = NULL;
return 0;
}
if (!l)
return NULL;
while (l->addresses)
if (l->manager)
while (l->dhcp_dns_servers)
while (l->link_dns_servers)
free(l);
return NULL;
}
static void link_allocate_scopes(Link *l) {
int r;
assert(l);
if (l->link_dns_servers || l->dhcp_dns_servers) {
if (!l->unicast_scope) {
if (r < 0)
}
} else
if (!l->llmnr_ipv4_scope) {
if (r < 0)
}
} else
if (!l->llmnr_ipv6_scope) {
if (r < 0)
}
} else
}
const char *n = NULL;
int r;
assert(l);
assert(m);
r = sd_rtnl_message_link_get_flags(m, &l->flags);
if (r < 0)
return r;
if (sd_rtnl_message_read_string(m, IFLA_IFNAME, &n) >= 0) {
char_array_0(l->name);
}
return 0;
}
static int link_update_dhcp_dns_servers(Link *l) {
int r, n, i;
assert(l);
r = sd_network_dhcp_use_dns(l->ifindex);
if (r <= 0)
goto clear;
if (r < 0)
goto clear;
s->marked = true;
if (n < 0) {
r = n;
goto clear;
}
for (i = 0; i < n; i++) {
if (s)
s->marked = false;
else {
if (r < 0)
goto clear;
}
}
if (s->marked)
dns_server_free(s);
return 0;
while (l->dhcp_dns_servers)
return r;
}
static int link_update_link_dns_servers(Link *l) {
int r, n, i;
assert(l);
s->marked = true;
if (n < 0) {
r = n;
goto clear;
}
for (i = 0; i < n; i++) {
if (s)
s->marked = false;
else {
if (r < 0)
goto clear;
}
}
if (n < 0) {
r = n;
goto clear;
}
for (i = 0; i < n; i++) {
if (s)
s->marked = false;
else {
if (r < 0)
goto clear;
}
}
if (s->marked)
dns_server_free(s);
return 0;
while (l->link_dns_servers)
return r;
}
int link_update_monitor(Link *l) {
assert(l);
return 0;
}
LinkAddress *a;
assert(l);
/* A link is relevant if it isn't a loopback device and has at
* least one relevant IP address */
if (l->flags & IFF_LOOPBACK)
return false;
return false;
return true;
return false;
}
LinkAddress *a;
assert(l);
return a;
return NULL;
}
DnsServer* link_find_dns_server(Link *l, DnsServerSource source, int family, union in_addr_union *in_addr) {
assert(l);
return s;
return NULL;
}
assert(l);
if (!l->current_dns_server)
l->current_dns_server = l->link_dns_servers;
if (!l->current_dns_server)
l->current_dns_server = l->dhcp_dns_servers;
return l->current_dns_server;
}
void link_next_dns_server(Link *l) {
assert(l);
/* Switch to the next DNS server */
if (!l->current_dns_server) {
l->current_dns_server = l->link_dns_servers;
if (l->current_dns_server)
return;
}
if (!l->current_dns_server) {
l->current_dns_server = l->dhcp_dns_servers;
if (l->current_dns_server)
return;
}
if (!l->current_dns_server)
return;
if (l->current_dns_server->servers_next) {
return;
}
l->current_dns_server = l->dhcp_dns_servers;
else {
l->current_dns_server = l->link_dns_servers;
}
}
LinkAddress *a;
assert(l);
if (!a)
return -ENOMEM;
a->link = l;
if (ret)
*ret = a;
return 0;
}
if (!a)
return NULL;
if (a->link)
free(a);
return NULL;
}
int r;
assert(a);
assert(m);
r = sd_rtnl_message_addr_get_flags(m, &a->flags);
if (r < 0)
return r;
sd_rtnl_message_addr_get_scope(m, &a->scope);
link_allocate_scopes(a->link);
return 0;
}
bool link_address_relevant(LinkAddress *a) {
assert(a);
if (a->flags & IFA_F_DEPRECATED)
return false;
return false;
return true;
}