summaryrefslogtreecommitdiffstatsabout
path: root/SylixOS
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2020-10-08 11:35:19 (GMT)
committer Hanhui <hanhui@acoinfo.com>2020-10-08 11:35:19 (GMT)
commit671bf5466dc97c1e2c06ffb879ef6d3d408420db (patch)
treee9901b026ec5b7a56264e71ac751ab0a25374f5b /SylixOS
parent4863ccb8e4f8fdfe2a854c2cd52a13c7ec520c91 (diff)
downloadlibsylixos-671bf5466dc97c1e2c06ffb879ef6d3d408420db.zip
libsylixos-671bf5466dc97c1e2c06ffb879ef6d3d408420db.tar.gz
libsylixos-671bf5466dc97c1e2c06ffb879ef6d3d408420db.tar.bz2
Add ARP table deletion option.
Diffstat (limited to 'SylixOS')
-rw-r--r--SylixOS/include/network/lwip/etharp.h2
-rw-r--r--SylixOS/include/network/lwip/netifapi.h2
-rw-r--r--SylixOS/net/lwip/lwip_arpctl.c49
-rw-r--r--SylixOS/net/lwip/lwip_shell.c2
-rw-r--r--SylixOS/net/lwip/src/api/netifapi.c4
-rw-r--r--SylixOS/net/lwip/src/core/ipv4/etharp.c4
6 files changed, 46 insertions, 17 deletions
diff --git a/SylixOS/include/network/lwip/etharp.h b/SylixOS/include/network/lwip/etharp.h
index 3a99f8d..097fbbf 100644
--- a/SylixOS/include/network/lwip/etharp.h
+++ b/SylixOS/include/network/lwip/etharp.h
@@ -95,7 +95,7 @@ err_t etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, str
#if ETHARP_SUPPORT_STATIC_ENTRIES
err_t etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr);
-err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr, u8_t force /* SylixOS Add force delete */);
+err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr, struct netif *netif, u8_t force /* SylixOS Add netif and force parameter */);
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
#ifdef SYLIXOS /* SylixOS Add Traversal ARP table */
diff --git a/SylixOS/include/network/lwip/netifapi.h b/SylixOS/include/network/lwip/netifapi.h
index d080995..c7ffdb4 100644
--- a/SylixOS/include/network/lwip/netifapi.h
+++ b/SylixOS/include/network/lwip/netifapi.h
@@ -63,7 +63,7 @@ enum netifapi_arp_entry {
/** @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);
+err_t netifapi_arp_remove(const ip4_addr_t *ipaddr, struct netif *netif /* SylixOS Add netif parameter */, enum netifapi_arp_entry type);
#ifdef SYLIXOS /* SylixOS Add this safe function */
void netifapi_arp_traversal(struct netif *netif, int (*callback)(), void *arg0, void *arg1,
diff --git a/SylixOS/net/lwip/lwip_arpctl.c b/SylixOS/net/lwip/lwip_arpctl.c
index def95ea..011628f 100644
--- a/SylixOS/net/lwip/lwip_arpctl.c
+++ b/SylixOS/net/lwip/lwip_arpctl.c
@@ -224,8 +224,8 @@ static INT __ifArpGet (struct arpreq *parpreq)
_ErrorHandle(EPROTOTYPE);
return (PX_ERROR);
}
+
ipaddr.addr = ((struct sockaddr_in *)&parpreq->arp_pa)->sin_addr.s_addr;
-
netif = LW_NULL;
netifapi_arp_traversal(LW_NULL, __ifArpSearch, &ipaddr, &netif, &arp_flags,
&ethaddr, LW_NULL, LW_NULL);
@@ -252,23 +252,52 @@ static INT __ifArpGet (struct arpreq *parpreq)
*********************************************************************************************************/
static INT __ifArpDel (const struct arpreq *parpreq)
{
- err_t err;
- ip4_addr_t ipaddr;
+ struct netif *netif;
+ err_t err;
+ ip4_addr_t ipaddr;
if (parpreq->arp_pa.sa_family != AF_INET) {
_ErrorHandle(EPROTOTYPE);
return (PX_ERROR);
}
+
ipaddr.addr = ((struct sockaddr_in *)&parpreq->arp_pa)->sin_addr.s_addr;
-
- if (parpreq->arp_flags & ATF_PERM) {
- err = netifapi_arp_remove(&ipaddr, NETIFAPI_ARP_PERM);
+ if (parpreq->arp_dev[0] == '\0') {
+ netif = netif_find(parpreq->arp_dev);
+ if (!netif) {
+ _ErrorHandle(EHOSTUNREACH);
+ return (PX_ERROR);
+ }
+
} else {
- err = netifapi_arp_remove(&ipaddr, NETIFAPI_ARP_COM);
+ netif = LW_NULL;
}
- if (err) {
- _ErrorHandle(err_to_errno(err));
- return (PX_ERROR);
+
+
+ if (ipaddr.addr == INADDR_ANY) {
+ if (netif) {
+ if (netif->flags & NETIF_FLAG_ETHARP) {
+ netifapi_arp_cleanup(netif);
+ }
+
+ } else {
+ NETIF_FOREACH(netif) {
+ if (netif->flags & NETIF_FLAG_ETHARP) {
+ netifapi_arp_cleanup(netif);
+ }
+ }
+ }
+
+ } else {
+ if (parpreq->arp_flags & ATF_PERM) {
+ err = netifapi_arp_remove(&ipaddr, netif, NETIFAPI_ARP_PERM);
+ } else {
+ err = netifapi_arp_remove(&ipaddr, netif, NETIFAPI_ARP_COM);
+ }
+ if (err) {
+ _ErrorHandle(err_to_errno(err));
+ return (PX_ERROR);
+ }
}
return (ERROR_NONE);
diff --git a/SylixOS/net/lwip/lwip_shell.c b/SylixOS/net/lwip/lwip_shell.c
index eaaebc3..188e060 100644
--- a/SylixOS/net/lwip/lwip_shell.c
+++ b/SylixOS/net/lwip/lwip_shell.c
@@ -1096,7 +1096,7 @@ static INT __tshellArp (INT iArgC, PCHAR *ppcArgV)
return (-ERROR_TSHELL_EPARAM);
}
- err = netifapi_arp_remove(&ipaddr, NETIFAPI_ARP_PERM);
+ err = netifapi_arp_remove(&ipaddr, LW_NULL, NETIFAPI_ARP_PERM);
return (err ? PX_ERROR : ERROR_NONE);
} else {
diff --git a/SylixOS/net/lwip/src/api/netifapi.c b/SylixOS/net/lwip/src/api/netifapi.c
index f60c993..4cd4363 100644
--- a/SylixOS/net/lwip/src/api/netifapi.c
+++ b/SylixOS/net/lwip/src/api/netifapi.c
@@ -194,7 +194,7 @@ netifapi_arp_add(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, enum netifa
* @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)
+netifapi_arp_remove(const ip4_addr_t *ipaddr, struct netif *netif /* SylixOS Add netif parameter */, enum netifapi_arp_entry type)
{
err_t err;
@@ -203,7 +203,7 @@ netifapi_arp_remove(const ip4_addr_t *ipaddr, enum netifapi_arp_entry type)
#if ETHARP_SUPPORT_STATIC_ENTRIES && LWIP_TCPIP_CORE_LOCKING
LOCK_TCPIP_CORE();
- err = etharp_remove_static_entry(ipaddr, type == NETIFAPI_ARP_COM ? 1 : 0 /* SylixOS Add force delete */);
+ err = etharp_remove_static_entry(ipaddr, netif, type == NETIFAPI_ARP_COM ? 1 : 0 /* SylixOS Add force delete */);
UNLOCK_TCPIP_CORE();
#else
/* @todo add new vars to struct netifapi_msg and create a 'do' func */
diff --git a/SylixOS/net/lwip/src/core/ipv4/etharp.c b/SylixOS/net/lwip/src/core/ipv4/etharp.c
index c2463e4..4eea947 100644
--- a/SylixOS/net/lwip/src/core/ipv4/etharp.c
+++ b/SylixOS/net/lwip/src/core/ipv4/etharp.c
@@ -655,7 +655,7 @@ etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr)
* ERR_ARG: entry wasn't a static entry but a dynamic one
*/
err_t
-etharp_remove_static_entry(const ip4_addr_t *ipaddr, u8_t force /* SylixOS Add force delete */)
+etharp_remove_static_entry(const ip4_addr_t *ipaddr, struct netif *netif, u8_t force /* SylixOS Add netif and force parameter */)
{
s16_t i;
LWIP_ASSERT_CORE_LOCKED();
@@ -663,7 +663,7 @@ etharp_remove_static_entry(const ip4_addr_t *ipaddr, u8_t force /* SylixOS Add f
ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr)));
/* find or create ARP entry */
- i = etharp_find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY, NULL, NULL);
+ i = etharp_find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY, netif, NULL);
/* bail out if no entry could be found */
if (i < 0) {
return (err_t)i;