Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
net_timeout.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2018 Intel Corporation
9 * Copyright (c) 2020 Nordic Semiconductor ASA
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 */
13
14#ifndef ZEPHYR_INCLUDE_NET_NET_TIMEOUT_H_
15#define ZEPHYR_INCLUDE_NET_NET_TIMEOUT_H_
16
24#include <string.h>
25#include <stdbool.h>
26#include <limits.h>
27#include <zephyr/types.h>
28#include <sys/slist.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
48#define NET_TIMEOUT_MAX_VALUE ((uint32_t)INT32_MAX)
49
63
64 /* Time at which the timer was last set.
65 *
66 * This usually corresponds to the low 32 bits of k_uptime_get(). */
68
69 /* Portion of remaining timeout that does not exceed
70 * NET_TIMEOUT_MAX_VALUE.
71 *
72 * This value is updated in parallel with timer_start and wrap_counter
73 * by net_timeout_evaluate().
74 */
76
77 /* Timer wrap count.
78 *
79 * This tracks multiples of NET_TIMEOUT_MAX_VALUE milliseconds that
80 * have yet to pass. It is also updated along with timer_start and
81 * wrap_counter by net_timeout_evaluate().
82 */
84};
85
96 uint32_t lifetime,
98
113 int64_t now);
114
133 uint32_t now);
134
154 uint32_t now);
155
156#ifdef __cplusplus
157}
158#endif
159
165#endif /* ZEPHYR_INCLUDE_NET_NET_TIMEOUT_H_ */
ZTEST_BMEM int timeout
Definition: main.c:31
uint32_t net_timeout_evaluate(struct net_timeout *timeout, uint32_t now)
Update state to reflect elapsed time and get new delay.
uint32_t net_timeout_remaining(const struct net_timeout *timeout, uint32_t now)
Calculate the remaining time to the timeout in whole seconds.
int64_t net_timeout_deadline(const struct net_timeout *timeout, int64_t now)
Return the 64-bit system time at which the timeout will complete.
void net_timeout_set(struct net_timeout *timeout, uint32_t lifetime, uint32_t now)
Configure a network timeout structure.
Single-linked list implementation.
struct _snode sys_snode_t
Definition: slist.h:33
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__INT64_TYPE__ int64_t
Definition: stdint.h:45
Definition: net_timeout.h:55
uint32_t timer_timeout
Definition: net_timeout.h:75
uint32_t wrap_counter
Definition: net_timeout.h:83
sys_snode_t node
Definition: net_timeout.h:62
uint32_t timer_start
Definition: net_timeout.h:67
static uint32_t now
Definition: main.c:25