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