]>
Commit | Line | Data |
---|---|---|
a6cc569e TG |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #pragma once | |
4 | ||
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright (C) 2013 Intel Corporation. All rights reserved. | |
9 | Copyright (C) 2014 Tom Gundersen | |
10 | ||
11 | systemd is free software; you can redistribute it and/or modify it | |
12 | under the terms of the GNU Lesser General Public License as published by | |
13 | the Free Software Foundation; either version 2.1 of the License, or | |
14 | (at your option) any later version. | |
15 | ||
16 | systemd is distributed in the hope that it will be useful, but | |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | Lesser General Public License for more details. | |
20 | ||
21 | You should have received a copy of the GNU Lesser General Public License | |
22 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
23 | ***/ | |
24 | ||
25 | #include <stdint.h> | |
26 | #include <linux/if_packet.h> | |
27 | ||
71d35b6b | 28 | #include "sd-dhcp-client.h" |
a6cc569e TG |
29 | |
30 | #include "dhcp-protocol.h" | |
71d35b6b TA |
31 | #include "list.h" |
32 | #include "util.h" | |
a6cc569e | 33 | |
e1ea665e EY |
34 | struct sd_dhcp_route { |
35 | struct in_addr dst_addr; | |
36 | struct in_addr gw_addr; | |
1caa12d0 | 37 | unsigned char dst_prefixlen; |
e1ea665e EY |
38 | }; |
39 | ||
7e753d9d AC |
40 | struct sd_dhcp_raw_option { |
41 | LIST_FIELDS(struct sd_dhcp_raw_option, options); | |
42 | ||
43 | uint8_t tag; | |
44 | uint8_t length; | |
45 | void *data; | |
46 | }; | |
47 | ||
a6cc569e | 48 | struct sd_dhcp_lease { |
86514214 | 49 | unsigned n_ref; |
a6cc569e | 50 | |
0339cd77 | 51 | /* each 0 if unset */ |
a6cc569e TG |
52 | uint32_t t1; |
53 | uint32_t t2; | |
54 | uint32_t lifetime; | |
0339cd77 LP |
55 | |
56 | /* each 0 if unset */ | |
a6cc569e TG |
57 | be32_t address; |
58 | be32_t server_address; | |
a6cc569e | 59 | be32_t router; |
8e34a618 | 60 | be32_t next_server; |
0339cd77 LP |
61 | |
62 | bool have_subnet_mask; | |
63 | be32_t subnet_mask; | |
64 | ||
65 | bool have_broadcast; | |
f5c0c00f | 66 | be32_t broadcast; |
0339cd77 | 67 | |
a6cc569e TG |
68 | struct in_addr *dns; |
69 | size_t dns_size; | |
0339cd77 | 70 | |
46844696 TG |
71 | struct in_addr *ntp; |
72 | size_t ntp_size; | |
0339cd77 | 73 | |
e1ea665e | 74 | struct sd_dhcp_route *static_route; |
0339cd77 LP |
75 | size_t static_route_size, static_route_allocated; |
76 | ||
77 | uint16_t mtu; /* 0 if unset */ | |
78 | ||
a6cc569e TG |
79 | char *domainname; |
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 | ||
94 | int dhcp_lease_new(sd_dhcp_lease **ret); | |
a6cc569e | 95 | |
0339cd77 LP |
96 | int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata); |
97 | int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len); | |
9e64dd72 | 98 | |
0339cd77 | 99 | int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease); |
e37f74a6 | 100 | |
0339cd77 | 101 | int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len); |
bd91b83e LP |
102 | |
103 | int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file); | |
104 | int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file); |