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