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