]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp-lease-internal.h
sd-dhcp-lease: use unaligned read helpers
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-lease-internal.h
CommitLineData
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
a6cc569e 28#include "refcnt.h"
09bee74d 29#include "util.h"
a6cc569e
TG
30
31#include "dhcp-protocol.h"
32
33#include "sd-dhcp-client.h"
34
e1ea665e
EY
35struct sd_dhcp_route {
36 struct in_addr dst_addr;
37 struct in_addr gw_addr;
38 uint8_t dst_prefixlen;
39};
40
a6cc569e
TG
41struct sd_dhcp_lease {
42 RefCount n_ref;
43
f5c0c00f 44 int32_t time_offset;
a6cc569e
TG
45 uint32_t t1;
46 uint32_t t2;
47 uint32_t lifetime;
f5c0c00f 48 uint32_t mtu_aging_timeout;
a6cc569e
TG
49 be32_t address;
50 be32_t server_address;
51 be32_t subnet_mask;
52 be32_t router;
8e34a618 53 be32_t next_server;
f5c0c00f 54 be32_t broadcast;
a6cc569e
TG
55 struct in_addr *dns;
56 size_t dns_size;
46844696
TG
57 struct in_addr *ntp;
58 size_t ntp_size;
f5c0c00f
TG
59 struct in_addr *policy_filter;
60 size_t policy_filter_size;
e1ea665e 61 struct sd_dhcp_route *static_route;
f5c0c00f 62 size_t static_route_size;
e1ea665e 63 size_t static_route_allocated;
f5c0c00f
TG
64 uint16_t boot_file_size;
65 uint16_t mdr;
a6cc569e 66 uint16_t mtu;
f5c0c00f
TG
67 uint8_t ttl;
68 bool ip_forward;
69 bool ip_forward_non_local;
a6cc569e
TG
70 char *domainname;
71 char *hostname;
ce78df79 72 char *root_path;
a6cc569e
TG
73};
74
75int dhcp_lease_new(sd_dhcp_lease **ret);
76int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
77 void *user_data);
78
fe8db0c5
TG
79int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
80int dhcp_lease_load(const char *lease_file, sd_dhcp_lease **ret);
81
9e64dd72
TG
82int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
83
a6cc569e
TG
84DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);
85#define _cleanup_dhcp_lease_unref_ _cleanup_(sd_dhcp_lease_unrefp)