Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
conn_mgr_connectivity.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_CONN_MGR_CONNECTIVITY_H_
14#define ZEPHYR_INCLUDE_CONN_MGR_CONNECTIVITY_H_
15
16#include <zephyr/device.h>
17#include <zephyr/net/net_if.h>
19#include <zephyr/net/net_mgmt.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
33
34
36
37/* Connectivity Events */
38#define NET_MGMT_CONN_LAYER NET_MGMT_LAYER(NET_MGMT_LAYER_L2)
39#define NET_MGMT_CONN_CODE NET_MGMT_LAYER_CODE(NET_MGMT_LAYER_CODE_CONN)
40#define NET_MGMT_CONN_BASE (NET_MGMT_CONN_LAYER | NET_MGMT_CONN_CODE | \
41 NET_MGMT_EVENT_BIT)
42#define NET_MGMT_CONN_IF_EVENT (NET_MGMT_IFACE_BIT | NET_MGMT_CONN_BASE)
43
44enum {
45 NET_EVENT_CONN_CMD_IF_TIMEOUT_VAL,
46 NET_EVENT_CONN_CMD_IF_FATAL_ERROR_VAL,
47 NET_EVENT_CONN_CMD_IF_IDLE_TIMEOUT_VAL,
48 NET_EVENT_CONN_CMD_IF_NO_CONFIGURATION_VAL,
49
50 NET_EVENT_CONN_CMD_MAX
51};
52
53BUILD_ASSERT(NET_EVENT_CONN_CMD_MAX <= NET_MGMT_MAX_COMMANDS,
54 "Number of events in net_event_conn_cmd exceeds the limit");
55
56enum net_event_conn_cmd {
57 NET_MGMT_CMD(NET_EVENT_CONN_CMD_IF_TIMEOUT),
58 NET_MGMT_CMD(NET_EVENT_CONN_CMD_IF_FATAL_ERROR),
59 NET_MGMT_CMD(NET_EVENT_CONN_CMD_IF_IDLE_TIMEOUT),
60 NET_MGMT_CMD(NET_EVENT_CONN_CMD_IF_NO_CONFIGURATION),
61};
62
64
68#define NET_EVENT_CONN_IF_TIMEOUT \
69 (NET_MGMT_CONN_IF_EVENT | NET_EVENT_CONN_CMD_IF_TIMEOUT)
70
74#define NET_EVENT_CONN_IF_FATAL_ERROR \
75 (NET_MGMT_CONN_IF_EVENT | NET_EVENT_CONN_CMD_IF_FATAL_ERROR)
76
80#define NET_EVENT_CONN_IF_IDLE_TIMEOUT \
81 (NET_MGMT_CONN_IF_EVENT | NET_EVENT_CONN_CMD_IF_IDLE_TIMEOUT)
82
86#define NET_EVENT_CONN_IF_NO_CONFIGURATION \
87 (NET_MGMT_CONN_IF_EVENT | NET_EVENT_CONN_CMD_IF_NO_CONFIGURATION)
88
100
108
116
122 CONN_MGR_IF_DISCONNECTING,
123
124 /* Total number of flags - must be at the end of the enum */
125 CONN_MGR_NUM_IF_FLAGS,
127};
128
132#define CONN_MGR_IF_NO_TIMEOUT 0
133
151int conn_mgr_if_connect(struct net_if *iface);
152
168
177bool conn_mgr_if_is_bound(struct net_if *iface);
178
198int conn_mgr_if_set_opt(struct net_if *iface, int optname, const void *optval, size_t optlen);
199
226int conn_mgr_if_get_opt(struct net_if *iface, int optname, void *optval, size_t *optlen);
227
240bool conn_mgr_if_get_flag(struct net_if *iface, enum conn_mgr_if_flag flag);
241
255int conn_mgr_if_set_flag(struct net_if *iface, enum conn_mgr_if_flag flag, bool value);
256
268
281int conn_mgr_if_set_timeout(struct net_if *iface, int timeout);
282
294
307int conn_mgr_if_set_idle_timeout(struct net_if *iface, int timeout);
308
309#if defined(CONFIG_NET_CONNECTION_MANAGER) || defined(__DOXYGEN__)
317void conn_mgr_if_used(struct net_if *iface);
318#else
319#define conn_mgr_if_used(iface) (void)(iface)
320#endif /* defined(CONFIG_NET_CONNECTION_MANAGER) || defined(__DOXYGEN__) */
321
325
334
345int conn_mgr_all_if_up(bool skip_ignored);
346
347
358int conn_mgr_all_if_down(bool skip_ignored);
359
371int conn_mgr_all_if_connect(bool skip_ignored);
372
384int conn_mgr_all_if_disconnect(bool skip_ignored);
385
389
390#ifdef __cplusplus
391}
392#endif
393
394#endif /* ZEPHYR_INCLUDE_CONN_MGR_CONNECTIVITY_H_ */
int conn_mgr_all_if_disconnect(bool skip_ignored)
Convenience function that disconnects all available ifaces that support connectivity without putting ...
int conn_mgr_all_if_connect(bool skip_ignored)
Convenience function that takes all available ifaces into the admin-up state, and connects those that...
int conn_mgr_all_if_up(bool skip_ignored)
Convenience function that takes all available ifaces into the admin-up state.
int conn_mgr_all_if_down(bool skip_ignored)
Convenience function that takes all available ifaces into the admin-down state.
bool conn_mgr_if_is_bound(struct net_if *iface)
Check whether the provided network interface supports connectivity / has been bound to a connectivity...
int conn_mgr_if_set_opt(struct net_if *iface, int optname, const void *optval, size_t optlen)
Set implementation-specific connectivity options.
void conn_mgr_if_used(struct net_if *iface)
Notify connection manager that interface was just used.
bool conn_mgr_if_get_flag(struct net_if *iface, enum conn_mgr_if_flag flag)
Check the value of connectivity flags.
int conn_mgr_if_set_timeout(struct net_if *iface, int timeout)
Set the connectivity timeout for an iface.
int conn_mgr_if_connect(struct net_if *iface)
Connect interface.
int conn_mgr_if_get_idle_timeout(struct net_if *iface)
Get the idle timeout for an iface.
int conn_mgr_if_set_idle_timeout(struct net_if *iface, int timeout)
Set the idle timeout for an iface.
int conn_mgr_if_get_opt(struct net_if *iface, int optname, void *optval, size_t *optlen)
Get implementation-specific connectivity options.
int conn_mgr_if_disconnect(struct net_if *iface)
Disconnect interface.
int conn_mgr_if_get_timeout(struct net_if *iface)
Get the connectivity timeout for an iface.
int conn_mgr_if_set_flag(struct net_if *iface, enum conn_mgr_if_flag flag, bool value)
Set the value of a connectivity flags.
conn_mgr_if_flag
Per-iface connectivity flags.
Definition conn_mgr_connectivity.h:92
@ CONN_MGR_IF_PERSISTENT
Persistent.
Definition conn_mgr_connectivity.h:99
@ CONN_MGR_IF_NO_AUTO_DOWN
No auto-down.
Definition conn_mgr_connectivity.h:115
@ CONN_MGR_IF_NO_AUTO_CONNECT
No auto-connect.
Definition conn_mgr_connectivity.h:107
@ NET_MGMT_CMD
Scan results available.
Definition wifi_mgmt.h:381
#define BUILD_ASSERT(EXPR, MSG...)
Definition llvm.h:51
Public API for network interface.
Network Management API public header.
Network Interface structure.
Definition net_if.h:731