Line data Source code
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 :
28 : #include "refcnt.h"
29 : #include "util.h"
30 :
31 : #include "dhcp-protocol.h"
32 :
33 : #include "sd-dhcp-client.h"
34 :
35 : struct sd_dhcp_route {
36 : struct in_addr dst_addr;
37 : struct in_addr gw_addr;
38 : unsigned char dst_prefixlen;
39 : };
40 :
41 : struct sd_dhcp_lease {
42 : RefCount n_ref;
43 :
44 : int32_t time_offset;
45 : uint32_t t1;
46 : uint32_t t2;
47 : uint32_t lifetime;
48 : uint32_t mtu_aging_timeout;
49 : be32_t address;
50 : be32_t server_address;
51 : be32_t subnet_mask;
52 : be32_t router;
53 : be32_t next_server;
54 : be32_t broadcast;
55 : struct in_addr *dns;
56 : size_t dns_size;
57 : struct in_addr *ntp;
58 : size_t ntp_size;
59 : struct in_addr *policy_filter;
60 : size_t policy_filter_size;
61 : struct sd_dhcp_route *static_route;
62 : size_t static_route_size;
63 : size_t static_route_allocated;
64 : uint16_t boot_file_size;
65 : uint16_t mdr;
66 : uint16_t mtu;
67 : uint8_t ttl;
68 : bool ip_forward;
69 : bool ip_forward_non_local;
70 : char *domainname;
71 : char *hostname;
72 : char *root_path;
73 : uint8_t *client_id;
74 : size_t client_id_len;
75 : uint8_t *vendor_specific;
76 : size_t vendor_specific_len;
77 : };
78 :
79 : int dhcp_lease_new(sd_dhcp_lease **ret);
80 : int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
81 : void *user_data);
82 :
83 : int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
84 :
85 : int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const uint8_t *client_id,
86 : size_t client_id_len);
87 :
88 2 : DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);
89 : #define _cleanup_dhcp_lease_unref_ _cleanup_(sd_dhcp_lease_unrefp)
|