ZG2100 Network interface source

Embed: (wiki syntax)

« Back to documentation index

ethernetif.c File Reference

ethernetif.c File Reference

Ethernet Interface Skeleton. More...

Go to the source code of this file.

Functions

static void ethernetif_input (struct netif *netif)
 This function should be called when a packet is ready to be read from the interface.
static void low_level_init (struct netif *netif)
 In this function, the hardware should be initialized.
static err_t low_level_output (struct netif *netif, struct pbuf *p)
 This function should do the actual transmission of the packet.
static struct pbuf * low_level_input (struct netif *netif)
 Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf.
err_t ethernetif_init (struct netif *netif)
 Should be called at the beginning of the program to set up the network interface.

Detailed Description

Ethernet Interface Skeleton.

Definition in file ethernetif.c.


Function Documentation

err_t ethernetif_init ( struct netif *  netif )

Should be called at the beginning of the program to set up the network interface.

It calls the function low_level_init() to do the actual setup of the hardware.

This function should be passed as a parameter to netif_add().

Parameters:
netifthe lwip network interface structure for this ethernetif
Returns:
ERR_OK if the loopif is initialized ERR_MEM if private data couldn't be allocated any other err_t on error

Definition at line 276 of file ethernetif.c.

static void ethernetif_input ( struct netif *  netif ) [static]

This function should be called when a packet is ready to be read from the interface.

It uses the function low_level_input() that should handle the actual reception of bytes from the network interface. Then the type of the received packet is determined and the appropriate input function is called.

Parameters:
netifthe lwip network interface structure for this ethernetif

Definition at line 224 of file ethernetif.c.

static void low_level_init ( struct netif *  netif ) [static]

In this function, the hardware should be initialized.

Called from ethernetif_init().

Parameters:
netifthe already initialized lwip network interface structure for this ethernetif

Definition at line 85 of file ethernetif.c.

static struct pbuf* low_level_input ( struct netif *  netif ) [static, read]

Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf.

Parameters:
netifthe lwip network interface structure for this ethernetif
Returns:
a pbuf filled with the received packet (including MAC header) NULL on memory error

Definition at line 162 of file ethernetif.c.

static err_t low_level_output ( struct netif *  netif,
struct pbuf *  p 
) [static]

This function should do the actual transmission of the packet.

The packet is contained in the pbuf that is passed to the function. This pbuf might be chained.

Parameters:
netifthe lwip network interface structure for this ethernetif
pthe MAC packet to send (e.g. IP packet including MAC addresses and type)
Returns:
ERR_OK if the packet could be sent an err_t value if the packet couldn't be sent
Note:
Returning ERR_MEM here if a DMA queue of your MAC is full can lead to strange results. You might consider waiting for space in the DMA queue to become availale since the stack doesn't retry to send a packet dropped because of memory failure (except for the TCP timers).

Definition at line 124 of file ethernetif.c.