cmd_arp: add device input for arp interface

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2022-12-06 13:42:15 +08:00
committed by Xiang Xiao
parent 11f0c2af43
commit df3121213e
7 changed files with 105 additions and 44 deletions

View File

@@ -51,13 +51,15 @@
*
* Parameters:
* inaddr The IPv4 address to use in the query
* ifname The Network device name
*
* Return:
* 0 on success; a negated errno value on failure.
*
****************************************************************************/
int netlib_del_arpmapping(FAR const struct sockaddr_in *inaddr)
int netlib_del_arpmapping(FAR const struct sockaddr_in *inaddr,
FAR const char *ifname)
{
int ret = -EINVAL;
@@ -70,6 +72,15 @@ int netlib_del_arpmapping(FAR const struct sockaddr_in *inaddr)
memcpy(&req.arp_pa, inaddr, sizeof(struct sockaddr_in));
memset(&req.arp_ha, 0, sizeof(struct sockaddr_in));
if (ifname != NULL)
{
strlcpy((FAR char *)&req.arp_dev, ifname,
sizeof(req.arp_dev));
}
else
{
req.arp_dev[0] = '\0';
}
ret = ioctl(sockfd, SIOCDARP, (unsigned long)((uintptr_t)&req));
if (ret < 0)