From b0d0f60389ef689ff5850c09522e2d2cf321f780 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 31 Oct 2023 13:55:57 +0200 Subject: [PATCH] net: shell: Print device and wifi information for iface cmd If the interface is WiFi one, then print information about it. Also the device information is useful to know so print device name corresponding to the network interface. Signed-off-by: Jukka Rissanen --- subsys/net/lib/shell/iface.c | 3 +++ subsys/net/lib/shell/net_shell.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/subsys/net/lib/shell/iface.c b/subsys/net/lib/shell/iface.c index a072a715b1c..89983bd4839 100644 --- a/subsys/net/lib/shell/iface.c +++ b/subsys/net/lib/shell/iface.c @@ -243,6 +243,9 @@ static void iface_cb(struct net_if *iface, void *user_data) PR("MTU : %d\n", net_if_get_mtu(iface)); PR("Flags : %s\n", iface_flags2str(iface)); + PR("Device : %s (%p)\n", + net_if_get_device(iface) ? net_if_get_device(iface)->name : "", + net_if_get_device(iface)); #if defined(CONFIG_NET_L2_ETHERNET_MGMT) if (net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET)) { diff --git a/subsys/net/lib/shell/net_shell.c b/subsys/net/lib/shell/net_shell.c index 81191c77c20..19bab12e029 100644 --- a/subsys/net/lib/shell/net_shell.c +++ b/subsys/net/lib/shell/net_shell.c @@ -18,6 +18,8 @@ LOG_MODULE_REGISTER(net_shell, LOG_LEVEL_DBG); #include #include +#include + #include "common.h" #include "net_shell.h" @@ -142,6 +144,16 @@ const char *iface2str(struct net_if *iface, const char **extra) #ifdef CONFIG_NET_L2_ETHERNET if (net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET)) { + struct ethernet_context *eth_ctx = net_if_l2_data(iface); + + if (eth_ctx->eth_if_type == L2_ETH_IF_TYPE_WIFI) { + if (extra) { + *extra = "===="; + } + + return "WiFi"; + } + if (extra) { *extra = "========"; }