OpenVPN
packet_id.c
Go to the documentation of this file.
1/*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single TCP/UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
7 *
8 * Copyright (C) 2002-2026 OpenVPN Inc <sales@openvpn.net>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, see <https://www.gnu.org/licenses/>.
21 */
22
23/*
24 * These routines are designed to catch replay attacks,
25 * where a man-in-the-middle captures packets and then
26 * attempts to replay them back later.
27 *
28 * We use the "sliding-window" algorithm, similar
29 * to IPSec.
30 */
31
32#ifdef HAVE_CONFIG_H
33#include "config.h"
34#endif
35
36#include "syshead.h"
37
38#include <stddef.h>
39
40#include "packet_id.h"
41#include "misc.h"
42#include "integer.h"
43
44#include "memdbg.h"
45
46/* #define PID_SIMULATE_BACKTRACK */
47
48/*
49 * Special time_t value that indicates that
50 * sequence number has expired.
51 */
52#define SEQ_UNSEEN ((time_t)0)
53#define SEQ_EXPIRED ((time_t)1)
54
55#ifndef ENABLE_SMALL
56static void packet_id_debug_print(msglvl_t msglevel, const struct packet_id_rec *p,
57 const struct packet_id_net *pin, const char *message,
59
60#endif
61
62static inline void
63packet_id_debug(msglvl_t msglevel, const struct packet_id_rec *p,
64 const struct packet_id_net *pin, const char *message, uint64_t value)
65{
66#ifndef ENABLE_SMALL
67 if (unlikely(check_debug_level(msglevel)))
68 {
69 packet_id_debug_print(msglevel, p, pin, message, value);
70 }
71#endif
72}
73
74static void
75packet_id_init_recv(struct packet_id_rec *rec, int seq_backtrack, int time_backtrack,
76 const char *name, int unit)
77{
78 rec->name = name;
79 rec->unit = unit;
80 if (seq_backtrack)
81 {
82 ASSERT(MIN_SEQ_BACKTRACK <= seq_backtrack && seq_backtrack <= MAX_SEQ_BACKTRACK);
83 ASSERT(MIN_TIME_BACKTRACK <= time_backtrack && time_backtrack <= MAX_TIME_BACKTRACK);
84 CIRC_LIST_ALLOC(rec->seq_list, struct seq_list, seq_backtrack);
85 rec->seq_backtrack = seq_backtrack;
86 rec->time_backtrack = time_backtrack;
87 }
88 rec->initialized = true;
89}
90void
91packet_id_init(struct packet_id *p, int seq_backtrack, int time_backtrack, const char *name,
92 int unit)
93{
94 dmsg(D_PID_DEBUG, "PID packet_id_init seq_backtrack=%d time_backtrack=%d", seq_backtrack,
95 time_backtrack);
96
97 ASSERT(p);
98 CLEAR(*p);
99
100 packet_id_init_recv(&p->rec, seq_backtrack, time_backtrack, name, unit);
101}
102
103void
105{
106 ASSERT(src);
107 ASSERT(dest);
108 /* clear free any old data in rec list */
109 free(dest->seq_list);
110 CLEAR(*dest);
111
112 /* Copy data to dest */
113 *dest = *src;
114
115 /* Reinitalise the source */
116 CLEAR(*src);
117 packet_id_init_recv(src, (int)dest->seq_backtrack, dest->time_backtrack, dest->name, dest->unit);
118}
119
120void
122{
123 if (p)
124 {
125 dmsg(D_PID_DEBUG, "PID packet_id_free");
126 free(p->rec.seq_list);
127 CLEAR(*p);
128 }
129}
130
131void
132packet_id_add(struct packet_id_rec *p, const struct packet_id_net *pin)
133{
134 const time_t local_now = now;
135 if (p->seq_list)
136 {
137 int64_t diff;
138
139 /*
140 * If time value increases, start a new sequence list of number
141 * sequence for the new time point.
142 */
143 if (!CIRC_LIST_SIZE(p->seq_list) || pin->time > p->time
144 || (pin->id >= p->seq_backtrack && pin->id - p->seq_backtrack > p->id))
145 {
146 p->time = pin->time;
147 p->id = 0;
148 if (pin->id > p->seq_backtrack)
149 {
150 p->id = pin->id - p->seq_backtrack;
151 }
153 }
154
155 while (p->id < pin->id
156#ifdef PID_SIMULATE_BACKTRACK
157 || (get_random() % 64) < 31
158#endif
159 )
160 {
162 ++p->id;
163 }
164
165 diff = p->id - pin->id;
166 if (diff < CIRC_LIST_SIZE(p->seq_list) && local_now > SEQ_EXPIRED)
167 {
168 CIRC_LIST_ITEM(p->seq_list, (int)diff) = local_now;
169 }
170 }
171 else
172 {
173 p->time = pin->time;
174 p->id = pin->id;
175 }
176}
177
178/*
179 * Expire sequence numbers which can no longer
180 * be accepted because they would violate
181 * time_backtrack.
182 */
183void
185{
186 const time_t local_now = now;
187 if (p->time_backtrack)
188 {
189 bool expire = false;
190 for (int i = 0; i < CIRC_LIST_SIZE(p->seq_list); ++i)
191 {
192 const time_t t = CIRC_LIST_ITEM(p->seq_list, i);
193 if (t == SEQ_EXPIRED)
194 {
195 break;
196 }
197 if (!expire && t && t + p->time_backtrack < local_now)
198 {
199 expire = true;
200 }
201 if (expire)
202 {
204 }
205 }
206 }
207 p->last_reap = local_now;
208}
209
210/*
211 * Return true if packet id is ok, or false if
212 * it is a replay.
213 */
214bool
215packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin)
216{
217 packet_id_debug(D_PID_DEBUG, p, pin, "PID_TEST", 0);
218
220
221 if (!pin->id)
222 {
223 return false;
224 }
225
226 if (p->seq_backtrack)
227 {
228 /*
229 * In backtrack mode, we allow packet reordering subject
230 * to the seq_backtrack and time_backtrack constraints.
231 *
232 * This mode is used with UDP.
233 */
234 if (pin->time == p->time)
235 {
236 /* is packet-id greater than any one we've seen yet? */
237 if (pin->id > p->id)
238 {
239 return true;
240 }
241
242 /* check packet-id sliding window for original/replay status */
243 const uint64_t diff = p->id - pin->id;
244
245 /* keep track of maximum backtrack seen for debugging purposes */
246 if (diff > p->max_backtrack_stat)
247 {
248 p->max_backtrack_stat = diff;
249 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR replay-window backtrack occurred",
251 }
252
253 if (diff >= (packet_id_type)CIRC_LIST_SIZE(p->seq_list))
254 {
255 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR large diff", diff);
256 return false;
257 }
258
259 const time_t v = CIRC_LIST_ITEM(p->seq_list, (int)diff);
260 if (v == 0)
261 {
262 return true;
263 }
264 else
265 {
266 /* raised from D_PID_DEBUG_LOW to reduce verbosity */
267 packet_id_debug(D_PID_DEBUG_MEDIUM, p, pin, "PID_ERR replay", diff);
268 return false;
269 }
270 }
271 else if (pin->time < p->time) /* if time goes back, reject */
272 {
273 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR time backtrack", 0);
274 return false;
275 }
276 else /* time moved forward */
277 {
278 return true;
279 }
280 }
281 else
282 {
283 /*
284 * In non-backtrack mode, all sequence number series must
285 * begin at some number n > 0 and must increment linearly without gaps.
286 *
287 * This mode is used with TCP.
288 */
289 if (pin->time == p->time)
290 {
291 return !p->id || pin->id == p->id + 1;
292 }
293 else if (pin->time < p->time) /* if time goes back, reject */
294 {
295 return false;
296 }
297 else /* time moved forward */
298 {
299 return pin->id == 1;
300 }
301 }
302}
303
304/*
305 * Read/write a packet ID to/from the buffer. Short form is sequence number
306 * only. Long form is sequence number and timestamp.
307 */
308
309bool
310packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
311{
312 packet_id_type net_id;
313 net_time_t net_time;
314
315 pin->id = 0;
316 pin->time = 0;
317
318 if (!buf_read(buf, &net_id, sizeof(net_id)))
319 {
320 return false;
321 }
322 pin->id = ntohpid(net_id);
323 if (long_form)
324 {
325 if (!buf_read(buf, &net_time, sizeof(net_time)))
326 {
327 return false;
328 }
329 pin->time = ntohtime(net_time);
330 }
331 return true;
332}
333
334static bool
335packet_id_send_update(struct packet_id_send *p, bool long_form)
336{
337 if (!p->time)
338 {
339 p->time = now;
340 }
341 if (p->id == PACKET_ID_MAX)
342 {
343 /* Packet ID only allowed to roll over if using long form and time has
344 * moved forward since last roll over.
345 */
346 if (!long_form || now <= p->time)
347 {
348 return false;
349 }
350 p->time = now;
351 p->id = 0;
352 }
353 p->id++;
354 return true;
355}
356
357static bool
359{
360 if (!p->time)
361 {
362 p->time = now;
363 }
364 if (p->id == PACKET_ID_EPOCH_MAX)
365 {
366 return false;
367 }
368 p->id++;
369 return true;
370}
371
372bool
373packet_id_write(struct packet_id_send *p, struct buffer *buf, bool long_form, bool prepend)
374{
375 if (!packet_id_send_update(p, long_form))
376 {
377 return false;
378 }
379
380 const packet_id_type net_id = htonpid((packet_id_type)p->id);
381 const net_time_t net_time = htontime(p->time);
382 if (prepend)
383 {
384 if (long_form)
385 {
386 if (!buf_write_prepend(buf, &net_time, sizeof(net_time)))
387 {
388 return false;
389 }
390 }
391 if (!buf_write_prepend(buf, &net_id, sizeof(net_id)))
392 {
393 return false;
394 }
395 }
396 else
397 {
398 if (!buf_write(buf, &net_id, sizeof(net_id)))
399 {
400 return false;
401 }
402 if (long_form)
403 {
404 if (!buf_write(buf, &net_time, sizeof(net_time)))
405 {
406 return false;
407 }
408 }
409 }
410 return true;
411}
412
413const char *
414packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
415{
416 struct buffer out = alloc_buf_gc(256, gc);
417
419 if (print_timestamp && pin->time)
420 {
421 buf_printf(&out, " / time = (" packet_id_format ") %s", (packet_id_print_type)pin->time,
422 time_string(pin->time, 0, false, gc));
423 }
424
425 buf_printf(&out, " ]");
426 return BSTR(&out);
427}
428
429/* initialize the packet_id_persist structure in a disabled state */
430void
432{
433 p->filename = NULL;
434 p->fd = -1;
435 p->time = p->time_last_written = 0;
436 p->id = p->id_last_written = 0;
437}
438
439/* close the file descriptor if it is open, and switch to disabled state */
440void
442{
444 {
445 if (close(p->fd))
446 {
447 msg(D_PID_PERSIST | M_ERRNO, "Close error on --replay-persist file %s", p->filename);
448 }
450 }
451}
452
453/* load persisted rec packet_id (time and id) only once from file, and set state to enabled */
454void
455packet_id_persist_load(struct packet_id_persist *p, const char *filename)
456{
457 struct gc_arena gc = gc_new();
459 {
460 /* open packet-id persist file for both read and write */
461 p->fd = platform_open(filename, O_CREAT | O_RDWR | O_BINARY, S_IRUSR | S_IWUSR);
462 if (p->fd == -1)
463 {
464 msg(D_PID_PERSIST | M_ERRNO, "Cannot open --replay-persist file %s for read/write",
465 filename);
466 }
467 else
468 {
469 struct packet_id_persist_file_image image;
470 ssize_t n;
471
472#if defined(HAVE_FLOCK) && defined(LOCK_EX) && defined(LOCK_NB)
473 if (flock(p->fd, LOCK_EX | LOCK_NB))
474 {
475 msg(M_ERR, "Cannot obtain exclusive lock on --replay-persist file %s", filename);
476 }
477#endif
478
479 p->filename = filename;
480 n = read(p->fd, &image, sizeof(image));
481 if (n == sizeof(image))
482 {
483 p->time = p->time_last_written = image.time;
484 p->id = p->id_last_written = image.id;
485 dmsg(D_PID_PERSIST_DEBUG, "PID Persist Read from %s: %s", p->filename,
487 }
488 else if (n == -1)
489 {
490 msg(D_PID_PERSIST | M_ERRNO, "Read error on --replay-persist file %s", p->filename);
491 }
492 }
493 }
494 gc_free(&gc);
495}
496
497/* save persisted rec packet_id (time and id) to file (only if enabled state) */
498void
500{
502 && (p->time != p->time_last_written || p->id != p->id_last_written))
503 {
504 struct packet_id_persist_file_image image;
505 CLEAR(image);
506 off_t seek_ret;
507 struct gc_arena gc = gc_new();
508
509 image.time = p->time;
510 image.id = p->id;
511 seek_ret = lseek(p->fd, (off_t)0, SEEK_SET);
512 if (seek_ret == (off_t)0)
513 {
514 const ssize_t n = write(p->fd, &image, sizeof(image));
515 if (n == sizeof(image))
516 {
517 p->time_last_written = p->time;
518 p->id_last_written = p->id;
519 dmsg(D_PID_PERSIST_DEBUG, "PID Persist Write to %s: %s", p->filename,
521 }
522 else
523 {
524 msg(D_PID_PERSIST | M_ERRNO, "Cannot write to --replay-persist file %s",
525 p->filename);
526 }
527 }
528 else
529 {
530 msg(D_PID_PERSIST | M_ERRNO, "Cannot seek to beginning of --replay-persist file %s",
531 p->filename);
532 }
533 gc_free(&gc);
534 }
535}
536
537/* transfer packet_id_persist -> packet_id */
538void
540{
541 if (p && pid && packet_id_persist_enabled(p) && p->time)
542 {
543 pid->rec.time = p->time;
544 pid->rec.id = p->id;
545 }
546}
547
548const char *
550{
551 struct buffer out = alloc_buf_gc(256, gc);
552
553 buf_printf(&out, "[");
554
556 {
558 if (p->time)
559 {
560 buf_printf(&out, " / time = (" packet_id_format ") %s", (packet_id_print_type)p->time,
561 time_string(p->time, 0, false, gc));
562 }
563 }
564
565 buf_printf(&out, " ]");
566 return (char *)out.data;
567}
568
569#ifndef ENABLE_SMALL
570
571static void
573 const struct packet_id_net *pin,
574 const char *message, packet_id_print_type value)
575{
576 struct gc_arena gc = gc_new();
577 struct buffer out = alloc_buf_gc(256, &gc);
578 struct timeval tv;
579 const time_t prev_now = now;
580 const struct seq_list *sl = p->seq_list;
581 int i;
582
583 CLEAR(tv);
584 gettimeofday(&tv, NULL);
585
586 buf_printf(&out, "%s [" packet_id_format "]", message, value);
587 buf_printf(&out, " [%s-%d] [", p->name, p->unit);
588 for (i = 0; sl != NULL && i < sl->x_size; ++i)
589 {
590 char c;
591 time_t v;
592
593 v = CIRC_LIST_ITEM(sl, i);
594 if (v == SEQ_UNSEEN)
595 {
596 c = '_';
597 }
598 else if (v == SEQ_EXPIRED)
599 {
600 c = 'E';
601 }
602 else
603 {
604 const int diff = (int)(prev_now - v);
605 if (diff < 0)
606 {
607 c = 'N';
608 }
609 else if (diff < 10)
610 {
611 c = (char)('0' + diff);
612 }
613 else
614 {
615 c = '>';
616 }
617 }
618 buf_printf(&out, "%c", c);
619 }
620 buf_printf(&out, "] %" PRIi64 ":" packet_id_format, (int64_t)p->time, p->id);
621 if (pin)
622 {
623 buf_printf(&out, " %" PRIi64 ":" packet_id_format, (int64_t)pin->time, pin->id);
624 }
625
626 buf_printf(&out, " t=%" PRIi64 "[%d]", (int64_t)prev_now, (int)(prev_now - tv.tv_sec));
627
628 buf_printf(&out, " r=[%d,%" PRIu64 ",%d,%" PRIu64 ",%d]", (int)(p->last_reap - tv.tv_sec),
630 if (sl != NULL)
631 {
632 buf_printf(&out, " sl=[%d,%d,%d,%zu]", sl->x_head, sl->x_size, sl->x_cap, sl->x_sizeof);
633 }
634
635
636 msg(msglevel, "%s", BSTR(&out));
637 gc_free(&gc);
638}
639
640#endif
641
642uint16_t
644{
645 uint64_t packet_id;
646
647 if (!buf_read(buf, &packet_id, sizeof(packet_id)))
648 {
649 return 0;
650 }
651
652 uint64_t id = ntohll(packet_id);
653 /* top most 16 bits */
654 uint16_t epoch = (uint16_t)(id >> 48);
655
656 pin->id = id & PACKET_ID_MASK;
657 return epoch;
658}
659
660bool
661packet_id_write_epoch(struct packet_id_send *p, uint16_t epoch, struct buffer *buf)
662{
664 {
665 return false;
666 }
667
668 /* Highest 16 bits of packet id is the epoch.
669 *
670 * The lower 48 bits are the per-epoch packet id counter. */
671 uint64_t net_id = ((uint64_t)epoch) << 48 | p->id;
672
673 /* convert to network order. This ensures that the highest bytes
674 * also become the first ones on the wire*/
675 net_id = htonll(net_id);
676
677 return buf_write(buf, &net_id, sizeof(net_id));
678}
bool buf_printf(struct buffer *buf, const char *format,...)
printf-style append to a buffer with overflow check.
Definition buffer.c:226
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Allocate a buffer of the given size under garbage collection.
Definition buffer.c:77
#define BSTR(buf)
Return the buffer content pointer cast to char *.
Definition buffer.h:157
static bool buf_write_prepend(struct buffer *dest, const void *src, int size)
Prepend data to a buffer.
Definition buffer.h:1263
static bool buf_read(struct buffer *src, void *dest, int size)
Read bytes from the front of a buffer into a caller-supplied destination.
Definition buffer.h:1451
static bool buf_write(struct buffer *dest, const void *src, size_t size)
Append data to a buffer.
Definition buffer.h:1239
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
Definition buffer.h:1965
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
Definition buffer.h:1949
#define CIRC_LIST_ALLOC(dest, list_type, size)
Definition circ_list.h:61
#define CIRC_LIST_PUSH(obj, item)
Definition circ_list.h:40
#define CIRC_LIST_ITEM(obj, index)
Definition circ_list.h:53
#define CIRC_LIST_RESET(obj)
Definition circ_list.h:55
#define CIRC_LIST_SIZE(obj)
Definition circ_list.h:47
int64_t get_random(void)
an analogue to the random() function, but use prng_bytes and also int64_t instead of long to avoid LL...
Definition crypto.c:1705
#define D_PID_DEBUG_LOW
Definition errlevel.h:105
#define D_PID_DEBUG_MEDIUM
Definition errlevel.h:106
#define D_PID_DEBUG
Definition errlevel.h:148
#define D_PID_PERSIST_DEBUG
Definition errlevel.h:169
#define D_PID_PERSIST
Definition errlevel.h:67
#define ntohll(x)
Definition integer.h:36
#define htonll(x)
Definition integer.h:29
@ write
@ read
#define CLEAR(x)
Definition basic.h:32
static bool check_debug_level(msglvl_t level)
Definition error.h:253
#define dmsg(flags,...)
Definition error.h:164
#define M_ERR
Definition error.h:106
#define msg(flags,...)
Definition error.h:152
unsigned int msglvl_t
Definition error.h:77
#define ASSERT(x)
Definition error.h:221
#define M_ERRNO
Definition error.h:95
const char * time_string(time_t t, tv_usec_t usec, bool show_usec, struct gc_arena *gc)
Definition otime.c:104
time_t now
Definition otime.c:33
static void packet_id_init_recv(struct packet_id_rec *rec, int seq_backtrack, int time_backtrack, const char *name, int unit)
Definition packet_id.c:75
void packet_id_persist_save(struct packet_id_persist *p)
Definition packet_id.c:499
const char * packet_id_persist_print(const struct packet_id_persist *p, struct gc_arena *gc)
Definition packet_id.c:549
void packet_id_persist_load_obj(const struct packet_id_persist *p, struct packet_id *pid)
Definition packet_id.c:539
uint16_t packet_id_read_epoch(struct packet_id_net *pin, struct buffer *buf)
Reads the packet ID containing both the epoch and the per-epoch counter from the buf.
Definition packet_id.c:643
void packet_id_init(struct packet_id *p, int seq_backtrack, int time_backtrack, const char *name, int unit)
Definition packet_id.c:91
#define SEQ_UNSEEN
Definition packet_id.c:52
void packet_id_persist_close(struct packet_id_persist *p)
Definition packet_id.c:441
static void packet_id_debug(msglvl_t msglevel, const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, uint64_t value)
Definition packet_id.c:63
bool packet_id_write_epoch(struct packet_id_send *p, uint16_t epoch, struct buffer *buf)
Writes the packet ID containing both the epoch and the packet id to the buffer specified by buf.
Definition packet_id.c:661
void packet_id_free(struct packet_id *p)
Definition packet_id.c:121
static bool packet_id_send_update_epoch(struct packet_id_send *p)
Definition packet_id.c:358
bool packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin)
Definition packet_id.c:215
bool packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
Definition packet_id.c:310
static bool packet_id_send_update(struct packet_id_send *p, bool long_form)
Definition packet_id.c:335
void packet_id_move_recv(struct packet_id_rec *dest, struct packet_id_rec *src)
Move the packet id recv structure from src to dest.
Definition packet_id.c:104
void packet_id_reap(struct packet_id_rec *p)
Definition packet_id.c:184
const char * packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
Definition packet_id.c:414
void packet_id_add(struct packet_id_rec *p, const struct packet_id_net *pin)
Definition packet_id.c:132
#define SEQ_EXPIRED
Definition packet_id.c:53
void packet_id_persist_load(struct packet_id_persist *p, const char *filename)
Definition packet_id.c:455
void packet_id_persist_init(struct packet_id_persist *p)
Definition packet_id.c:431
static void packet_id_debug_print(msglvl_t msglevel, const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, packet_id_print_type value)
Definition packet_id.c:572
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.
Definition packet_id.c:373
#define packet_id_format
Definition packet_id.h:76
#define htonpid(x)
Definition packet_id.h:61
static bool packet_id_persist_enabled(const struct packet_id_persist *p)
Definition packet_id.h:278
uint64_t packet_id_print_type
Definition packet_id.h:77
#define MAX_SEQ_BACKTRACK
Definition packet_id.h:85
uint32_t net_time_t
Definition packet_id.h:51
uint32_t packet_id_type
Definition packet_id.h:45
#define PACKET_ID_MAX
Definition packet_id.h:46
#define ntohtime(x)
Definition packet_id.h:70
#define MIN_SEQ_BACKTRACK
Definition packet_id.h:84
#define MAX_TIME_BACKTRACK
Definition packet_id.h:94
#define ntohpid(x)
Definition packet_id.h:64
#define MIN_TIME_BACKTRACK
Definition packet_id.h:93
#define htontime(x)
Definition packet_id.h:67
#define PACKET_ID_EPOCH_MAX
Definition packet_id.h:47
#define PACKET_ID_MASK
Mask of the bits that contain the 48-bit of the per-epoch packet counter in the packet id.
Definition packet_id.h:50
int platform_open(const char *path, int flags, int mode)
Definition platform.c:513
Wrapper structure for dynamically allocated memory.
Definition buffer.h:71
uint8_t * data
Pointer to the allocated memory.
Definition buffer.h:78
int len
Length in bytes of the actual content within the allocated memory.
Definition buffer.h:76
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:127
Data structure for describing the packet id that is received/send to the network.
Definition packet_id.h:191
uint64_t id
Definition packet_id.h:194
const char * filename
Definition packet_id.h:133
packet_id_type id_last_written
Definition packet_id.h:138
packet_id_type id
Definition packet_id.h:136
time_t time_last_written
Definition packet_id.h:137
uint64_t max_backtrack_stat
Definition packet_id.h:120
uint64_t seq_backtrack
Definition packet_id.h:118
const char * name
Definition packet_id.h:123
uint64_t id
Definition packet_id.h:117
time_t last_reap
Definition packet_id.h:115
struct seq_list * seq_list
Definition packet_id.h:122
uint64_t id
Definition packet_id.h:153
struct packet_id_rec rec
Definition packet_id.h:201
#define O_BINARY
Definition syshead.h:425
#define unlikely(x)
Definition syshead.h:35
struct gc_arena gc
Definition test_ssl.c:138