RetroArch
Classes | Macros | Functions | Variables
etharp.h File Reference
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/ip.h"
Include dependency graph for etharp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  eth_addr
 
struct  eth_hdr
 
struct  etharp_hdr
 
struct  ethip_hdr
 

Macros

#define ETH_PAD_SIZE   0
 
#define ARP_TMR_INTERVAL   5000
 
#define ETHTYPE_ARP   0x0806
 
#define ETHTYPE_IP   0x0800
 

Functions

void etharp_init (void)
 
void etharp_tmr (void)
 
void etharp_ip_input (struct netif *netif, struct pbuf *p)
 
void etharp_arp_input (struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
 
err_t etharp_output (struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
 
err_t etharp_query (struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
 
err_t etharp_request (struct netif *netif, struct ip_addr *ipaddr)
 

Variables

PACK_STRUCT_BEGIN struct eth_addr PACK_STRUCT_STRUCT
 

Macro Definition Documentation

◆ ARP_TMR_INTERVAL

#define ARP_TMR_INTERVAL   5000

5 seconds period

◆ ETH_PAD_SIZE

#define ETH_PAD_SIZE   0

◆ ETHTYPE_ARP

#define ETHTYPE_ARP   0x0806

◆ ETHTYPE_IP

#define ETHTYPE_IP   0x0800

Function Documentation

◆ etharp_arp_input()

void etharp_arp_input ( struct netif netif,
struct eth_addr ethaddr,
struct pbuf p 
)

Responds to ARP requests to us. Upon ARP replies to us, add entry to cache send out queued IP packets. Updates cache with snooped address pairs.

Should be called for incoming ARP packets. The pbuf in the argument is freed by this function.

Parameters
netifThe lwIP network interface on which the ARP packet pbuf arrived.
pbufThe ARP packet that arrived on netif. Is freed by this function.
ethaddrEthernet address of netif.
Returns
NULL
See also
pbuf_free()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ etharp_init()

void etharp_init ( void  )

Initializes ARP module.

Here is the caller graph for this function:

◆ etharp_ip_input()

void etharp_ip_input ( struct netif netif,
struct pbuf p 
)

Updates the ARP table using the given IP packet.

Uses the incoming IP packet's source address to update the ARP cache for the local network. The function does not alter or free the packet. This function must be called before the packet p is passed to the IP layer.

Parameters
netifThe lwIP network interface on which the IP packet pbuf arrived.
pbufThe IP packet that arrived on netif.
Returns
NULL
See also
pbuf_free()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ etharp_output()

err_t etharp_output ( struct netif netif,
struct ip_addr ipaddr,
struct pbuf q 
)

Resolve and fill-in Ethernet address header for outgoing packet.

For IP multicast and broadcast, corresponding Ethernet addresses are selected and the packet is transmitted on the link.

For unicast addresses, the packet is submitted to etharp_query(). In case the IP address is outside the local network, the IP address of the gateway is used.

Parameters
netifThe lwIP network interface which the IP packet will be sent on.
ipaddrThe IP address of the packet destination.
pbufThe pbuf(s) containing the IP packet to be sent.
Returns
  • ERR_RTE No route to destination (no gateway to external networks), or the return type of either etharp_query() or netif->linkoutput().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ etharp_query()

err_t etharp_query ( struct netif netif,
struct ip_addr ipaddr,
struct pbuf q 
)

Send an ARP request for the given IP address and/or queue a packet.

If the IP address was not yet in the cache, a pending ARP cache entry is added and an ARP request is sent for the given address. The packet is queued on this entry.

If the IP address was already pending in the cache, a new ARP request is sent for the given address. The packet is queued on this entry.

If the IP address was already stable in the cache, and a packet is given, it is directly sent and no ARP request is sent out.

If the IP address was already stable in the cache, and no packet is given, an ARP request is sent out.

Parameters
netifThe lwIP network interface on which ipaddr must be queried for.
ipaddrThe IP address to be resolved.
qIf non-NULL, a pbuf that must be delivered to the IP address. q is not freed by this function.
Returns
  • ERR_BUF Could not make room for Ethernet header.
  • ERR_MEM Hardware address unknown, and no more ARP entries available to query for address or queue the packet.
  • ERR_MEM Could not queue packet due to memory shortage.
  • ERR_RTE No route to destination (no gateway to external networks).
  • ERR_ARG Non-unicast address given, those will not appear in ARP cache.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ etharp_request()

err_t etharp_request ( struct netif netif,
struct ip_addr ipaddr 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ etharp_tmr()

void etharp_tmr ( void  )

Clears expired entries in the ARP table.

This function should be called every ETHARP_TMR_INTERVAL microseconds (5 seconds), in order to expire entries in the ARP table.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ PACK_STRUCT_STRUCT

PACK_STRUCT_END PACK_STRUCT_BEGIN struct ethip_hdr PACK_STRUCT_STRUCT