diff --git a/include/zephyr/net/net_event.h b/include/zephyr/net/net_event.h index 6d5abf4177f..881bb8dc276 100644 --- a/include/zephyr/net/net_event.h +++ b/include/zephyr/net/net_event.h @@ -210,6 +210,8 @@ enum net_event_l4_cmd { NET_EVENT_L4_CMD_DNS_SERVER_ADD, NET_EVENT_L4_CMD_DNS_SERVER_DEL, NET_EVENT_L4_CMD_HOSTNAME_CHANGED, + NET_EVENT_L4_CMD_CAPTURE_STARTED, + NET_EVENT_L4_CMD_CAPTURE_STOPPED, }; #define NET_EVENT_L4_CONNECTED \ @@ -227,6 +229,12 @@ enum net_event_l4_cmd { #define NET_EVENT_HOSTNAME_CHANGED \ (_NET_EVENT_L4_BASE | NET_EVENT_L4_CMD_HOSTNAME_CHANGED) +#define NET_EVENT_CAPTURE_STARTED \ + (_NET_EVENT_L4_BASE | NET_EVENT_L4_CMD_CAPTURE_STARTED) + +#define NET_EVENT_CAPTURE_STOPPED \ + (_NET_EVENT_L4_BASE | NET_EVENT_L4_CMD_CAPTURE_STOPPED) + /** @endcond */ /** diff --git a/subsys/net/lib/capture/capture.c b/subsys/net/lib/capture/capture.c index d786dca3365..f945a05e7f1 100644 --- a/subsys/net/lib/capture/capture.c +++ b/subsys/net/lib/capture/capture.c @@ -486,6 +486,8 @@ static int capture_enable(const struct device *dev, struct net_if *iface) ctx->capture_iface = iface; ctx->is_enabled = true; + net_mgmt_event_notify(NET_EVENT_CAPTURE_STARTED, iface); + net_if_up(ctx->tunnel_iface); return 0; @@ -494,12 +496,15 @@ static int capture_enable(const struct device *dev, struct net_if *iface) static int capture_disable(const struct device *dev) { struct net_capture *ctx = dev->data; + struct net_if *iface = ctx->capture_iface; ctx->capture_iface = NULL; ctx->is_enabled = false; net_if_down(ctx->tunnel_iface); + net_mgmt_event_notify(NET_EVENT_CAPTURE_STOPPED, iface); + return 0; } diff --git a/subsys/net/lib/shell/events.c b/subsys/net/lib/shell/events.c index b7c1651cb17..44037a76f3f 100644 --- a/subsys/net/lib/shell/events.c +++ b/subsys/net/lib/shell/events.c @@ -267,6 +267,12 @@ static const char *get_l4_desc(uint32_t event) case NET_EVENT_COAP_OBSERVER_REMOVED: desc = "CoAP observer removed"; break; + case NET_EVENT_CAPTURE_STARTED: + desc = "Capture started"; + break; + case NET_EVENT_CAPTURE_STOPPED: + desc = "Capture stopped"; + break; } return desc;