net: shell: capture: Set capture device if user did not use shell
If user created the capture device using the API and not via the shell, then the device name was not set. Use the default capture device in this case. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
2064306d41
commit
78a0cfbd94
|
@ -15,6 +15,7 @@ LOG_MODULE_DECLARE(net_shell);
|
|||
#include <zephyr/net/capture.h>
|
||||
|
||||
#if defined(CONFIG_NET_CAPTURE)
|
||||
#define DEFAULT_DEV_NAME "NET_CAPTURE0"
|
||||
static const struct device *capture_dev;
|
||||
|
||||
static void get_address_str(const struct sockaddr *addr,
|
||||
|
@ -74,6 +75,10 @@ static int cmd_net_capture(const struct shell *sh, size_t argc, char *argv[])
|
|||
#if defined(CONFIG_NET_CAPTURE)
|
||||
bool ret;
|
||||
|
||||
if (capture_dev == NULL) {
|
||||
capture_dev = device_get_binding(DEFAULT_DEV_NAME);
|
||||
}
|
||||
|
||||
if (capture_dev == NULL) {
|
||||
PR_INFO("Network packet capture %s\n", "not configured");
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue