Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

DHCPv4. More...

Typedefs

typedef void(* net_dhcpv4_option_callback_handler_t) (struct net_dhcpv4_option_callback *cb, size_t length, enum net_dhcpv4_msg_type msg_type, struct net_if *iface)
 Define the application callback handler function signature.

Enumerations

enum  net_dhcpv4_msg_type {
  NET_DHCPV4_MSG_TYPE_DISCOVER = 1 , NET_DHCPV4_MSG_TYPE_OFFER = 2 , NET_DHCPV4_MSG_TYPE_REQUEST = 3 , NET_DHCPV4_MSG_TYPE_DECLINE = 4 ,
  NET_DHCPV4_MSG_TYPE_ACK = 5 , NET_DHCPV4_MSG_TYPE_NAK = 6 , NET_DHCPV4_MSG_TYPE_RELEASE = 7 , NET_DHCPV4_MSG_TYPE_INFORM = 8
}
 DHCPv4 message types. More...

Functions

static void net_dhcpv4_init_option_callback (struct net_dhcpv4_option_callback *callback, net_dhcpv4_option_callback_handler_t handler, uint8_t option, void *data, size_t max_length)
 Helper to initialize a struct net_dhcpv4_option_callback properly.
int net_dhcpv4_add_option_callback (struct net_dhcpv4_option_callback *cb)
 Add an application callback.
int net_dhcpv4_remove_option_callback (struct net_dhcpv4_option_callback *cb)
 Remove an application callback.
static void net_dhcpv4_init_option_vendor_callback (struct net_dhcpv4_option_callback *callback, net_dhcpv4_option_callback_handler_t handler, uint8_t option, void *data, size_t max_length)
 Helper to initialize a struct net_dhcpv4_option_callback for encapsulated vendor-specific options properly.
int net_dhcpv4_add_option_vendor_callback (struct net_dhcpv4_option_callback *cb)
 Add an application callback for encapsulated vendor-specific options.
int net_dhcpv4_remove_option_vendor_callback (struct net_dhcpv4_option_callback *cb)
 Remove an application callback for encapsulated vendor-specific options.
void net_dhcpv4_start (struct net_if *iface)
 Start DHCPv4 client on an iface.
void net_dhcpv4_stop (struct net_if *iface)
 Stop DHCPv4 client on an iface.
void net_dhcpv4_restart (struct net_if *iface)
 Restart DHCPv4 client on an iface.
int net_dhcpv4_set_reboot_hint (struct net_if *iface, const struct net_in_addr *requested_ip)
 Set the address requested in INIT-REBOOT.
const char * net_dhcpv4_msg_type_name (enum net_dhcpv4_msg_type msg_type)
 Return a text representation of the msg_type.

Detailed Description

DHCPv4.

Since
1.7
Version
0.8.0

Typedef Documentation

◆ net_dhcpv4_option_callback_handler_t

typedef void(* net_dhcpv4_option_callback_handler_t) (struct net_dhcpv4_option_callback *cb, size_t length, enum net_dhcpv4_msg_type msg_type, struct net_if *iface)

#include <dhcpv4.h>

Define the application callback handler function signature.

Parameters
cbOriginal struct net_dhcpv4_option_callback owning this handler
lengthThe length of data returned by the server. If this is greater than cb->max_length, only cb->max_length bytes will be available in cb->data
msg_typeType of DHCP message that triggered the callback
ifaceThe interface on which the DHCP message was received

Note: cb pointer can be used to retrieve private data through CONTAINER_OF() if original struct net_dhcpv4_option_callback is stored in another private structure.

Enumeration Type Documentation

◆ net_dhcpv4_msg_type

#include <dhcpv4.h>

DHCPv4 message types.

These enumerations represent the message type codes defined in @rfc{2132,section-9.6}, hence they should not be renumbered.

Additions, removals and reorders in this definition must be reflected within corresponding changes to net_dhcpv4_msg_type_name.

Enumerator
NET_DHCPV4_MSG_TYPE_DISCOVER 

Discover message.

NET_DHCPV4_MSG_TYPE_OFFER 

Offer message.

NET_DHCPV4_MSG_TYPE_REQUEST 

Request message.

NET_DHCPV4_MSG_TYPE_DECLINE 

Decline message.

NET_DHCPV4_MSG_TYPE_ACK 

Acknowledge message.

NET_DHCPV4_MSG_TYPE_NAK 

Negative acknowledge message.

NET_DHCPV4_MSG_TYPE_RELEASE 

Release message.

NET_DHCPV4_MSG_TYPE_INFORM 

Inform message.

Function Documentation

◆ net_dhcpv4_add_option_callback()

int net_dhcpv4_add_option_callback ( struct net_dhcpv4_option_callback * cb)

#include <dhcpv4.h>

Add an application callback.

Parameters
cbA valid application's callback structure pointer.
Returns
0 if successful, negative errno code on failure.

◆ net_dhcpv4_add_option_vendor_callback()

int net_dhcpv4_add_option_vendor_callback ( struct net_dhcpv4_option_callback * cb)

#include <dhcpv4.h>

Add an application callback for encapsulated vendor-specific options.

Parameters
cbA valid application's callback structure pointer.
Returns
0 if successful, negative errno code on failure.

◆ net_dhcpv4_init_option_callback()

void net_dhcpv4_init_option_callback ( struct net_dhcpv4_option_callback * callback,
net_dhcpv4_option_callback_handler_t handler,
uint8_t option,
void * data,
size_t max_length )
inlinestatic

#include <dhcpv4.h>

Helper to initialize a struct net_dhcpv4_option_callback properly.

Parameters
callbackA valid Application's callback structure pointer.
handlerA valid handler function pointer.
optionThe DHCP option the callback responds to.
dataA pointer to a buffer for max_length bytes.
max_lengthThe maximum length of the data returned.

◆ net_dhcpv4_init_option_vendor_callback()

void net_dhcpv4_init_option_vendor_callback ( struct net_dhcpv4_option_callback * callback,
net_dhcpv4_option_callback_handler_t handler,
uint8_t option,
void * data,
size_t max_length )
inlinestatic

#include <dhcpv4.h>

Helper to initialize a struct net_dhcpv4_option_callback for encapsulated vendor-specific options properly.

Parameters
callbackA valid Application's callback structure pointer.
handlerA valid handler function pointer.
optionThe DHCP encapsulated vendor-specific option the callback responds to.
dataA pointer to a buffer for max_length bytes.
max_lengthThe maximum length of the data returned.

◆ net_dhcpv4_msg_type_name()

const char * net_dhcpv4_msg_type_name ( enum net_dhcpv4_msg_type msg_type)

#include <dhcpv4.h>

Return a text representation of the msg_type.

Parameters
msg_typeThe msg_type to be converted to text
Returns
A text representation of msg_type

◆ net_dhcpv4_remove_option_callback()

int net_dhcpv4_remove_option_callback ( struct net_dhcpv4_option_callback * cb)

#include <dhcpv4.h>

Remove an application callback.

Parameters
cbA valid application's callback structure pointer.
Returns
0 if successful, negative errno code on failure.

◆ net_dhcpv4_remove_option_vendor_callback()

int net_dhcpv4_remove_option_vendor_callback ( struct net_dhcpv4_option_callback * cb)

#include <dhcpv4.h>

Remove an application callback for encapsulated vendor-specific options.

Parameters
cbA valid application's callback structure pointer.
Returns
0 if successful, negative errno code on failure.

◆ net_dhcpv4_restart()

void net_dhcpv4_restart ( struct net_if * iface)

#include <dhcpv4.h>

Restart DHCPv4 client on an iface.

Restart DHCPv4 client on a given interface. DHCPv4 client will restart the state machine without any of the initial delays used in start.

Parameters
ifaceA valid pointer on an interface

◆ net_dhcpv4_set_reboot_hint()

int net_dhcpv4_set_reboot_hint ( struct net_if * iface,
const struct net_in_addr * requested_ip )

#include <dhcpv4.h>

Set the address requested in INIT-REBOOT.

Seed the DHCPv4 client with a previously leased address, for example one restored from non-volatile storage, so that the next net_dhcpv4_start begins in INIT-REBOOT state and requests it directly instead of performing a full discovery. Must be called while the DHCPv4 client is stopped. Requires

CONFIG_NET_DHCPV4_INIT_REBOOT 

.

Parameters
ifaceDHCPv4 interface.
requested_ipAddress to request, or an unspecified address to clear the hint.
Return values
0On success.
-EINVALInvalid argument.
-EBUSYDHCPv4 client is active.
-ENOTSUPINIT-REBOOT support is disabled.

◆ net_dhcpv4_start()

void net_dhcpv4_start ( struct net_if * iface)

#include <dhcpv4.h>

Start DHCPv4 client on an iface.

Start DHCPv4 client on a given interface. DHCPv4 client will start negotiation for IPv4 address. Once the negotiation is success IPv4 address details will be added to interface.

Parameters
ifaceA valid pointer on an interface

◆ net_dhcpv4_stop()

void net_dhcpv4_stop ( struct net_if * iface)

#include <dhcpv4.h>

Stop DHCPv4 client on an iface.

Stop DHCPv4 client on a given interface. DHCPv4 client will remove all configuration obtained from a DHCP server from the interface and stop any further negotiation with the server.

Parameters
ifaceA valid pointer on an interface