]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-dhcp-client.h
Merge pull request #15197 from ssahani/smtp-dhcp
[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/***
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 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,
727b5734 42 SD_DHCP_CLIENT_EVENT_SELECTING = 5,
3e3d8f78
PF
43};
44
22805d92
BG
45enum {
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,
19b8398f 63 /* Windows 10 option to send when Anonymize=true */
64 SD_DHCP_OPTION_ROUTER_DISCOVER = 31,
22805d92
BG
65 SD_DHCP_OPTION_STATIC_ROUTE = 33,
66 SD_DHCP_OPTION_NTP_SERVER = 42,
67 SD_DHCP_OPTION_VENDOR_SPECIFIC = 43,
19b8398f 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,
22805d92
BG
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,
2c649ca1 86 SD_DHCP_OPTION_SMTP_SERVER = 69,
f678ac7e 87 SD_DHCP_OPTION_POP3_SERVER = 70,
af1c0de0 88 SD_DHCP_OPTION_USER_CLASS = 77,
22805d92
BG
89 SD_DHCP_OPTION_FQDN = 81,
90 SD_DHCP_OPTION_NEW_POSIX_TIMEZONE = 100,
91 SD_DHCP_OPTION_NEW_TZDB_TIMEZONE = 101,
b85bc551 92 SD_DHCP_OPTION_DOMAIN_SEARCH_LIST = 119,
299d578f 93 SD_DHCP_OPTION_SIP_SERVER = 120,
22805d92
BG
94 SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
95 SD_DHCP_OPTION_PRIVATE_BASE = 224,
19b8398f 96 /* Windows 10 option to send when Anonymize=true */
97 SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE = 249,
98 /* Windows 10 option to send when Anonymize=true */
99 SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY = 252,
22805d92
BG
100 SD_DHCP_OPTION_PRIVATE_LAST = 254,
101 SD_DHCP_OPTION_END = 255,
102};
103
011feef8
PF
104typedef struct sd_dhcp_client sd_dhcp_client;
105
727b5734 106typedef int (*sd_dhcp_client_callback_t)(sd_dhcp_client *client, int event, void *userdata);
4b558378
ZJS
107int sd_dhcp_client_set_callback(
108 sd_dhcp_client *client,
109 sd_dhcp_client_callback_t cb,
110 void *userdata);
111
112int sd_dhcp_client_set_request_option(
113 sd_dhcp_client *client,
114 uint8_t option);
115int sd_dhcp_client_set_request_address(
116 sd_dhcp_client *client,
117 const struct in_addr *last_address);
118int sd_dhcp_client_set_request_broadcast(
119 sd_dhcp_client *client,
120 int broadcast);
2f8e7633 121int sd_dhcp_client_set_ifindex(
4b558378
ZJS
122 sd_dhcp_client *client,
123 int interface_index);
124int sd_dhcp_client_set_mac(
125 sd_dhcp_client *client,
126 const uint8_t *addr,
127 size_t addr_len,
128 uint16_t arp_type);
129int sd_dhcp_client_set_client_id(
130 sd_dhcp_client *client,
131 uint8_t type,
132 const uint8_t *data,
133 size_t data_len);
134int sd_dhcp_client_set_iaid_duid(
135 sd_dhcp_client *client,
8217ed5e 136 bool iaid_set,
4b558378
ZJS
137 uint32_t iaid,
138 uint16_t duid_type,
f7a92d1a 139 const void *duid,
4b558378 140 size_t duid_len);
7e90a499
YW
141int sd_dhcp_client_set_iaid_duid_llt(
142 sd_dhcp_client *client,
8217ed5e 143 bool iaid_set,
7e90a499
YW
144 uint32_t iaid,
145 uint64_t llt_time);
dace710c
YW
146int sd_dhcp_client_set_duid(
147 sd_dhcp_client *client,
148 uint16_t duid_type,
149 const void *duid,
150 size_t duid_len);
7e90a499
YW
151int sd_dhcp_client_set_duid_llt(
152 sd_dhcp_client *client,
153 uint64_t llt_time);
4b558378
ZJS
154int sd_dhcp_client_get_client_id(
155 sd_dhcp_client *client,
156 uint8_t *type,
157 const uint8_t **data,
158 size_t *data_len);
159int sd_dhcp_client_set_mtu(
160 sd_dhcp_client *client,
161 uint32_t mtu);
715cedfb
SS
162int sd_dhcp_client_set_max_attempts(
163 sd_dhcp_client *client,
164 uint64_t attempt);
9faed222
SS
165int sd_dhcp_client_set_client_port(
166 sd_dhcp_client *client,
167 uint16_t port);
4b558378
ZJS
168int sd_dhcp_client_set_hostname(
169 sd_dhcp_client *client,
170 const char *hostname);
171int sd_dhcp_client_set_vendor_class_identifier(
172 sd_dhcp_client *client,
173 const char *vci);
af1c0de0
SS
174int sd_dhcp_client_set_user_class(
175 sd_dhcp_client *client,
176 const char* const *user_class);
4b558378
ZJS
177int sd_dhcp_client_get_lease(
178 sd_dhcp_client *client,
179 sd_dhcp_lease **ret);
afe42aef
SC
180int sd_dhcp_client_set_service_type(
181 sd_dhcp_client *client,
182 int type);
a6cc569e 183
7354900d
DW
184int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v);
185int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v);
cb29c156 186
bbdf06d9 187int sd_dhcp_client_stop(sd_dhcp_client *client);
46a66b79 188int sd_dhcp_client_start(sd_dhcp_client *client);
1501b429 189int sd_dhcp_client_send_release(sd_dhcp_client *client);
0f3ff4ea 190int sd_dhcp_client_send_decline(sd_dhcp_client *client);
1c9a2e26 191int sd_dhcp_client_send_renew(sd_dhcp_client *client);
e5b04c8d
PF
192
193sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
194sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
195
db3d2358 196/* NOTE: anonymize parameter is used to initialize PRL memory with different
197 * options when using RFC7844 Anonymity Profiles */
198int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize);
b25ef18b 199
4b558378
ZJS
200int sd_dhcp_client_attach_event(
201 sd_dhcp_client *client,
202 sd_event *event,
203 int64_t priority);
b25ef18b
TG
204int sd_dhcp_client_detach_event(sd_dhcp_client *client);
205sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
011feef8 206
4afd3348
LP
207_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref);
208
04c01369
LP
209_SD_END_DECLARATIONS;
210
011feef8 211#endif