]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-dhcp-client.h
Merge pull request #14338 from keszybz/functional-test-rework
[thirdparty/systemd.git] / src / systemd / sd-dhcp-client.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #ifndef foosddhcpclienthfoo
3 #define foosddhcpclienthfoo
4
5 /***
6 Copyright © 2013 Intel Corporation. All rights reserved.
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <inttypes.h>
23 #include <net/ethernet.h>
24 #include <netinet/in.h>
25 #include <sys/types.h>
26 #include <stdbool.h>
27
28 #include "sd-dhcp-lease.h"
29 #include "sd-dhcp-option.h"
30 #include "sd-event.h"
31
32 #include "_sd-common.h"
33
34 _SD_BEGIN_DECLARATIONS;
35
36 enum {
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,
42 SD_DHCP_CLIENT_EVENT_SELECTING = 5,
43 };
44
45 enum {
46 SD_DHCP_OPTION_PAD = 0,
47 SD_DHCP_OPTION_SUBNET_MASK = 1,
48 SD_DHCP_OPTION_TIME_OFFSET = 2,
49 SD_DHCP_OPTION_ROUTER = 3,
50 SD_DHCP_OPTION_DOMAIN_NAME_SERVER = 6,
51 SD_DHCP_OPTION_HOST_NAME = 12,
52 SD_DHCP_OPTION_BOOT_FILE_SIZE = 13,
53 SD_DHCP_OPTION_DOMAIN_NAME = 15,
54 SD_DHCP_OPTION_ROOT_PATH = 17,
55 SD_DHCP_OPTION_ENABLE_IP_FORWARDING = 19,
56 SD_DHCP_OPTION_ENABLE_IP_FORWARDING_NL = 20,
57 SD_DHCP_OPTION_POLICY_FILTER = 21,
58 SD_DHCP_OPTION_INTERFACE_MDR = 22,
59 SD_DHCP_OPTION_INTERFACE_TTL = 23,
60 SD_DHCP_OPTION_INTERFACE_MTU_AGING_TIMEOUT = 24,
61 SD_DHCP_OPTION_INTERFACE_MTU = 26,
62 SD_DHCP_OPTION_BROADCAST = 28,
63 /* Windows 10 option to send when Anonymize=true */
64 SD_DHCP_OPTION_ROUTER_DISCOVER = 31,
65 SD_DHCP_OPTION_STATIC_ROUTE = 33,
66 SD_DHCP_OPTION_NTP_SERVER = 42,
67 SD_DHCP_OPTION_VENDOR_SPECIFIC = 43,
68 /* Windows 10 option to send when Anonymize=true */
69 SD_DHCP_OPTION_NETBIOS_NAMESERVER = 44,
70 /* Windows 10 option to send when Anonymize=true */
71 SD_DHCP_OPTION_NETBIOS_NODETYPE = 46,
72 /* Windows 10 option to send when Anonymize=true */
73 SD_DHCP_OPTION_NETBIOS_SCOPE = 47,
74 SD_DHCP_OPTION_REQUESTED_IP_ADDRESS = 50,
75 SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME = 51,
76 SD_DHCP_OPTION_OVERLOAD = 52,
77 SD_DHCP_OPTION_MESSAGE_TYPE = 53,
78 SD_DHCP_OPTION_SERVER_IDENTIFIER = 54,
79 SD_DHCP_OPTION_PARAMETER_REQUEST_LIST = 55,
80 SD_DHCP_OPTION_ERROR_MESSAGE = 56,
81 SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE = 57,
82 SD_DHCP_OPTION_RENEWAL_T1_TIME = 58,
83 SD_DHCP_OPTION_REBINDING_T2_TIME = 59,
84 SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER = 60,
85 SD_DHCP_OPTION_CLIENT_IDENTIFIER = 61,
86 SD_DHCP_OPTION_POP3_SERVER = 70,
87 SD_DHCP_OPTION_USER_CLASS = 77,
88 SD_DHCP_OPTION_FQDN = 81,
89 SD_DHCP_OPTION_NEW_POSIX_TIMEZONE = 100,
90 SD_DHCP_OPTION_NEW_TZDB_TIMEZONE = 101,
91 SD_DHCP_OPTION_DOMAIN_SEARCH_LIST = 119,
92 SD_DHCP_OPTION_SIP_SERVER = 120,
93 SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
94 SD_DHCP_OPTION_PRIVATE_BASE = 224,
95 /* Windows 10 option to send when Anonymize=true */
96 SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE = 249,
97 /* Windows 10 option to send when Anonymize=true */
98 SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY = 252,
99 SD_DHCP_OPTION_PRIVATE_LAST = 254,
100 SD_DHCP_OPTION_END = 255,
101 };
102
103 typedef struct sd_dhcp_client sd_dhcp_client;
104
105 typedef int (*sd_dhcp_client_callback_t)(sd_dhcp_client *client, int event, void *userdata);
106 int sd_dhcp_client_set_callback(
107 sd_dhcp_client *client,
108 sd_dhcp_client_callback_t cb,
109 void *userdata);
110
111 int sd_dhcp_client_set_request_option(
112 sd_dhcp_client *client,
113 uint8_t option);
114 int sd_dhcp_client_set_request_address(
115 sd_dhcp_client *client,
116 const struct in_addr *last_address);
117 int sd_dhcp_client_set_request_broadcast(
118 sd_dhcp_client *client,
119 int broadcast);
120 int sd_dhcp_client_set_ifindex(
121 sd_dhcp_client *client,
122 int interface_index);
123 int sd_dhcp_client_set_mac(
124 sd_dhcp_client *client,
125 const uint8_t *addr,
126 size_t addr_len,
127 uint16_t arp_type);
128 int sd_dhcp_client_set_client_id(
129 sd_dhcp_client *client,
130 uint8_t type,
131 const uint8_t *data,
132 size_t data_len);
133 int sd_dhcp_client_set_iaid_duid(
134 sd_dhcp_client *client,
135 bool iaid_set,
136 uint32_t iaid,
137 uint16_t duid_type,
138 const void *duid,
139 size_t duid_len);
140 int sd_dhcp_client_set_iaid_duid_llt(
141 sd_dhcp_client *client,
142 bool iaid_set,
143 uint32_t iaid,
144 uint64_t llt_time);
145 int sd_dhcp_client_set_duid(
146 sd_dhcp_client *client,
147 uint16_t duid_type,
148 const void *duid,
149 size_t duid_len);
150 int sd_dhcp_client_set_duid_llt(
151 sd_dhcp_client *client,
152 uint64_t llt_time);
153 int sd_dhcp_client_get_client_id(
154 sd_dhcp_client *client,
155 uint8_t *type,
156 const uint8_t **data,
157 size_t *data_len);
158 int sd_dhcp_client_set_mtu(
159 sd_dhcp_client *client,
160 uint32_t mtu);
161 int sd_dhcp_client_set_max_attempts(
162 sd_dhcp_client *client,
163 uint64_t attempt);
164 int sd_dhcp_client_set_client_port(
165 sd_dhcp_client *client,
166 uint16_t port);
167 int sd_dhcp_client_set_hostname(
168 sd_dhcp_client *client,
169 const char *hostname);
170 int sd_dhcp_client_set_vendor_class_identifier(
171 sd_dhcp_client *client,
172 const char *vci);
173 int sd_dhcp_client_set_user_class(
174 sd_dhcp_client *client,
175 const char* const *user_class);
176 int sd_dhcp_client_get_lease(
177 sd_dhcp_client *client,
178 sd_dhcp_lease **ret);
179 int sd_dhcp_client_set_service_type(
180 sd_dhcp_client *client,
181 int type);
182
183 int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v);
184 int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v);
185
186 int sd_dhcp_client_stop(sd_dhcp_client *client);
187 int sd_dhcp_client_start(sd_dhcp_client *client);
188 int sd_dhcp_client_send_release(sd_dhcp_client *client);
189 int sd_dhcp_client_send_decline(sd_dhcp_client *client);
190 int sd_dhcp_client_send_renew(sd_dhcp_client *client);
191
192 sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
193 sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
194
195 /* NOTE: anonymize parameter is used to initialize PRL memory with different
196 * options when using RFC7844 Anonymity Profiles */
197 int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize);
198
199 int sd_dhcp_client_attach_event(
200 sd_dhcp_client *client,
201 sd_event *event,
202 int64_t priority);
203 int sd_dhcp_client_detach_event(sd_dhcp_client *client);
204 sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
205
206 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref);
207
208 _SD_END_DECLARATIONS;
209
210 #endif