sd-dhcp6-client.c revision d1b0afe3653b4316a6361d204169620726d468a0
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 Intel Corporation. All rights reserved.
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 <errno.h>
#include <string.h>
#include "udev.h"
#include "udev-util.h"
#include "virt.h"
#include "siphash24.h"
#include "util.h"
#include "refcnt.h"
#include "network-internal.h"
#include "sd-dhcp6-client.h"
#include "dhcp6-protocol.h"
#include "dhcp6-internal.h"
#define SYSTEMD_PEN 43793
struct sd_dhcp6_client {
enum DHCP6State state;
int event_priority;
int index;
struct ether_addr mac_addr;
void *userdata;
struct duid_en {
};
{
return 0;
}
{
return 0;
}
const struct ether_addr *mac_addr)
{
if (mac_addr)
else
return 0;
}
}
return client;
}
{
client->retransmit_time = 0;
client->retransmit_count = 0;
return 0;
}
if (client)
return client;
}
void *userdata) {
assert(s);
return 0;
}
}
void *userdata) {
int r = 0;
char time_string[FORMAT_TIMESPAN_MAX];
assert(s);
case DHCP6_STATE_SOLICITATION:
max_retransmit_count = 0;
break;
case DHCP6_STATE_STOPPED:
case DHCP6_STATE_RS:
return 0;
}
if (max_retransmit_count &&
return 0;
}
if (r < 0)
goto error;
if (!client->retransmit_time) {
} else {
if (max_retransmit_time &&
else
}
client->retransmit_time, 0));
client);
if (r < 0)
goto error;
if (r < 0)
goto error;
if (r < 0)
goto error;
if (r < 0)
goto error;
}
if (r < 0)
client_stop(client, r);
return 0;
}
return 0;
if (detect_container(NULL) <= 0) {
/* not in a container, udev will be around */
if (!udev)
return -ENOMEM;
if (!device)
return -errno;
if (udev_device_get_is_initialized(device) <= 0)
/* not yet ready */
return -EBUSY;
}
if (name)
else
/* fall back to mac address if no predictable name available */
/* fold into 32 bits */
return 0;
}
{
int r;
r = client_ensure_iaid(client);
if (r < 0)
return r;
CLOCK_MONOTONIC, 0, 0, client_timeout_resend,
client);
if (r < 0)
return r;
if (r < 0)
return r;
return 0;
}
{
return 0;
}
{
int r = 0;
r = client_initialize(client);
if (r < 0)
return r;
return client_start(client);
}
int priority)
{
int r;
if (event)
else {
if (r < 0)
return 0;
}
return 0;
}
return 0;
}
if (!client)
return NULL;
}
if (client)
return client;
}
return NULL;
}
return client;
}
{
int r;
if (!client)
return -ENOMEM;
/* initialize DUID */
r = sd_id128_get_machine(&machine_id);
if (r < 0)
return r;
/* a bit of snake-oil perhaps, but no need to expose the machine-id
directly */
return 0;
}