1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 Copyright © 2013 Intel Corporation. All rights reserved.
8 #include "sd-dhcp-server.h"
11 #include "dhcp-internal.h"
12 #include "ordered-set.h"
14 #include "time-util.h"
16 typedef 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_IPV6ADDRESS
,
23 _DHCP_RAW_OPTION_DATA_MAX
,
24 _DHCP_RAW_OPTION_DATA_INVALID
,
27 typedef struct DHCPClientId
{
32 typedef struct DHCPLease
{
33 DHCPClientId client_id
;
41 struct sd_dhcp_server
{
46 sd_event_source
*receive_message
;
60 DHCPServerData servers
[_SD_DHCP_LEASE_SERVER_TYPE_MAX
];
62 OrderedSet
*extra_options
;
63 OrderedSet
*vendor_options
;
67 Hashmap
*leases_by_client_id
;
68 DHCPLease
**bound_leases
;
69 DHCPLease invalid_lease
;
71 uint32_t max_lease_time
, default_lease_time
;
73 sd_dhcp_server_callback_t callback
;
74 void *callback_userdata
;
77 typedef struct DHCPRequest
{
78 /* received message */
82 DHCPClientId client_id
;
89 #define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, PROJECT_FILE, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
90 #define log_dhcp_server_errno(client, error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
92 int dhcp_server_handle_message(sd_dhcp_server
*server
, DHCPMessage
*message
,
94 int dhcp_server_send_packet(sd_dhcp_server
*server
,
95 DHCPRequest
*req
, DHCPPacket
*packet
,
96 int type
, size_t optoffset
);
98 void client_id_hash_func(const DHCPClientId
*p
, struct siphash
*state
);
99 int client_id_compare_func(const DHCPClientId
*a
, const DHCPClientId
*b
);