]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp-server-internal.h
networkd: Add EmitRouter= option for DHCP Server (#3251)
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-server-internal.h
CommitLineData
0ef6f454
LP
1#pragma once
2
b44cd882
TG
3/***
4 This file is part of systemd.
5
6 Copyright (C) 2013 Intel Corporation. All rights reserved.
7 Copyright (C) 2014 Tom Gundersen
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
b44cd882 23#include "sd-dhcp-server.h"
71d35b6b 24#include "sd-event.h"
b44cd882 25
71d35b6b 26#include "dhcp-internal.h"
87322b3a 27#include "hashmap.h"
b44cd882 28#include "log.h"
71d35b6b 29#include "util.h"
be077570 30
87322b3a
TG
31typedef struct DHCPClientId {
32 size_t length;
9a0f246f 33 void *data;
87322b3a
TG
34} DHCPClientId;
35
36typedef struct DHCPLease {
37 DHCPClientId client_id;
38
39 be32_t address;
52750344
TG
40 be32_t gateway;
41 uint8_t chaddr[16];
87322b3a
TG
42 usec_t expiration;
43} DHCPLease;
44
b44cd882 45struct sd_dhcp_server {
3733eec3 46 unsigned n_ref;
b44cd882
TG
47
48 sd_event *event;
49 int event_priority;
ff734080
TG
50 sd_event_source *receive_message;
51 int fd;
8de4a226 52 int fd_raw;
3a864fe4 53
b3ec603c 54 int ifindex;
20af7091 55 be32_t address;
59b8f6b6 56 be32_t netmask;
99634696
TG
57 be32_t subnet;
58 uint32_t pool_offset;
59 uint32_t pool_size;
b44cd882 60
8eb9058d
LP
61 char *timezone;
62
1a04db0f
LP
63 struct in_addr *ntp, *dns;
64 unsigned n_ntp, n_dns;
65
77ff6022
CG
66 bool emit_router;
67
87322b3a
TG
68 Hashmap *leases_by_client_id;
69 DHCPLease **bound_leases;
99634696 70 DHCPLease invalid_lease;
586ac6f7
LP
71
72 uint32_t max_lease_time, default_lease_time;
87322b3a 73};
816e2e7a
TG
74
75typedef struct DHCPRequest {
76 /* received message */
77 DHCPMessage *message;
78
79 /* options */
80 DHCPClientId client_id;
81 size_t max_optlen;
82 be32_t server_id;
2dead812 83 be32_t requested_ip;
586ac6f7 84 uint32_t lifetime;
816e2e7a
TG
85} DHCPRequest;
86
79008bdd 87#define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
be077570
TG
88
89int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
90 size_t length);
969b009d
TG
91int dhcp_server_send_packet(sd_dhcp_server *server,
92 DHCPRequest *req, DHCPPacket *packet,
93 int type, size_t optoffset);
87322b3a 94
b826ab58 95void client_id_hash_func(const void *p, struct siphash *state);
87322b3a 96int client_id_compare_func(const void *_a, const void *_b);