networkd-dhcp4.c revision 22805d9207d5242681e5667ee304572e4abf9b94
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013-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 "alloc-util.h"
#include "dhcp-lease-internal.h"
#include "hostname-util.h"
#include "network-internal.h"
#include "networkd-link.h"
void *userdata) {
int r;
link->dhcp4_messages --;
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
}
if (link->dhcp4_messages == 0) {
link->dhcp4_configured = true;
}
return 1;
}
int r, n, i;
if (r < 0 && r != -ENODATA)
if (r >= 0) {
if (r < 0)
if (r < 0)
if (r < 0)
/* The dhcp netmask may mask out the gateway. Add an explicit
* route for the gw host so that we can route no matter the
* netmask or existing kernel route tables. */
if (r < 0)
link->dhcp4_messages ++;
if (r < 0) {
return r;
}
link->dhcp4_messages ++;
}
if (n == -ENODATA)
return 0;
if (n < 0)
for (i = 0; i < n; i++) {
if (r < 0)
assert_se(sd_dhcp_route_get_destination_prefix_length(static_routes[i], &route->dst_prefixlen) >= 0);
if (r < 0)
link->dhcp4_messages ++;
}
return 0;
}
unsigned prefixlen = 0;
int r;
int n, i;
if (n >= 0) {
for (i = 0; i < n; i++) {
if (r >= 0) {
}
}
}
}
r = address_new(&address);
if (r >= 0) {
if (r >= 0) {
if (r >= 0) {
}
if (r >= 0) {
}
}
if (r >= 0) {
if (r >= 0)
}
}
if (r < 0) {
"DHCP error: could not reset MTU");
return r;
}
}
}
else
if (hostname) {
/* If a hostname was set due to the lease, then unset it now. */
if (r < 0)
}
}
link->dhcp4_configured = false;
return 0;
}
void *userdata) {
int r;
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
} else if (r >= 0)
return 1;
}
unsigned prefixlen;
int r;
r = address_new(&addr);
if (r < 0)
return r;
/* allow reusing an existing address and simply update its lifetime
* in case it already exists */
if (r < 0)
return r;
return 0;
}
int r;
if (r < 0)
link->dhcp4_configured = false;
if (r < 0)
if (r < 0)
if (r < 0)
}
if (r < 0) {
return r;
}
return 0;
}
unsigned prefixlen;
int r;
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0 && r != -ENODATA)
if (r >= 0)
"PREFIXLEN=%u", prefixlen,
NULL);
else
"PREFIXLEN=%u", prefixlen,
NULL);
if (r >= 0) {
if (r < 0)
}
}
else
if (hostname) {
if (r < 0)
}
}
if (tz) {
if (r < 0)
}
}
if (r < 0) {
return r;
}
}
if (r < 0) {
return r;
}
return 0;
}
int r = 0;
return;
switch (event) {
log_link_error(link, "DHCPv4 connection considered system critical, ignoring request to reconfigure it.");
return;
}
if (link->dhcp_lease) {
r = dhcp_lease_lost(link);
if (r < 0) {
return;
}
}
if (event == SD_DHCP_CLIENT_EVENT_IP_CHANGE) {
if (r < 0) {
return;
}
}
break;
if (r < 0) {
return;
}
break;
if (r < 0) {
return;
}
break;
default:
if (event < 0)
else
break;
}
return;
}
int r;
if (!link->dhcp_client) {
if (r < 0)
return r;
}
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
}
if (r < 0)
return r;
}
if (r < 0)
return r;
if (r < 0)
return r;
}
/* Always acquire the timezone and NTP*/
if (r < 0)
return r;
if (r < 0)
return r;
if (!hostname)
return -ENOMEM;
} else
if (!is_localhost(hn)) {
if (r < 0)
return r;
}
}
if (r < 0)
return r;
}
case DHCP_CLIENT_ID_DUID:
/* Library defaults to this. */
break;
case DHCP_CLIENT_ID_MAC:
if (r < 0)
return r;
break;
default:
assert_not_reached("Unknown client identifier type.");
}
return 0;
}