]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-lease-internal.h
Merge pull request #16112 from poettering/nss-systemd-block-fix
[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 "sd-dhcp-client.h"
9
10 #include "dhcp-internal.h"
11 #include "dhcp-protocol.h"
12 #include "list.h"
13 #include "util.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 uint8_t option;
21 };
22
23 struct sd_dhcp_raw_option {
24 LIST_FIELDS(struct sd_dhcp_raw_option, options);
25
26 uint8_t tag;
27 uint8_t length;
28 void *data;
29 };
30
31 struct sd_dhcp_lease {
32 unsigned n_ref;
33
34 /* each 0 if unset */
35 uint32_t t1;
36 uint32_t t2;
37 uint32_t lifetime;
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 DHCPServerData servers[_SD_DHCP_LEASE_SERVER_TYPE_MAX];
54
55 struct sd_dhcp_route *static_route;
56 size_t static_route_size, static_route_allocated;
57
58 uint16_t mtu; /* 0 if unset */
59
60 char *domainname;
61 char **search_domains;
62 char *hostname;
63 char *root_path;
64
65 void *client_id;
66 size_t client_id_len;
67
68 void *vendor_specific;
69 size_t vendor_specific_len;
70
71 char *timezone;
72
73 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
74 };
75
76 int dhcp_lease_new(sd_dhcp_lease **ret);
77
78 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
79 int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains);
80 int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
81
82 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
83
84 int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);