Skip to content

Commit c120179

Browse files
jukkarkartben
authored andcommitted
net: shell: Print interface status for iface command
Print interface status information for "net iface" command. This is useful information when debugging connectivity issues. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 9d20c5c commit c120179

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

subsys/net/ip/net_if.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5487,9 +5487,8 @@ static void notify_iface_down(struct net_if *iface)
54875487
}
54885488
}
54895489

5490-
static inline const char *net_if_oper_state2str(enum net_if_oper_state state)
5490+
const char *net_if_oper_state2str(enum net_if_oper_state state)
54915491
{
5492-
#if CONFIG_NET_IF_LOG_LEVEL >= LOG_LEVEL_DBG
54935492
switch (state) {
54945493
case NET_IF_OPER_UNKNOWN:
54955494
return "UNKNOWN";
@@ -5510,11 +5509,6 @@ static inline const char *net_if_oper_state2str(enum net_if_oper_state state)
55105509
}
55115510

55125511
return "<invalid>";
5513-
#else
5514-
ARG_UNUSED(state);
5515-
5516-
return "";
5517-
#endif /* CONFIG_NET_IF_LOG_LEVEL >= LOG_LEVEL_DBG */
55185512
}
55195513

55205514
static void update_operational_state(struct net_if *iface)

subsys/net/ip/net_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern void net_if_init(void);
5959
extern void net_if_post_init(void);
6060
extern void net_if_stats_reset(struct net_if *iface);
6161
extern void net_if_stats_reset_all(void);
62+
extern const char *net_if_oper_state2str(enum net_if_oper_state state);
6263
extern void net_process_rx_packet(struct net_pkt *pkt);
6364
extern void net_process_tx_packet(struct net_pkt *pkt);
6465

subsys/net/lib/shell/iface.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ static void iface_cb(struct net_if *iface, void *user_data)
274274
net_if_get_device(iface) ? net_if_get_device(iface)->name : "<?>",
275275
net_if_get_device(iface));
276276

277+
PR("Status : oper=%s, admin=%s, carrier=%s\n",
278+
net_if_oper_state2str(net_if_oper_state(iface)),
279+
net_if_is_admin_up(iface) ? "UP" : "DOWN",
280+
net_if_is_carrier_ok(iface) ? "ON" : "OFF");
281+
277282
#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
278283
if (net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET)) {
279284
count = 0;

0 commit comments

Comments
 (0)