]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-lease-internal.h
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-lease-internal.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright © 2013 Intel Corporation. All rights reserved.
6 ***/
7
8 #include <stdint.h>
9 #include <linux/if_packet.h>
10
11 #include "sd-dhcp-client.h"
12
13 #include "dhcp-protocol.h"
14 #include "list.h"
15 #include "util.h"
16
17 struct sd_dhcp_route {
18 struct in_addr dst_addr;
19 struct in_addr gw_addr;
20 unsigned char dst_prefixlen;
21
22 uint8_t option;
23 };
24
25 struct sd_dhcp_raw_option {
26 LIST_FIELDS(struct sd_dhcp_raw_option, options);
27
28 uint8_t tag;
29 uint8_t length;
30 void *data;
31 };
32
33 struct sd_dhcp_lease {
34 unsigned n_ref;
35
36 /* each 0 if unset */
37 uint32_t t1;
38 uint32_t t2;
39 uint32_t lifetime;
40
41 /* each 0 if unset */
42 be32_t address;
43 be32_t server_address;
44 be32_t next_server;
45
46 bool have_subnet_mask;
47 be32_t subnet_mask;
48
49 bool have_broadcast;
50 be32_t broadcast;
51
52 struct in_addr *router;
53 size_t router_size;
54
55 struct in_addr *dns;
56 size_t dns_size;
57
58 struct in_addr *ntp;
59 size_t ntp_size;
60
61 struct sd_dhcp_route *static_route;
62 size_t static_route_size, static_route_allocated;
63
64 uint16_t mtu; /* 0 if unset */
65
66 char *domainname;
67 char **search_domains;
68 char *hostname;
69 char *root_path;
70
71 void *client_id;
72 size_t client_id_len;
73
74 void *vendor_specific;
75 size_t vendor_specific_len;
76
77 char *timezone;
78
79 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
80 };
81
82 int dhcp_lease_new(sd_dhcp_lease **ret);
83
84 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
85 int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains);
86 int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
87
88 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
89
90 int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);
91
92 int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
93 int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);