mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 22:20:01 +08:00
boards/boardctl: Add BOARDIOC_MACADDR command
Add a new boardctl command BOARDIOC_MACADDR to retrieve the MAC address of the network interface. The board_macaddr function needs to be implemented by the board logic. Signed-off-by: daichuan <daichuan@xiaomi.com>
This commit is contained in:
@@ -110,6 +110,16 @@ Board information
|
||||
which to receive the board unique ID.
|
||||
|
||||
:dependencies: Board logic must provide the :c:func:`board_uniqueid` interface.
|
||||
|
||||
.. c:macro:: BOARDIOC_MACADDR
|
||||
|
||||
Get the network driver MAC address.
|
||||
|
||||
:Argument: A pointer to an instance of :c:struct:`boardioc_macaddr_s`.
|
||||
|
||||
:configuration: CONFIG_BOARDCTL_MACADDR
|
||||
|
||||
:dependencies: Board logic must provide the :c:func:`board_macaddr` interface.
|
||||
|
||||
Filesystems
|
||||
-----------
|
||||
|
||||
@@ -5322,6 +5322,14 @@ config BOARDCTL_START_CPU
|
||||
Architecture specific logic must provide the board_start_cpu()
|
||||
interface.
|
||||
|
||||
config BOARDCTL_MACADDR
|
||||
bool "Get network MAC address"
|
||||
default n
|
||||
---help---
|
||||
Enables support for the BOARDIOC_MACADDR boardctl() command.
|
||||
Architecture specific logic must provide the board_macaddr()
|
||||
interface.
|
||||
|
||||
config BOARDCTL_IOCTL
|
||||
bool "Board-specific boardctl() commands"
|
||||
default n
|
||||
|
||||
@@ -906,6 +906,25 @@ int boardctl(unsigned int cmd, uintptr_t arg)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_MACADDR
|
||||
/* CMD: BOARDIOC_MACADDR
|
||||
* DESCRIPTION: Get the network driver mac address.
|
||||
* ARG: A pointer to an instance of struct
|
||||
* boardioc_macaddr_s.
|
||||
* CONFIGURATION: CONFIG_BOARDCTL_MACADDR
|
||||
* DEPENDENCIES: Board logic must provide board_macaddr()
|
||||
*/
|
||||
|
||||
case BOARDIOC_MACADDR:
|
||||
{
|
||||
FAR struct boardioc_macaddr_s *req =
|
||||
(FAR struct boardioc_macaddr_s *)arg;
|
||||
|
||||
ret = board_macaddr(req->ifname, req->macaddr);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
{
|
||||
#ifdef CONFIG_BOARDCTL_IOCTL
|
||||
|
||||
@@ -635,6 +635,26 @@ void board_autoled_off(int led);
|
||||
# define board_autoled_off(led)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_macaddr
|
||||
*
|
||||
* Description:
|
||||
* Get the network driver mac address.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ifname - The interface name.
|
||||
* macaddr - The mac address.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_MACADDR
|
||||
int board_macaddr(FAR const char *ifname, FAR uint8_t *macaddr);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_initialize
|
||||
*
|
||||
|
||||
+15
-1
@@ -48,6 +48,11 @@
|
||||
# include <nuttx/spinlock.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_MACADDR
|
||||
# include <net/if.h>
|
||||
# include <nuttx/net/netdev.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL
|
||||
|
||||
/****************************************************************************
|
||||
@@ -216,6 +221,7 @@
|
||||
#define BOARDIOC_RESET_CAUSE _BOARDIOC(0x0015)
|
||||
#define BOARDIOC_IRQ_AFFINITY _BOARDIOC(0x0016)
|
||||
#define BOARDIOC_START_CPU _BOARDIOC(0x0017)
|
||||
#define BOARDIOC_MACADDR _BOARDIOC(0x0018)
|
||||
|
||||
/* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support.
|
||||
* In this case, all commands not recognized by boardctl() will be forwarded
|
||||
@@ -224,7 +230,7 @@
|
||||
* User defined board commands may begin with this value:
|
||||
*/
|
||||
|
||||
#define BOARDIOC_USER _BOARDIOC(0x0018)
|
||||
#define BOARDIOC_USER _BOARDIOC(0x0019)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
@@ -478,6 +484,14 @@ struct boardioc_reset_cause_s
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_MACADDR
|
||||
struct boardioc_macaddr_s
|
||||
{
|
||||
char ifname[IFNAMSIZ];
|
||||
uint8_t macaddr[RADIO_MAX_ADDRLEN];
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user