]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
011feef8 PF |
2 | #ifndef foosddhcpclienthfoo |
3 | #define foosddhcpclienthfoo | |
4 | ||
5 | /*** | |
810adae9 | 6 | Copyright © 2013 Intel Corporation. All rights reserved. |
011feef8 PF |
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 | ||
04c01369 | 22 | #include <inttypes.h> |
46a66b79 | 23 | #include <net/ethernet.h> |
04c01369 LP |
24 | #include <netinet/in.h> |
25 | #include <sys/types.h> | |
8217ed5e | 26 | #include <stdbool.h> |
011feef8 | 27 | |
fe8db0c5 | 28 | #include "sd-dhcp-lease.h" |
461dbb2f | 29 | #include "sd-dhcp-option.h" |
71d35b6b | 30 | #include "sd-event.h" |
d3d8ac2f | 31 | |
04c01369 LP |
32 | #include "_sd-common.h" |
33 | ||
34 | _SD_BEGIN_DECLARATIONS; | |
35 | ||
3e3d8f78 | 36 | enum { |
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, | |
727b5734 | 42 | SD_DHCP_CLIENT_EVENT_SELECTING = 5, |
fb536bc5 ZJS |
43 | SD_DHCP_CLIENT_EVENT_TRANSIENT_FAILURE = 6, /* Sent when we have not received a reply after the first few attempts. |
44 | * The client may want to start acquiring link-local addresses. */ | |
3e3d8f78 PF |
45 | }; |
46 | ||
22805d92 BG |
47 | enum { |
48 | SD_DHCP_OPTION_PAD = 0, | |
49 | SD_DHCP_OPTION_SUBNET_MASK = 1, | |
50 | SD_DHCP_OPTION_TIME_OFFSET = 2, | |
51 | SD_DHCP_OPTION_ROUTER = 3, | |
52 | SD_DHCP_OPTION_DOMAIN_NAME_SERVER = 6, | |
50018bfa | 53 | SD_DHCP_OPTION_LPR_SERVER = 9, |
22805d92 BG |
54 | SD_DHCP_OPTION_HOST_NAME = 12, |
55 | SD_DHCP_OPTION_BOOT_FILE_SIZE = 13, | |
56 | SD_DHCP_OPTION_DOMAIN_NAME = 15, | |
57 | SD_DHCP_OPTION_ROOT_PATH = 17, | |
58 | SD_DHCP_OPTION_ENABLE_IP_FORWARDING = 19, | |
59 | SD_DHCP_OPTION_ENABLE_IP_FORWARDING_NL = 20, | |
60 | SD_DHCP_OPTION_POLICY_FILTER = 21, | |
61 | SD_DHCP_OPTION_INTERFACE_MDR = 22, | |
62 | SD_DHCP_OPTION_INTERFACE_TTL = 23, | |
63 | SD_DHCP_OPTION_INTERFACE_MTU_AGING_TIMEOUT = 24, | |
64 | SD_DHCP_OPTION_INTERFACE_MTU = 26, | |
65 | SD_DHCP_OPTION_BROADCAST = 28, | |
19b8398f | 66 | /* Windows 10 option to send when Anonymize=true */ |
67 | SD_DHCP_OPTION_ROUTER_DISCOVER = 31, | |
22805d92 BG |
68 | SD_DHCP_OPTION_STATIC_ROUTE = 33, |
69 | SD_DHCP_OPTION_NTP_SERVER = 42, | |
70 | SD_DHCP_OPTION_VENDOR_SPECIFIC = 43, | |
19b8398f | 71 | /* Windows 10 option to send when Anonymize=true */ |
72 | SD_DHCP_OPTION_NETBIOS_NAMESERVER = 44, | |
73 | /* Windows 10 option to send when Anonymize=true */ | |
74 | SD_DHCP_OPTION_NETBIOS_NODETYPE = 46, | |
75 | /* Windows 10 option to send when Anonymize=true */ | |
76 | SD_DHCP_OPTION_NETBIOS_SCOPE = 47, | |
22805d92 BG |
77 | SD_DHCP_OPTION_REQUESTED_IP_ADDRESS = 50, |
78 | SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME = 51, | |
79 | SD_DHCP_OPTION_OVERLOAD = 52, | |
80 | SD_DHCP_OPTION_MESSAGE_TYPE = 53, | |
81 | SD_DHCP_OPTION_SERVER_IDENTIFIER = 54, | |
82 | SD_DHCP_OPTION_PARAMETER_REQUEST_LIST = 55, | |
83 | SD_DHCP_OPTION_ERROR_MESSAGE = 56, | |
84 | SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE = 57, | |
85 | SD_DHCP_OPTION_RENEWAL_T1_TIME = 58, | |
86 | SD_DHCP_OPTION_REBINDING_T2_TIME = 59, | |
87 | SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER = 60, | |
88 | SD_DHCP_OPTION_CLIENT_IDENTIFIER = 61, | |
2c649ca1 | 89 | SD_DHCP_OPTION_SMTP_SERVER = 69, |
f678ac7e | 90 | SD_DHCP_OPTION_POP3_SERVER = 70, |
af1c0de0 | 91 | SD_DHCP_OPTION_USER_CLASS = 77, |
22805d92 BG |
92 | SD_DHCP_OPTION_FQDN = 81, |
93 | SD_DHCP_OPTION_NEW_POSIX_TIMEZONE = 100, | |
94 | SD_DHCP_OPTION_NEW_TZDB_TIMEZONE = 101, | |
b85bc551 | 95 | SD_DHCP_OPTION_DOMAIN_SEARCH_LIST = 119, |
299d578f | 96 | SD_DHCP_OPTION_SIP_SERVER = 120, |
22805d92 | 97 | SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121, |
d11d4a64 | 98 | SD_DHCP_OPTION_MUD_URL = 161, |
22805d92 | 99 | SD_DHCP_OPTION_PRIVATE_BASE = 224, |
19b8398f | 100 | /* Windows 10 option to send when Anonymize=true */ |
101 | SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE = 249, | |
102 | /* Windows 10 option to send when Anonymize=true */ | |
103 | SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY = 252, | |
22805d92 BG |
104 | SD_DHCP_OPTION_PRIVATE_LAST = 254, |
105 | SD_DHCP_OPTION_END = 255, | |
106 | }; | |
107 | ||
011feef8 PF |
108 | typedef struct sd_dhcp_client sd_dhcp_client; |
109 | ||
727b5734 | 110 | typedef int (*sd_dhcp_client_callback_t)(sd_dhcp_client *client, int event, void *userdata); |
4b558378 ZJS |
111 | int sd_dhcp_client_set_callback( |
112 | sd_dhcp_client *client, | |
113 | sd_dhcp_client_callback_t cb, | |
114 | void *userdata); | |
115 | ||
116 | int sd_dhcp_client_set_request_option( | |
117 | sd_dhcp_client *client, | |
118 | uint8_t option); | |
119 | int sd_dhcp_client_set_request_address( | |
120 | sd_dhcp_client *client, | |
121 | const struct in_addr *last_address); | |
122 | int sd_dhcp_client_set_request_broadcast( | |
123 | sd_dhcp_client *client, | |
124 | int broadcast); | |
2f8e7633 | 125 | int sd_dhcp_client_set_ifindex( |
4b558378 ZJS |
126 | sd_dhcp_client *client, |
127 | int interface_index); | |
128 | int sd_dhcp_client_set_mac( | |
129 | sd_dhcp_client *client, | |
130 | const uint8_t *addr, | |
14b66dbc | 131 | const uint8_t *bcast_addr, |
4b558378 ZJS |
132 | size_t addr_len, |
133 | uint16_t arp_type); | |
134 | int sd_dhcp_client_set_client_id( | |
135 | sd_dhcp_client *client, | |
136 | uint8_t type, | |
137 | const uint8_t *data, | |
138 | size_t data_len); | |
139 | int sd_dhcp_client_set_iaid_duid( | |
140 | sd_dhcp_client *client, | |
8217ed5e | 141 | bool iaid_set, |
4b558378 ZJS |
142 | uint32_t iaid, |
143 | uint16_t duid_type, | |
f7a92d1a | 144 | const void *duid, |
4b558378 | 145 | size_t duid_len); |
7e90a499 YW |
146 | int sd_dhcp_client_set_iaid_duid_llt( |
147 | sd_dhcp_client *client, | |
8217ed5e | 148 | bool iaid_set, |
7e90a499 YW |
149 | uint32_t iaid, |
150 | uint64_t llt_time); | |
dace710c YW |
151 | int sd_dhcp_client_set_duid( |
152 | sd_dhcp_client *client, | |
153 | uint16_t duid_type, | |
154 | const void *duid, | |
155 | size_t duid_len); | |
7e90a499 YW |
156 | int sd_dhcp_client_set_duid_llt( |
157 | sd_dhcp_client *client, | |
158 | uint64_t llt_time); | |
4b558378 ZJS |
159 | int sd_dhcp_client_get_client_id( |
160 | sd_dhcp_client *client, | |
161 | uint8_t *type, | |
162 | const uint8_t **data, | |
163 | size_t *data_len); | |
164 | int sd_dhcp_client_set_mtu( | |
165 | sd_dhcp_client *client, | |
166 | uint32_t mtu); | |
715cedfb SS |
167 | int sd_dhcp_client_set_max_attempts( |
168 | sd_dhcp_client *client, | |
169 | uint64_t attempt); | |
9faed222 SS |
170 | int sd_dhcp_client_set_client_port( |
171 | sd_dhcp_client *client, | |
172 | uint16_t port); | |
4b558378 ZJS |
173 | int sd_dhcp_client_set_hostname( |
174 | sd_dhcp_client *client, | |
175 | const char *hostname); | |
176 | int sd_dhcp_client_set_vendor_class_identifier( | |
177 | sd_dhcp_client *client, | |
178 | const char *vci); | |
d11d4a64 SS |
179 | int sd_dhcp_client_set_mud_url( |
180 | sd_dhcp_client *client, | |
181 | const char *mudurl); | |
af1c0de0 SS |
182 | int sd_dhcp_client_set_user_class( |
183 | sd_dhcp_client *client, | |
e4336c0a | 184 | char * const *user_class); |
4b558378 ZJS |
185 | int sd_dhcp_client_get_lease( |
186 | sd_dhcp_client *client, | |
187 | sd_dhcp_lease **ret); | |
afe42aef SC |
188 | int sd_dhcp_client_set_service_type( |
189 | sd_dhcp_client *client, | |
190 | int type); | |
4c0b8d56 SS |
191 | int sd_dhcp_client_set_fallback_lease_lifetime( |
192 | sd_dhcp_client *client, | |
193 | uint32_t fallback_lease_lifetime); | |
a6cc569e | 194 | |
7354900d DW |
195 | int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v); |
196 | int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v); | |
cb29c156 | 197 | |
bbdf06d9 | 198 | int sd_dhcp_client_stop(sd_dhcp_client *client); |
46a66b79 | 199 | int sd_dhcp_client_start(sd_dhcp_client *client); |
1501b429 | 200 | int sd_dhcp_client_send_release(sd_dhcp_client *client); |
0f3ff4ea | 201 | int sd_dhcp_client_send_decline(sd_dhcp_client *client); |
1c9a2e26 | 202 | int sd_dhcp_client_send_renew(sd_dhcp_client *client); |
e5b04c8d PF |
203 | |
204 | sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client); | |
205 | sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client); | |
206 | ||
db3d2358 | 207 | /* NOTE: anonymize parameter is used to initialize PRL memory with different |
208 | * options when using RFC7844 Anonymity Profiles */ | |
209 | int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize); | |
b25ef18b | 210 | |
7be32612 MAL |
211 | int sd_dhcp_client_id_to_string(const void *data, size_t len, char **ret); |
212 | ||
4b558378 ZJS |
213 | int sd_dhcp_client_attach_event( |
214 | sd_dhcp_client *client, | |
215 | sd_event *event, | |
216 | int64_t priority); | |
b25ef18b TG |
217 | int sd_dhcp_client_detach_event(sd_dhcp_client *client); |
218 | sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client); | |
011feef8 | 219 | |
4afd3348 LP |
220 | _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref); |
221 | ||
04c01369 LP |
222 | _SD_END_DECLARATIONS; |
223 | ||
011feef8 | 224 | #endif |