123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #ifndef ZEPHYR_INCLUDE_NET_TRICKLE_H_
- #define ZEPHYR_INCLUDE_NET_TRICKLE_H_
- #include <stdbool.h>
- #include <zephyr/types.h>
- #include <kernel.h>
- #include <net/net_core.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct net_trickle;
- typedef void (*net_trickle_cb_t)(struct net_trickle *trickle,
- bool do_suppress, void *user_data);
- struct net_trickle {
- uint32_t Imin;
- uint8_t Imax;
- uint8_t k;
- uint32_t I;
- uint32_t Istart;
- uint8_t c;
- uint32_t Imax_abs;
- bool double_to;
- struct k_work_delayable timer;
- net_trickle_cb_t cb;
- void *user_data;
- };
- #define NET_TRICKLE_INFINITE_REDUNDANCY 0
- int net_trickle_create(struct net_trickle *trickle,
- uint32_t Imin,
- uint8_t Imax,
- uint8_t k);
- int net_trickle_start(struct net_trickle *trickle,
- net_trickle_cb_t cb,
- void *user_data);
- int net_trickle_stop(struct net_trickle *trickle);
- void net_trickle_consistency(struct net_trickle *trickle);
- void net_trickle_inconsistency(struct net_trickle *trickle);
- static inline bool net_trickle_is_running(struct net_trickle *trickle)
- {
- NET_ASSERT(trickle);
- return trickle->I != 0U;
- }
- #ifdef __cplusplus
- }
- #endif
- #endif
|