Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
DHCPv4 server

DHCPv4 server . More...

Typedefs

typedef 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.
 
typedef 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.
 

Functions

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_stop (struct net_if *iface)
 Stop DHCPv4 server instance on an iface.
 
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.
 
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.
 

Detailed Description

DHCPv4 server .

Since
3.6
Version
0.8.0

Typedef Documentation

◆ net_dhcpv4_lease_cb_t

typedef void(* net_dhcpv4_lease_cb_t) (struct net_if *iface, struct dhcpv4_addr_slot *lease, void *user_data)

#include <zephyr/net/dhcpv4_server.h>

Callback used while iterating over active DHCPv4 address leases.

Parameters
ifacePointer to the network interface
leasePointer to the DHPCv4 address lease slot
user_dataA valid pointer to user data or NULL

◆ net_dhcpv4_server_provider_cb_t

typedef 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)

#include <zephyr/net/dhcpv4_server.h>

Callback used to let application provide an address for a given client ID.

This function is called before assigning an address to a client, and lets the application override the address for a given client. If the callback returns 0, addr needs to be a valid address and will be assigned to the client. If the callback returns anything non-zero, the client will be assigned an address from the pool.

Parameters
ifacePointer to the network interface
client_idPointer to client requesting an address
addrAddress to be assigned to client
user_dataA valid pointer to user data or NULL

Function Documentation

◆ net_dhcpv4_server_foreach_lease()

int net_dhcpv4_server_foreach_lease ( struct net_if * iface,
net_dhcpv4_lease_cb_t cb,
void * user_data )

#include <zephyr/net/dhcpv4_server.h>

Iterate over all DHCPv4 address leases on a given network interface and call callback for each lease.

In case no network interface is provided (NULL interface pointer), will iterate over all interfaces running DHCPv4 server instance.

Parameters
ifacePointer to the network interface, can be NULL
cbUser-supplied callback function to call
user_dataUser specified data

◆ net_dhcpv4_server_set_provider_cb()

void net_dhcpv4_server_set_provider_cb ( net_dhcpv4_server_provider_cb_t cb,
void * user_data )

#include <zephyr/net/dhcpv4_server.h>

Set the callback used to provide addresses to the DHCP server.

Parameters
cbUser-supplied callback function to call
user_dataA valid pointer to user data or NULL

◆ net_dhcpv4_server_start()

int net_dhcpv4_server_start ( struct net_if * iface,
struct in_addr * base_addr )

#include <zephyr/net/dhcpv4_server.h>

Start DHCPv4 server instance on an iface.

Start DHCPv4 server on a given interface. The server will start listening for DHCPv4 Discover/Request messages on the interface and assign IPv4 addresses from the configured address pool accordingly.

Parameters
ifaceA valid pointer on an interface
base_addrFirst IPv4 address from the DHCPv4 address pool. The number of addresses in the pool is configured statically with Kconfig (CONFIG_NET_DHCPV4_SERVER_ADDR_COUNT).
Returns
0 on success, a negative error code otherwise.

◆ net_dhcpv4_server_stop()

int net_dhcpv4_server_stop ( struct net_if * iface)

#include <zephyr/net/dhcpv4_server.h>

Stop DHCPv4 server instance on an iface.

Stop DHCPv4 server on a given interface. DHCPv4 requests will no longer be handled on the interface, and all of the allocations are cleared.

Parameters
ifaceA valid pointer on an interface
Returns
0 on success, a negative error code otherwise.