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