]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-dhcp-client.h
fix: UnsetProperty example in systemd.link.xml
[thirdparty/systemd.git] / src / systemd / sd-dhcp-client.h
CommitLineData
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
85fce6f4 19 along with systemd; If not, see <https://www.gnu.org/licenses/>.
011feef8
PF
20***/
21
8217ed5e 22#include <stdbool.h>
011feef8 23
1cf40697 24#include "_sd-common.h"
d3d8ac2f 25
04c01369
LP
26_SD_BEGIN_DECLARATIONS;
27
5cdf13c7
DDM
28struct in_addr;
29
30typedef struct sd_device sd_device;
31typedef struct sd_dhcp_client_id sd_dhcp_client_id;
32typedef struct sd_dhcp_lease sd_dhcp_lease;
33typedef struct sd_dhcp_option sd_dhcp_option;
34typedef struct sd_event sd_event;
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,
5476cb98
JJ
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
011feef8
PF
47typedef struct sd_dhcp_client sd_dhcp_client;
48
727b5734 49typedef int (*sd_dhcp_client_callback_t)(sd_dhcp_client *client, int event, void *userdata);
4b558378
ZJS
50int sd_dhcp_client_set_callback(
51 sd_dhcp_client *client,
52 sd_dhcp_client_callback_t cb,
53 void *userdata);
54
55int sd_dhcp_client_set_request_option(
56 sd_dhcp_client *client,
57 uint8_t option);
58int sd_dhcp_client_set_request_address(
59 sd_dhcp_client *client,
60 const struct in_addr *last_address);
61int sd_dhcp_client_set_request_broadcast(
62 sd_dhcp_client *client,
63 int broadcast);
2f8e7633 64int sd_dhcp_client_set_ifindex(
4b558378
ZJS
65 sd_dhcp_client *client,
66 int interface_index);
61a9fa8f
YW
67int sd_dhcp_client_set_ifname(
68 sd_dhcp_client *client,
69 const char *interface_name);
5977b71f 70int sd_dhcp_client_get_ifname(sd_dhcp_client *client, const char **ret);
4b558378
ZJS
71int sd_dhcp_client_set_mac(
72 sd_dhcp_client *client,
7e5c25b2 73 const uint8_t *hw_addr,
14b66dbc 74 const uint8_t *bcast_addr,
4b558378
ZJS
75 size_t addr_len,
76 uint16_t arp_type);
6efa51f8
YW
77int sd_dhcp_client_get_client_id(
78 sd_dhcp_client *client,
79 const sd_dhcp_client_id **ret);
4b558378
ZJS
80int sd_dhcp_client_set_client_id(
81 sd_dhcp_client *client,
82 uint8_t type,
83 const uint8_t *data,
84 size_t data_len);
53488ea3 85__extension__ int sd_dhcp_client_set_iaid_duid_llt(
4b558378 86 sd_dhcp_client *client,
8217ed5e 87 bool iaid_set,
4b558378 88 uint32_t iaid,
53488ea3
YW
89 uint64_t llt_time);
90__extension__ int sd_dhcp_client_set_iaid_duid_ll(
91 sd_dhcp_client *client,
92 bool iaid_set,
93 uint32_t iaid);
94__extension__ int sd_dhcp_client_set_iaid_duid_en(
95 sd_dhcp_client *client,
96 bool iaid_set,
97 uint32_t iaid);
98__extension__ int sd_dhcp_client_set_iaid_duid_uuid(
99 sd_dhcp_client *client,
100 bool iaid_set,
101 uint32_t iaid);
102__extension__ int sd_dhcp_client_set_iaid_duid_raw(
7e90a499 103 sd_dhcp_client *client,
8217ed5e 104 bool iaid_set,
7e90a499 105 uint32_t iaid,
53488ea3
YW
106 uint16_t duid_type,
107 const uint8_t *duid,
108 size_t duid_len);
808b65a0
RP
109__extension__ int sd_dhcp_client_set_rapid_commit(
110 sd_dhcp_client *client,
111 bool rapid_commit);
4b558378
ZJS
112int sd_dhcp_client_set_mtu(
113 sd_dhcp_client *client,
114 uint32_t mtu);
715cedfb
SS
115int sd_dhcp_client_set_max_attempts(
116 sd_dhcp_client *client,
117 uint64_t attempt);
9faed222
SS
118int sd_dhcp_client_set_client_port(
119 sd_dhcp_client *client,
120 uint16_t port);
ea932bd3
MI
121int sd_dhcp_client_set_port(
122 sd_dhcp_client *client,
123 uint16_t port);
4b558378
ZJS
124int sd_dhcp_client_set_hostname(
125 sd_dhcp_client *client,
126 const char *hostname);
127int sd_dhcp_client_set_vendor_class_identifier(
128 sd_dhcp_client *client,
129 const char *vci);
d11d4a64
SS
130int sd_dhcp_client_set_mud_url(
131 sd_dhcp_client *client,
132 const char *mudurl);
af1c0de0
SS
133int sd_dhcp_client_set_user_class(
134 sd_dhcp_client *client,
e4336c0a 135 char * const *user_class);
4b558378
ZJS
136int sd_dhcp_client_get_lease(
137 sd_dhcp_client *client,
138 sd_dhcp_lease **ret);
afe42aef
SC
139int sd_dhcp_client_set_service_type(
140 sd_dhcp_client *client,
141 int type);
ea577968 142int sd_dhcp_client_set_socket_priority(
143 sd_dhcp_client *client,
144 int so_priority);
4c0b8d56
SS
145int sd_dhcp_client_set_fallback_lease_lifetime(
146 sd_dhcp_client *client,
5fde4d37 147 uint64_t fallback_lease_lifetime);
4ad29bad
CF
148int sd_dhcp_client_set_bootp(
149 sd_dhcp_client *client,
150 int bootp);
a6cc569e 151
7354900d
DW
152int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v);
153int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v);
cb29c156 154
041ea9f9 155int sd_dhcp_client_is_running(sd_dhcp_client *client);
bbdf06d9 156int sd_dhcp_client_stop(sd_dhcp_client *client);
46a66b79 157int sd_dhcp_client_start(sd_dhcp_client *client);
1501b429 158int sd_dhcp_client_send_release(sd_dhcp_client *client);
0f3ff4ea 159int sd_dhcp_client_send_decline(sd_dhcp_client *client);
1c9a2e26 160int sd_dhcp_client_send_renew(sd_dhcp_client *client);
a91b888f 161int sd_dhcp_client_set_ipv6_connectivity(sd_dhcp_client *client, int have);
0bc30a20 162int sd_dhcp_client_interrupt_ipv6_only_mode(sd_dhcp_client *client);
e5b04c8d
PF
163
164sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
165sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
166
db3d2358 167/* NOTE: anonymize parameter is used to initialize PRL memory with different
168 * options when using RFC7844 Anonymity Profiles */
169int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize);
b25ef18b 170
4b558378
ZJS
171int sd_dhcp_client_attach_event(
172 sd_dhcp_client *client,
173 sd_event *event,
174 int64_t priority);
b25ef18b
TG
175int sd_dhcp_client_detach_event(sd_dhcp_client *client);
176sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
be615f7c 177int sd_dhcp_client_attach_device(sd_dhcp_client *client, sd_device *dev);
011feef8 178
4afd3348
LP
179_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref);
180
04c01369
LP
181_SD_END_DECLARATIONS;
182
011feef8 183#endif