Skip to content

Commit e109a27

Browse files
jukkarkartben
authored andcommitted
net: shell: events: Print event id for unknown events
To simplify debugging what event code is missing from the events shell module, print also event id for the for unknown events. This way it is a bit easier to figure out what the unknown event is. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent b2dcaa8 commit e109a27

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

subsys/net/lib/shell/events.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static struct net_mgmt_event_callback l4_cb;
3939
static struct k_thread event_mon;
4040
static K_THREAD_STACK_DEFINE(event_mon_stack, CONFIG_NET_MGMT_EVENT_MONITOR_STACK_SIZE);
4141

42+
static const char unknown_event_str[] = "<unknown event>";
43+
4244
struct event_msg {
4345
struct net_if *iface;
4446
size_t len;
@@ -75,7 +77,7 @@ static char *get_l2_desc(struct event_msg *msg,
7577
const char **desc, const char **desc2,
7678
char *extra_info, size_t extra_info_len)
7779
{
78-
static const char *desc_unknown = "<unknown event>";
80+
static const char *desc_unknown = unknown_event_str;
7981
char *info = NULL;
8082

8183
#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
@@ -137,7 +139,7 @@ static char *get_l3_desc(struct event_msg *msg,
137139
const char **desc, const char **desc2,
138140
char *extra_info, size_t extra_info_len)
139141
{
140-
static const char *desc_unknown = "<unknown event>";
142+
static const char *desc_unknown = unknown_event_str;
141143
char *info = NULL;
142144

143145
#if defined(CONFIG_NET_PMTU)
@@ -359,7 +361,7 @@ static char *get_l3_desc(struct event_msg *msg,
359361

360362
static const char *get_l4_desc(uint32_t event)
361363
{
362-
static const char *desc = "<unknown event>";
364+
static const char *desc = unknown_event_str;
363365

364366
switch (event) {
365367
case NET_EVENT_L4_CONNECTED:
@@ -471,10 +473,17 @@ static void event_mon_handler(const struct shell *sh, void *p2, void *p3)
471473
desc = get_l4_desc(msg.event);
472474
}
473475

474-
PR_INFO("EVENT: %s [%d] %s%s%s%s%s\n", layer_str,
475-
net_if_get_by_iface(msg.iface), desc,
476-
desc2 ? " " : "", desc2 ? desc2 : "",
477-
info ? " " : "", info ? info : "");
476+
if (desc == unknown_event_str) {
477+
PR_INFO("EVENT: %s [%d] %s%s%s%s%s (0x%08x)\n", layer_str,
478+
net_if_get_by_iface(msg.iface), desc,
479+
desc2 ? " " : "", desc2 ? desc2 : "",
480+
info ? " " : "", info ? info : "", msg.event);
481+
} else {
482+
PR_INFO("EVENT: %s [%d] %s%s%s%s%s\n", layer_str,
483+
net_if_get_by_iface(msg.iface), desc,
484+
desc2 ? " " : "", desc2 ? desc2 : "",
485+
info ? " " : "", info ? info : "");
486+
}
478487
}
479488

480489
net_mgmt_del_event_callback(&l2_cb);

0 commit comments

Comments
 (0)