]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp-server-internal.h
network: Fix split in `SendOption=` on client and server
[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 4/***
810adae9 5 Copyright © 2013 Intel Corporation. All rights reserved.
b44cd882
TG
6***/
7
b44cd882 8#include "sd-dhcp-server.h"
71d35b6b 9#include "sd-event.h"
b44cd882 10
71d35b6b 11#include "dhcp-internal.h"
87322b3a 12#include "hashmap.h"
b44cd882 13#include "log.h"
ca78ad1d 14#include "time-util.h"
be077570 15
564ca984
SS
16typedef enum DHCPRawOption {
17 DHCP_RAW_OPTION_DATA_UINT8,
18 DHCP_RAW_OPTION_DATA_UINT16,
19 DHCP_RAW_OPTION_DATA_UINT32,
20 DHCP_RAW_OPTION_DATA_STRING,
21 DHCP_RAW_OPTION_DATA_IPV4ADDRESS,
22 _DHCP_RAW_OPTION_DATA_MAX,
23 _DHCP_RAW_OPTION_DATA_INVALID,
24} DHCPRawOption;
25
87322b3a
TG
26typedef struct DHCPClientId {
27 size_t length;
9a0f246f 28 void *data;
87322b3a
TG
29} DHCPClientId;
30
31typedef struct DHCPLease {
32 DHCPClientId client_id;
33
34 be32_t address;
52750344
TG
35 be32_t gateway;
36 uint8_t chaddr[16];
87322b3a
TG
37 usec_t expiration;
38} DHCPLease;
39
b44cd882 40struct sd_dhcp_server {
3733eec3 41 unsigned n_ref;
b44cd882
TG
42
43 sd_event *event;
44 int event_priority;
ff734080
TG
45 sd_event_source *receive_message;
46 int fd;
8de4a226 47 int fd_raw;
3a864fe4 48
b3ec603c 49 int ifindex;
20af7091 50 be32_t address;
59b8f6b6 51 be32_t netmask;
99634696
TG
52 be32_t subnet;
53 uint32_t pool_offset;
54 uint32_t pool_size;
b44cd882 55
8eb9058d
LP
56 char *timezone;
57
299d578f
SS
58 struct in_addr *ntp, *dns, *sip;
59 unsigned n_ntp, n_dns, n_sip;
1a04db0f 60
7354900d
DW
61 OrderedHashmap *extra_options;
62 OrderedHashmap *vendor_options;
564ca984 63
77ff6022
CG
64 bool emit_router;
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
62c6bbbc
ZJS
85#define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, PROJECT_FILE, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
86#define log_dhcp_server_errno(client, error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
be077570
TG
87
88int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
89 size_t length);
969b009d
TG
90int dhcp_server_send_packet(sd_dhcp_server *server,
91 DHCPRequest *req, DHCPPacket *packet,
92 int type, size_t optoffset);
87322b3a 93
7a08d314
YW
94void client_id_hash_func(const DHCPClientId *p, struct siphash *state);
95int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b);