You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
820 B
36 lines
820 B
#ifndef NTP_NODE_TIME_H |
|
#define NTP_NODE_TIME_H |
|
|
|
#include <stdint.h> |
|
|
|
#ifdef __cplusplus |
|
extern "C" { |
|
#endif |
|
|
|
struct UTUN_INSTANCE; |
|
|
|
#define NTP_NODE_MAX_PEERS 32 |
|
|
|
#define NTP_NODE_DRIFT_WARN_US 2000000LL // 2 seconds |
|
#define NTP_NODE_DRIFT_ERROR_US 10000000LL // 10 seconds |
|
|
|
struct NTP_NODE_PEER { |
|
uint64_t node_id; |
|
int64_t offset_us; // my_time_recv - peer_time (positive = my clock ahead) |
|
int has_offset; // first offset already stored, subsequent deltas are real drift |
|
}; |
|
|
|
struct NTP_NODE_TIME { |
|
struct NTP_NODE_PEER peers[NTP_NODE_MAX_PEERS]; |
|
int peer_count; |
|
}; |
|
|
|
int ntp_node_time_init(struct UTUN_INSTANCE* inst); |
|
void ntp_node_time_destroy(struct UTUN_INSTANCE* inst); |
|
void ntp_node_sync_peers(struct UTUN_INSTANCE* inst); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
|
|
#endif // NTP_NODE_TIME_H
|
|
|