1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #ifndef foosddhcpserverhfoo 3 #define foosddhcpserverhfoo 4 5 /*** 6 Copyright © 2013 Intel Corporation. All rights reserved. 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 21 #include <inttypes.h> 22 #include <netinet/in.h> 23 24 #include "sd-dhcp-lease.h" 25 #include "sd-dhcp-option.h" 26 #include "sd-event.h" 27 28 #include "_sd-common.h" 29 30 _SD_BEGIN_DECLARATIONS; 31 32 typedef struct sd_dhcp_server sd_dhcp_server; 33 34 enum { 35 SD_DHCP_SERVER_EVENT_LEASE_CHANGED = 1 << 0, 36 }; 37 38 int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex); 39 40 int sd_dhcp_server_set_ifname(sd_dhcp_server *server, const char *ifname); 41 int sd_dhcp_server_get_ifname(sd_dhcp_server *server, const char **ret); 42 43 sd_dhcp_server *sd_dhcp_server_ref(sd_dhcp_server *server); 44 sd_dhcp_server *sd_dhcp_server_unref(sd_dhcp_server *server); 45 46 int sd_dhcp_server_attach_event(sd_dhcp_server *client, sd_event *event, int64_t priority); 47 int sd_dhcp_server_detach_event(sd_dhcp_server *client); 48 sd_event *sd_dhcp_server_get_event(sd_dhcp_server *client); 49 50 typedef void (*sd_dhcp_server_callback_t)(sd_dhcp_server *server, uint64_t event, void *userdata); 51 52 int sd_dhcp_server_set_callback(sd_dhcp_server *server, sd_dhcp_server_callback_t cb, void *userdata); 53 54 int sd_dhcp_server_is_running(sd_dhcp_server *server); 55 56 int sd_dhcp_server_start(sd_dhcp_server *server); 57 int sd_dhcp_server_stop(sd_dhcp_server *server); 58 59 int sd_dhcp_server_configure_pool(sd_dhcp_server *server, const struct in_addr *address, unsigned char prefixlen, uint32_t offset, uint32_t size); 60 61 int sd_dhcp_server_set_boot_server_address(sd_dhcp_server *server, const struct in_addr *address); 62 int sd_dhcp_server_set_boot_server_name(sd_dhcp_server *server, const char *name); 63 int sd_dhcp_server_set_boot_filename(sd_dhcp_server *server, const char *filename); 64 int sd_dhcp_server_set_bind_to_interface(sd_dhcp_server *server, int enabled); 65 int sd_dhcp_server_set_timezone(sd_dhcp_server *server, const char *timezone); 66 int sd_dhcp_server_set_router(sd_dhcp_server *server, const struct in_addr *address); 67 68 int sd_dhcp_server_set_servers( 69 sd_dhcp_server *server, 70 sd_dhcp_lease_server_type_t what, 71 const struct in_addr addresses[], 72 size_t n_addresses); 73 74 int sd_dhcp_server_set_lpr(sd_dhcp_server *server, const struct in_addr lpr[], size_t n); 75 int sd_dhcp_server_set_dns(sd_dhcp_server *server, const struct in_addr dns[], size_t n); 76 int sd_dhcp_server_set_ntp(sd_dhcp_server *server, const struct in_addr ntp[], size_t n); 77 int sd_dhcp_server_set_sip(sd_dhcp_server *server, const struct in_addr sip[], size_t n); 78 int sd_dhcp_server_set_pop3(sd_dhcp_server *server, const struct in_addr pop3[], size_t n); 79 int sd_dhcp_server_set_smtp(sd_dhcp_server *server, const struct in_addr smtp[], size_t n); 80 81 int sd_dhcp_server_add_option(sd_dhcp_server *server, sd_dhcp_option *v); 82 int sd_dhcp_server_add_vendor_option(sd_dhcp_server *server, sd_dhcp_option *v); 83 int sd_dhcp_server_set_static_lease(sd_dhcp_server *server, const struct in_addr *address, uint8_t *client_id, size_t client_id_size); 84 85 int sd_dhcp_server_set_max_lease_time(sd_dhcp_server *server, uint32_t t); 86 int sd_dhcp_server_set_default_lease_time(sd_dhcp_server *server, uint32_t t); 87 88 int sd_dhcp_server_forcerenew(sd_dhcp_server *server); 89 90 int sd_dhcp_server_is_in_relay_mode(sd_dhcp_server *server); 91 int sd_dhcp_server_set_relay_target(sd_dhcp_server *server, const struct in_addr* address); 92 int sd_dhcp_server_set_relay_agent_information(sd_dhcp_server *server, const char* circuit_id, const char* remote_id); 93 94 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_server, sd_dhcp_server_unref); 95 96 _SD_END_DECLARATIONS; 97 98 #endif 99