net: conn_mgr: Reorganize files

Since conn_mgr is a subsystem rather than a library, relocate it
directly into subsys/net rather than subsys/net/lib/

Rename header files to better match their function.

Remove net_ prefix from conn_mgr types, API, and files, since it is
unnecessary.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
This commit is contained in:
Georges Oates_Larsen 2023-03-28 13:12:35 -07:00 committed by Carles Cufí
parent d240d2e019
commit 716c19f7ef
23 changed files with 53 additions and 54 deletions

View File

@ -4,8 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_NET_CONN_MGR_H_
#define ZEPHYR_INCLUDE_NET_CONN_MGR_H_
#ifndef ZEPHYR_INCLUDE_CONN_MGR_H_
#define ZEPHYR_INCLUDE_CONN_MGR_H_
#ifdef __cplusplus
extern "C" {
@ -13,11 +13,11 @@ extern "C" {
#if defined(CONFIG_NET_CONNECTION_MANAGER)
void net_conn_mgr_resend_status(void);
void conn_mgr_resend_status(void);
#else
#define net_conn_mgr_resend_status(...)
#define conn_mgr_resend_status(...)
#endif /* CONFIG_NET_CONNECTION_MANAGER */
@ -25,4 +25,4 @@ void net_conn_mgr_resend_status(void);
}
#endif
#endif /* ZEPHYR_INCLUDE_NET_CONN_MGR_H_ */
#endif /* ZEPHYR_INCLUDE_CONN_MGR_H_ */

View File

@ -12,7 +12,7 @@
#include <zephyr/net/socket.h>
#include <zephyr/net/net_mgmt.h>
#include <zephyr/net/net_event.h>
#include <zephyr/net/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#include <zephyr/net/mqtt.h>
#include <zephyr/sys/ring_buffer.h>

View File

@ -10,7 +10,7 @@
#include <zephyr/drivers/uart.h>
#include <zephyr/net/net_mgmt.h>
#include <zephyr/net/net_event.h>
#include <zephyr/net/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#include <zephyr/drivers/modem/gsm_ppp.h>
#include <zephyr/devicetree.h>

View File

@ -11,7 +11,7 @@
#include <zephyr/kernel.h>
#include <zephyr/net/mqtt_sn.h>
#include <zephyr/net/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.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);
net_conn_mgr_resend_status();
conn_mgr_resend_status();
}
}

View File

@ -10,7 +10,7 @@
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/net/mqtt_sn.h>
#include <zephyr/net/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#include <zephyr/net/net_mgmt.h>
#include <zephyr/net/socket.h>

View File

@ -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/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#define MY_PORT 8080
@ -426,7 +426,7 @@ int main(void)
event_handler, EVENT_MASK);
net_mgmt_add_event_callback(&mgmt_cb);
net_conn_mgr_resend_status();
conn_mgr_resend_status();
}
if (!IS_ENABLED(CONFIG_NET_CONNECTION_MANAGER)) {

View File

@ -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/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#if defined(CONFIG_USERSPACE)
#include <zephyr/app_memory/app_memdomain.h>
@ -271,7 +271,7 @@ static void init_app(void)
event_handler, EVENT_MASK);
net_mgmt_add_event_callback(&mgmt_cb);
net_conn_mgr_resend_status();
conn_mgr_resend_status();
}
init_vlan();

View File

@ -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/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#include "common.h"
#include "certificate.h"
@ -196,7 +196,7 @@ static void init_app(void)
event_handler, EVENT_MASK);
net_mgmt_add_event_callback(&mgmt_cb);
net_conn_mgr_resend_status();
conn_mgr_resend_status();
}
init_vlan();
@ -210,7 +210,7 @@ static int cmd_sample_quit(const struct shell *sh,
{
want_to_quit = true;
net_conn_mgr_resend_status();
conn_mgr_resend_status();
quit();

View File

@ -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/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#include <zephyr/net/socket.h>
#include <zephyr/net/ethernet.h>
@ -497,7 +497,7 @@ static int cmd_sample_quit(const struct shell *sh,
quit();
net_conn_mgr_resend_status();
conn_mgr_resend_status();
return 0;
}
@ -535,7 +535,7 @@ int main(void)
net_mgmt_add_event_callback(&dhcpv4_cb);
}
net_conn_mgr_resend_status();
conn_mgr_resend_status();
}
/* The VLAN in this example is created for demonstration purposes.

View File

@ -8,7 +8,7 @@
#include <zephyr/mgmt/updatehub.h>
#include <zephyr/net/net_mgmt.h>
#include <zephyr/net/net_event.h>
#include <zephyr/net/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#include <zephyr/net/wifi_mgmt.h>
#if defined(CONFIG_UPDATEHUB_DTLS)
@ -150,6 +150,6 @@ int main(void)
net_mgmt_init_event_callback(&mgmt_cb, event_handler, EVENT_MASK);
net_mgmt_add_event_callback(&mgmt_cb);
net_conn_mgr_resend_status();
conn_mgr_resend_status();
return 0;
}

View File

@ -30,7 +30,7 @@
#include <zephyr/mgmt/mcumgr/mgmt/handlers.h>
#include <zephyr/net/net_mgmt.h>
#include <zephyr/net/net_event.h>
#include <zephyr/net/net_conn_mgr.h>
#include <zephyr/net/conn_mgr.h>
#endif
#define LOG_LEVEL CONFIG_MCUMGR_LOG_LEVEL
@ -316,7 +316,7 @@ static void smp_udp_start(void)
net_mgmt_init_event_callback(&smp_udp_mgmt_cb, smp_udp_net_event_handler,
(NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED));
net_mgmt_add_event_callback(&smp_udp_mgmt_cb);
net_conn_mgr_resend_status();
conn_mgr_resend_status();
}
MCUMGR_HANDLER_DEFINE(smp_udp, smp_udp_start);

View File

@ -20,3 +20,4 @@ if(CONFIG_NETWORKING)
endif()
add_subdirectory(lib)
add_subdirectory_ifdef(CONFIG_NET_CONNECTION_MANAGER conn_mgr)

View File

@ -80,6 +80,8 @@ source "subsys/net/pkt_filter/Kconfig"
source "subsys/net/lib/Kconfig"
source "subsys/net/conn_mgr/Kconfig"
endif
endmenu

View File

@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(conn_mgr, CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL);
#include <zephyr/net/net_mgmt.h>
#include <zephyr/net/conn_mgr_connectivity.h>
#include <conn_mgr.h>
#include "conn_mgr_private.h"
#if defined(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
@ -27,43 +27,43 @@ uint16_t iface_states[CONN_MGR_IFACE_MAX];
K_SEM_DEFINE(conn_mgr_lock, 1, K_SEM_MAX_LIMIT);
static enum net_conn_mgr_state conn_mgr_iface_status(int index)
static enum conn_mgr_state conn_mgr_iface_status(int index)
{
if (iface_states[index] & NET_STATE_IFACE_UP) {
return NET_CONN_MGR_STATE_CONNECTED;
return CONN_MGR_STATE_CONNECTED;
}
return NET_CONN_MGR_STATE_DISCONNECTED;
return CONN_MGR_STATE_DISCONNECTED;
}
#if defined(CONFIG_NET_IPV6)
static enum net_conn_mgr_state conn_mgr_ipv6_status(int index)
static enum conn_mgr_state conn_mgr_ipv6_status(int index)
{
if ((iface_states[index] & CONN_MGR_IPV6_STATUS_MASK) ==
CONN_MGR_IPV6_STATUS_MASK) {
NET_DBG("IPv6 connected on iface index %u", index + 1);
return NET_CONN_MGR_STATE_CONNECTED;
return CONN_MGR_STATE_CONNECTED;
}
return NET_CONN_MGR_STATE_DISCONNECTED;
return CONN_MGR_STATE_DISCONNECTED;
}
#else
#define conn_mgr_ipv6_status(...) NET_CONN_MGR_STATE_CONNECTED
#define conn_mgr_ipv6_status(...) CONN_MGR_STATE_CONNECTED
#endif /* CONFIG_NET_IPV6 */
#if defined(CONFIG_NET_IPV4)
static enum net_conn_mgr_state conn_mgr_ipv4_status(int index)
static enum conn_mgr_state conn_mgr_ipv4_status(int index)
{
if ((iface_states[index] & CONN_MGR_IPV4_STATUS_MASK) ==
CONN_MGR_IPV4_STATUS_MASK) {
NET_DBG("IPv4 connected on iface index %u", index + 1);
return NET_CONN_MGR_STATE_CONNECTED;
return CONN_MGR_STATE_CONNECTED;
}
return NET_CONN_MGR_STATE_DISCONNECTED;
return CONN_MGR_STATE_DISCONNECTED;
}
#else
#define conn_mgr_ipv4_status(...) NET_CONN_MGR_STATE_CONNECTED
#define conn_mgr_ipv4_status(...) CONN_MGR_STATE_CONNECTED
#endif /* CONFIG_NET_IPV4 */
static void conn_mgr_notify_status(int index)
@ -90,7 +90,7 @@ static void conn_mgr_act_on_changes(void)
int idx;
for (idx = 0; idx < ARRAY_SIZE(iface_states); idx++) {
enum net_conn_mgr_state state;
enum conn_mgr_state state;
if (iface_states[idx] == 0) {
/* This interface is not used */
@ -101,12 +101,11 @@ static void conn_mgr_act_on_changes(void)
continue;
}
state = NET_CONN_MGR_STATE_CONNECTED;
state = CONN_MGR_STATE_CONNECTED;
state &= conn_mgr_iface_status(idx);
if (state) {
enum net_conn_mgr_state ip_state =
NET_CONN_MGR_STATE_DISCONNECTED;
enum conn_mgr_state ip_state = CONN_MGR_STATE_DISCONNECTED;
if (IS_ENABLED(CONFIG_NET_IPV6)) {
ip_state |= conn_mgr_ipv6_status(idx);
@ -121,12 +120,12 @@ static void conn_mgr_act_on_changes(void)
iface_states[idx] &= ~NET_STATE_CHANGED;
if (state == NET_CONN_MGR_STATE_CONNECTED &&
if (state == CONN_MGR_STATE_CONNECTED &&
!(iface_states[idx] & NET_STATE_CONNECTED)) {
iface_states[idx] |= NET_STATE_CONNECTED;
conn_mgr_notify_status(idx);
} else if (state != NET_CONN_MGR_STATE_CONNECTED &&
} else if (state != CONN_MGR_STATE_CONNECTED &&
(iface_states[idx] & NET_STATE_CONNECTED)) {
iface_states[idx] &= ~NET_STATE_CONNECTED;
@ -194,7 +193,7 @@ K_THREAD_DEFINE(conn_mgr, CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE,
(k_thread_entry_t)conn_mgr_handler, NULL, NULL, NULL,
THREAD_PRIORITY, 0, 0);
void net_conn_mgr_resend_status(void)
void conn_mgr_resend_status(void)
{
int idx;

View File

@ -4,8 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __CONN_MGR_H__
#define __CONN_MGR_H__
#ifndef __CONN_MGR_PRV_H__
#define __CONN_MGR_PRV_H__
#if defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_IPV4)
#define CONN_MGR_IFACE_MAX MAX(CONFIG_NET_IF_MAX_IPV6_COUNT, \
@ -42,11 +42,11 @@
extern struct k_sem conn_mgr_lock;
enum net_conn_mgr_state {
NET_CONN_MGR_STATE_DISCONNECTED = 0,
NET_CONN_MGR_STATE_CONNECTED = 1,
enum conn_mgr_state {
CONN_MGR_STATE_DISCONNECTED = 0,
CONN_MGR_STATE_CONNECTED = 1,
};
void conn_mgr_init_events_handler(void);
#endif /* __CONN_MGR_H__ */
#endif /* __CONN_MGR_PRV_H__ */

View File

@ -11,7 +11,7 @@ LOG_MODULE_DECLARE(conn_mgr, CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL);
#include <zephyr/net/net_if.h>
#include <zephyr/net/net_mgmt.h>
#include <conn_mgr.h>
#include "conn_mgr_private.h"
extern uint16_t iface_states[CONN_MGR_IFACE_MAX];

View File

@ -11,7 +11,6 @@ add_subdirectory_ifdef(CONFIG_TFTP_LIB tftp)
add_subdirectory_ifdef(CONFIG_NET_CONFIG_SETTINGS config)
add_subdirectory_ifdef(CONFIG_NET_SOCKETS sockets)
add_subdirectory_ifdef(CONFIG_TLS_CREDENTIALS tls_credentials)
add_subdirectory_ifdef(CONFIG_NET_CONNECTION_MANAGER conn_mgr)
add_subdirectory_ifdef(CONFIG_NET_CAPTURE capture)
add_subdirectory_ifdef(CONFIG_NET_ZPERF zperf)

View File

@ -37,8 +37,6 @@ endmenu
menu "Network additional services"
source "subsys/net/lib/conn_mgr/Kconfig"
source "subsys/net/lib/capture/Kconfig"
source "subsys/net/lib/zperf/Kconfig"

View File

@ -716,7 +716,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);
net_conn_mgr_resend_status();
conn_mgr_resend_status();
return 0;
}