1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #ifndef foosddhcpclienthfoo
3 #define foosddhcpclienthfoo
6 Copyright © 2013 Intel Corporation. All rights reserved.
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.
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.
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/>.
23 #include <net/ethernet.h>
24 #include <netinet/in.h>
25 #include <sys/types.h>
28 #include "sd-dhcp-lease.h"
29 #include "sd-dhcp-option.h"
32 #include "_sd-common.h"
34 _SD_BEGIN_DECLARATIONS
;
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,
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_LPR_SERVER
= 9,
52 SD_DHCP_OPTION_HOST_NAME
= 12,
53 SD_DHCP_OPTION_BOOT_FILE_SIZE
= 13,
54 SD_DHCP_OPTION_DOMAIN_NAME
= 15,
55 SD_DHCP_OPTION_ROOT_PATH
= 17,
56 SD_DHCP_OPTION_ENABLE_IP_FORWARDING
= 19,
57 SD_DHCP_OPTION_ENABLE_IP_FORWARDING_NL
= 20,
58 SD_DHCP_OPTION_POLICY_FILTER
= 21,
59 SD_DHCP_OPTION_INTERFACE_MDR
= 22,
60 SD_DHCP_OPTION_INTERFACE_TTL
= 23,
61 SD_DHCP_OPTION_INTERFACE_MTU_AGING_TIMEOUT
= 24,
62 SD_DHCP_OPTION_INTERFACE_MTU
= 26,
63 SD_DHCP_OPTION_BROADCAST
= 28,
64 /* Windows 10 option to send when Anonymize=true */
65 SD_DHCP_OPTION_ROUTER_DISCOVER
= 31,
66 SD_DHCP_OPTION_STATIC_ROUTE
= 33,
67 SD_DHCP_OPTION_NTP_SERVER
= 42,
68 SD_DHCP_OPTION_VENDOR_SPECIFIC
= 43,
69 /* Windows 10 option to send when Anonymize=true */
70 SD_DHCP_OPTION_NETBIOS_NAMESERVER
= 44,
71 /* Windows 10 option to send when Anonymize=true */
72 SD_DHCP_OPTION_NETBIOS_NODETYPE
= 46,
73 /* Windows 10 option to send when Anonymize=true */
74 SD_DHCP_OPTION_NETBIOS_SCOPE
= 47,
75 SD_DHCP_OPTION_REQUESTED_IP_ADDRESS
= 50,
76 SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME
= 51,
77 SD_DHCP_OPTION_OVERLOAD
= 52,
78 SD_DHCP_OPTION_MESSAGE_TYPE
= 53,
79 SD_DHCP_OPTION_SERVER_IDENTIFIER
= 54,
80 SD_DHCP_OPTION_PARAMETER_REQUEST_LIST
= 55,
81 SD_DHCP_OPTION_ERROR_MESSAGE
= 56,
82 SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE
= 57,
83 SD_DHCP_OPTION_RENEWAL_T1_TIME
= 58,
84 SD_DHCP_OPTION_REBINDING_T2_TIME
= 59,
85 SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER
= 60,
86 SD_DHCP_OPTION_CLIENT_IDENTIFIER
= 61,
87 SD_DHCP_OPTION_SMTP_SERVER
= 69,
88 SD_DHCP_OPTION_POP3_SERVER
= 70,
89 SD_DHCP_OPTION_USER_CLASS
= 77,
90 SD_DHCP_OPTION_FQDN
= 81,
91 SD_DHCP_OPTION_NEW_POSIX_TIMEZONE
= 100,
92 SD_DHCP_OPTION_NEW_TZDB_TIMEZONE
= 101,
93 SD_DHCP_OPTION_DOMAIN_SEARCH_LIST
= 119,
94 SD_DHCP_OPTION_SIP_SERVER
= 120,
95 SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE
= 121,
96 SD_DHCP_OPTION_MUD_URL
= 161,
97 SD_DHCP_OPTION_PRIVATE_BASE
= 224,
98 /* Windows 10 option to send when Anonymize=true */
99 SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE
= 249,
100 /* Windows 10 option to send when Anonymize=true */
101 SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY
= 252,
102 SD_DHCP_OPTION_PRIVATE_LAST
= 254,
103 SD_DHCP_OPTION_END
= 255,
106 typedef struct sd_dhcp_client sd_dhcp_client
;
108 typedef int (*sd_dhcp_client_callback_t
)(sd_dhcp_client
*client
, int event
, void *userdata
);
109 int sd_dhcp_client_set_callback(
110 sd_dhcp_client
*client
,
111 sd_dhcp_client_callback_t cb
,
114 int sd_dhcp_client_set_request_option(
115 sd_dhcp_client
*client
,
117 int sd_dhcp_client_set_request_address(
118 sd_dhcp_client
*client
,
119 const struct in_addr
*last_address
);
120 int sd_dhcp_client_set_request_broadcast(
121 sd_dhcp_client
*client
,
123 int sd_dhcp_client_set_ifindex(
124 sd_dhcp_client
*client
,
125 int interface_index
);
126 int sd_dhcp_client_set_mac(
127 sd_dhcp_client
*client
,
131 int sd_dhcp_client_set_client_id(
132 sd_dhcp_client
*client
,
136 int sd_dhcp_client_set_iaid_duid(
137 sd_dhcp_client
*client
,
143 int sd_dhcp_client_set_iaid_duid_llt(
144 sd_dhcp_client
*client
,
148 int sd_dhcp_client_set_duid(
149 sd_dhcp_client
*client
,
153 int sd_dhcp_client_set_duid_llt(
154 sd_dhcp_client
*client
,
156 int sd_dhcp_client_get_client_id(
157 sd_dhcp_client
*client
,
159 const uint8_t **data
,
161 int sd_dhcp_client_set_mtu(
162 sd_dhcp_client
*client
,
164 int sd_dhcp_client_set_max_attempts(
165 sd_dhcp_client
*client
,
167 int sd_dhcp_client_set_client_port(
168 sd_dhcp_client
*client
,
170 int sd_dhcp_client_set_hostname(
171 sd_dhcp_client
*client
,
172 const char *hostname
);
173 int sd_dhcp_client_set_vendor_class_identifier(
174 sd_dhcp_client
*client
,
176 int sd_dhcp_client_set_mud_url(
177 sd_dhcp_client
*client
,
179 int sd_dhcp_client_set_user_class(
180 sd_dhcp_client
*client
,
181 const char* const *user_class
);
182 int sd_dhcp_client_get_lease(
183 sd_dhcp_client
*client
,
184 sd_dhcp_lease
**ret
);
185 int sd_dhcp_client_set_service_type(
186 sd_dhcp_client
*client
,
188 int sd_dhcp_client_set_fallback_lease_lifetime(
189 sd_dhcp_client
*client
,
190 uint32_t fallback_lease_lifetime
);
192 int sd_dhcp_client_add_option(sd_dhcp_client
*client
, sd_dhcp_option
*v
);
193 int sd_dhcp_client_add_vendor_option(sd_dhcp_client
*client
, sd_dhcp_option
*v
);
195 int sd_dhcp_client_stop(sd_dhcp_client
*client
);
196 int sd_dhcp_client_start(sd_dhcp_client
*client
);
197 int sd_dhcp_client_send_release(sd_dhcp_client
*client
);
198 int sd_dhcp_client_send_decline(sd_dhcp_client
*client
);
199 int sd_dhcp_client_send_renew(sd_dhcp_client
*client
);
201 sd_dhcp_client
*sd_dhcp_client_ref(sd_dhcp_client
*client
);
202 sd_dhcp_client
*sd_dhcp_client_unref(sd_dhcp_client
*client
);
204 /* NOTE: anonymize parameter is used to initialize PRL memory with different
205 * options when using RFC7844 Anonymity Profiles */
206 int sd_dhcp_client_new(sd_dhcp_client
**ret
, int anonymize
);
208 int sd_dhcp_client_id_to_string(const void *data
, size_t len
, char **ret
);
210 int sd_dhcp_client_attach_event(
211 sd_dhcp_client
*client
,
214 int sd_dhcp_client_detach_event(sd_dhcp_client
*client
);
215 sd_event
*sd_dhcp_client_get_event(sd_dhcp_client
*client
);
217 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client
, sd_dhcp_client_unref
);
219 _SD_END_DECLARATIONS
;