1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright (C) 2013 Intel Corporation. All rights reserved.
7 Copyright (C) 2014 Tom Gundersen
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.
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.
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/>.
24 #include "sd-dhcp-server.h"
31 #include "dhcp-internal.h"
33 typedef struct DHCPClientId {
38 typedef struct DHCPLease {
39 DHCPClientId client_id;
47 struct sd_dhcp_server {
52 sd_event_source *receive_message;
63 Hashmap *leases_by_client_id;
64 DHCPLease **bound_leases;
67 typedef struct DHCPRequest {
68 /* received message */
72 DHCPClientId client_id;
79 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_server*, sd_dhcp_server_unref);
80 #define _cleanup_dhcp_server_unref_ _cleanup_(sd_dhcp_server_unrefp)
82 #define log_dhcp_server(client, fmt, ...) log_meta(LOG_DEBUG, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
84 int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
86 int dhcp_server_send_packet(sd_dhcp_server *server,
87 DHCPRequest *req, DHCPPacket *packet,
88 int type, size_t optoffset);
90 unsigned long client_id_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
91 int client_id_compare_func(const void *_a, const void *_b);