Skip to content

Commit e979139

Browse files
committed
boards/boardctl: Add BOARDIOC_NET_GETMAC command
This commit adds a new boardctl command BOARDIOC_NET_GETMAC to retrieve the MAC address of the network interface. The board_get_netmac function needs to be implemented by the board logic. Signed-off-by: daichuan <daichuan@xiaomi.com>
1 parent e143acf commit e979139

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

boards/boardctl.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,19 @@ int boardctl(unsigned int cmd, uintptr_t arg)
906906
break;
907907
#endif
908908

909+
/* CMD: BOARDIOC_NET_GETMAC
910+
* DESCRIPTION: Get the network driver mac address.
911+
* ARG: The mac address.
912+
* CONFIGURATION: None
913+
* DEPENDENCIES: Board logic must provide board_get_netmac()
914+
*/
915+
916+
case BOARDIOC_NET_GETMAC:
917+
{
918+
ret = board_get_netmac(0, (FAR uint8_t *)arg);
919+
}
920+
break;
921+
909922
default:
910923
{
911924
#ifdef CONFIG_BOARDCTL_IOCTL

include/nuttx/board.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,24 @@ void board_autoled_off(int led);
635635
# define board_autoled_off(led)
636636
#endif
637637

638+
/****************************************************************************
639+
* Name: board_get_netmac
640+
*
641+
* Description:
642+
* Get the network driver mac address.
643+
*
644+
* Input Parameters:
645+
* iface - The interface index.
646+
* mac - The mac address.
647+
*
648+
* Returned Value:
649+
* Zero (OK) is returned on success; a negated errno value is returned on
650+
* any failure.
651+
*
652+
****************************************************************************/
653+
654+
int board_get_netmac(int iface, FAR uint8_t *mac);
655+
638656
/****************************************************************************
639657
* Name: board_userled_initialize
640658
*

include/sys/boardctl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
#define BOARDIOC_RESET_CAUSE _BOARDIOC(0x0015)
217217
#define BOARDIOC_IRQ_AFFINITY _BOARDIOC(0x0016)
218218
#define BOARDIOC_START_CPU _BOARDIOC(0x0017)
219+
#define BOARDIOC_NET_GETMAC _BOARDIOC(0x0018)
219220

220221
/* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support.
221222
* In this case, all commands not recognized by boardctl() will be forwarded
@@ -224,7 +225,7 @@
224225
* User defined board commands may begin with this value:
225226
*/
226227

227-
#define BOARDIOC_USER _BOARDIOC(0x0018)
228+
#define BOARDIOC_USER _BOARDIOC(0x0019)
228229

229230
/****************************************************************************
230231
* Public Type Definitions

0 commit comments

Comments
 (0)