]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
a6cc569e TG |
2 | #pragma once |
3 | ||
4 | /*** | |
a6cc569e TG |
5 | Copyright (C) 2013 Intel Corporation. All rights reserved. |
6 | Copyright (C) 2014 Tom Gundersen | |
a6cc569e TG |
7 | ***/ |
8 | ||
9 | #include <stdint.h> | |
10 | #include <linux/if_packet.h> | |
11 | ||
71d35b6b | 12 | #include "sd-dhcp-client.h" |
a6cc569e TG |
13 | |
14 | #include "dhcp-protocol.h" | |
71d35b6b TA |
15 | #include "list.h" |
16 | #include "util.h" | |
a6cc569e | 17 | |
e1ea665e EY |
18 | struct sd_dhcp_route { |
19 | struct in_addr dst_addr; | |
20 | struct in_addr gw_addr; | |
1caa12d0 | 21 | unsigned char dst_prefixlen; |
8cdc46e7 SS |
22 | |
23 | uint8_t option; | |
e1ea665e EY |
24 | }; |
25 | ||
7e753d9d AC |
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 | ||
a6cc569e | 34 | struct sd_dhcp_lease { |
86514214 | 35 | unsigned n_ref; |
a6cc569e | 36 | |
0339cd77 | 37 | /* each 0 if unset */ |
a6cc569e TG |
38 | uint32_t t1; |
39 | uint32_t t2; | |
40 | uint32_t lifetime; | |
0339cd77 LP |
41 | |
42 | /* each 0 if unset */ | |
a6cc569e TG |
43 | be32_t address; |
44 | be32_t server_address; | |
a6cc569e | 45 | be32_t router; |
8e34a618 | 46 | be32_t next_server; |
0339cd77 LP |
47 | |
48 | bool have_subnet_mask; | |
49 | be32_t subnet_mask; | |
50 | ||
51 | bool have_broadcast; | |
f5c0c00f | 52 | be32_t broadcast; |
0339cd77 | 53 | |
a6cc569e TG |
54 | struct in_addr *dns; |
55 | size_t dns_size; | |
0339cd77 | 56 | |
46844696 TG |
57 | struct in_addr *ntp; |
58 | size_t ntp_size; | |
0339cd77 | 59 | |
e1ea665e | 60 | struct sd_dhcp_route *static_route; |
0339cd77 LP |
61 | size_t static_route_size, static_route_allocated; |
62 | ||
63 | uint16_t mtu; /* 0 if unset */ | |
64 | ||
a6cc569e | 65 | char *domainname; |
b85bc551 | 66 | char **search_domains; |
a6cc569e | 67 | char *hostname; |
ce78df79 | 68 | char *root_path; |
0339cd77 | 69 | |
e4735228 | 70 | void *client_id; |
e37f74a6 | 71 | size_t client_id_len; |
0339cd77 | 72 | |
e4735228 | 73 | void *vendor_specific; |
e43a8393 | 74 | size_t vendor_specific_len; |
0339cd77 | 75 | |
8eb9058d | 76 | char *timezone; |
0339cd77 | 77 | |
7e753d9d | 78 | LIST_HEAD(struct sd_dhcp_raw_option, private_options); |
a6cc569e TG |
79 | }; |
80 | ||
81 | int dhcp_lease_new(sd_dhcp_lease **ret); | |
a6cc569e | 82 | |
0339cd77 | 83 | int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata); |
b85bc551 | 84 | int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains); |
0339cd77 | 85 | int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len); |
9e64dd72 | 86 | |
0339cd77 | 87 | int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease); |
e37f74a6 | 88 | |
0339cd77 | 89 | int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len); |
bd91b83e LP |
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); |