]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp-lease-internal.h
Merge pull request #12048 from jengelh/master
[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/***
810adae9 5 Copyright © 2013 Intel Corporation. All rights reserved.
a6cc569e
TG
6***/
7
8#include <stdint.h>
9#include <linux/if_packet.h>
10
71d35b6b 11#include "sd-dhcp-client.h"
a6cc569e
TG
12
13#include "dhcp-protocol.h"
71d35b6b
TA
14#include "list.h"
15#include "util.h"
a6cc569e 16
e1ea665e
EY
17struct sd_dhcp_route {
18 struct in_addr dst_addr;
19 struct in_addr gw_addr;
1caa12d0 20 unsigned char dst_prefixlen;
8cdc46e7
SS
21
22 uint8_t option;
e1ea665e
EY
23};
24
7e753d9d
AC
25struct 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
a6cc569e 33struct sd_dhcp_lease {
86514214 34 unsigned n_ref;
a6cc569e 35
0339cd77 36 /* each 0 if unset */
a6cc569e
TG
37 uint32_t t1;
38 uint32_t t2;
39 uint32_t lifetime;
0339cd77
LP
40
41 /* each 0 if unset */
a6cc569e
TG
42 be32_t address;
43 be32_t server_address;
8e34a618 44 be32_t next_server;
0339cd77
LP
45
46 bool have_subnet_mask;
47 be32_t subnet_mask;
48
49 bool have_broadcast;
f5c0c00f 50 be32_t broadcast;
0339cd77 51
f8862395
TH
52 struct in_addr *router;
53 size_t router_size;
54
a6cc569e
TG
55 struct in_addr *dns;
56 size_t dns_size;
0339cd77 57
46844696
TG
58 struct in_addr *ntp;
59 size_t ntp_size;
0339cd77 60
e1ea665e 61 struct sd_dhcp_route *static_route;
0339cd77
LP
62 size_t static_route_size, static_route_allocated;
63
64 uint16_t mtu; /* 0 if unset */
65
a6cc569e 66 char *domainname;
b85bc551 67 char **search_domains;
a6cc569e 68 char *hostname;
ce78df79 69 char *root_path;
0339cd77 70
e4735228 71 void *client_id;
e37f74a6 72 size_t client_id_len;
0339cd77 73
e4735228 74 void *vendor_specific;
e43a8393 75 size_t vendor_specific_len;
0339cd77 76
8eb9058d 77 char *timezone;
0339cd77 78
7e753d9d 79 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
a6cc569e
TG
80};
81
82int dhcp_lease_new(sd_dhcp_lease **ret);
a6cc569e 83
0339cd77 84int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
b85bc551 85int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains);
0339cd77 86int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
9e64dd72 87
0339cd77 88int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
e37f74a6 89
0339cd77 90int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);
bd91b83e
LP
91
92int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
93int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);