mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-20 04:26:04 +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 query
|
||||
* macaddr The location to return the mapped Ethernet MAC address
|
||||
* ifname The Network device name
|
||||
*
|
||||
* Return:
|
||||
* 0 on success; a negated errno value on failure.
|
||||
@@ -60,7 +61,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
int netlib_get_arpmapping(FAR const struct sockaddr_in *inaddr,
|
||||
FAR uint8_t *macaddr)
|
||||
FAR uint8_t *macaddr, FAR const char *ifname)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
@@ -72,6 +73,16 @@ int netlib_get_arpmapping(FAR const struct sockaddr_in *inaddr,
|
||||
struct arpreq req;
|
||||
|
||||
memcpy(&req.arp_pa, inaddr, 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, SIOCGARP, (unsigned long)((uintptr_t)&req));
|
||||
if (ret < 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user