]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-lease-internal.h
pkgconfig: define variables relative to ${prefix}/${rootprefix}/${sysconfdir}
[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 router;
45 be32_t next_server;
46
47 bool have_subnet_mask;
48 be32_t subnet_mask;
49
50 bool have_broadcast;
51 be32_t broadcast;
52
53 struct in_addr *dns;
54 size_t dns_size;
55
56 struct in_addr *ntp;
57 size_t ntp_size;
58
59 struct sd_dhcp_route *static_route;
60 size_t static_route_size, static_route_allocated;
61
62 uint16_t mtu; /* 0 if unset */
63
64 char *domainname;
65 char **search_domains;
66 char *hostname;
67 char *root_path;
68
69 void *client_id;
70 size_t client_id_len;
71
72 void *vendor_specific;
73 size_t vendor_specific_len;
74
75 char *timezone;
76
77 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
78 };
79
80 int dhcp_lease_new(sd_dhcp_lease **ret);
81
82 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
83 int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains);
84 int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
85
86 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
87
88 int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);
89
90 int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
91 int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);