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