1 /*
2  * Copyright (c) 2018 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_CONN_MGR_H_
8 #define ZEPHYR_INCLUDE_CONN_MGR_H_
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #if defined(CONFIG_NET_CONNECTION_MANAGER) || defined(__DOXYGEN__)
15 
16 /**
17  * @brief Connection Manager API
18  * @defgroup conn_mgr Connection Manager API
19  * @ingroup networking
20  * @{
21  */
22 
23 struct net_if;
24 struct net_l2;
25 
26 /**
27  * @brief Resend either NET_L4_CONNECTED or NET_L4_DISCONNECTED depending on whether connectivity
28  * is currently available.
29  */
30 void conn_mgr_mon_resend_status(void);
31 
32 /**
33  * @brief Mark an iface to be ignored by conn_mgr.
34  *
35  * Ignoring an iface forces conn_mgr to consider it unready/disconnected.
36  *
37  * This means that events related to the iface connecting/disconnecting will not be fired,
38  * and if the iface was connected before being ignored, events will be fired as though it
39  * disconnected at that moment.
40  *
41  * @param iface iface to be ignored.
42  */
43 void conn_mgr_ignore_iface(struct net_if *iface);
44 
45 /**
46  * @brief Watch (stop ignoring) an iface.
47  *
48  * conn_mgr will no longer be forced to consider the iface unreadly/disconnected.
49  *
50  * Events related to the iface connecting/disconnecting will no longer be blocked,
51  * and if the iface was connected before being watched, events will be fired as though
52  * it connected in that moment.
53  *
54  * All ifaces default to watched at boot.
55  *
56  * @param iface iface to no longer ignore.
57  */
58 void conn_mgr_watch_iface(struct net_if *iface);
59 
60 /**
61  * @brief Check whether the provided iface is currently ignored.
62  *
63  * @param iface The iface to check.
64  * @retval true if the iface is being ignored by conn_mgr.
65  * @retval false if the iface is being watched by conn_mgr.
66  */
67 bool conn_mgr_is_iface_ignored(struct net_if *iface);
68 
69 /**
70  * @brief Mark an L2 to be ignored by conn_mgr.
71  *
72  * This is a wrapper for conn_mgr_ignore_iface that ignores all ifaces that use the L2.
73  *
74  * @param l2 L2 to be ignored.
75  */
76 void conn_mgr_ignore_l2(const struct net_l2 *l2);
77 
78 /**
79  * @brief Watch (stop ignoring) an L2.
80  *
81  *  This is a wrapper for conn_mgr_watch_iface that watches all ifaces that use the L2.
82  *
83  * @param l2 L2 to watch.
84  */
85 void conn_mgr_watch_l2(const struct net_l2 *l2);
86 
87 /**
88  * @}
89  */
90 
91 #else
92 
93 #define conn_mgr_mon_resend_status(...)
94 #define conn_mgr_ignore_iface(...)
95 #define conn_mgr_watch_iface(...)
96 #define conn_mgr_ignore_l2(...)
97 #define conn_mgr_watch_l2(...)
98 
99 #endif /* CONFIG_NET_CONNECTION_MANAGER */
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* ZEPHYR_INCLUDE_CONN_MGR_H_ */
106