net: conn_mgr: Rename connectivity monitor
The connectivity monitoring subfeature of conn_mgr is currently also named conn_mgr, which is confusing. This commit renames it to conn_mgr_monitor, or conn_mgr_mon for short, for clarity. Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
This commit is contained in:
parent
2e762836d5
commit
b25ea4742e
|
@ -927,7 +927,7 @@ scripts/build/gen_image_info.py @tejlmand
|
|||
/tests/lib/cmsis_dsp/ @stephanosio
|
||||
/tests/net/ @rlubos @tbursztyka @jukkar
|
||||
/tests/net/buf/ @jhedberg @tbursztyka @jukkar
|
||||
/tests/net/conn_mgr/ @rlubos @glarsennordic @jukkar
|
||||
/tests/net/conn_mgr_monitor/ @rlubos @glarsennordic @jukkar
|
||||
/tests/net/conn_mgr_conn/ @rlubos @glarsennordic @jukkar
|
||||
/tests/net/ieee802154/l2/ @rlubos @tbursztyka @jukkar @fgrandel
|
||||
/tests/net/lib/ @rlubos @tbursztyka @jukkar
|
||||
|
|
|
@ -1911,7 +1911,7 @@ Networking:
|
|||
files:
|
||||
- include/zephyr/net/conn_mgr*.h
|
||||
- subsys/net/conn_mgr/
|
||||
- tests/net/conn_mgr/
|
||||
- tests/net/conn_mgr_monitor/
|
||||
- tests/net/conn_mgr_conn/
|
||||
labels:
|
||||
- "area: Networking"
|
||||
|
|
|
@ -20,7 +20,7 @@ struct net_l2;
|
|||
* @brief Resend either NET_L4_CONNECTED or NET_L4_DISCONNECTED depending on whether connectivity
|
||||
* is currently available.
|
||||
*/
|
||||
void conn_mgr_resend_status(void);
|
||||
void conn_mgr_mon_resend_status(void);
|
||||
|
||||
/**
|
||||
* @brief Mark an iface to be ignored by conn_mgr.
|
||||
|
@ -77,7 +77,7 @@ void conn_mgr_watch_l2(const struct net_l2 *l2);
|
|||
|
||||
#else
|
||||
|
||||
#define conn_mgr_resend_status(...)
|
||||
#define conn_mgr_mon_resend_status(...)
|
||||
#define conn_mgr_ignore_iface(...)
|
||||
#define conn_mgr_watch_iface(...)
|
||||
#define conn_mgr_ignore_l2(...)
|
|
@ -12,7 +12,7 @@
|
|||
#include <zephyr/net/socket.h>
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/net_event.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
#include <zephyr/net/mqtt.h>
|
||||
#include <zephyr/sys/ring_buffer.h>
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <zephyr/drivers/uart.h>
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/net_event.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
#include <zephyr/drivers/modem/gsm_ppp.h>
|
||||
#include <zephyr/devicetree.h>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/net/mqtt_sn.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/socket.h>
|
||||
|
||||
|
@ -79,7 +79,7 @@ static void init_app(void)
|
|||
net_mgmt_init_event_callback(&mgmt_cb, net_event_handler, EVENT_MASK);
|
||||
net_mgmt_add_event_callback(&mgmt_cb);
|
||||
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/net/mqtt_sn.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/socket.h>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ LOG_MODULE_REGISTER(net_dumb_http_srv_mt_sample);
|
|||
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/net_event.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
|
||||
#define MY_PORT 8080
|
||||
|
||||
|
@ -426,7 +426,7 @@ int main(void)
|
|||
event_handler, EVENT_MASK);
|
||||
net_mgmt_add_event_callback(&mgmt_cb);
|
||||
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_NET_CONNECTION_MANAGER)) {
|
||||
|
|
|
@ -7,5 +7,5 @@ CONFIG_MAIN_STACK_SIZE=65535
|
|||
CONFIG_IDLE_STACK_SIZE=65535
|
||||
CONFIG_ISR_STACK_SIZE=65535
|
||||
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=65535
|
||||
CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=65535
|
||||
CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=65535
|
||||
CONFIG_SHELL_STACK_SIZE=65535
|
||||
|
|
|
@ -29,7 +29,7 @@ LOG_MODULE_REGISTER(net_echo_client_sample, LOG_LEVEL_DBG);
|
|||
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/net_event.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
|
||||
#if defined(CONFIG_USERSPACE)
|
||||
#include <zephyr/app_memory/app_memdomain.h>
|
||||
|
@ -272,7 +272,7 @@ static void init_app(void)
|
|||
event_handler, EVENT_MASK);
|
||||
net_mgmt_add_event_callback(&mgmt_cb);
|
||||
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
}
|
||||
|
||||
init_vlan();
|
||||
|
|
|
@ -7,5 +7,5 @@ CONFIG_MAIN_STACK_SIZE=65535
|
|||
CONFIG_IDLE_STACK_SIZE=65535
|
||||
CONFIG_ISR_STACK_SIZE=65535
|
||||
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=65535
|
||||
CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=65535
|
||||
CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=65535
|
||||
CONFIG_SHELL_STACK_SIZE=65535
|
||||
|
|
|
@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(net_echo_server_sample, LOG_LEVEL_DBG);
|
|||
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/net_event.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "certificate.h"
|
||||
|
@ -191,7 +191,7 @@ static void init_app(void)
|
|||
event_handler, EVENT_MASK);
|
||||
net_mgmt_add_event_callback(&mgmt_cb);
|
||||
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
}
|
||||
|
||||
init_vlan();
|
||||
|
@ -205,7 +205,7 @@ static int cmd_sample_quit(const struct shell *sh,
|
|||
{
|
||||
want_to_quit = true;
|
||||
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
|
||||
quit();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ LOG_MODULE_REGISTER(net_txtime_sample, LOG_LEVEL_DBG);
|
|||
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/net_event.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
|
||||
#include <zephyr/net/socket.h>
|
||||
#include <zephyr/net/ethernet.h>
|
||||
|
@ -496,7 +496,7 @@ static int cmd_sample_quit(const struct shell *sh,
|
|||
|
||||
quit();
|
||||
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ int main(void)
|
|||
net_mgmt_add_event_callback(&dhcpv4_cb);
|
||||
}
|
||||
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
}
|
||||
|
||||
/* The VLAN in this example is created for demonstration purposes.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <zephyr/mgmt/updatehub.h>
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/net_event.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
|
||||
#ifdef CONFIG_NET_L2_WIFI_MGMT
|
||||
#include <zephyr/net/wifi_mgmt.h>
|
||||
|
@ -153,6 +153,6 @@ int main(void)
|
|||
|
||||
net_mgmt_init_event_callback(&mgmt_cb, event_handler, EVENT_MASK);
|
||||
net_mgmt_add_event_callback(&mgmt_cb);
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <zephyr/mgmt/mcumgr/mgmt/handlers.h>
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/net_event.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <mgmt/mcumgr/transport/smp_internal.h>
|
||||
|
@ -337,7 +337,7 @@ int smp_udp_open(void)
|
|||
|
||||
if (started) {
|
||||
/* One or more threads were started, send interface notifications */
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -4,7 +4,7 @@ zephyr_include_directories(.)
|
|||
|
||||
zephyr_library()
|
||||
zephyr_library_sources(
|
||||
conn_mgr.c
|
||||
conn_mgr_monitor.c
|
||||
events_handler.c
|
||||
conn_mgr_connectivity.c
|
||||
)
|
||||
|
|
|
@ -22,19 +22,18 @@ module-str = Log level for connection manager
|
|||
module-help = Enables connection manager code to output debug messages.
|
||||
source "subsys/net/Kconfig.template.log_config.net"
|
||||
|
||||
config NET_CONNECTION_MANAGER_STACK_SIZE
|
||||
int "Size of the stack allocated for the connection manager"
|
||||
config NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE
|
||||
int "Size of the stack allocated for the conn_mgr_monitor thread"
|
||||
default 512
|
||||
help
|
||||
Sets the stack size which will be used by the connection manager
|
||||
thread.
|
||||
Sets the stack size which will be used by the connection manager for connectivity monitoring.
|
||||
|
||||
config NET_CONNECTION_MANAGER_PRIORITY
|
||||
int "Thread starting priority"
|
||||
config NET_CONNECTION_MANAGER_MONITOR_PRIORITY
|
||||
int "Monitoring thread starting priority"
|
||||
default 1
|
||||
range 1 99
|
||||
help
|
||||
This sets the starting priority of the connection manager thread.
|
||||
This sets the starting priority of the conn_mgr_monitor thread.
|
||||
|
||||
config NET_CONNECTION_MANAGER_AUTO_IF_DOWN
|
||||
bool "Automatically call net_if_down on ifaces that have given up on connecting"
|
||||
|
|
|
@ -9,7 +9,7 @@ LOG_MODULE_REGISTER(conn_mgr_conn, CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL);
|
|||
|
||||
#include <zephyr/net/net_if.h>
|
||||
#include <zephyr/sys/iterable_sections.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
#include <zephyr/net/conn_mgr_connectivity.h>
|
||||
#include <zephyr/net/conn_mgr_connectivity_impl.h>
|
||||
#include "conn_mgr_private.h"
|
||||
|
|
|
@ -23,13 +23,13 @@ LOG_MODULE_REGISTER(conn_mgr, CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL);
|
|||
#define THREAD_PRIORITY K_PRIO_PREEMPT(7)
|
||||
#endif
|
||||
|
||||
static K_THREAD_STACK_DEFINE(conn_mgr_thread_stack,
|
||||
CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE);
|
||||
static struct k_thread conn_mgr_thread;
|
||||
static K_THREAD_STACK_DEFINE(conn_mgr_mon_stack,
|
||||
CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE);
|
||||
static struct k_thread conn_mgr_mon_thread;
|
||||
|
||||
/* Internal state array tracking readiness, flags, and other state information for all available
|
||||
* ifaces. Note that indexing starts at 0, whereas Zephyr iface indices start at 1.
|
||||
* conn_mgr_get_if_by_index and conn_mgr_get_index_for_if are used to go back and forth between
|
||||
* conn_mgr_mon_get_if_by_index and conn_mgr_get_index_for_if are used to go back and forth between
|
||||
* iface_states indices and Zephyr iface pointers.
|
||||
*/
|
||||
uint16_t iface_states[CONN_MGR_IFACE_MAX];
|
||||
|
@ -42,10 +42,10 @@ static struct net_if *last_iface_down;
|
|||
static struct net_if *last_iface_up;
|
||||
|
||||
/* Used to signal when modifications have been made that need to be responded to */
|
||||
K_SEM_DEFINE(conn_mgr_event_signal, 1, 1);
|
||||
K_SEM_DEFINE(conn_mgr_mon_updated, 1, 1);
|
||||
|
||||
/* Used to protect conn_mgr state */
|
||||
K_MUTEX_DEFINE(conn_mgr_lock);
|
||||
/* Used to protect conn_mgr_monitor state */
|
||||
K_MUTEX_DEFINE(conn_mgr_mon_lock);
|
||||
|
||||
/**
|
||||
* @brief Retrieves pointer to an iface by the index that corresponds to it in iface_states
|
||||
|
@ -53,7 +53,7 @@ K_MUTEX_DEFINE(conn_mgr_lock);
|
|||
* @param index - The index in iface_states to find the corresponding iface for.
|
||||
* @return net_if* - The corresponding iface.
|
||||
*/
|
||||
static struct net_if *conn_mgr_get_if_by_index(int index)
|
||||
static struct net_if *conn_mgr_mon_get_if_by_index(int index)
|
||||
{
|
||||
return net_if_get_by_index(index + 1);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ static int conn_mgr_get_index_for_if(struct net_if *iface)
|
|||
* @param idx - index (in iface_states) of the iface to mark ready or unready
|
||||
* @param readiness - true if the iface should be considered ready, otherwise false
|
||||
*/
|
||||
static void conn_mgr_set_ready(int idx, bool readiness)
|
||||
static void conn_mgr_mon_set_ready(int idx, bool readiness)
|
||||
{
|
||||
/* Clear and then update the L4-readiness bit */
|
||||
iface_states[idx] &= ~CONN_MGR_IF_READY;
|
||||
|
@ -84,14 +84,14 @@ static void conn_mgr_set_ready(int idx, bool readiness)
|
|||
iface_states[idx] |= CONN_MGR_IF_READY;
|
||||
|
||||
ready_count += 1;
|
||||
last_iface_up = conn_mgr_get_if_by_index(idx);
|
||||
last_iface_up = conn_mgr_mon_get_if_by_index(idx);
|
||||
} else {
|
||||
ready_count -= 1;
|
||||
last_iface_down = conn_mgr_get_if_by_index(idx);
|
||||
last_iface_down = conn_mgr_mon_get_if_by_index(idx);
|
||||
}
|
||||
}
|
||||
|
||||
static void conn_mgr_act_on_changes(void)
|
||||
static void conn_mgr_mon_handle_update(void)
|
||||
{
|
||||
int idx;
|
||||
int original_ready_count;
|
||||
|
@ -103,7 +103,7 @@ static void conn_mgr_act_on_changes(void)
|
|||
bool was_l4_ready;
|
||||
bool is_ignored;
|
||||
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
original_ready_count = ready_count;
|
||||
for (idx = 0; idx < ARRAY_SIZE(iface_states); idx++) {
|
||||
|
@ -132,7 +132,7 @@ static void conn_mgr_act_on_changes(void)
|
|||
/* Respond to changes to iface readiness */
|
||||
if (was_l4_ready != is_l4_ready) {
|
||||
/* Track the iface readiness change */
|
||||
conn_mgr_set_ready(idx, is_l4_ready);
|
||||
conn_mgr_mon_set_ready(idx, is_l4_ready);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ static void conn_mgr_act_on_changes(void)
|
|||
}
|
||||
}
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,11 +155,11 @@ static void conn_mgr_act_on_changes(void)
|
|||
*
|
||||
* @param iface - iface to initialize from.
|
||||
*/
|
||||
static void conn_mgr_initial_state(struct net_if *iface)
|
||||
static void conn_mgr_mon_initial_state(struct net_if *iface)
|
||||
{
|
||||
int idx = net_if_get_by_iface(iface) - 1;
|
||||
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
if (net_if_is_up(iface)) {
|
||||
NET_DBG("Iface %p UP", iface);
|
||||
|
@ -183,42 +183,42 @@ static void conn_mgr_initial_state(struct net_if *iface)
|
|||
|
||||
iface_states[idx] |= CONN_MGR_IF_CHANGED;
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
|
||||
static void conn_mgr_init_cb(struct net_if *iface, void *user_data)
|
||||
static void conn_mgr_mon_init_cb(struct net_if *iface, void *user_data)
|
||||
{
|
||||
ARG_UNUSED(user_data);
|
||||
|
||||
conn_mgr_initial_state(iface);
|
||||
conn_mgr_mon_initial_state(iface);
|
||||
}
|
||||
|
||||
static void conn_mgr_handler(void)
|
||||
static void conn_mgr_mon_thread_fn(void)
|
||||
{
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
conn_mgr_conn_init();
|
||||
|
||||
conn_mgr_init_events_handler();
|
||||
|
||||
net_if_foreach(conn_mgr_init_cb, NULL);
|
||||
net_if_foreach(conn_mgr_mon_init_cb, NULL);
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
|
||||
NET_DBG("Connection Manager started");
|
||||
|
||||
while (true) {
|
||||
/* Wait for changes */
|
||||
k_sem_take(&conn_mgr_event_signal, K_FOREVER);
|
||||
k_sem_take(&conn_mgr_mon_updated, K_FOREVER);
|
||||
|
||||
/* Respond to changes */
|
||||
conn_mgr_act_on_changes();
|
||||
conn_mgr_mon_handle_update();
|
||||
}
|
||||
}
|
||||
|
||||
void conn_mgr_resend_status(void)
|
||||
void conn_mgr_mon_resend_status(void)
|
||||
{
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
if (ready_count == 0) {
|
||||
net_mgmt_event_notify(NET_EVENT_L4_DISCONNECTED, last_iface_down);
|
||||
|
@ -226,39 +226,39 @@ void conn_mgr_resend_status(void)
|
|||
net_mgmt_event_notify(NET_EVENT_L4_CONNECTED, last_iface_up);
|
||||
}
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
|
||||
void conn_mgr_ignore_iface(struct net_if *iface)
|
||||
{
|
||||
int idx = conn_mgr_get_index_for_if(iface);
|
||||
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
if (!(iface_states[idx] & CONN_MGR_IF_IGNORED)) {
|
||||
/* Set ignored flag and mark state as changed */
|
||||
iface_states[idx] |= CONN_MGR_IF_IGNORED;
|
||||
iface_states[idx] |= CONN_MGR_IF_CHANGED;
|
||||
k_sem_give(&conn_mgr_event_signal);
|
||||
k_sem_give(&conn_mgr_mon_updated);
|
||||
}
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
|
||||
void conn_mgr_watch_iface(struct net_if *iface)
|
||||
{
|
||||
int idx = conn_mgr_get_index_for_if(iface);
|
||||
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
if (iface_states[idx] & CONN_MGR_IF_IGNORED) {
|
||||
/* Clear ignored flag and mark state as changed */
|
||||
iface_states[idx] &= ~CONN_MGR_IF_IGNORED;
|
||||
iface_states[idx] |= CONN_MGR_IF_CHANGED;
|
||||
k_sem_give(&conn_mgr_event_signal);
|
||||
k_sem_give(&conn_mgr_mon_updated);
|
||||
}
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
|
||||
bool conn_mgr_is_iface_ignored(struct net_if *iface)
|
||||
|
@ -267,11 +267,11 @@ bool conn_mgr_is_iface_ignored(struct net_if *iface)
|
|||
|
||||
bool ret = false;
|
||||
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
ret = iface_states[idx] & CONN_MGR_IF_IGNORED;
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ void conn_mgr_ignore_l2(const struct net_l2 *l2)
|
|||
/* conn_mgr_ignore_iface already locks the mutex, but we lock it here too
|
||||
* so that all matching ifaces are updated simultaneously.
|
||||
*/
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
STRUCT_SECTION_FOREACH(net_if, iface) {
|
||||
if (iface_uses_l2(iface, l2)) {
|
||||
|
@ -303,7 +303,7 @@ void conn_mgr_ignore_l2(const struct net_l2 *l2)
|
|||
}
|
||||
}
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
|
||||
void conn_mgr_watch_l2(const struct net_l2 *l2)
|
||||
|
@ -311,7 +311,7 @@ void conn_mgr_watch_l2(const struct net_l2 *l2)
|
|||
/* conn_mgr_watch_iface already locks the mutex, but we lock it here too
|
||||
* so that all matching ifaces are updated simultaneously.
|
||||
*/
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
STRUCT_SECTION_FOREACH(net_if, iface) {
|
||||
if (iface_uses_l2(iface, l2)) {
|
||||
|
@ -319,10 +319,10 @@ void conn_mgr_watch_l2(const struct net_l2 *l2)
|
|||
}
|
||||
}
|
||||
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
|
||||
static int conn_mgr_init(void)
|
||||
static int conn_mgr_mon_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -330,12 +330,12 @@ static int conn_mgr_init(void)
|
|||
iface_states[i] = 0;
|
||||
}
|
||||
|
||||
k_thread_create(&conn_mgr_thread, conn_mgr_thread_stack,
|
||||
CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE,
|
||||
(k_thread_entry_t)conn_mgr_handler,
|
||||
k_thread_create(&conn_mgr_mon_thread, conn_mgr_mon_stack,
|
||||
CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE,
|
||||
(k_thread_entry_t)conn_mgr_mon_thread_fn,
|
||||
NULL, NULL, NULL, THREAD_PRIORITY, 0, K_NO_WAIT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(conn_mgr_init, APPLICATION, CONFIG_NET_CONNECTION_MANAGER_PRIORITY);
|
||||
SYS_INIT(conn_mgr_mon_init, APPLICATION, CONFIG_NET_CONNECTION_MANAGER_MONITOR_PRIORITY);
|
|
@ -51,8 +51,8 @@
|
|||
#define CONN_MGR_IPV4_EVENTS_MASK (NET_EVENT_IPV4_ADDR_ADD | \
|
||||
NET_EVENT_IPV4_ADDR_DEL)
|
||||
|
||||
extern struct k_sem conn_mgr_event_signal;
|
||||
extern struct k_mutex conn_mgr_lock;
|
||||
extern struct k_sem conn_mgr_mon_updated;
|
||||
extern struct k_mutex conn_mgr_mon_lock;
|
||||
|
||||
void conn_mgr_init_events_handler(void);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ static void conn_mgr_iface_events_handler(struct net_mgmt_event_callback *cb,
|
|||
|
||||
NET_DBG("Iface index %u", idx);
|
||||
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
switch (NET_MGMT_GET_COMMAND(mgmt_event)) {
|
||||
case NET_EVENT_IF_CMD_DOWN:
|
||||
|
@ -49,10 +49,10 @@ static void conn_mgr_iface_events_handler(struct net_mgmt_event_callback *cb,
|
|||
}
|
||||
|
||||
iface_states[idx] |= CONN_MGR_IF_CHANGED;
|
||||
k_sem_give(&conn_mgr_event_signal);
|
||||
k_sem_give(&conn_mgr_mon_updated);
|
||||
|
||||
done:
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_IPV6)
|
||||
|
@ -73,7 +73,7 @@ static void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb,
|
|||
|
||||
NET_DBG("Iface index %u", idx);
|
||||
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
switch (NET_MGMT_GET_COMMAND(mgmt_event)) {
|
||||
case NET_EVENT_IPV6_CMD_DAD_SUCCEED:
|
||||
|
@ -96,10 +96,10 @@ static void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb,
|
|||
}
|
||||
|
||||
iface_states[idx] |= CONN_MGR_IF_CHANGED;
|
||||
k_sem_give(&conn_mgr_event_signal);
|
||||
k_sem_give(&conn_mgr_mon_updated);
|
||||
|
||||
done:
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
#else
|
||||
static inline
|
||||
|
@ -131,7 +131,7 @@ static void conn_mgr_ipv4_events_handler(struct net_mgmt_event_callback *cb,
|
|||
|
||||
NET_DBG("Iface index %u", idx);
|
||||
|
||||
k_mutex_lock(&conn_mgr_lock, K_FOREVER);
|
||||
k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER);
|
||||
|
||||
switch (NET_MGMT_GET_COMMAND(mgmt_event)) {
|
||||
case NET_EVENT_IPV4_CMD_ADDR_ADD:
|
||||
|
@ -149,10 +149,10 @@ static void conn_mgr_ipv4_events_handler(struct net_mgmt_event_callback *cb,
|
|||
}
|
||||
|
||||
iface_states[idx] |= CONN_MGR_IF_CHANGED;
|
||||
k_sem_give(&conn_mgr_event_signal);
|
||||
k_sem_give(&conn_mgr_mon_updated);
|
||||
|
||||
done:
|
||||
k_mutex_unlock(&conn_mgr_lock);
|
||||
k_mutex_unlock(&conn_mgr_mon_lock);
|
||||
}
|
||||
#else
|
||||
static inline
|
||||
|
|
|
@ -719,7 +719,7 @@ static int enable(const struct shell_transport *transport, bool blocking)
|
|||
|
||||
/* Listen for network connection status */
|
||||
net_mgmt_add_event_callback(&sh_mqtt->mgmt_cb);
|
||||
conn_mgr_resend_status();
|
||||
conn_mgr_mon_resend_status();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <zephyr/net/net_if.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
#include <zephyr/net/conn_mgr_connectivity.h>
|
||||
#include <zephyr/net/conn_mgr_connectivity_impl.h>
|
||||
#include "test_conn_impl.h"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <zephyr/net/net_if.h>
|
||||
#include <zephyr/net/dummy.h>
|
||||
#include <zephyr/net/conn_mgr.h>
|
||||
#include <zephyr/net/conn_mgr_monitor.h>
|
||||
#include <zephyr/net/conn_mgr_connectivity.h>
|
||||
#include "conn_mgr_private.h"
|
||||
#include "test_ifaces.h"
|
||||
|
@ -63,13 +63,13 @@ static void reset_test_iface(struct net_if *iface)
|
|||
/* Thread-safe test statistics */
|
||||
K_MUTEX_DEFINE(stats_mutex);
|
||||
static struct test_stats {
|
||||
/** The number of times conn_mgr has raised a connect event */
|
||||
/** The number of times conn_mgr_monitor has raised a connect event */
|
||||
int conn_count;
|
||||
|
||||
/** The number of times conn_mgr has raised a disconnect event */
|
||||
/** The number of times conn_mgr_monitor has raised a disconnect event */
|
||||
int dconn_count;
|
||||
|
||||
/** The total number of connectivity events fired by conn_mgr */
|
||||
/** The total number of connectivity events fired by conn_mgr_monitor */
|
||||
int event_count;
|
||||
|
||||
/** The iface blamed for the last disconnect event */
|
||||
|
@ -377,7 +377,7 @@ enum ip_order {
|
|||
|
||||
/**
|
||||
* @brief Cycles a single iface through all possible ready and pre-ready states,
|
||||
* ensuring the correct events are observed and generated by conn_mgr.
|
||||
* ensuring the correct events are observed and generated by conn_mgr_monitor.
|
||||
*
|
||||
* Ifaces can be in one of four states that are relevant to L4 readiness:
|
||||
* 00: oper-down, no IPs associated (unready state)
|
||||
|
@ -623,7 +623,7 @@ static void cycle_iface_states(struct net_if *iface, enum ip_order ifa_ipm)
|
|||
/* Make sure all readiness transitions of a pair of connectivity-enabled ifaces results in all
|
||||
* expected events.
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_ready_CC)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_ready_CC)
|
||||
{
|
||||
cycle_ready_ifaces(if_conn_a, if_conn_b);
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ ZTEST(conn_mgr, test_cycle_ready_CC)
|
|||
/* Make sure half of all readiness transitions of a connectivity-enabled iface and a simple
|
||||
* iface results in all expected events.
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_ready_CNC)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_ready_CNC)
|
||||
{
|
||||
cycle_ready_ifaces(if_conn_a, if_simp_a);
|
||||
}
|
||||
|
@ -639,14 +639,14 @@ ZTEST(conn_mgr, test_cycle_ready_CNC)
|
|||
/* Make sure the other half of all readiness transitions of a connectivity-enabled iface and a
|
||||
* simple iface results in all expected events.
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_ready_NCC)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_ready_NCC)
|
||||
{
|
||||
cycle_ready_ifaces(if_simp_a, if_conn_a);
|
||||
}
|
||||
|
||||
/* Make sure all readiness transitions of a pair of simple ifaces results in all expected events.
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_ready_NCNC)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_ready_NCNC)
|
||||
{
|
||||
cycle_ready_ifaces(if_simp_a, if_simp_b);
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ ZTEST(conn_mgr, test_cycle_ready_NCNC)
|
|||
/* Make sure that a simple iface can be successfully ignored without interfering with the events
|
||||
* fired by another simple iface
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_ready_NCINC)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_ready_NCINC)
|
||||
{
|
||||
cycle_ignored_iface(if_simp_a, if_simp_b);
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ ZTEST(conn_mgr, test_cycle_ready_NCINC)
|
|||
/* Make sure that a connectivity-enabled iface can be successfully ignored without interfering
|
||||
* with the events fired by another connectivity-enabled iface
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_ready_CIC)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_ready_CIC)
|
||||
{
|
||||
cycle_ignored_iface(if_conn_a, if_conn_b);
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ ZTEST(conn_mgr, test_cycle_ready_CIC)
|
|||
/* Make sure that a connectivity-enabled iface can be successfully ignored without interfering
|
||||
* with the events fired by a simple iface
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_ready_CINC)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_ready_CINC)
|
||||
{
|
||||
cycle_ignored_iface(if_conn_a, if_simp_a);
|
||||
}
|
||||
|
@ -678,13 +678,13 @@ ZTEST(conn_mgr, test_cycle_ready_CINC)
|
|||
/* Make sure that a simple iface can be successfully ignored without interfering
|
||||
* with the events fired by a connectivity-enabled iface
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_ready_NCIC)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_ready_NCIC)
|
||||
{
|
||||
cycle_ignored_iface(if_simp_a, if_conn_a);
|
||||
}
|
||||
|
||||
/* Make sure that DAD readiness is actually verified by conn_mgr */
|
||||
ZTEST(conn_mgr, test_DAD)
|
||||
/* Make sure that DAD readiness is actually verified by conn_mgr_monitor */
|
||||
ZTEST(conn_mgr_monitor, test_DAD)
|
||||
{
|
||||
struct test_stats stats;
|
||||
|
||||
|
@ -711,7 +711,7 @@ ZTEST(conn_mgr, test_DAD)
|
|||
}
|
||||
|
||||
/* Test whether ignoring and un-ignoring a ready iface fires the appropriate events */
|
||||
ZTEST(conn_mgr, test_ignore_while_ready)
|
||||
ZTEST(conn_mgr_monitor, test_ignore_while_ready)
|
||||
{
|
||||
struct test_stats stats;
|
||||
|
||||
|
@ -763,7 +763,7 @@ ZTEST(conn_mgr, test_ignore_while_ready)
|
|||
}
|
||||
|
||||
/* Test L2 and iface ignore API */
|
||||
ZTEST(conn_mgr, test_ignores)
|
||||
ZTEST(conn_mgr_monitor, test_ignores)
|
||||
{
|
||||
/* Ignore if_simp_a, ensuring if_simp_b is unaffected */
|
||||
conn_mgr_ignore_iface(if_simp_a);
|
||||
|
@ -823,7 +823,7 @@ ZTEST(conn_mgr, test_ignores)
|
|||
/* Make sure all state transitions of a single connectivity-enabled iface result in all expected
|
||||
* events. Perform IPv4 changes before IPv6 changes.
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_states_connected_ipv46)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_states_connected_ipv46)
|
||||
{
|
||||
cycle_iface_states(if_conn_a, IPV4_FIRST);
|
||||
}
|
||||
|
@ -831,7 +831,7 @@ ZTEST(conn_mgr, test_cycle_states_connected_ipv46)
|
|||
/* Make sure all state transitions of a single connectivity-enabled iface result in all expected
|
||||
* events. Perform IPv6 changes before IPv4 changes.
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_states_connected_ipv64)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_states_connected_ipv64)
|
||||
{
|
||||
cycle_iface_states(if_conn_a, IPV6_FIRST);
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ ZTEST(conn_mgr, test_cycle_states_connected_ipv64)
|
|||
/* Make sure all state transitions of a single simple iface result in all expected events.
|
||||
* Perform IPv4 changes before IPv6 changes.
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_states_simple_ipv46)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_states_simple_ipv46)
|
||||
{
|
||||
cycle_iface_states(if_simp_a, IPV4_FIRST);
|
||||
}
|
||||
|
@ -847,9 +847,9 @@ ZTEST(conn_mgr, test_cycle_states_simple_ipv46)
|
|||
/* Make sure all state transitions of a single simple iface result in all expected events.
|
||||
* Perform IPv6 changes before IPv4 changes.
|
||||
*/
|
||||
ZTEST(conn_mgr, test_cycle_states_simple_ipv64)
|
||||
ZTEST(conn_mgr_monitor, test_cycle_states_simple_ipv64)
|
||||
{
|
||||
cycle_iface_states(if_simp_a, IPV6_FIRST);
|
||||
}
|
||||
|
||||
ZTEST_SUITE(conn_mgr, NULL, conn_mgr_setup, conn_mgr_before, NULL, NULL);
|
||||
ZTEST_SUITE(conn_mgr_monitor, NULL, conn_mgr_setup, conn_mgr_before, NULL, NULL);
|
Loading…
Reference in a new issue