mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-12 21:41:28 +00:00
netifapi: add thread safe ARP APIs (task #14724)
This adds thread safe netifapi ARP cache APIs for add/remove
This commit is contained in:
parent
40a563cdd3
commit
c47d161d4a
@ -6,6 +6,9 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2017-11-14: Joel Cunningham
|
||||||
|
* netifapi: Add thread safe ARP cache APIs (task #14724)
|
||||||
|
|
||||||
2017-11-06: Axel Lin
|
2017-11-06: Axel Lin
|
||||||
* TCP: kill existing connections with a LOWER priority than the one currently being opened.
|
* TCP: kill existing connections with a LOWER priority than the one currently being opened.
|
||||||
Previous implementations also kill existing connections of the SAME priority.
|
Previous implementations also kill existing connections of the SAME priority.
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
|
#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
|
#include "lwip/etharp.h"
|
||||||
#include "lwip/netifapi.h"
|
#include "lwip/netifapi.h"
|
||||||
#include "lwip/memp.h"
|
#include "lwip/memp.h"
|
||||||
#include "lwip/priv/tcpip_priv.h"
|
#include "lwip/priv/tcpip_priv.h"
|
||||||
@ -147,6 +148,69 @@ netifapi_do_netif_common(struct tcpip_api_call_data *m)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LWIP_ARP && LWIP_IPV4
|
||||||
|
/**
|
||||||
|
* @ingroup netifapi_arp
|
||||||
|
* Add or update an entry in the ARP cache.
|
||||||
|
* For an update, ipaddr is used to find the cache entry.
|
||||||
|
*
|
||||||
|
* @param ipaddr IPv4 address of cache entry
|
||||||
|
* @param ethaddr hardware address mapped to ipaddr
|
||||||
|
* @param type type of ARP cache entry
|
||||||
|
* @return ERR_OK: entry added/updated, else error from err_t
|
||||||
|
*/
|
||||||
|
err_t
|
||||||
|
netifapi_arp_add(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, enum netifapi_arp_entry type)
|
||||||
|
{
|
||||||
|
err_t err;
|
||||||
|
|
||||||
|
/* We only support permanent entries currently */
|
||||||
|
LWIP_UNUSED_ARG(type);
|
||||||
|
|
||||||
|
#if ETHARP_SUPPORT_STATIC_ENTRIES && LWIP_TCPIP_CORE_LOCKING
|
||||||
|
LOCK_TCPIP_CORE();
|
||||||
|
err = etharp_add_static_entry(ipaddr, ethaddr);
|
||||||
|
UNLOCK_TCPIP_CORE();
|
||||||
|
#else
|
||||||
|
/* @todo add new vars to struct netifapi_msg and create a 'do' func */
|
||||||
|
LWIP_UNUSED_ARG(ipaddr);
|
||||||
|
LWIP_UNUSED_ARG(ethaddr);
|
||||||
|
err = ERR_VAL;
|
||||||
|
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES && LWIP_TCPIP_CORE_LOCKING */
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup netifapi_arp
|
||||||
|
* Remove an entry in the ARP cache identified by ipaddr
|
||||||
|
*
|
||||||
|
* @param ipaddr IPv4 address of cache entry
|
||||||
|
* @param type type of ARP cache entry
|
||||||
|
* @return ERR_OK: entry removed, else error from err_t
|
||||||
|
*/
|
||||||
|
err_t
|
||||||
|
netifapi_arp_remove(const ip4_addr_t *ipaddr, enum netifapi_arp_entry type)
|
||||||
|
{
|
||||||
|
err_t err;
|
||||||
|
|
||||||
|
/* We only support permanent entries currently */
|
||||||
|
LWIP_UNUSED_ARG(type);
|
||||||
|
|
||||||
|
#if ETHARP_SUPPORT_STATIC_ENTRIES && LWIP_TCPIP_CORE_LOCKING
|
||||||
|
LOCK_TCPIP_CORE();
|
||||||
|
err = etharp_remove_static_entry(ipaddr);
|
||||||
|
UNLOCK_TCPIP_CORE();
|
||||||
|
#else
|
||||||
|
/* @todo add new vars to struct netifapi_msg and create a 'do' func */
|
||||||
|
LWIP_UNUSED_ARG(ipaddr);
|
||||||
|
err = ERR_VAL;
|
||||||
|
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES && LWIP_TCPIP_CORE_LOCKING */
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
#endif /* LWIP_ARP && LWIP_IPV4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup netifapi_netif
|
* @ingroup netifapi_netif
|
||||||
* Call netif_add() in a thread-safe way by running that function inside the
|
* Call netif_add() in a thread-safe way by running that function inside the
|
||||||
|
@ -42,12 +42,26 @@
|
|||||||
#include "lwip/autoip.h"
|
#include "lwip/autoip.h"
|
||||||
#include "lwip/priv/tcpip_priv.h"
|
#include "lwip/priv/tcpip_priv.h"
|
||||||
#include "lwip/priv/api_msg.h"
|
#include "lwip/priv/api_msg.h"
|
||||||
|
#include "lwip/prot/ethernet.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* API for application */
|
/* API for application */
|
||||||
|
#if LWIP_ARP && LWIP_IPV4
|
||||||
|
/* Used for netfiapi_arp_* APIs */
|
||||||
|
enum netifapi_arp_entry {
|
||||||
|
NETIFAPI_ARP_PERM /* Permanent entry */
|
||||||
|
/* Other entry types can be added here */
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @ingroup netifapi_arp */
|
||||||
|
err_t netifapi_arp_add(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, enum netifapi_arp_entry type);
|
||||||
|
/** @ingroup netifapi_arp */
|
||||||
|
err_t netifapi_arp_remove(const ip4_addr_t *ipaddr, enum netifapi_arp_entry type);
|
||||||
|
#endif /* LWIP_ARP && LWIP_IPV4 */
|
||||||
|
|
||||||
err_t netifapi_netif_add(struct netif *netif,
|
err_t netifapi_netif_add(struct netif *netif,
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
|
const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
|
||||||
|
Loading…
Reference in New Issue
Block a user