Go to the documentation of this file.
45 #define PACKET_ID_MAX UINT32_MAX
53 #define PACKET_ID_WRAP_TRIGGER 0xFF000000
56 #define htonpid(x) htonl(x)
59 #define ntohpid(x) ntohl(x)
62 #define htontime(x) htonl((net_time_t)x)
65 #define ntohtime(x) ((time_t)ntohl(x))
78 #define PACKET_ID_WRAP_TRIGGER 0x80
80 #define htonpid(x) (x)
81 #define ntohpid(x) (x)
82 #define htontime(x) htons((net_time_t)x)
83 #define ntohtime(x) ((time_t)ntohs(x))
90 #define packet_id_format "%u"
98 #define MIN_SEQ_BACKTRACK 0
99 #define MAX_SEQ_BACKTRACK 65536
100 #define DEFAULT_SEQ_BACKTRACK 64
107 #define MIN_TIME_BACKTRACK 0
108 #define MAX_TIME_BACKTRACK 600
109 #define DEFAULT_TIME_BACKTRACK 15
118 #define SEQ_REAP_INTERVAL 5
261 bool long_form,
bool prepend);
325 const time_t local_now =
now;
327 if (local_now >= remote)
329 abs = local_now - remote;
333 abs = remote - local_now;
335 return abs <= max_delta;
void packet_id_persist_init(struct packet_id_persist *p)
bool packet_id_write(struct packet_id_send *p, struct buffer *buf, bool long_form, bool prepend)
Write a packet ID to buf, and update the packet ID state.
static bool packet_id_persist_enabled(const struct packet_id_persist *p)
const char * packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
CIRC_LIST(seq_list, time_t)
static bool packet_id_initialized(const struct packet_id *pid)
Is this struct packet_id initialized?
#define SEQ_REAP_INTERVAL
const char * packet_id_persist_print(const struct packet_id_persist *p, struct gc_arena *gc)
bool packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
void packet_id_persist_close(struct packet_id_persist *p)
void packet_id_persist_load(struct packet_id_persist *p, const char *filename)
static void packet_id_persist_save_obj(struct packet_id_persist *p, const struct packet_id *pid)
static void reset_packet_id_send(struct packet_id_send *p)
Reset the current send packet id to its initial state.
#define PACKET_ID_WRAP_TRIGGER
bool packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin)
void packet_id_persist_load_obj(const struct packet_id_persist *p, struct packet_id *pid)
Wrapper structure for dynamically allocated memory.
void packet_id_persist_save(struct packet_id_persist *p)
unsigned int packet_id_print_type
static void packet_id_reap_test(struct packet_id_rec *p)
Garbage collection arena used to keep track of dynamically allocated memory.
void packet_id_init(struct packet_id *p, int seq_backtrack, int time_backtrack, const char *name, int unit)
void packet_id_free(struct packet_id *p)
packet_id_type id_last_written
struct packet_id_send send
static int packet_id_size(bool long_form)
void packet_id_add(struct packet_id_rec *p, const struct packet_id_net *pin)
static bool check_timestamp_delta(time_t remote, unsigned int max_delta)
static bool packet_id_close_to_wrapping(const struct packet_id_send *p)
void packet_id_reap(struct packet_id_rec *p)
struct seq_list * seq_list