Network Component  Version 7.19.0
MDK Middleware for IPv4 and IPv6 Networking

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

Functions

void netETH_Notify (uint32_t if_num, netETH_Event event, uint32_t val)
 Notify the user of Ethernet link state change event. [user-provided]. More...
 
void netETH_ReceiveRaw (uint32_t if_num, const uint8_t *buf, uint32_t len)
 Receive raw Ethernet data. [user-provided]. More...
 

Description

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

An Ethernet link state change is reported by the function netETH_Notify. If you need to monitor the status of your connection, you must implement this function.

Function Documentation

◆ netETH_Notify()

void netETH_Notify ( uint32_t  if_num,
netETH_Event  event,
uint32_t  val 
)

Notify the user of Ethernet link state change event. [user-provided].

Parameters
[in]if_numEthernet interface number.
[in]eventEthernet link state event as defined in netETH_Event.
[in]valpointer to the event value.
Returns
none.

The callback function netETH_Notify polls the link status and notifies the user about state changes.

The argument if_num specifies the Ethernet Interface for which the link status has changed.

The argument event specifies link event, as defined in netETH_Event enumeration:

Event Description
netETH_LinkDown Link down
netETH_LinkUp Link up; val=link_info
netETH_Wakeup Wake-up (on Magic Packet)
netETH_TimerAlarm Timer Alarm (PTP)

The argument val stores the value of the link event.

Code Example

void netETH_Notify (uint32_t if_num, netETH_Event event, uint32_t val) {
switch (event) {
printf ("Link is down\n");
break;
printf ("Link is up\n");
info = (NET_ETH_LINK_INFO *)&val;
switch (info->speed) {
case 0:
printf ("10 MBit\n");
break;
case 1:
printf ("100 MBit\n");
break;
case 2:
printf ("1 GBit\n");
break;
}
switch (info->duplex) {
case 0:
printf ("Half duplex\n");
break;
case 1:
printf ("Full duplex\n");
break;
}
break;
printf ("Wakeup frame received\n");
break;
printf ("Timer alarm\n");
break;
}
}

◆ netETH_ReceiveRaw()

void netETH_ReceiveRaw ( uint32_t  if_num,
const uint8_t *  buf,
uint32_t  len 
)

Receive raw Ethernet data. [user-provided].

Parameters
[in]if_numEthernet interface number.
[in]bufbuffer containing the received data.
[in]lenlength of received data in bytes.
Returns
none.

The user function netETH_ReceiveRaw is called by the Ethernet interface to provide raw Ethernet frames to the user. The data contains Ethernet header and payload data. This allows the users to implement additional Ethernet protocols, which are not supported by the network library.

The network library calls this function, if the Ethernet Type is not supported. For supported Ethernet Types: ARP (0x0806), IPv4 (0x0800) and IPv6 (0x86dd), the function is not called.

The argument if_num specifies the Ethernet Interface which received the frame.

The argument buf points to a buffer containing the received Ethernet frame data.

The argument len specifies the number of received data bytes.

Note
  • This function is optional. It is not required for a default Ethernet interface configuration.

Code Example

void netETH_ReceiveRaw (uint32_t if_num, const uint8_t *buf, uint32_t len) {
uint16_t ether_type;
ether_type = (buf[12] << 8) | buf[13];
if (ether_type == 0x888E) { // EAPoL protocol
// Process the frame here
}
}