1 /*
2  * Copyright (c) 2019 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef __CONN_MGR_PRV_H__
8 #define __CONN_MGR_PRV_H__
9 
10 #include <zephyr/net/conn_mgr_connectivity.h>
11 #include <zephyr/sys/iterable_sections.h>
12 
13 #if defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_IPV4)
14 #define CONN_MGR_IFACE_MAX		MAX(CONFIG_NET_IF_MAX_IPV6_COUNT, \
15 					    CONFIG_NET_IF_MAX_IPV4_COUNT)
16 #elif defined(CONFIG_NET_IPV6)
17 #define CONN_MGR_IFACE_MAX		CONFIG_NET_IF_MAX_IPV6_COUNT
18 #else
19 #define CONN_MGR_IFACE_MAX		CONFIG_NET_IF_MAX_IPV4_COUNT
20 #endif
21 
22 /* External state flags */
23 #define CONN_MGR_IF_UP			BIT(0)
24 #define CONN_MGR_IF_IPV6_SET		BIT(1)
25 #define CONN_MGR_IF_IPV4_SET		BIT(2)
26 
27 /* Configuration flags */
28 #define CONN_MGR_IF_IGNORED		BIT(7)
29 
30 /* Internal state flags */
31 #define CONN_MGR_IF_READY		BIT(14)
32 
33 /* Event flags */
34 #define CONN_MGR_IF_CHANGED		BIT(15)
35 
36 /* NET_MGMT event masks */
37 #define CONN_MGR_IFACE_EVENTS_MASK	(NET_EVENT_IF_DOWN		| \
38 					 NET_EVENT_IF_UP)
39 
40 #define CONN_MGR_CONN_IFACE_EVENTS_MASK	(NET_EVENT_IF_ADMIN_UP		|\
41 					 NET_EVENT_IF_DOWN)
42 
43 #define CONN_MGR_CONN_SELF_EVENTS_MASK	(NET_EVENT_CONN_IF_TIMEOUT	| \
44 					 NET_EVENT_CONN_IF_FATAL_ERROR)
45 
46 #define CONN_MGR_IPV6_EVENTS_MASK	(NET_EVENT_IPV6_ADDR_ADD	| \
47 					 NET_EVENT_IPV6_ADDR_DEL	| \
48 					 NET_EVENT_IPV6_DAD_SUCCEED	| \
49 					 NET_EVENT_IPV6_DAD_FAILED)
50 
51 #define CONN_MGR_IPV4_EVENTS_MASK	(NET_EVENT_IPV4_ADDR_ADD	| \
52 					 NET_EVENT_IPV4_ADDR_DEL)
53 
54 extern struct k_sem conn_mgr_mon_updated;
55 extern struct k_mutex conn_mgr_mon_lock;
56 
57 void conn_mgr_init_events_handler(void);
58 
59 /* Cause conn_mgr_connectivity to Initialize all connectivity implementation bindings */
60 void conn_mgr_conn_init(void);
61 
62 #endif /* __CONN_MGR_PRV_H__ */
63