]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-dhcp-client.h
core: Record ExecMainStartTimestamp before forking
[thirdparty/systemd.git] / src / systemd / sd-dhcp-client.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
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 <https://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-device.h"
29 #include "sd-dhcp-client-id.h"
30 #include "sd-dhcp-lease.h"
31 #include "sd-dhcp-option.h"
32 #include "sd-event.h"
33
34 #include "_sd-common.h"
35
36 _SD_BEGIN_DECLARATIONS;
37
38 enum {
39 SD_DHCP_CLIENT_EVENT_STOP = 0,
40 SD_DHCP_CLIENT_EVENT_IP_ACQUIRE = 1,
41 SD_DHCP_CLIENT_EVENT_IP_CHANGE = 2,
42 SD_DHCP_CLIENT_EVENT_EXPIRED = 3,
43 SD_DHCP_CLIENT_EVENT_RENEW = 4,
44 SD_DHCP_CLIENT_EVENT_SELECTING = 5,
45 SD_DHCP_CLIENT_EVENT_TRANSIENT_FAILURE = 6 /* Sent when we have not received a reply after the first few attempts.
46 * The client may want to start acquiring link-local addresses. */
47 };
48
49 typedef struct sd_dhcp_client sd_dhcp_client;
50
51 typedef int (*sd_dhcp_client_callback_t)(sd_dhcp_client *client, int event, void *userdata);
52 int sd_dhcp_client_set_callback(
53 sd_dhcp_client *client,
54 sd_dhcp_client_callback_t cb,
55 void *userdata);
56
57 int sd_dhcp_client_set_request_option(
58 sd_dhcp_client *client,
59 uint8_t option);
60 int sd_dhcp_client_set_request_address(
61 sd_dhcp_client *client,
62 const struct in_addr *last_address);
63 int sd_dhcp_client_set_request_broadcast(
64 sd_dhcp_client *client,
65 int broadcast);
66 int sd_dhcp_client_set_ifindex(
67 sd_dhcp_client *client,
68 int interface_index);
69 int sd_dhcp_client_set_ifname(
70 sd_dhcp_client *client,
71 const char *interface_name);
72 int sd_dhcp_client_get_ifname(sd_dhcp_client *client, const char **ret);
73 int sd_dhcp_client_set_mac(
74 sd_dhcp_client *client,
75 const uint8_t *hw_addr,
76 const uint8_t *bcast_addr,
77 size_t addr_len,
78 uint16_t arp_type);
79 int sd_dhcp_client_get_client_id(
80 sd_dhcp_client *client,
81 const sd_dhcp_client_id **ret);
82 int sd_dhcp_client_set_client_id(
83 sd_dhcp_client *client,
84 uint8_t type,
85 const uint8_t *data,
86 size_t data_len);
87 __extension__ int sd_dhcp_client_set_iaid_duid_llt(
88 sd_dhcp_client *client,
89 bool iaid_set,
90 uint32_t iaid,
91 uint64_t llt_time);
92 __extension__ int sd_dhcp_client_set_iaid_duid_ll(
93 sd_dhcp_client *client,
94 bool iaid_set,
95 uint32_t iaid);
96 __extension__ int sd_dhcp_client_set_iaid_duid_en(
97 sd_dhcp_client *client,
98 bool iaid_set,
99 uint32_t iaid);
100 __extension__ int sd_dhcp_client_set_iaid_duid_uuid(
101 sd_dhcp_client *client,
102 bool iaid_set,
103 uint32_t iaid);
104 __extension__ int sd_dhcp_client_set_iaid_duid_raw(
105 sd_dhcp_client *client,
106 bool iaid_set,
107 uint32_t iaid,
108 uint16_t duid_type,
109 const uint8_t *duid,
110 size_t duid_len);
111 __extension__ int sd_dhcp_client_set_rapid_commit(
112 sd_dhcp_client *client,
113 bool rapid_commit);
114 int sd_dhcp_client_set_mtu(
115 sd_dhcp_client *client,
116 uint32_t mtu);
117 int sd_dhcp_client_set_max_attempts(
118 sd_dhcp_client *client,
119 uint64_t attempt);
120 int sd_dhcp_client_set_client_port(
121 sd_dhcp_client *client,
122 uint16_t port);
123 int sd_dhcp_client_set_port(
124 sd_dhcp_client *client,
125 uint16_t port);
126 int sd_dhcp_client_set_hostname(
127 sd_dhcp_client *client,
128 const char *hostname);
129 int sd_dhcp_client_set_vendor_class_identifier(
130 sd_dhcp_client *client,
131 const char *vci);
132 int sd_dhcp_client_set_mud_url(
133 sd_dhcp_client *client,
134 const char *mudurl);
135 int sd_dhcp_client_set_user_class(
136 sd_dhcp_client *client,
137 char * const *user_class);
138 int sd_dhcp_client_get_lease(
139 sd_dhcp_client *client,
140 sd_dhcp_lease **ret);
141 int sd_dhcp_client_set_service_type(
142 sd_dhcp_client *client,
143 int type);
144 int sd_dhcp_client_set_socket_priority(
145 sd_dhcp_client *client,
146 int so_priority);
147 int sd_dhcp_client_set_fallback_lease_lifetime(
148 sd_dhcp_client *client,
149 uint64_t fallback_lease_lifetime);
150
151 int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v);
152 int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v);
153
154 int sd_dhcp_client_is_running(sd_dhcp_client *client);
155 int sd_dhcp_client_stop(sd_dhcp_client *client);
156 int sd_dhcp_client_start(sd_dhcp_client *client);
157 int sd_dhcp_client_send_release(sd_dhcp_client *client);
158 int sd_dhcp_client_send_decline(sd_dhcp_client *client);
159 int sd_dhcp_client_send_renew(sd_dhcp_client *client);
160 int sd_dhcp_client_set_ipv6_connectivity(sd_dhcp_client *client, int have);
161 int sd_dhcp_client_interrupt_ipv6_only_mode(sd_dhcp_client *client);
162
163 sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
164 sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
165
166 /* NOTE: anonymize parameter is used to initialize PRL memory with different
167 * options when using RFC7844 Anonymity Profiles */
168 int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize);
169
170 int sd_dhcp_client_attach_event(
171 sd_dhcp_client *client,
172 sd_event *event,
173 int64_t priority);
174 int sd_dhcp_client_detach_event(sd_dhcp_client *client);
175 sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
176 int sd_dhcp_client_attach_device(sd_dhcp_client *client, sd_device *dev);
177
178 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref);
179
180 _SD_END_DECLARATIONS;
181
182 #endif