chiark / gitweb /
sd-dhcp6-lease: Add helper function to compute remaining expiry time
[elogind.git] / src / libsystemd-network / dhcp-lease-internal.h
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_lease {
36         RefCount n_ref;
37
38         int32_t time_offset;
39         uint32_t t1;
40         uint32_t t2;
41         uint32_t lifetime;
42         uint32_t mtu_aging_timeout;
43         be32_t address;
44         be32_t server_address;
45         be32_t subnet_mask;
46         be32_t router;
47         be32_t next_server;
48         be32_t broadcast;
49         struct in_addr *dns;
50         size_t dns_size;
51         struct in_addr *ntp;
52         size_t ntp_size;
53         struct in_addr *policy_filter;
54         size_t policy_filter_size;
55         struct in_addr *static_route;
56         size_t static_route_size;
57         uint16_t boot_file_size;
58         uint16_t mdr;
59         uint16_t mtu;
60         uint8_t ttl;
61         bool ip_forward;
62         bool ip_forward_non_local;
63         char *domainname;
64         char *hostname;
65         char *root_path;
66 };
67
68 int dhcp_lease_new(sd_dhcp_lease **ret);
69 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
70                               void *user_data);
71
72 int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
73 int dhcp_lease_load(const char *lease_file, sd_dhcp_lease **ret);
74
75 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
76
77 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);
78 #define _cleanup_dhcp_lease_unref_ _cleanup_(sd_dhcp_lease_unrefp)