Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
dhcpv4_server.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2024 Nordic Semiconductor ASA
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11#ifndef ZEPHYR_INCLUDE_NET_DHCPV4_SERVER_H_
12#define ZEPHYR_INCLUDE_NET_DHCPV4_SERVER_H_
13
14#include <zephyr/net/net_ip.h>
15#include <zephyr/sys_clock.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
32struct net_if;
33
34#define DHCPV4_CLIENT_ID_MAX_SIZE 20
35
36enum dhcpv4_server_addr_state {
37 DHCPV4_SERVER_ADDR_FREE,
38 DHCPV4_SERVER_ADDR_RESERVED,
39 DHCPV4_SERVER_ADDR_ALLOCATED,
40 DHCPV4_SERVER_ADDR_DECLINED,
41};
42
43struct dhcpv4_client_id {
44 uint8_t buf[DHCPV4_CLIENT_ID_MAX_SIZE];
45 uint8_t len;
46};
47
48struct dhcpv4_addr_slot {
49 enum dhcpv4_server_addr_state state;
50 struct dhcpv4_client_id client_id;
51 struct in_addr addr;
52 uint32_t lease_time;
53 k_timepoint_t expiry;
54};
55
72int net_dhcpv4_server_start(struct net_if *iface, struct in_addr *base_addr);
73
84int net_dhcpv4_server_stop(struct net_if *iface);
85
94typedef void (*net_dhcpv4_lease_cb_t)(struct net_if *iface,
95 struct dhcpv4_addr_slot *lease,
96 void *user_data);
97
110 void *user_data);
111
127typedef int (*net_dhcpv4_server_provider_cb_t)(struct net_if *iface,
128 const struct dhcpv4_client_id *client_id,
129 struct in_addr *addr,
130 void *user_data);
138 void *user_data);
139
144#ifdef __cplusplus
145}
146#endif
147
148#endif /* ZEPHYR_INCLUDE_NET_DHCPV4_SERVER_H_ */
void net_dhcpv4_server_set_provider_cb(net_dhcpv4_server_provider_cb_t cb, void *user_data)
Set the callback used to provide addresses to the DHCP server.
int net_dhcpv4_server_start(struct net_if *iface, struct in_addr *base_addr)
Start DHCPv4 server instance on an iface.
int(* net_dhcpv4_server_provider_cb_t)(struct net_if *iface, const struct dhcpv4_client_id *client_id, struct in_addr *addr, void *user_data)
Callback used to let application provide an address for a given client ID.
Definition dhcpv4_server.h:127
int net_dhcpv4_server_foreach_lease(struct net_if *iface, net_dhcpv4_lease_cb_t cb, void *user_data)
Iterate over all DHCPv4 address leases on a given network interface and call callback for each lease.
int net_dhcpv4_server_stop(struct net_if *iface)
Stop DHCPv4 server instance on an iface.
void(* net_dhcpv4_lease_cb_t)(struct net_if *iface, struct dhcpv4_addr_slot *lease, void *user_data)
Callback used while iterating over active DHCPv4 address leases.
Definition dhcpv4_server.h:94
IPv6 and IPv4 definitions.
state
Definition parser_state.h:29
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
IPv4 address struct.
Definition net_ip.h:154
Kernel timepoint type.
Definition sys_clock.h:219
Network Interface structure.
Definition net_if.h:690
Variables needed for system clock.