]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-lease-internal.h
Merge pull request #12818 from yuwata/network-issue-8726
[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 in_addr *sip;
62 size_t sip_size;
63
64 struct sd_dhcp_route *static_route;
65 size_t static_route_size, static_route_allocated;
66
67 uint16_t mtu; /* 0 if unset */
68
69 char *domainname;
70 char **search_domains;
71 char *hostname;
72 char *root_path;
73
74 void *client_id;
75 size_t client_id_len;
76
77 void *vendor_specific;
78 size_t vendor_specific_len;
79
80 char *timezone;
81
82 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
83 };
84
85 int dhcp_lease_new(sd_dhcp_lease **ret);
86
87 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
88 int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains);
89 int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
90
91 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
92
93 int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);
94
95 int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
96 int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);