]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp-lease-internal.h
dhcp: rename index to ifindex
[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
09bee74d 28#include "util.h"
7e753d9d 29#include "list.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;
1caa12d0 38 unsigned char dst_prefixlen;
e1ea665e
EY
39};
40
7e753d9d
AC
41struct sd_dhcp_raw_option {
42 LIST_FIELDS(struct sd_dhcp_raw_option, options);
43
44 uint8_t tag;
45 uint8_t length;
46 void *data;
47};
48
a6cc569e 49struct sd_dhcp_lease {
3733eec3 50 int n_ref;
a6cc569e 51
f5c0c00f 52 int32_t time_offset;
a6cc569e
TG
53 uint32_t t1;
54 uint32_t t2;
55 uint32_t lifetime;
f5c0c00f 56 uint32_t mtu_aging_timeout;
a6cc569e
TG
57 be32_t address;
58 be32_t server_address;
59 be32_t subnet_mask;
60 be32_t router;
8e34a618 61 be32_t next_server;
f5c0c00f 62 be32_t broadcast;
a6cc569e
TG
63 struct in_addr *dns;
64 size_t dns_size;
46844696
TG
65 struct in_addr *ntp;
66 size_t ntp_size;
f5c0c00f
TG
67 struct in_addr *policy_filter;
68 size_t policy_filter_size;
e1ea665e 69 struct sd_dhcp_route *static_route;
f5c0c00f 70 size_t static_route_size;
e1ea665e 71 size_t static_route_allocated;
f5c0c00f
TG
72 uint16_t boot_file_size;
73 uint16_t mdr;
a6cc569e 74 uint16_t mtu;
f5c0c00f
TG
75 uint8_t ttl;
76 bool ip_forward;
77 bool ip_forward_non_local;
a6cc569e
TG
78 char *domainname;
79 char *hostname;
ce78df79 80 char *root_path;
e4735228 81 void *client_id;
e37f74a6 82 size_t client_id_len;
e4735228 83 void *vendor_specific;
e43a8393 84 size_t vendor_specific_len;
8eb9058d 85 char *timezone;
7e753d9d 86 LIST_HEAD(struct sd_dhcp_raw_option, private_options);
a6cc569e
TG
87};
88
89int dhcp_lease_new(sd_dhcp_lease **ret);
e4735228 90int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option,
89ca10c6 91 void *userdata);
7e753d9d 92int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag,
e4735228 93 const void *data, uint8_t len);
a6cc569e 94
9e64dd72
TG
95int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
96
e4735228 97int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id,
e37f74a6
DW
98 size_t client_id_len);
99
a6cc569e
TG
100DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);
101#define _cleanup_dhcp_lease_unref_ _cleanup_(sd_dhcp_lease_unrefp)
bd91b83e
LP
102
103int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
104int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);