sd-dhcp6-lease.c revision 5da1b97f3c3d15521f2dcfbc18eccd6580122ebc
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering This file is part of systemd.
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering Copyright (C) 2014 Tom Gundersen
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering Copyright (C) 2014-2015 Intel Corporation. All rights reserved.
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering systemd is free software; you can redistribute it and/or modify it
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering under the terms of the GNU Lesser General Public License as published by
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering (at your option) any later version.
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering systemd is distributed in the hope that it will be useful, but
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering Lesser General Public License for more details.
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering You should have received a copy of the GNU Lesser General Public License
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "dhcp6-lease-internal.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_clear_timers(DHCP6IA *ia) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ia->timeout_t1 = sd_event_source_unref(ia->timeout_t1);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ia->timeout_t2 = sd_event_source_unref(ia->timeout_t2);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_ia_rebind_expire(const DHCP6IA *ia, uint32_t *expire) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek LIST_FOREACH(addresses, addr, ia->addresses) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek t = be32toh(addr->iaaddr.lifetime_valid);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-SzmekDHCP6IA *dhcp6_lease_free_ia(DHCP6IA *ia) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek LIST_REMOVE(addresses, ia->addresses, address);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_set_serverid(sd_dhcp6_lease *lease, const uint8_t *id,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek lease->serverid = memdup(id, len);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_get_serverid(sd_dhcp6_lease *lease, uint8_t **id, size_t *len) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_set_preference(sd_dhcp6_lease *lease, uint8_t preference) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_get_preference(sd_dhcp6_lease *lease, uint8_t *preference) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek assert_return(preference, -EINVAL);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *preference = lease->preference;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_set_rapid_commit(sd_dhcp6_lease *lease) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_get_rapid_commit(sd_dhcp6_lease *lease, bool *rapid_commit) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *rapid_commit = lease->rapid_commit;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid) {
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poetteringint sd_dhcp6_lease_get_address(sd_dhcp6_lease *lease, struct in6_addr *addr,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek assert_return(lifetime_preferred, -EINVAL);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek assert_return(lifetime_valid, -EINVAL);
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering memcpy(addr, &lease->addr_iter->iaaddr.address,
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering be32toh(lease->addr_iter->iaaddr.lifetime_preferred);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *lifetime_valid = be32toh(lease->addr_iter->iaaddr.lifetime_valid);
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering lease->addr_iter = lease->addr_iter->addresses_next;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekvoid sd_dhcp6_lease_reset_address_iter(sd_dhcp6_lease *lease) {
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek lease->addr_iter = lease->ia.addresses;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
75d67e683735035949bfdcf71140747b9909d8a1Lennart Poettering r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->dns,
strerror(-r));
return -ENOENT;
char **domains;
if (!optlen)
return -ENOENT;
if (lease)
return lease;
return NULL;
if (!lease)
return -ENOMEM;