]> git.ipfire.org Git - thirdparty/systemd.git/blame - 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
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
a6cc569e
TG
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
71d35b6b 27#include "sd-dhcp-client.h"
a6cc569e
TG
28
29#include "dhcp-protocol.h"
71d35b6b
TA
30#include "list.h"
31#include "util.h"
a6cc569e 32
e1ea665e
EY
33struct sd_dhcp_route {
34 struct in_addr dst_addr;
35 struct in_addr gw_addr;
1caa12d0 36 unsigned char dst_prefixlen;
e1ea665e
EY
37};
38
7e753d9d
AC
39struct 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
a6cc569e 47struct sd_dhcp_lease {
86514214 48 unsigned n_ref;
a6cc569e 49
0339cd77 50 /* each 0 if unset */
a6cc569e
TG
51 uint32_t t1;
52 uint32_t t2;
53 uint32_t lifetime;
0339cd77
LP
54
55 /* each 0 if unset */
a6cc569e
TG
56 be32_t address;
57 be32_t server_address;
a6cc569e 58 be32_t router;
8e34a618 59 be32_t next_server;
0339cd77
LP
60
61 bool have_subnet_mask;
62 be32_t subnet_mask;
63
64 bool have_broadcast;
f5c0c00f 65 be32_t broadcast;
0339cd77 66
a6cc569e
TG
67 struct in_addr *dns;
68 size_t dns_size;
0339cd77 69
46844696
TG
70 struct in_addr *ntp;
71 size_t ntp_size;
0339cd77 72
e1ea665e 73 struct sd_dhcp_route *static_route;
0339cd77
LP
74 size_t static_route_size, static_route_allocated;
75
76 uint16_t mtu; /* 0 if unset */
77
a6cc569e 78 char *domainname;
b85bc551 79 char **search_domains;
a6cc569e 80 char *hostname;
ce78df79 81 char *root_path;
0339cd77 82
e4735228 83 void *client_id;
e37f74a6 84 size_t client_id_len;
0339cd77 85
e4735228 86 void *vendor_specific;
e43a8393 87 size_t vendor_specific_len;
0339cd77 88
8eb9058d 89 char *timezone;
0339cd77 90
7e753d9d 91 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
a6cc569e
TG
92};
93
94int dhcp_lease_new(sd_dhcp_lease **ret);
a6cc569e 95
0339cd77 96int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
b85bc551 97int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains);
0339cd77 98int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
9e64dd72 99
0339cd77 100int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
e37f74a6 101
0339cd77 102int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);
bd91b83e
LP
103
104int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
105int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);