]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-lease-internal.h
Merge pull request #30513 from rpigott/resolved-ede
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-lease-internal.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 /***
5 Copyright © 2013 Intel Corporation. All rights reserved.
6 ***/
7
8 #include "sd-dhcp-client.h"
9
10 #include "alloc-util.h"
11 #include "dhcp-client-id-internal.h"
12 #include "dhcp-option.h"
13 #include "list.h"
14 #include "time-util.h"
15
16 struct sd_dhcp_route {
17 struct in_addr dst_addr;
18 struct in_addr gw_addr;
19 unsigned char dst_prefixlen;
20 };
21
22 struct sd_dhcp_raw_option {
23 LIST_FIELDS(struct sd_dhcp_raw_option, options);
24
25 uint8_t tag;
26 uint8_t length;
27 void *data;
28 };
29
30 struct sd_dhcp_lease {
31 unsigned n_ref;
32
33 /* each 0 if unset */
34 usec_t t1;
35 usec_t t2;
36 usec_t lifetime;
37 triple_timestamp timestamp;
38 usec_t ipv6_only_preferred_usec;
39
40 /* each 0 if unset */
41 be32_t address;
42 be32_t server_address;
43 be32_t next_server;
44
45 bool have_subnet_mask;
46 be32_t subnet_mask;
47
48 bool have_broadcast;
49 be32_t broadcast;
50
51 struct in_addr *router;
52 size_t router_size;
53
54 bool rapid_commit;
55
56 DHCPServerData servers[_SD_DHCP_LEASE_SERVER_TYPE_MAX];
57
58 struct sd_dhcp_route *static_routes;
59 size_t n_static_routes;
60 struct sd_dhcp_route *classless_routes;
61 size_t n_classless_routes;
62
63 uint16_t mtu; /* 0 if unset */
64
65 char *domainname;
66 char **search_domains;
67 char *hostname;
68 char *root_path;
69 char *captive_portal;
70
71 sd_dhcp_client_id client_id;
72
73 void *vendor_specific;
74 size_t vendor_specific_len;
75
76 char *timezone;
77
78 uint8_t sixrd_ipv4masklen;
79 uint8_t sixrd_prefixlen;
80 struct in6_addr sixrd_prefix;
81 struct in_addr *sixrd_br_addresses;
82 size_t sixrd_n_br_addresses;
83
84 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
85 };
86
87 int dhcp_lease_new(sd_dhcp_lease **ret);
88
89 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
90 int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains);
91 int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
92
93 void dhcp_lease_set_timestamp(sd_dhcp_lease *lease, const triple_timestamp *timestamp);
94 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
95 int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const sd_dhcp_client_id *client_id);
96
97 #define dhcp_lease_unref_and_replace(a, b) \
98 unref_and_replace_full(a, b, sd_dhcp_lease_ref, sd_dhcp_lease_unref)