net: capture: Generate events when starting / stopping capture
The event NET_EVENT_CAPTURE_STARTED is generated when the capture is enabled, and NET_EVENT_CAPTURE_STOPPED when capture is disabled. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
dca5f48165
commit
2064306d41
|
@ -210,6 +210,8 @@ enum net_event_l4_cmd {
|
||||||
NET_EVENT_L4_CMD_DNS_SERVER_ADD,
|
NET_EVENT_L4_CMD_DNS_SERVER_ADD,
|
||||||
NET_EVENT_L4_CMD_DNS_SERVER_DEL,
|
NET_EVENT_L4_CMD_DNS_SERVER_DEL,
|
||||||
NET_EVENT_L4_CMD_HOSTNAME_CHANGED,
|
NET_EVENT_L4_CMD_HOSTNAME_CHANGED,
|
||||||
|
NET_EVENT_L4_CMD_CAPTURE_STARTED,
|
||||||
|
NET_EVENT_L4_CMD_CAPTURE_STOPPED,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NET_EVENT_L4_CONNECTED \
|
#define NET_EVENT_L4_CONNECTED \
|
||||||
|
@ -227,6 +229,12 @@ enum net_event_l4_cmd {
|
||||||
#define NET_EVENT_HOSTNAME_CHANGED \
|
#define NET_EVENT_HOSTNAME_CHANGED \
|
||||||
(_NET_EVENT_L4_BASE | NET_EVENT_L4_CMD_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 */
|
/** @endcond */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -486,6 +486,8 @@ static int capture_enable(const struct device *dev, struct net_if *iface)
|
||||||
ctx->capture_iface = iface;
|
ctx->capture_iface = iface;
|
||||||
ctx->is_enabled = true;
|
ctx->is_enabled = true;
|
||||||
|
|
||||||
|
net_mgmt_event_notify(NET_EVENT_CAPTURE_STARTED, iface);
|
||||||
|
|
||||||
net_if_up(ctx->tunnel_iface);
|
net_if_up(ctx->tunnel_iface);
|
||||||
|
|
||||||
return 0;
|
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)
|
static int capture_disable(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct net_capture *ctx = dev->data;
|
struct net_capture *ctx = dev->data;
|
||||||
|
struct net_if *iface = ctx->capture_iface;
|
||||||
|
|
||||||
ctx->capture_iface = NULL;
|
ctx->capture_iface = NULL;
|
||||||
ctx->is_enabled = false;
|
ctx->is_enabled = false;
|
||||||
|
|
||||||
net_if_down(ctx->tunnel_iface);
|
net_if_down(ctx->tunnel_iface);
|
||||||
|
|
||||||
|
net_mgmt_event_notify(NET_EVENT_CAPTURE_STOPPED, iface);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,6 +267,12 @@ static const char *get_l4_desc(uint32_t event)
|
||||||
case NET_EVENT_COAP_OBSERVER_REMOVED:
|
case NET_EVENT_COAP_OBSERVER_REMOVED:
|
||||||
desc = "CoAP observer removed";
|
desc = "CoAP observer removed";
|
||||||
break;
|
break;
|
||||||
|
case NET_EVENT_CAPTURE_STARTED:
|
||||||
|
desc = "Capture started";
|
||||||
|
break;
|
||||||
|
case NET_EVENT_CAPTURE_STOPPED:
|
||||||
|
desc = "Capture stopped";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
|
|
Loading…
Reference in a new issue