]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-lease-internal.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-lease-internal.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright (C) 2013 Intel Corporation. All rights reserved.
8 Copyright (C) 2014 Tom Gundersen
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include <stdint.h>
25 #include <linux/if_packet.h>
26
27 #include "sd-dhcp-client.h"
28
29 #include "dhcp-protocol.h"
30 #include "list.h"
31 #include "util.h"
32
33 struct sd_dhcp_route {
34 struct in_addr dst_addr;
35 struct in_addr gw_addr;
36 unsigned char dst_prefixlen;
37 };
38
39 struct sd_dhcp_raw_option {
40 LIST_FIELDS(struct sd_dhcp_raw_option, options);
41
42 uint8_t tag;
43 uint8_t length;
44 void *data;
45 };
46
47 struct sd_dhcp_lease {
48 unsigned n_ref;
49
50 /* each 0 if unset */
51 uint32_t t1;
52 uint32_t t2;
53 uint32_t lifetime;
54
55 /* each 0 if unset */
56 be32_t address;
57 be32_t server_address;
58 be32_t router;
59 be32_t next_server;
60
61 bool have_subnet_mask;
62 be32_t subnet_mask;
63
64 bool have_broadcast;
65 be32_t broadcast;
66
67 struct in_addr *dns;
68 size_t dns_size;
69
70 struct in_addr *ntp;
71 size_t ntp_size;
72
73 struct sd_dhcp_route *static_route;
74 size_t static_route_size, static_route_allocated;
75
76 uint16_t mtu; /* 0 if unset */
77
78 char *domainname;
79 char **search_domains;
80 char *hostname;
81 char *root_path;
82
83 void *client_id;
84 size_t client_id_len;
85
86 void *vendor_specific;
87 size_t vendor_specific_len;
88
89 char *timezone;
90
91 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
92 };
93
94 int dhcp_lease_new(sd_dhcp_lease **ret);
95
96 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
97 int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains);
98 int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
99
100 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
101
102 int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);
103
104 int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
105 int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);