mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-19 19:44:35 +08:00
cmd_arp: add device input for arp interface
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
* Parameters:
|
||||
* inaddr The IPv4 address to use in the mapping
|
||||
* macaddr The Ethernet MAC address to use in the mapping
|
||||
* ifname The Network device name
|
||||
*
|
||||
* Return:
|
||||
* 0 on success; a negated errno value on failure.
|
||||
@@ -60,7 +61,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
int netlib_set_arpmapping(FAR const struct sockaddr_in *inaddr,
|
||||
FAR const uint8_t *macaddr)
|
||||
FAR const uint8_t *macaddr, FAR const char *ifname)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
@@ -75,6 +76,15 @@ int netlib_set_arpmapping(FAR const struct sockaddr_in *inaddr,
|
||||
|
||||
req.arp_ha.sa_family = ARPHRD_ETHER;
|
||||
memcpy(&req.arp_ha.sa_data, macaddr, ETHER_ADDR_LEN);
|
||||
if (ifname != NULL)
|
||||
{
|
||||
strlcpy((FAR char *)&req.arp_dev, ifname,
|
||||
sizeof(req.arp_dev));
|
||||
}
|
||||
else
|
||||
{
|
||||
req.arp_dev[0] = '\0';
|
||||
}
|
||||
|
||||
ret = ioctl(sockfd, SIOCSARP, (unsigned long)((uintptr_t)&req));
|
||||
if (ret < 0)
|
||||
|
Reference in New Issue
Block a user