2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2014-06-19 14:38:50 +02:00
|
|
|
#ifndef foosddhcp6clienthfoo
|
|
|
|
#define foosddhcp6clienthfoo
|
|
|
|
|
|
|
|
/***
|
2018-06-12 17:15:23 +02:00
|
|
|
Copyright © 2014 Intel Corporation. All rights reserved.
|
2014-06-19 14:38:50 +02:00
|
|
|
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
|
|
|
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/>.
|
|
|
|
***/
|
|
|
|
|
2015-10-24 23:42:56 +02:00
|
|
|
#include <inttypes.h>
|
2014-06-19 14:38:50 +02:00
|
|
|
#include <net/ethernet.h>
|
2015-10-24 23:42:56 +02:00
|
|
|
#include <sys/types.h>
|
2014-06-19 14:38:50 +02:00
|
|
|
|
2014-06-19 14:39:45 +02:00
|
|
|
#include "sd-dhcp6-lease.h"
|
2020-05-01 16:30:31 +02:00
|
|
|
#include "sd-dhcp6-option.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "sd-event.h"
|
2014-06-19 14:39:45 +02:00
|
|
|
|
2015-10-24 23:42:56 +02:00
|
|
|
#include "_sd-common.h"
|
|
|
|
|
|
|
|
_SD_BEGIN_DECLARATIONS;
|
|
|
|
|
2014-06-19 14:38:50 +02:00
|
|
|
enum {
|
2015-09-22 14:52:23 +02:00
|
|
|
SD_DHCP6_CLIENT_EVENT_STOP = 0,
|
|
|
|
SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE = 10,
|
|
|
|
SD_DHCP6_CLIENT_EVENT_RETRANS_MAX = 11,
|
|
|
|
SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE = 12,
|
|
|
|
SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST = 13,
|
2014-06-19 14:38:50 +02:00
|
|
|
};
|
|
|
|
|
2016-01-20 14:44:28 +01:00
|
|
|
enum {
|
|
|
|
SD_DHCP6_OPTION_CLIENTID = 1,
|
|
|
|
SD_DHCP6_OPTION_SERVERID = 2,
|
|
|
|
SD_DHCP6_OPTION_IA_NA = 3,
|
|
|
|
SD_DHCP6_OPTION_IA_TA = 4,
|
|
|
|
SD_DHCP6_OPTION_IAADDR = 5,
|
|
|
|
SD_DHCP6_OPTION_ORO = 6,
|
|
|
|
SD_DHCP6_OPTION_PREFERENCE = 7,
|
|
|
|
SD_DHCP6_OPTION_ELAPSED_TIME = 8,
|
|
|
|
SD_DHCP6_OPTION_RELAY_MSG = 9,
|
|
|
|
/* option code 10 is unassigned */
|
|
|
|
SD_DHCP6_OPTION_AUTH = 11,
|
|
|
|
SD_DHCP6_OPTION_UNICAST = 12,
|
|
|
|
SD_DHCP6_OPTION_STATUS_CODE = 13,
|
|
|
|
SD_DHCP6_OPTION_RAPID_COMMIT = 14,
|
|
|
|
SD_DHCP6_OPTION_USER_CLASS = 15,
|
|
|
|
SD_DHCP6_OPTION_VENDOR_CLASS = 16,
|
|
|
|
SD_DHCP6_OPTION_VENDOR_OPTS = 17,
|
|
|
|
SD_DHCP6_OPTION_INTERFACE_ID = 18,
|
|
|
|
SD_DHCP6_OPTION_RECONF_MSG = 19,
|
|
|
|
SD_DHCP6_OPTION_RECONF_ACCEPT = 20,
|
|
|
|
|
|
|
|
SD_DHCP6_OPTION_DNS_SERVERS = 23, /* RFC 3646 */
|
|
|
|
SD_DHCP6_OPTION_DOMAIN_LIST = 24, /* RFC 3646 */
|
2018-01-04 14:11:45 +01:00
|
|
|
SD_DHCP6_OPTION_IA_PD = 25, /* RFC 3633, prefix delegation */
|
|
|
|
SD_DHCP6_OPTION_IA_PD_PREFIX = 26, /* RFC 3633, prefix delegation */
|
2016-01-20 14:44:28 +01:00
|
|
|
|
|
|
|
SD_DHCP6_OPTION_SNTP_SERVERS = 31, /* RFC 4075, deprecated */
|
2019-09-06 20:29:46 +02:00
|
|
|
SD_DHCP6_OPTION_INFORMATION_REFRESH_TIME = 32, /* RFC 8415, sec. 21.23 */
|
2016-01-20 14:44:28 +01:00
|
|
|
|
|
|
|
/* option code 35 is unassigned */
|
|
|
|
|
2017-11-16 10:07:07 +01:00
|
|
|
SD_DHCP6_OPTION_FQDN = 39, /* RFC 4704 */
|
|
|
|
|
2016-01-20 14:44:28 +01:00
|
|
|
SD_DHCP6_OPTION_NTP_SERVER = 56, /* RFC 5908 */
|
2020-03-30 16:30:46 +02:00
|
|
|
SD_DHCP6_OPTION_MUD_URL = 112, /* RFC 8250 */
|
2016-01-20 14:44:28 +01:00
|
|
|
|
|
|
|
/* option codes 89-142 are unassigned */
|
|
|
|
/* option codes 144-65535 are unassigned */
|
|
|
|
};
|
|
|
|
|
2014-06-19 14:38:50 +02:00
|
|
|
typedef struct sd_dhcp6_client sd_dhcp6_client;
|
|
|
|
|
2016-05-03 17:52:44 +02:00
|
|
|
typedef void (*sd_dhcp6_client_callback_t)(sd_dhcp6_client *client, int event, void *userdata);
|
|
|
|
int sd_dhcp6_client_set_callback(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
sd_dhcp6_client_callback_t cb,
|
|
|
|
void *userdata);
|
|
|
|
|
2016-05-23 16:13:18 +02:00
|
|
|
int sd_dhcp6_client_set_ifindex(
|
2016-05-03 17:52:44 +02:00
|
|
|
sd_dhcp6_client *client,
|
|
|
|
int interface_index);
|
|
|
|
int sd_dhcp6_client_set_local_address(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
const struct in6_addr *local_address);
|
|
|
|
int sd_dhcp6_client_set_mac(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
const uint8_t *addr,
|
|
|
|
size_t addr_len,
|
|
|
|
uint16_t arp_type);
|
|
|
|
int sd_dhcp6_client_set_duid(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
uint16_t duid_type,
|
2016-05-03 18:08:56 +02:00
|
|
|
const void *duid,
|
2016-05-03 17:52:44 +02:00
|
|
|
size_t duid_len);
|
2018-08-07 06:55:38 +02:00
|
|
|
int sd_dhcp6_client_set_duid_llt(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
uint64_t llt_time);
|
2016-05-03 17:52:44 +02:00
|
|
|
int sd_dhcp6_client_set_iaid(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
uint32_t iaid);
|
2020-06-09 10:48:36 +02:00
|
|
|
int sd_dhcp6_client_get_iaid(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
uint32_t *iaid);
|
2020-06-09 16:47:49 +02:00
|
|
|
int sd_dhcp6_client_duid_as_string(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
char **duid);
|
2017-11-16 10:07:07 +01:00
|
|
|
int sd_dhcp6_client_set_fqdn(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
const char *fqdn);
|
2016-05-03 17:52:44 +02:00
|
|
|
int sd_dhcp6_client_set_information_request(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
int enabled);
|
|
|
|
int sd_dhcp6_client_get_information_request(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
int *enabled);
|
|
|
|
int sd_dhcp6_client_set_request_option(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
uint16_t option);
|
2020-03-30 16:30:46 +02:00
|
|
|
int sd_dhcp6_client_set_request_mud_url(
|
|
|
|
sd_dhcp6_client *client,
|
2020-04-24 09:15:59 +02:00
|
|
|
const char *mudurl);
|
2020-05-18 14:46:50 +02:00
|
|
|
int sd_dhcp6_client_set_request_user_class(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
char** user_class);
|
2020-04-20 09:04:58 +02:00
|
|
|
int sd_dhcp6_client_set_request_vendor_class(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
char** vendor_class);
|
2019-09-25 05:14:12 +02:00
|
|
|
int sd_dhcp6_client_set_prefix_delegation_hint(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
uint8_t prefixlen,
|
|
|
|
const struct in6_addr *pd_address);
|
2018-09-06 19:31:48 +02:00
|
|
|
int sd_dhcp6_client_get_prefix_delegation(sd_dhcp6_client *client,
|
|
|
|
int *delegation);
|
2018-01-04 14:11:50 +01:00
|
|
|
int sd_dhcp6_client_set_prefix_delegation(sd_dhcp6_client *client,
|
2018-09-06 19:31:48 +02:00
|
|
|
int delegation);
|
2018-09-07 22:00:10 +02:00
|
|
|
int sd_dhcp6_client_get_address_request(sd_dhcp6_client *client,
|
|
|
|
int *request);
|
|
|
|
int sd_dhcp6_client_set_address_request(sd_dhcp6_client *client,
|
|
|
|
int request);
|
2020-05-22 08:39:14 +02:00
|
|
|
int sd_dhcp6_client_set_transaction_id(sd_dhcp6_client *client,
|
|
|
|
uint32_t transaction_id);
|
|
|
|
int sd_dhcp6_client_add_vendor_option(sd_dhcp6_client *client,
|
|
|
|
sd_dhcp6_option *v);
|
2016-05-03 17:52:44 +02:00
|
|
|
|
|
|
|
int sd_dhcp6_client_get_lease(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
sd_dhcp6_lease **ret);
|
2014-06-19 14:39:45 +02:00
|
|
|
|
2020-05-01 16:30:31 +02:00
|
|
|
int sd_dhcp6_client_add_option(sd_dhcp6_client *client, sd_dhcp6_option *v);
|
|
|
|
|
2014-06-19 14:38:50 +02:00
|
|
|
int sd_dhcp6_client_stop(sd_dhcp6_client *client);
|
|
|
|
int sd_dhcp6_client_start(sd_dhcp6_client *client);
|
2015-11-10 15:41:30 +01:00
|
|
|
int sd_dhcp6_client_is_running(sd_dhcp6_client *client);
|
2016-05-03 17:52:44 +02:00
|
|
|
int sd_dhcp6_client_attach_event(
|
|
|
|
sd_dhcp6_client *client,
|
|
|
|
sd_event *event,
|
|
|
|
int64_t priority);
|
2014-06-19 14:38:50 +02:00
|
|
|
int sd_dhcp6_client_detach_event(sd_dhcp6_client *client);
|
|
|
|
sd_event *sd_dhcp6_client_get_event(sd_dhcp6_client *client);
|
|
|
|
sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client);
|
|
|
|
sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client);
|
|
|
|
int sd_dhcp6_client_new(sd_dhcp6_client **ret);
|
|
|
|
|
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.
With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.
The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).
This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.
Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:
#define _cleanup_(function) __attribute__((cleanup(function)))
Or similar, to make the gcc feature easier to use.
Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.
See #2008.
2015-11-27 19:13:45 +01:00
|
|
|
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp6_client, sd_dhcp6_client_unref);
|
|
|
|
|
2015-10-24 23:42:56 +02:00
|
|
|
_SD_END_DECLARATIONS;
|
|
|
|
|
2014-06-19 14:38:50 +02:00
|
|
|
#endif
|