2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2013-12-09 22:43:08 +01:00
|
|
|
#ifndef foosddhcpclienthfoo
|
|
|
|
#define foosddhcpclienthfoo
|
|
|
|
|
|
|
|
/***
|
2018-06-12 17:15:23 +02:00
|
|
|
Copyright © 2013 Intel Corporation. All rights reserved.
|
2013-12-09 22:43:08 +01: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>
|
2013-12-09 22:43:19 +01:00
|
|
|
#include <net/ethernet.h>
|
2015-10-24 23:42:56 +02:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <sys/types.h>
|
2018-11-23 22:19:26 +01:00
|
|
|
#include <stdbool.h>
|
2013-12-09 22:43:08 +01:00
|
|
|
|
2014-02-27 01:24:05 +01:00
|
|
|
#include "sd-dhcp-lease.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "sd-event.h"
|
2013-12-09 22:43:25 +01:00
|
|
|
|
2015-10-24 23:42:56 +02:00
|
|
|
#include "_sd-common.h"
|
|
|
|
|
|
|
|
_SD_BEGIN_DECLARATIONS;
|
|
|
|
|
2013-12-09 22:43:29 +01:00
|
|
|
enum {
|
2015-09-22 14:46:21 +02:00
|
|
|
SD_DHCP_CLIENT_EVENT_STOP = 0,
|
|
|
|
SD_DHCP_CLIENT_EVENT_IP_ACQUIRE = 1,
|
|
|
|
SD_DHCP_CLIENT_EVENT_IP_CHANGE = 2,
|
|
|
|
SD_DHCP_CLIENT_EVENT_EXPIRED = 3,
|
|
|
|
SD_DHCP_CLIENT_EVENT_RENEW = 4,
|
2013-12-09 22:43:29 +01:00
|
|
|
};
|
|
|
|
|
2016-01-20 14:44:24 +01:00
|
|
|
enum {
|
|
|
|
SD_DHCP_OPTION_PAD = 0,
|
|
|
|
SD_DHCP_OPTION_SUBNET_MASK = 1,
|
|
|
|
SD_DHCP_OPTION_TIME_OFFSET = 2,
|
|
|
|
SD_DHCP_OPTION_ROUTER = 3,
|
|
|
|
SD_DHCP_OPTION_DOMAIN_NAME_SERVER = 6,
|
|
|
|
SD_DHCP_OPTION_HOST_NAME = 12,
|
|
|
|
SD_DHCP_OPTION_BOOT_FILE_SIZE = 13,
|
|
|
|
SD_DHCP_OPTION_DOMAIN_NAME = 15,
|
|
|
|
SD_DHCP_OPTION_ROOT_PATH = 17,
|
|
|
|
SD_DHCP_OPTION_ENABLE_IP_FORWARDING = 19,
|
|
|
|
SD_DHCP_OPTION_ENABLE_IP_FORWARDING_NL = 20,
|
|
|
|
SD_DHCP_OPTION_POLICY_FILTER = 21,
|
|
|
|
SD_DHCP_OPTION_INTERFACE_MDR = 22,
|
|
|
|
SD_DHCP_OPTION_INTERFACE_TTL = 23,
|
|
|
|
SD_DHCP_OPTION_INTERFACE_MTU_AGING_TIMEOUT = 24,
|
|
|
|
SD_DHCP_OPTION_INTERFACE_MTU = 26,
|
|
|
|
SD_DHCP_OPTION_BROADCAST = 28,
|
2017-08-03 03:23:39 +02:00
|
|
|
/* Windows 10 option to send when Anonymize=true */
|
|
|
|
SD_DHCP_OPTION_ROUTER_DISCOVER = 31,
|
2016-01-20 14:44:24 +01:00
|
|
|
SD_DHCP_OPTION_STATIC_ROUTE = 33,
|
|
|
|
SD_DHCP_OPTION_NTP_SERVER = 42,
|
|
|
|
SD_DHCP_OPTION_VENDOR_SPECIFIC = 43,
|
2017-08-03 03:23:39 +02:00
|
|
|
/* Windows 10 option to send when Anonymize=true */
|
|
|
|
SD_DHCP_OPTION_NETBIOS_NAMESERVER = 44,
|
|
|
|
/* Windows 10 option to send when Anonymize=true */
|
|
|
|
SD_DHCP_OPTION_NETBIOS_NODETYPE = 46,
|
|
|
|
/* Windows 10 option to send when Anonymize=true */
|
|
|
|
SD_DHCP_OPTION_NETBIOS_SCOPE = 47,
|
2016-01-20 14:44:24 +01:00
|
|
|
SD_DHCP_OPTION_REQUESTED_IP_ADDRESS = 50,
|
|
|
|
SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME = 51,
|
|
|
|
SD_DHCP_OPTION_OVERLOAD = 52,
|
|
|
|
SD_DHCP_OPTION_MESSAGE_TYPE = 53,
|
|
|
|
SD_DHCP_OPTION_SERVER_IDENTIFIER = 54,
|
|
|
|
SD_DHCP_OPTION_PARAMETER_REQUEST_LIST = 55,
|
|
|
|
SD_DHCP_OPTION_ERROR_MESSAGE = 56,
|
|
|
|
SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE = 57,
|
|
|
|
SD_DHCP_OPTION_RENEWAL_T1_TIME = 58,
|
|
|
|
SD_DHCP_OPTION_REBINDING_T2_TIME = 59,
|
|
|
|
SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER = 60,
|
|
|
|
SD_DHCP_OPTION_CLIENT_IDENTIFIER = 61,
|
2018-05-07 14:21:02 +02:00
|
|
|
SD_DHCP_OPTION_USER_CLASS = 77,
|
2016-01-20 14:44:24 +01:00
|
|
|
SD_DHCP_OPTION_FQDN = 81,
|
|
|
|
SD_DHCP_OPTION_NEW_POSIX_TIMEZONE = 100,
|
|
|
|
SD_DHCP_OPTION_NEW_TZDB_TIMEZONE = 101,
|
2017-05-13 16:19:32 +02:00
|
|
|
SD_DHCP_OPTION_DOMAIN_SEARCH_LIST = 119,
|
2016-01-20 14:44:24 +01:00
|
|
|
SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
|
|
|
|
SD_DHCP_OPTION_PRIVATE_BASE = 224,
|
2017-08-03 03:23:39 +02:00
|
|
|
/* Windows 10 option to send when Anonymize=true */
|
|
|
|
SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE = 249,
|
|
|
|
/* Windows 10 option to send when Anonymize=true */
|
|
|
|
SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY = 252,
|
2016-01-20 14:44:24 +01:00
|
|
|
SD_DHCP_OPTION_PRIVATE_LAST = 254,
|
|
|
|
SD_DHCP_OPTION_END = 255,
|
|
|
|
};
|
|
|
|
|
2013-12-09 22:43:08 +01:00
|
|
|
typedef struct sd_dhcp_client sd_dhcp_client;
|
|
|
|
|
2016-05-03 17:52:44 +02:00
|
|
|
typedef void (*sd_dhcp_client_callback_t)(sd_dhcp_client *client, int event, void *userdata);
|
|
|
|
int sd_dhcp_client_set_callback(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
sd_dhcp_client_callback_t cb,
|
|
|
|
void *userdata);
|
|
|
|
|
|
|
|
int sd_dhcp_client_set_request_option(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
uint8_t option);
|
|
|
|
int sd_dhcp_client_set_request_address(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
const struct in_addr *last_address);
|
|
|
|
int sd_dhcp_client_set_request_broadcast(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
int broadcast);
|
2016-05-23 16:13:18 +02:00
|
|
|
int sd_dhcp_client_set_ifindex(
|
2016-05-03 17:52:44 +02:00
|
|
|
sd_dhcp_client *client,
|
|
|
|
int interface_index);
|
|
|
|
int sd_dhcp_client_set_mac(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
const uint8_t *addr,
|
|
|
|
size_t addr_len,
|
|
|
|
uint16_t arp_type);
|
|
|
|
int sd_dhcp_client_set_client_id(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
uint8_t type,
|
|
|
|
const uint8_t *data,
|
|
|
|
size_t data_len);
|
|
|
|
int sd_dhcp_client_set_iaid_duid(
|
|
|
|
sd_dhcp_client *client,
|
2018-11-23 22:19:26 +01:00
|
|
|
bool iaid_set,
|
2016-05-03 17:52:44 +02:00
|
|
|
uint32_t iaid,
|
|
|
|
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_dhcp_client_set_iaid_duid_llt(
|
|
|
|
sd_dhcp_client *client,
|
2018-11-23 22:19:26 +01:00
|
|
|
bool iaid_set,
|
2018-08-07 06:55:38 +02:00
|
|
|
uint32_t iaid,
|
|
|
|
uint64_t llt_time);
|
2018-03-12 17:18:07 +01:00
|
|
|
int sd_dhcp_client_set_duid(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
uint16_t duid_type,
|
|
|
|
const void *duid,
|
|
|
|
size_t duid_len);
|
2018-08-07 06:55:38 +02:00
|
|
|
int sd_dhcp_client_set_duid_llt(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
uint64_t llt_time);
|
2016-05-03 17:52:44 +02:00
|
|
|
int sd_dhcp_client_get_client_id(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
uint8_t *type,
|
|
|
|
const uint8_t **data,
|
|
|
|
size_t *data_len);
|
|
|
|
int sd_dhcp_client_set_mtu(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
uint32_t mtu);
|
2019-05-04 13:40:54 +02:00
|
|
|
int sd_dhcp_client_set_max_attempts(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
uint64_t attempt);
|
2016-11-11 00:34:19 +01:00
|
|
|
int sd_dhcp_client_set_client_port(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
uint16_t port);
|
2016-05-03 17:52:44 +02:00
|
|
|
int sd_dhcp_client_set_hostname(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
const char *hostname);
|
|
|
|
int sd_dhcp_client_set_vendor_class_identifier(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
const char *vci);
|
2018-05-07 14:21:02 +02:00
|
|
|
int sd_dhcp_client_set_user_class(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
const char* const *user_class);
|
2016-05-03 17:52:44 +02:00
|
|
|
int sd_dhcp_client_get_lease(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
sd_dhcp_lease **ret);
|
2014-02-04 23:13:52 +01:00
|
|
|
|
2013-12-09 22:43:23 +01:00
|
|
|
int sd_dhcp_client_stop(sd_dhcp_client *client);
|
2013-12-09 22:43:19 +01:00
|
|
|
int sd_dhcp_client_start(sd_dhcp_client *client);
|
2014-04-09 12:12:07 +02:00
|
|
|
|
|
|
|
sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
|
|
|
|
sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
|
|
|
|
|
2017-08-03 03:32:46 +02:00
|
|
|
/* NOTE: anonymize parameter is used to initialize PRL memory with different
|
|
|
|
* options when using RFC7844 Anonymity Profiles */
|
|
|
|
int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize);
|
2014-01-18 19:32:45 +01:00
|
|
|
|
2016-05-03 17:52:44 +02:00
|
|
|
int sd_dhcp_client_attach_event(
|
|
|
|
sd_dhcp_client *client,
|
|
|
|
sd_event *event,
|
|
|
|
int64_t priority);
|
2014-01-18 19:32:45 +01:00
|
|
|
int sd_dhcp_client_detach_event(sd_dhcp_client *client);
|
|
|
|
sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
|
2013-12-09 22:43:08 +01:00
|
|
|
|
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_dhcp_client, sd_dhcp_client_unref);
|
|
|
|
|
2015-10-24 23:42:56 +02:00
|
|
|
_SD_END_DECLARATIONS;
|
|
|
|
|
2013-12-09 22:43:08 +01:00
|
|
|
#endif
|