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