Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
conn_mgr_monitor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
11
12#ifndef ZEPHYR_INCLUDE_NET_CONN_MGR_MONITOR_H_
13#define ZEPHYR_INCLUDE_NET_CONN_MGR_MONITOR_H_
14
15#include <errno.h>
16#include <stddef.h>
17#include <stdint.h>
18#include <zephyr/kernel.h>
19#include <zephyr/net/net_ip.h>
20#include <zephyr/sys/clock.h>
21#include <zephyr/sys/util.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
35
42#define CONN_MGR_READY_IPV4 BIT(0)
44#define CONN_MGR_READY_IPV6 BIT(1)
46#define CONN_MGR_READY_IP_ANY BIT(2)
54#define CONN_MGR_READY_DNS BIT(3)
56
57#if defined(CONFIG_NET_CONNECTION_MANAGER) || defined(__DOXYGEN__)
58
59struct net_if;
60struct net_l2;
61
72
84
95
112
150int conn_mgr_wait_ready(uint32_t mask, uint32_t *last_seen, k_timeout_t timeout);
151
163void conn_mgr_ignore_iface(struct net_if *iface);
164
178void conn_mgr_watch_iface(struct net_if *iface);
179
188
196void conn_mgr_ignore_l2(const struct net_l2 *l2);
197
205void conn_mgr_watch_l2(const struct net_l2 *l2);
206
207#else
208
209#define conn_mgr_mon_resend_status(...)
210#define conn_mgr_ignore_iface(...)
211#define conn_mgr_watch_iface(...)
212#define conn_mgr_ignore_l2(...)
213#define conn_mgr_watch_l2(...)
214
215/* Readiness is not tracked: everything is assumed ready */
216static inline uint32_t conn_mgr_get_readiness(void)
217{
220}
221
223{
224 return NET_AF_UNSPEC;
225}
226
227static inline int conn_mgr_wait_ready(uint32_t mask, uint32_t *last_seen, k_timeout_t timeout)
228{
229 if ((mask == 0U) || ((mask & ~(CONN_MGR_READY_IPV4 | CONN_MGR_READY_IPV6 |
231 return -EINVAL;
232 }
233
234 if (last_seen == NULL) {
235 return 0;
236 }
237
238 /* Ready since boot: the first call returns at once, later ones after timeout */
239 if (*last_seen == 0U) {
240 *last_seen = 1U;
241 return 0;
242 }
243
244 k_sleep(timeout);
245
246 return 0;
247}
248
249#endif /* CONFIG_NET_CONNECTION_MANAGER */
250
254
255#ifdef __cplusplus
256}
257#endif
258
259#endif /* ZEPHYR_INCLUDE_NET_CONN_MGR_MONITOR_H_ */
System clock APIs.
System error numbers.
#define CONN_MGR_READY_IPV6
An iface is ready with IPv6, see NET_EVENT_L4_IPV6_CONNECTED.
Definition conn_mgr_monitor.h:44
#define CONN_MGR_READY_DNS
A unicast DNS server is configured for a ready IP family, or name resolution is offloaded,...
Definition conn_mgr_monitor.h:54
uint32_t conn_mgr_get_readiness(void)
Get the current readiness flags.
int conn_mgr_wait_ready(uint32_t mask, uint32_t *last_seen, k_timeout_t timeout)
Wait until it is time to try to connect.
void conn_mgr_ignore_l2(const struct net_l2 *l2)
Mark an L2 to be ignored by conn_mgr.
#define CONN_MGR_READY_IP_ANY
CONN_MGR_READY_IPV4 or CONN_MGR_READY_IPV6 is set.
Definition conn_mgr_monitor.h:46
void conn_mgr_ignore_iface(struct net_if *iface)
Mark an iface to be ignored by conn_mgr.
bool conn_mgr_dns_is_ready(void)
Check whether name resolution is currently available.
void conn_mgr_watch_iface(struct net_if *iface)
Watch (stop ignoring) an iface.
void conn_mgr_mon_resend_status(void)
Resend L4 connectivity and DNS readiness events depending on current status.
void conn_mgr_watch_l2(const struct net_l2 *l2)
Watch (stop ignoring) an L2.
bool conn_mgr_is_iface_ignored(struct net_if *iface)
Check whether the provided iface is currently ignored.
#define CONN_MGR_READY_IPV4
An iface is ready with IPv4, see NET_EVENT_L4_IPV4_CONNECTED.
Definition conn_mgr_monitor.h:42
net_sa_family_t conn_mgr_get_ready_addr_family(void)
Get the address family to use in getaddrinfo() hints.
#define NET_AF_UNSPEC
Unspecified address family.
Definition net_ip.h:54
unsigned short int net_sa_family_t
Socket address family type.
Definition net_ip.h:169
#define EINVAL
Invalid argument.
Definition errno.h:61
static ALWAYS_INLINE int32_t k_sleep(k_timeout_t timeout)
Put the current thread to sleep.
Definition sleep.h:204
Public kernel APIs.
IPv6 and IPv4 definitions.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Kernel timeout type.
Definition clock.h:65
Network Interface structure.
Definition net_if.h:875
Network L2 structure.
Definition net_l2.h:58
Misc utilities.