]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp-server-internal.h
Merge pull request #2495 from heftig/master
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-server-internal.h
CommitLineData
b44cd882
TG
1/***
2 This file is part of systemd.
3
4 Copyright (C) 2013 Intel Corporation. All rights reserved.
5 Copyright (C) 2014 Tom Gundersen
6
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
11
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
19***/
20
c9403dce
ZJS
21#pragma once
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
87322b3a
TG
66 Hashmap *leases_by_client_id;
67 DHCPLease **bound_leases;
99634696 68 DHCPLease invalid_lease;
586ac6f7
LP
69
70 uint32_t max_lease_time, default_lease_time;
87322b3a 71};
816e2e7a
TG
72
73typedef struct DHCPRequest {
74 /* received message */
75 DHCPMessage *message;
76
77 /* options */
78 DHCPClientId client_id;
79 size_t max_optlen;
80 be32_t server_id;
2dead812 81 be32_t requested_ip;
586ac6f7 82 uint32_t lifetime;
816e2e7a
TG
83} DHCPRequest;
84
79008bdd 85#define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
be077570
TG
86
87int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
88 size_t length);
969b009d
TG
89int dhcp_server_send_packet(sd_dhcp_server *server,
90 DHCPRequest *req, DHCPPacket *packet,
91 int type, size_t optoffset);
87322b3a 92
b826ab58 93void client_id_hash_func(const void *p, struct siphash *state);
87322b3a 94int client_id_compare_func(const void *_a, const void *_b);