chiark / gitweb /
sd-dhcp-lease: add NTP support
[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
30 #include "dhcp-protocol.h"
31
32 #include "sd-dhcp-client.h"
33
34 struct sd_dhcp_lease {
35         RefCount n_ref;
36
37         uint32_t t1;
38         uint32_t t2;
39         uint32_t lifetime;
40         be32_t address;
41         be32_t server_address;
42         be32_t subnet_mask;
43         be32_t router;
44         be32_t next_server;
45         struct in_addr *dns;
46         size_t dns_size;
47         struct in_addr *ntp;
48         size_t ntp_size;
49         uint16_t mtu;
50         char *domainname;
51         char *hostname;
52         char *root_path;
53 };
54
55 int dhcp_lease_new(sd_dhcp_lease **ret);
56 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
57                               void *user_data);
58
59 int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
60 int dhcp_lease_load(const char *lease_file, sd_dhcp_lease **ret);
61
62 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
63
64 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);
65 #define _cleanup_dhcp_lease_unref_ _cleanup_(sd_dhcp_lease_unrefp)