]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-dhcp-client.h
meson: generate m4 preprocessor from config.h (#8914)
[thirdparty/systemd.git] / src / systemd / sd-dhcp-client.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
011feef8
PF
2#ifndef foosddhcpclienthfoo
3#define foosddhcpclienthfoo
4
5/***
6 This file is part of systemd.
7
8 Copyright (C) 2013 Intel Corporation. All rights reserved.
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
04c01369 24#include <inttypes.h>
46a66b79 25#include <net/ethernet.h>
04c01369
LP
26#include <netinet/in.h>
27#include <sys/types.h>
011feef8 28
fe8db0c5 29#include "sd-dhcp-lease.h"
71d35b6b 30#include "sd-event.h"
d3d8ac2f 31
04c01369
LP
32#include "_sd-common.h"
33
34_SD_BEGIN_DECLARATIONS;
35
3e3d8f78 36enum {
03748142
DH
37 SD_DHCP_CLIENT_EVENT_STOP = 0,
38 SD_DHCP_CLIENT_EVENT_IP_ACQUIRE = 1,
39 SD_DHCP_CLIENT_EVENT_IP_CHANGE = 2,
40 SD_DHCP_CLIENT_EVENT_EXPIRED = 3,
41 SD_DHCP_CLIENT_EVENT_RENEW = 4,
3e3d8f78
PF
42};
43
22805d92
BG
44enum {
45 SD_DHCP_OPTION_PAD = 0,
46 SD_DHCP_OPTION_SUBNET_MASK = 1,
47 SD_DHCP_OPTION_TIME_OFFSET = 2,
48 SD_DHCP_OPTION_ROUTER = 3,
49 SD_DHCP_OPTION_DOMAIN_NAME_SERVER = 6,
50 SD_DHCP_OPTION_HOST_NAME = 12,
51 SD_DHCP_OPTION_BOOT_FILE_SIZE = 13,
52 SD_DHCP_OPTION_DOMAIN_NAME = 15,
53 SD_DHCP_OPTION_ROOT_PATH = 17,
54 SD_DHCP_OPTION_ENABLE_IP_FORWARDING = 19,
55 SD_DHCP_OPTION_ENABLE_IP_FORWARDING_NL = 20,
56 SD_DHCP_OPTION_POLICY_FILTER = 21,
57 SD_DHCP_OPTION_INTERFACE_MDR = 22,
58 SD_DHCP_OPTION_INTERFACE_TTL = 23,
59 SD_DHCP_OPTION_INTERFACE_MTU_AGING_TIMEOUT = 24,
60 SD_DHCP_OPTION_INTERFACE_MTU = 26,
61 SD_DHCP_OPTION_BROADCAST = 28,
19b8398f 62 /* Windows 10 option to send when Anonymize=true */
63 SD_DHCP_OPTION_ROUTER_DISCOVER = 31,
22805d92
BG
64 SD_DHCP_OPTION_STATIC_ROUTE = 33,
65 SD_DHCP_OPTION_NTP_SERVER = 42,
66 SD_DHCP_OPTION_VENDOR_SPECIFIC = 43,
19b8398f 67 /* Windows 10 option to send when Anonymize=true */
68 SD_DHCP_OPTION_NETBIOS_NAMESERVER = 44,
69 /* Windows 10 option to send when Anonymize=true */
70 SD_DHCP_OPTION_NETBIOS_NODETYPE = 46,
71 /* Windows 10 option to send when Anonymize=true */
72 SD_DHCP_OPTION_NETBIOS_SCOPE = 47,
22805d92
BG
73 SD_DHCP_OPTION_REQUESTED_IP_ADDRESS = 50,
74 SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME = 51,
75 SD_DHCP_OPTION_OVERLOAD = 52,
76 SD_DHCP_OPTION_MESSAGE_TYPE = 53,
77 SD_DHCP_OPTION_SERVER_IDENTIFIER = 54,
78 SD_DHCP_OPTION_PARAMETER_REQUEST_LIST = 55,
79 SD_DHCP_OPTION_ERROR_MESSAGE = 56,
80 SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE = 57,
81 SD_DHCP_OPTION_RENEWAL_T1_TIME = 58,
82 SD_DHCP_OPTION_REBINDING_T2_TIME = 59,
83 SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER = 60,
84 SD_DHCP_OPTION_CLIENT_IDENTIFIER = 61,
85 SD_DHCP_OPTION_FQDN = 81,
86 SD_DHCP_OPTION_NEW_POSIX_TIMEZONE = 100,
87 SD_DHCP_OPTION_NEW_TZDB_TIMEZONE = 101,
b85bc551 88 SD_DHCP_OPTION_DOMAIN_SEARCH_LIST = 119,
22805d92
BG
89 SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
90 SD_DHCP_OPTION_PRIVATE_BASE = 224,
19b8398f 91 /* Windows 10 option to send when Anonymize=true */
92 SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE = 249,
93 /* Windows 10 option to send when Anonymize=true */
94 SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY = 252,
22805d92
BG
95 SD_DHCP_OPTION_PRIVATE_LAST = 254,
96 SD_DHCP_OPTION_END = 255,
97};
98
011feef8
PF
99typedef struct sd_dhcp_client sd_dhcp_client;
100
4b558378
ZJS
101typedef void (*sd_dhcp_client_callback_t)(sd_dhcp_client *client, int event, void *userdata);
102int sd_dhcp_client_set_callback(
103 sd_dhcp_client *client,
104 sd_dhcp_client_callback_t cb,
105 void *userdata);
106
107int sd_dhcp_client_set_request_option(
108 sd_dhcp_client *client,
109 uint8_t option);
110int sd_dhcp_client_set_request_address(
111 sd_dhcp_client *client,
112 const struct in_addr *last_address);
113int sd_dhcp_client_set_request_broadcast(
114 sd_dhcp_client *client,
115 int broadcast);
2f8e7633 116int sd_dhcp_client_set_ifindex(
4b558378
ZJS
117 sd_dhcp_client *client,
118 int interface_index);
119int sd_dhcp_client_set_mac(
120 sd_dhcp_client *client,
121 const uint8_t *addr,
122 size_t addr_len,
123 uint16_t arp_type);
124int sd_dhcp_client_set_client_id(
125 sd_dhcp_client *client,
126 uint8_t type,
127 const uint8_t *data,
128 size_t data_len);
129int sd_dhcp_client_set_iaid_duid(
130 sd_dhcp_client *client,
131 uint32_t iaid,
132 uint16_t duid_type,
f7a92d1a 133 const void *duid,
4b558378 134 size_t duid_len);
dace710c
YW
135int sd_dhcp_client_set_duid(
136 sd_dhcp_client *client,
137 uint16_t duid_type,
138 const void *duid,
139 size_t duid_len);
4b558378
ZJS
140int sd_dhcp_client_get_client_id(
141 sd_dhcp_client *client,
142 uint8_t *type,
143 const uint8_t **data,
144 size_t *data_len);
145int sd_dhcp_client_set_mtu(
146 sd_dhcp_client *client,
147 uint32_t mtu);
9faed222
SS
148int sd_dhcp_client_set_client_port(
149 sd_dhcp_client *client,
150 uint16_t port);
4b558378
ZJS
151int sd_dhcp_client_set_hostname(
152 sd_dhcp_client *client,
153 const char *hostname);
154int sd_dhcp_client_set_vendor_class_identifier(
155 sd_dhcp_client *client,
156 const char *vci);
157int sd_dhcp_client_get_lease(
158 sd_dhcp_client *client,
159 sd_dhcp_lease **ret);
a6cc569e 160
bbdf06d9 161int sd_dhcp_client_stop(sd_dhcp_client *client);
46a66b79 162int sd_dhcp_client_start(sd_dhcp_client *client);
e5b04c8d
PF
163
164sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
165sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
166
db3d2358 167/* NOTE: anonymize parameter is used to initialize PRL memory with different
168 * options when using RFC7844 Anonymity Profiles */
169int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize);
b25ef18b 170
4b558378
ZJS
171int sd_dhcp_client_attach_event(
172 sd_dhcp_client *client,
173 sd_event *event,
174 int64_t priority);
b25ef18b
TG
175int sd_dhcp_client_detach_event(sd_dhcp_client *client);
176sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
011feef8 177
4afd3348
LP
178_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref);
179
04c01369
LP
180_SD_END_DECLARATIONS;
181
011feef8 182#endif