Network Component  
MDK Middleware for IPv4 and IPv6 Networking
 
Loading...
Searching...
No Matches
User Callbacks

Functions to notify the user application about events on the interface. More...

Functions

void netDHCP_Notify (uint32_t if_id, uint8_t option, const uint8_t *val, uint32_t len)
 Notify the user of DHCP event or extended DHCP option. [user-provided].
 
void netDHCP6_Notify (uint32_t if_id, uint8_t option, const uint8_t *val, uint32_t len)
 Notify the user of DHCPv6 event or extended DHCPv6 option. [user-provided].
 

Description

Functions to notify the user application about events on the interface.

An interface configuration change is reported by the function netDHCP_Notify for IPv4 and netDHCP6_Notify for IPv6. If you need to monitor the status of your connection, you must implement these functions.

Function Documentation

◆ netDHCP6_Notify()

void netDHCP6_Notify ( uint32_t  if_id,
uint8_t  option,
const uint8_t *  val,
uint32_t  len 
)

Notify the user of DHCPv6 event or extended DHCPv6 option. [user-provided].

Parameters
[in]if_idInterface identification (class and number).
[in]optionDHCPv6 option code.
[in]valpointer to option value.
[in]lenlength of option value in bytes.

The user function netDHCP6_Notify is called by the DHCPv6 client to signal IPv6 address changes or provide information about extended DHCPv6 options. Extended DHCP options are enabled in the Configuration files.

DHCPv6 client notifications require the implementation of the function netDHCP6_Notify in the user code.

The parameter if_id indicates the Interface Identification number.

The parameter option specifies the extended DHCPv6 option code.

The parameter val is a pointer to information provided by the DCHPv6 server replies (see table below).

The parameter len contains the length of the option value in bytes.

The following table shows the various option codes.

Option Code (option) Description val is
NET_DHCP6_OPTION_IP_ADDRESS IP address change event pointer to new dynamic IPv6 address (binary)
Note
  • This function is optional. It is not required for a default DHCPv6 client configuration.
  • The DHCPv6 service is supported only for IPv6 networks.

Code Example

// Process DCHPv6 server information
void netDHCP6_Notify (uint32_t if_id, uint8_t option, const uint8_t *val, uint32_t len) {
char ip_ascii[40];
switch (option) {
case NET_DHCP6_OPTION_IP_ADDRESS: // IPv6 address has changed
netIP_ntoa (NET_ADDR_IP6, &val[0], ip_ascii, sizeof(ip_ascii));
printf ("IP6 address: %s", ip_ascii);
break;
}
}

◆ netDHCP_Notify()

void netDHCP_Notify ( uint32_t  if_id,
uint8_t  option,
const uint8_t *  val,
uint32_t  len 
)

Notify the user of DHCP event or extended DHCP option. [user-provided].

Parameters
[in]if_idInterface identification (class and number).
[in]optionDHCP option code.
[in]valpointer to option value.
[in]lenlength of option value in bytes.

The user function netDHCP_Notify is called by the DHCP client to signal IP address changes or provide information about extended DHCP options. Extended DHCP options are enabled in the Configuration files and that allow request information such as a boot file name or NTP Server IP addresses.

DHCP client notifications require the implementation of the function netDHCP_Notify in the user code.

The parameter if_id indicates the Interface Identification number.

The parameter option specifies the extended DHCP option code.

The parameter val is a pointer to information provided by the DCHP server replies (see table below).

The parameter len contains the length of the option value in bytes.

The following table shows the various option codes.

Option Code (option) Description val is
NET_DHCP_OPTION_IP_ADDRESS IP address change event pointer to new dynamic IPv4 address (binary)
NET_DHCP_OPTION_NTP_SERVERS IP addresses of NTP Server pointer to list of NTP Server IPv4 addresses (binary)
NET_DHCP_OPTION_BOOTFILE_NAME Boot file name from DHCP server pointer to boot file name (ASCII string)
Note
  • This function is optional. It is not required for a default DHCP client configuration.
  • The DHCP service is supported only for IPv4 networks.

Code Example

// Process DCHP server information
void netDHCP_Notify (uint32_t if_id, uint8_t option, const uint8_t *val, uint32_t len) {
char ip_ascii[16];
uint32_t idx;
switch (option) {
case NET_DHCP_OPTION_IP_ADDRESS: // IP address has changed
netIP_ntoa (NET_ADDR_IP4, &val[0], ip_ascii, sizeof(ip_ascii));
printf ("IP address: %s", ip_ascii);
break;
case NET_DHCP_OPTION_NTP_SERVERS: // List of NTP Server IP addresses
printf ("NTP Server IP address list:\n");
idx = 0;
while ((idx+3) < len) {
netIP_ntoa (NET_ADDR_IP4, &val[idx], ip_ascii, sizeof(ip_ascii));
printf ("IP address: %s", ip_ascii);
idx += 4;
}
break;
case NET_DHCP_OPTION_BOOTFILE_NAME: // DCHP server boot file
printf ("Boot File: %s\n", val);
break;
}
}