]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-dhcp-client.h
tree-wide: make use of the new WRITE_STRING_FILE_MKDIR_0755 flag
[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-event.h"
30
31 #include "_sd-common.h"
32
33 _SD_BEGIN_DECLARATIONS;
34
35 enum {
36 SD_DHCP_CLIENT_EVENT_STOP = 0,
37 SD_DHCP_CLIENT_EVENT_IP_ACQUIRE = 1,
38 SD_DHCP_CLIENT_EVENT_IP_CHANGE = 2,
39 SD_DHCP_CLIENT_EVENT_EXPIRED = 3,
40 SD_DHCP_CLIENT_EVENT_RENEW = 4,
41 };
42
43 enum {
44 SD_DHCP_OPTION_PAD = 0,
45 SD_DHCP_OPTION_SUBNET_MASK = 1,
46 SD_DHCP_OPTION_TIME_OFFSET = 2,
47 SD_DHCP_OPTION_ROUTER = 3,
48 SD_DHCP_OPTION_DOMAIN_NAME_SERVER = 6,
49 SD_DHCP_OPTION_HOST_NAME = 12,
50 SD_DHCP_OPTION_BOOT_FILE_SIZE = 13,
51 SD_DHCP_OPTION_DOMAIN_NAME = 15,
52 SD_DHCP_OPTION_ROOT_PATH = 17,
53 SD_DHCP_OPTION_ENABLE_IP_FORWARDING = 19,
54 SD_DHCP_OPTION_ENABLE_IP_FORWARDING_NL = 20,
55 SD_DHCP_OPTION_POLICY_FILTER = 21,
56 SD_DHCP_OPTION_INTERFACE_MDR = 22,
57 SD_DHCP_OPTION_INTERFACE_TTL = 23,
58 SD_DHCP_OPTION_INTERFACE_MTU_AGING_TIMEOUT = 24,
59 SD_DHCP_OPTION_INTERFACE_MTU = 26,
60 SD_DHCP_OPTION_BROADCAST = 28,
61 /* Windows 10 option to send when Anonymize=true */
62 SD_DHCP_OPTION_ROUTER_DISCOVER = 31,
63 SD_DHCP_OPTION_STATIC_ROUTE = 33,
64 SD_DHCP_OPTION_NTP_SERVER = 42,
65 SD_DHCP_OPTION_VENDOR_SPECIFIC = 43,
66 /* Windows 10 option to send when Anonymize=true */
67 SD_DHCP_OPTION_NETBIOS_NAMESERVER = 44,
68 /* Windows 10 option to send when Anonymize=true */
69 SD_DHCP_OPTION_NETBIOS_NODETYPE = 46,
70 /* Windows 10 option to send when Anonymize=true */
71 SD_DHCP_OPTION_NETBIOS_SCOPE = 47,
72 SD_DHCP_OPTION_REQUESTED_IP_ADDRESS = 50,
73 SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME = 51,
74 SD_DHCP_OPTION_OVERLOAD = 52,
75 SD_DHCP_OPTION_MESSAGE_TYPE = 53,
76 SD_DHCP_OPTION_SERVER_IDENTIFIER = 54,
77 SD_DHCP_OPTION_PARAMETER_REQUEST_LIST = 55,
78 SD_DHCP_OPTION_ERROR_MESSAGE = 56,
79 SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE = 57,
80 SD_DHCP_OPTION_RENEWAL_T1_TIME = 58,
81 SD_DHCP_OPTION_REBINDING_T2_TIME = 59,
82 SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER = 60,
83 SD_DHCP_OPTION_CLIENT_IDENTIFIER = 61,
84 SD_DHCP_OPTION_USER_CLASS = 77,
85 SD_DHCP_OPTION_FQDN = 81,
86 SD_DHCP_OPTION_NEW_POSIX_TIMEZONE = 100,
87 SD_DHCP_OPTION_NEW_TZDB_TIMEZONE = 101,
88 SD_DHCP_OPTION_DOMAIN_SEARCH_LIST = 119,
89 SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
90 SD_DHCP_OPTION_PRIVATE_BASE = 224,
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,
95 SD_DHCP_OPTION_PRIVATE_LAST = 254,
96 SD_DHCP_OPTION_END = 255,
97 };
98
99 typedef struct sd_dhcp_client sd_dhcp_client;
100
101 typedef void (*sd_dhcp_client_callback_t)(sd_dhcp_client *client, int event, void *userdata);
102 int sd_dhcp_client_set_callback(
103 sd_dhcp_client *client,
104 sd_dhcp_client_callback_t cb,
105 void *userdata);
106
107 int sd_dhcp_client_set_request_option(
108 sd_dhcp_client *client,
109 uint8_t option);
110 int sd_dhcp_client_set_request_address(
111 sd_dhcp_client *client,
112 const struct in_addr *last_address);
113 int sd_dhcp_client_set_request_broadcast(
114 sd_dhcp_client *client,
115 int broadcast);
116 int sd_dhcp_client_set_ifindex(
117 sd_dhcp_client *client,
118 int interface_index);
119 int 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);
124 int 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);
129 int sd_dhcp_client_set_iaid_duid(
130 sd_dhcp_client *client,
131 bool iaid_set,
132 uint32_t iaid,
133 uint16_t duid_type,
134 const void *duid,
135 size_t duid_len);
136 int sd_dhcp_client_set_iaid_duid_llt(
137 sd_dhcp_client *client,
138 bool iaid_set,
139 uint32_t iaid,
140 uint64_t llt_time);
141 int sd_dhcp_client_set_duid(
142 sd_dhcp_client *client,
143 uint16_t duid_type,
144 const void *duid,
145 size_t duid_len);
146 int sd_dhcp_client_set_duid_llt(
147 sd_dhcp_client *client,
148 uint64_t llt_time);
149 int sd_dhcp_client_get_client_id(
150 sd_dhcp_client *client,
151 uint8_t *type,
152 const uint8_t **data,
153 size_t *data_len);
154 int sd_dhcp_client_set_mtu(
155 sd_dhcp_client *client,
156 uint32_t mtu);
157 int sd_dhcp_client_set_max_attempts(
158 sd_dhcp_client *client,
159 uint64_t attempt);
160 int sd_dhcp_client_set_client_port(
161 sd_dhcp_client *client,
162 uint16_t port);
163 int sd_dhcp_client_set_hostname(
164 sd_dhcp_client *client,
165 const char *hostname);
166 int sd_dhcp_client_set_vendor_class_identifier(
167 sd_dhcp_client *client,
168 const char *vci);
169 int sd_dhcp_client_set_user_class(
170 sd_dhcp_client *client,
171 const char* const *user_class);
172 int sd_dhcp_client_get_lease(
173 sd_dhcp_client *client,
174 sd_dhcp_lease **ret);
175
176 int sd_dhcp_client_stop(sd_dhcp_client *client);
177 int sd_dhcp_client_start(sd_dhcp_client *client);
178
179 sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
180 sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
181
182 /* NOTE: anonymize parameter is used to initialize PRL memory with different
183 * options when using RFC7844 Anonymity Profiles */
184 int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize);
185
186 int sd_dhcp_client_attach_event(
187 sd_dhcp_client *client,
188 sd_event *event,
189 int64_t priority);
190 int sd_dhcp_client_detach_event(sd_dhcp_client *client);
191 sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
192
193 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref);
194
195 _SD_END_DECLARATIONS;
196
197 #endif