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-2025 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#ifdef ENABLE_DEBUG
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 /* ENABLE_DEBUG */
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#ifdef ENABLE_DEBUG
67 if (unlikely(check_debug_level(msglevel)))
68 {
69 packet_id_debug_print(msglevel, p, pin, message, value);
70 }
71#endif
72}
73
74#if defined(__GNUC__) || defined(__clang__)
75#pragma GCC diagnostic push
76#pragma GCC diagnostic ignored "-Wconversion"
77#endif
78
79static void
80packet_id_init_recv(struct packet_id_rec *rec, int seq_backtrack, int time_backtrack,
81 const char *name, int unit)
82{
83 rec->name = name;
84 rec->unit = unit;
85 if (seq_backtrack)
86 {
87 ASSERT(MIN_SEQ_BACKTRACK <= seq_backtrack && seq_backtrack <= MAX_SEQ_BACKTRACK);
88 ASSERT(MIN_TIME_BACKTRACK <= time_backtrack && time_backtrack <= MAX_TIME_BACKTRACK);
89 CIRC_LIST_ALLOC(rec->seq_list, struct seq_list, seq_backtrack);
90 rec->seq_backtrack = seq_backtrack;
91 rec->time_backtrack = time_backtrack;
92 }
93 rec->initialized = true;
94}
95void
96packet_id_init(struct packet_id *p, int seq_backtrack, int time_backtrack, const char *name,
97 int unit)
98{
99 dmsg(D_PID_DEBUG, "PID packet_id_init seq_backtrack=%d time_backtrack=%d", seq_backtrack,
100 time_backtrack);
101
102 ASSERT(p);
103 CLEAR(*p);
104
105 packet_id_init_recv(&p->rec, seq_backtrack, time_backtrack, name, unit);
106}
107
108void
110{
111 ASSERT(src);
112 ASSERT(dest);
113 /* clear free any old data in rec list */
114 free(dest->seq_list);
115 CLEAR(*dest);
116
117 /* Copy data to dest */
118 *dest = *src;
119
120 /* Reinitalise the source */
121 CLEAR(*src);
122 packet_id_init_recv(src, dest->seq_backtrack, dest->time_backtrack, dest->name, dest->unit);
123}
124
125void
127{
128 if (p)
129 {
130 dmsg(D_PID_DEBUG, "PID packet_id_free");
131 free(p->rec.seq_list);
132 CLEAR(*p);
133 }
134}
135
136void
137packet_id_add(struct packet_id_rec *p, const struct packet_id_net *pin)
138{
139 const time_t local_now = now;
140 if (p->seq_list)
141 {
142 int64_t diff;
143
144 /*
145 * If time value increases, start a new sequence list of number
146 * sequence for the new time point.
147 */
148 if (!CIRC_LIST_SIZE(p->seq_list) || pin->time > p->time
149 || (pin->id >= p->seq_backtrack && pin->id - p->seq_backtrack > p->id))
150 {
151 p->time = pin->time;
152 p->id = 0;
153 if (pin->id > p->seq_backtrack)
154 {
155 p->id = pin->id - p->seq_backtrack;
156 }
158 }
159
160 while (p->id < pin->id
161#ifdef PID_SIMULATE_BACKTRACK
162 || (get_random() % 64) < 31
163#endif
164 )
165 {
167 ++p->id;
168 }
169
170 diff = p->id - pin->id;
171 if (diff < CIRC_LIST_SIZE(p->seq_list) && local_now > SEQ_EXPIRED)
172 {
173 CIRC_LIST_ITEM(p->seq_list, diff) = local_now;
174 }
175 }
176 else
177 {
178 p->time = pin->time;
179 p->id = pin->id;
180 }
181}
182
183/*
184 * Expire sequence numbers which can no longer
185 * be accepted because they would violate
186 * time_backtrack.
187 */
188void
190{
191 const time_t local_now = now;
192 if (p->time_backtrack)
193 {
194 bool expire = false;
195 for (int i = 0; i < CIRC_LIST_SIZE(p->seq_list); ++i)
196 {
197 const time_t t = CIRC_LIST_ITEM(p->seq_list, i);
198 if (t == SEQ_EXPIRED)
199 {
200 break;
201 }
202 if (!expire && t && t + p->time_backtrack < local_now)
203 {
204 expire = true;
205 }
206 if (expire)
207 {
209 }
210 }
211 }
212 p->last_reap = local_now;
213}
214
215/*
216 * Return true if packet id is ok, or false if
217 * it is a replay.
218 */
219bool
220packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin)
221{
222 uint64_t diff;
223
224 packet_id_debug(D_PID_DEBUG, p, pin, "PID_TEST", 0);
225
227
228 if (!pin->id)
229 {
230 return false;
231 }
232
233 if (p->seq_backtrack)
234 {
235 /*
236 * In backtrack mode, we allow packet reordering subject
237 * to the seq_backtrack and time_backtrack constraints.
238 *
239 * This mode is used with UDP.
240 */
241 if (pin->time == p->time)
242 {
243 /* is packet-id greater than any one we've seen yet? */
244 if (pin->id > p->id)
245 {
246 return true;
247 }
248
249 /* check packet-id sliding window for original/replay status */
250 diff = p->id - pin->id;
251
252 /* keep track of maximum backtrack seen for debugging purposes */
253 if (diff > p->max_backtrack_stat)
254 {
255 p->max_backtrack_stat = diff;
256 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR replay-window backtrack occurred",
258 }
259
260 if (diff >= (packet_id_type)CIRC_LIST_SIZE(p->seq_list))
261 {
262 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR large diff", diff);
263 return false;
264 }
265
266 {
267 const time_t v = CIRC_LIST_ITEM(p->seq_list, diff);
268 if (v == 0)
269 {
270 return true;
271 }
272 else
273 {
274 /* raised from D_PID_DEBUG_LOW to reduce verbosity */
275 packet_id_debug(D_PID_DEBUG_MEDIUM, p, pin, "PID_ERR replay", diff);
276 return false;
277 }
278 }
279 }
280 else if (pin->time < p->time) /* if time goes back, reject */
281 {
282 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR time backtrack", 0);
283 return false;
284 }
285 else /* time moved forward */
286 {
287 return true;
288 }
289 }
290 else
291 {
292 /*
293 * In non-backtrack mode, all sequence number series must
294 * begin at some number n > 0 and must increment linearly without gaps.
295 *
296 * This mode is used with TCP.
297 */
298 if (pin->time == p->time)
299 {
300 return !p->id || pin->id == p->id + 1;
301 }
302 else if (pin->time < p->time) /* if time goes back, reject */
303 {
304 return false;
305 }
306 else /* time moved forward */
307 {
308 return pin->id == 1;
309 }
310 }
311}
312
313/*
314 * Read/write a packet ID to/from the buffer. Short form is sequence number
315 * only. Long form is sequence number and timestamp.
316 */
317
318bool
319packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
320{
321 packet_id_type net_id;
322 net_time_t net_time;
323
324 pin->id = 0;
325 pin->time = 0;
326
327 if (!buf_read(buf, &net_id, sizeof(net_id)))
328 {
329 return false;
330 }
331 pin->id = ntohpid(net_id);
332 if (long_form)
333 {
334 if (!buf_read(buf, &net_time, sizeof(net_time)))
335 {
336 return false;
337 }
338 pin->time = ntohtime(net_time);
339 }
340 return true;
341}
342
343static bool
344packet_id_send_update(struct packet_id_send *p, bool long_form)
345{
346 if (!p->time)
347 {
348 p->time = now;
349 }
350 if (p->id == PACKET_ID_MAX)
351 {
352 /* Packet ID only allowed to roll over if using long form and time has
353 * moved forward since last roll over.
354 */
355 if (!long_form || now <= p->time)
356 {
357 return false;
358 }
359 p->time = now;
360 p->id = 0;
361 }
362 p->id++;
363 return true;
364}
365
366static bool
368{
369 if (!p->time)
370 {
371 p->time = now;
372 }
373 if (p->id == PACKET_ID_EPOCH_MAX)
374 {
375 return false;
376 }
377 p->id++;
378 return true;
379}
380
381bool
382packet_id_write(struct packet_id_send *p, struct buffer *buf, bool long_form, bool prepend)
383{
384 if (!packet_id_send_update(p, long_form))
385 {
386 return false;
387 }
388
389 const packet_id_type net_id = htonpid(p->id);
390 const net_time_t net_time = htontime(p->time);
391 if (prepend)
392 {
393 if (long_form)
394 {
395 if (!buf_write_prepend(buf, &net_time, sizeof(net_time)))
396 {
397 return false;
398 }
399 }
400 if (!buf_write_prepend(buf, &net_id, sizeof(net_id)))
401 {
402 return false;
403 }
404 }
405 else
406 {
407 if (!buf_write(buf, &net_id, sizeof(net_id)))
408 {
409 return false;
410 }
411 if (long_form)
412 {
413 if (!buf_write(buf, &net_time, sizeof(net_time)))
414 {
415 return false;
416 }
417 }
418 }
419 return true;
420}
421
422const char *
423packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
424{
425 struct buffer out = alloc_buf_gc(256, gc);
426
428 if (print_timestamp && pin->time)
429 {
430 buf_printf(&out, " / time = (" packet_id_format ") %s", (packet_id_print_type)pin->time,
431 time_string(pin->time, 0, false, gc));
432 }
433
434 buf_printf(&out, " ]");
435 return BSTR(&out);
436}
437
438/* initialize the packet_id_persist structure in a disabled state */
439void
441{
442 p->filename = NULL;
443 p->fd = -1;
444 p->time = p->time_last_written = 0;
445 p->id = p->id_last_written = 0;
446}
447
448/* close the file descriptor if it is open, and switch to disabled state */
449void
451{
453 {
454 if (close(p->fd))
455 {
456 msg(D_PID_PERSIST | M_ERRNO, "Close error on --replay-persist file %s", p->filename);
457 }
459 }
460}
461
462/* load persisted rec packet_id (time and id) only once from file, and set state to enabled */
463void
464packet_id_persist_load(struct packet_id_persist *p, const char *filename)
465{
466 struct gc_arena gc = gc_new();
468 {
469 /* open packet-id persist file for both read and write */
470 p->fd = platform_open(filename, O_CREAT | O_RDWR | O_BINARY, S_IRUSR | S_IWUSR);
471 if (p->fd == -1)
472 {
473 msg(D_PID_PERSIST | M_ERRNO, "Cannot open --replay-persist file %s for read/write",
474 filename);
475 }
476 else
477 {
478 struct packet_id_persist_file_image image;
479 ssize_t n;
480
481#if defined(HAVE_FLOCK) && defined(LOCK_EX) && defined(LOCK_NB)
482 if (flock(p->fd, LOCK_EX | LOCK_NB))
483 {
484 msg(M_ERR, "Cannot obtain exclusive lock on --replay-persist file %s", filename);
485 }
486#endif
487
488 p->filename = filename;
489 n = read(p->fd, &image, sizeof(image));
490 if (n == sizeof(image))
491 {
492 p->time = p->time_last_written = image.time;
493 p->id = p->id_last_written = image.id;
494 dmsg(D_PID_PERSIST_DEBUG, "PID Persist Read from %s: %s", p->filename,
496 }
497 else if (n == -1)
498 {
499 msg(D_PID_PERSIST | M_ERRNO, "Read error on --replay-persist file %s", p->filename);
500 }
501 }
502 }
503 gc_free(&gc);
504}
505
506/* save persisted rec packet_id (time and id) to file (only if enabled state) */
507void
509{
511 && (p->time != p->time_last_written || p->id != p->id_last_written))
512 {
513 struct packet_id_persist_file_image image;
514 ssize_t n;
515 off_t seek_ret;
516 struct gc_arena gc = gc_new();
517
518 image.time = p->time;
519 image.id = p->id;
520 seek_ret = lseek(p->fd, (off_t)0, SEEK_SET);
521 if (seek_ret == (off_t)0)
522 {
523 n = write(p->fd, &image, sizeof(image));
524 if (n == sizeof(image))
525 {
526 p->time_last_written = p->time;
527 p->id_last_written = p->id;
528 dmsg(D_PID_PERSIST_DEBUG, "PID Persist Write to %s: %s", p->filename,
530 }
531 else
532 {
533 msg(D_PID_PERSIST | M_ERRNO, "Cannot write to --replay-persist file %s",
534 p->filename);
535 }
536 }
537 else
538 {
539 msg(D_PID_PERSIST | M_ERRNO, "Cannot seek to beginning of --replay-persist file %s",
540 p->filename);
541 }
542 gc_free(&gc);
543 }
544}
545
546/* transfer packet_id_persist -> packet_id */
547void
549{
550 if (p && pid && packet_id_persist_enabled(p) && p->time)
551 {
552 pid->rec.time = p->time;
553 pid->rec.id = p->id;
554 }
555}
556
557const char *
559{
560 struct buffer out = alloc_buf_gc(256, gc);
561
562 buf_printf(&out, "[");
563
565 {
567 if (p->time)
568 {
569 buf_printf(&out, " / time = (" packet_id_format ") %s", (packet_id_print_type)p->time,
570 time_string(p->time, 0, false, gc));
571 }
572 }
573
574 buf_printf(&out, " ]");
575 return (char *)out.data;
576}
577
578#ifdef ENABLE_DEBUG
579
580static void
581packet_id_debug_print(msglvl_t msglevel, const struct packet_id_rec *p,
582 const struct packet_id_net *pin,
583 const char *message, packet_id_print_type value)
584{
585 struct gc_arena gc = gc_new();
586 struct buffer out = alloc_buf_gc(256, &gc);
587 struct timeval tv;
588 const time_t prev_now = now;
589 const struct seq_list *sl = p->seq_list;
590 int i;
591
592 CLEAR(tv);
593 gettimeofday(&tv, NULL);
594
595 buf_printf(&out, "%s [" packet_id_format "]", message, value);
596 buf_printf(&out, " [%s-%d] [", p->name, p->unit);
597 for (i = 0; sl != NULL && i < sl->x_size; ++i)
598 {
599 char c;
600 time_t v;
601 int diff;
602
603 v = CIRC_LIST_ITEM(sl, i);
604 if (v == SEQ_UNSEEN)
605 {
606 c = '_';
607 }
608 else if (v == SEQ_EXPIRED)
609 {
610 c = 'E';
611 }
612 else
613 {
614 diff = (int)(prev_now - v);
615 if (diff < 0)
616 {
617 c = 'N';
618 }
619 else if (diff < 10)
620 {
621 c = (char)('0' + diff);
622 }
623 else
624 {
625 c = '>';
626 }
627 }
628 buf_printf(&out, "%c", c);
629 }
630 buf_printf(&out, "] %" PRIi64 ":" packet_id_format, (int64_t)p->time, p->id);
631 if (pin)
632 {
633 buf_printf(&out, " %" PRIi64 ":" packet_id_format, (int64_t)pin->time, pin->id);
634 }
635
636 buf_printf(&out, " t=%" PRIi64 "[%d]", (int64_t)prev_now, (int)(prev_now - tv.tv_sec));
637
638 buf_printf(&out, " r=[%d,%" PRIu64 ",%d,%" PRIu64 ",%d]", (int)(p->last_reap - tv.tv_sec),
640 if (sl != NULL)
641 {
642 buf_printf(&out, " sl=[%d,%d,%d,%d]", sl->x_head, sl->x_size, sl->x_cap, sl->x_sizeof);
643 }
644
645
646 msg(msglevel, "%s", BSTR(&out));
647 gc_free(&gc);
648}
649
650#endif /* ifdef ENABLE_DEBUG */
651
652uint16_t
654{
655 uint64_t packet_id;
656
657
658 if (!buf_read(buf, &packet_id, sizeof(packet_id)))
659 {
660 return 0;
661 }
662
663 uint64_t id = ntohll(packet_id);
664 /* top most 16 bits */
665 uint16_t epoch = id >> 48;
666
667 pin->id = id & PACKET_ID_MASK;
668 return epoch;
669}
670
671#if defined(__GNUC__) || defined(__clang__)
672#pragma GCC diagnostic pop
673#endif
674
675bool
676packet_id_write_epoch(struct packet_id_send *p, uint16_t epoch, struct buffer *buf)
677{
679 {
680 return false;
681 }
682
683 /* Highest 16 bits of packet id is the epoch.
684 *
685 * The lower 48 bits are the per-epoch packet id counter. */
686 uint64_t net_id = ((uint64_t)epoch) << 48 | p->id;
687
688 /* convert to network order. This ensures that the highest bytes
689 * also become the first ones on the wire*/
690 net_id = htonll(net_id);
691
692 return buf_write(buf, &net_id, sizeof(net_id));
693}
bool buf_printf(struct buffer *buf, const char *format,...)
Definition buffer.c:241
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Definition buffer.c:89
#define BSTR(buf)
Definition buffer.h:128
static bool buf_write_prepend(struct buffer *dest, const void *src, int size)
Definition buffer.h:672
static bool buf_read(struct buffer *src, void *dest, int size)
Definition buffer.h:762
static bool buf_write(struct buffer *dest, const void *src, size_t size)
Definition buffer.h:660
static void gc_free(struct gc_arena *a)
Definition buffer.h:1015
static struct gc_arena gc_new(void)
Definition buffer.h:1007
#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
long int get_random(void)
Definition crypto.c:1725
#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:259
#define dmsg(flags,...)
Definition error.h:172
#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:219
#define M_ERRNO
Definition error.h:95
const char * time_string(time_t t, long usec, bool show_usec, struct gc_arena *gc)
Definition otime.c:109
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:80
void packet_id_persist_save(struct packet_id_persist *p)
Definition packet_id.c:508
const char * packet_id_persist_print(const struct packet_id_persist *p, struct gc_arena *gc)
Definition packet_id.c:558
void packet_id_persist_load_obj(const struct packet_id_persist *p, struct packet_id *pid)
Definition packet_id.c:548
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:653
void packet_id_init(struct packet_id *p, int seq_backtrack, int time_backtrack, const char *name, int unit)
Definition packet_id.c:96
#define SEQ_UNSEEN
Definition packet_id.c:52
void packet_id_persist_close(struct packet_id_persist *p)
Definition packet_id.c:450
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:676
void packet_id_free(struct packet_id *p)
Definition packet_id.c:126
static bool packet_id_send_update_epoch(struct packet_id_send *p)
Definition packet_id.c:367
bool packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin)
Definition packet_id.c:220
bool packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
Definition packet_id.c:319
static bool packet_id_send_update(struct packet_id_send *p, bool long_form)
Definition packet_id.c:344
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:109
void packet_id_reap(struct packet_id_rec *p)
Definition packet_id.c:189
const char * packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
Definition packet_id.c:423
void packet_id_add(struct packet_id_rec *p, const struct packet_id_net *pin)
Definition packet_id.c:137
#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:464
void packet_id_persist_init(struct packet_id_persist *p)
Definition packet_id.c:440
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:382
#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:517
Wrapper structure for dynamically allocated memory.
Definition buffer.h:60
uint8_t * data
Pointer to the allocated memory.
Definition buffer.h:67
int len
Length in bytes of the actual content within the allocated memory.
Definition buffer.h:65
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:116
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:420
#define unlikely(x)
Definition syshead.h:35
struct gc_arena gc
Definition test_ssl.c:131