#include "lwip/opt.h"
#include "lwip/inet.h"
#include "lwip/ip.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/dhcp.h"
#include "lwip/autoip.h"
#include "netif/etharp.h"
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | etharp_entry |
Defines | |
#define | ARP_MAXAGE 240 |
#define | ARP_MAXPENDING 2 |
#define | HWTYPE_ETHERNET 1 |
#define | ARPH_HWLEN(hdr) (ntohs((hdr)->_hwlen_protolen) >> 8) |
#define | ARPH_PROTOLEN(hdr) (ntohs((hdr)->_hwlen_protolen) & 0xff) |
#define | ARPH_HWLEN_SET(hdr, len) (hdr)->_hwlen_protolen = htons(ARPH_PROTOLEN(hdr) | ((len) << 8)) |
#define | ARPH_PROTOLEN_SET(hdr, len) (hdr)->_hwlen_protolen = htons((len) | (ARPH_HWLEN(hdr) << 8)) |
#define | ETHARP_TRY_HARD 1 |
#define | ETHARP_FIND_ONLY 2 |
Enumerations | |
enum | etharp_state { ETHARP_STATE_EMPTY = 0, ETHARP_STATE_PENDING, ETHARP_STATE_STABLE } |
Functions | |
void | etharp_tmr (void) |
s8_t | etharp_find_addr (struct netif *netif, struct ip_addr *ipaddr, struct eth_addr **eth_ret, struct ip_addr **ip_ret) |
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 pbuf *q, struct ip_addr *ipaddr) |
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) |
err_t | ethernet_input (struct pbuf *p, struct netif *netif) |
Variables | |
struct eth_addr | ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}} |
struct eth_addr | ethzero = {{0,0,0,0,0,0}} |
Address Resolution Protocol module for IP over Ethernet
Functionally, ARP is divided into two parts. The first maps an IP address to a physical address when sending a packet, and the second part answers requests from other machines for our physical address.
This implementation complies with RFC 826 (Ethernet ARP). It supports Gratuitious ARP from RFC3220 (IP Mobility Support for IPv4) section 4.6 if an interface calls etharp_gratuitous(our_netif) upon address change.
Definition in file etharp.c.
#define ARP_MAXAGE 240 |
#define ARP_MAXPENDING 2 |
#define ETHARP_TRY_HARD 1 |
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.
netif | The lwIP network interface on which the ARP packet pbuf arrived. | |
ethaddr | Ethernet address of netif. | |
p | The ARP packet that arrived on netif. Is freed by this function. |
Definition at line 625 of file etharp.c.
s8_t etharp_find_addr | ( | struct netif * | netif, | |
struct ip_addr * | ipaddr, | |||
struct eth_addr ** | eth_ret, | |||
struct ip_addr ** | ip_ret | |||
) |
Finds (stable) ethernet/IP address pair from ARP table using interface and IP address index.
netif | points to interface index | |
ipaddr | points to the (network order) IP address index | |
eth_ret | points to return pointer | |
ip_ret | points to return pointer |
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.
netif | The lwIP network interface on which the IP packet pbuf arrived. | |
p | The IP packet that arrived on netif. |
Resolve and fill-in Ethernet address header for outgoing IP 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.
netif | The lwIP network interface which the IP packet will be sent on. | |
q | The pbuf(s) containing the IP packet to be sent. | |
ipaddr | The IP address of the packet destination. |
Definition at line 801 of file etharp.c.
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.
netif | The lwIP network interface on which ipaddr must be queried for. | |
ipaddr | The IP address to be resolved. | |
q | If non-NULL, a pbuf that must be delivered to the IP address. q is not freed by this function. |
Definition at line 892 of file etharp.c.
Send an ARP request packet asking for ipaddr.
netif | the lwip network interface on which to send the request | |
ipaddr | the IP address for which to ask |
void etharp_tmr | ( | void | ) |
Process received ethernet frames. Using this function instead of directly calling ip_input and passing ARP frames through etharp in ethernetif_input, the ARP cache is protected from concurrent access.
p | the recevied packet, p->payload pointing to the ethernet header | |
netif | the network interface on which the packet was received |
Definition at line 1147 of file etharp.c.