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
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 packet_id_debug(D_PID_DEBUG, p, pin, "PID_TEST", 0);
223
225
226 if (!pin->id)
227 {
228 return false;
229 }
230
231 if (p->seq_backtrack)
232 {
233 /*
234 * In backtrack mode, we allow packet reordering subject
235 * to the seq_backtrack and time_backtrack constraints.
236 *
237 * This mode is used with UDP.
238 */
239 if (pin->time == p->time)
240 {
241 /* is packet-id greater than any one we've seen yet? */
242 if (pin->id > p->id)
243 {
244 return true;
245 }
246
247 /* check packet-id sliding window for original/replay status */
248 const uint64_t diff = p->id - pin->id;
249
250 /* keep track of maximum backtrack seen for debugging purposes */
251 if (diff > p->max_backtrack_stat)
252 {
253 p->max_backtrack_stat = diff;
254 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR replay-window backtrack occurred",
256 }
257
258 if (diff >= (packet_id_type)CIRC_LIST_SIZE(p->seq_list))
259 {
260 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR large diff", diff);
261 return false;
262 }
263
264 {
265 const time_t v = CIRC_LIST_ITEM(p->seq_list, diff);
266 if (v == 0)
267 {
268 return true;
269 }
270 else
271 {
272 /* raised from D_PID_DEBUG_LOW to reduce verbosity */
273 packet_id_debug(D_PID_DEBUG_MEDIUM, p, pin, "PID_ERR replay", diff);
274 return false;
275 }
276 }
277 }
278 else if (pin->time < p->time) /* if time goes back, reject */
279 {
280 packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR time backtrack", 0);
281 return false;
282 }
283 else /* time moved forward */
284 {
285 return true;
286 }
287 }
288 else
289 {
290 /*
291 * In non-backtrack mode, all sequence number series must
292 * begin at some number n > 0 and must increment linearly without gaps.
293 *
294 * This mode is used with TCP.
295 */
296 if (pin->time == p->time)
297 {
298 return !p->id || pin->id == p->id + 1;
299 }
300 else if (pin->time < p->time) /* if time goes back, reject */
301 {
302 return false;
303 }
304 else /* time moved forward */
305 {
306 return pin->id == 1;
307 }
308 }
309}
310
311/*
312 * Read/write a packet ID to/from the buffer. Short form is sequence number
313 * only. Long form is sequence number and timestamp.
314 */
315
316bool
317packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
318{
319 packet_id_type net_id;
320 net_time_t net_time;
321
322 pin->id = 0;
323 pin->time = 0;
324
325 if (!buf_read(buf, &net_id, sizeof(net_id)))
326 {
327 return false;
328 }
329 pin->id = ntohpid(net_id);
330 if (long_form)
331 {
332 if (!buf_read(buf, &net_time, sizeof(net_time)))
333 {
334 return false;
335 }
336 pin->time = ntohtime(net_time);
337 }
338 return true;
339}
340
341static bool
342packet_id_send_update(struct packet_id_send *p, bool long_form)
343{
344 if (!p->time)
345 {
346 p->time = now;
347 }
348 if (p->id == PACKET_ID_MAX)
349 {
350 /* Packet ID only allowed to roll over if using long form and time has
351 * moved forward since last roll over.
352 */
353 if (!long_form || now <= p->time)
354 {
355 return false;
356 }
357 p->time = now;
358 p->id = 0;
359 }
360 p->id++;
361 return true;
362}
363
364static bool
366{
367 if (!p->time)
368 {
369 p->time = now;
370 }
371 if (p->id == PACKET_ID_EPOCH_MAX)
372 {
373 return false;
374 }
375 p->id++;
376 return true;
377}
378
379bool
380packet_id_write(struct packet_id_send *p, struct buffer *buf, bool long_form, bool prepend)
381{
382 if (!packet_id_send_update(p, long_form))
383 {
384 return false;
385 }
386
387 const packet_id_type net_id = htonpid(p->id);
388 const net_time_t net_time = htontime(p->time);
389 if (prepend)
390 {
391 if (long_form)
392 {
393 if (!buf_write_prepend(buf, &net_time, sizeof(net_time)))
394 {
395 return false;
396 }
397 }
398 if (!buf_write_prepend(buf, &net_id, sizeof(net_id)))
399 {
400 return false;
401 }
402 }
403 else
404 {
405 if (!buf_write(buf, &net_id, sizeof(net_id)))
406 {
407 return false;
408 }
409 if (long_form)
410 {
411 if (!buf_write(buf, &net_time, sizeof(net_time)))
412 {
413 return false;
414 }
415 }
416 }
417 return true;
418}
419
420const char *
421packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
422{
423 struct buffer out = alloc_buf_gc(256, gc);
424
426 if (print_timestamp && pin->time)
427 {
428 buf_printf(&out, " / time = (" packet_id_format ") %s", (packet_id_print_type)pin->time,
429 time_string(pin->time, 0, false, gc));
430 }
431
432 buf_printf(&out, " ]");
433 return BSTR(&out);
434}
435
436/* initialize the packet_id_persist structure in a disabled state */
437void
439{
440 p->filename = NULL;
441 p->fd = -1;
442 p->time = p->time_last_written = 0;
443 p->id = p->id_last_written = 0;
444}
445
446/* close the file descriptor if it is open, and switch to disabled state */
447void
449{
451 {
452 if (close(p->fd))
453 {
454 msg(D_PID_PERSIST | M_ERRNO, "Close error on --replay-persist file %s", p->filename);
455 }
457 }
458}
459
460/* load persisted rec packet_id (time and id) only once from file, and set state to enabled */
461void
462packet_id_persist_load(struct packet_id_persist *p, const char *filename)
463{
464 struct gc_arena gc = gc_new();
466 {
467 /* open packet-id persist file for both read and write */
468 p->fd = platform_open(filename, O_CREAT | O_RDWR | O_BINARY, S_IRUSR | S_IWUSR);
469 if (p->fd == -1)
470 {
471 msg(D_PID_PERSIST | M_ERRNO, "Cannot open --replay-persist file %s for read/write",
472 filename);
473 }
474 else
475 {
476 struct packet_id_persist_file_image image;
477 ssize_t n;
478
479#if defined(HAVE_FLOCK) && defined(LOCK_EX) && defined(LOCK_NB)
480 if (flock(p->fd, LOCK_EX | LOCK_NB))
481 {
482 msg(M_ERR, "Cannot obtain exclusive lock on --replay-persist file %s", filename);
483 }
484#endif
485
486 p->filename = filename;
487 n = read(p->fd, &image, sizeof(image));
488 if (n == sizeof(image))
489 {
490 p->time = p->time_last_written = image.time;
491 p->id = p->id_last_written = image.id;
492 dmsg(D_PID_PERSIST_DEBUG, "PID Persist Read from %s: %s", p->filename,
494 }
495 else if (n == -1)
496 {
497 msg(D_PID_PERSIST | M_ERRNO, "Read error on --replay-persist file %s", p->filename);
498 }
499 }
500 }
501 gc_free(&gc);
502}
503
504/* save persisted rec packet_id (time and id) to file (only if enabled state) */
505void
507{
509 && (p->time != p->time_last_written || p->id != p->id_last_written))
510 {
511 struct packet_id_persist_file_image image;
512 CLEAR(image);
513 off_t seek_ret;
514 struct gc_arena gc = gc_new();
515
516 image.time = p->time;
517 image.id = p->id;
518 seek_ret = lseek(p->fd, (off_t)0, SEEK_SET);
519 if (seek_ret == (off_t)0)
520 {
521 const ssize_t n = write(p->fd, &image, sizeof(image));
522 if (n == sizeof(image))
523 {
524 p->time_last_written = p->time;
525 p->id_last_written = p->id;
526 dmsg(D_PID_PERSIST_DEBUG, "PID Persist Write to %s: %s", p->filename,
528 }
529 else
530 {
531 msg(D_PID_PERSIST | M_ERRNO, "Cannot write to --replay-persist file %s",
532 p->filename);
533 }
534 }
535 else
536 {
537 msg(D_PID_PERSIST | M_ERRNO, "Cannot seek to beginning of --replay-persist file %s",
538 p->filename);
539 }
540 gc_free(&gc);
541 }
542}
543
544/* transfer packet_id_persist -> packet_id */
545void
547{
548 if (p && pid && packet_id_persist_enabled(p) && p->time)
549 {
550 pid->rec.time = p->time;
551 pid->rec.id = p->id;
552 }
553}
554
555const char *
557{
558 struct buffer out = alloc_buf_gc(256, gc);
559
560 buf_printf(&out, "[");
561
563 {
565 if (p->time)
566 {
567 buf_printf(&out, " / time = (" packet_id_format ") %s", (packet_id_print_type)p->time,
568 time_string(p->time, 0, false, gc));
569 }
570 }
571
572 buf_printf(&out, " ]");
573 return (char *)out.data;
574}
575
576#ifndef ENABLE_SMALL
577
578static void
580 const struct packet_id_net *pin,
581 const char *message, packet_id_print_type value)
582{
583 struct gc_arena gc = gc_new();
584 struct buffer out = alloc_buf_gc(256, &gc);
585 struct timeval tv;
586 const time_t prev_now = now;
587 const struct seq_list *sl = p->seq_list;
588 int i;
589
590 CLEAR(tv);
591 gettimeofday(&tv, NULL);
592
593 buf_printf(&out, "%s [" packet_id_format "]", message, value);
594 buf_printf(&out, " [%s-%d] [", p->name, p->unit);
595 for (i = 0; sl != NULL && i < sl->x_size; ++i)
596 {
597 char c;
598 time_t v;
599
600 v = CIRC_LIST_ITEM(sl, i);
601 if (v == SEQ_UNSEEN)
602 {
603 c = '_';
604 }
605 else if (v == SEQ_EXPIRED)
606 {
607 c = 'E';
608 }
609 else
610 {
611 const int diff = (int)(prev_now - v);
612 if (diff < 0)
613 {
614 c = 'N';
615 }
616 else if (diff < 10)
617 {
618 c = (char)('0' + diff);
619 }
620 else
621 {
622 c = '>';
623 }
624 }
625 buf_printf(&out, "%c", c);
626 }
627 buf_printf(&out, "] %" PRIi64 ":" packet_id_format, (int64_t)p->time, p->id);
628 if (pin)
629 {
630 buf_printf(&out, " %" PRIi64 ":" packet_id_format, (int64_t)pin->time, pin->id);
631 }
632
633 buf_printf(&out, " t=%" PRIi64 "[%d]", (int64_t)prev_now, (int)(prev_now - tv.tv_sec));
634
635 buf_printf(&out, " r=[%d,%" PRIu64 ",%d,%" PRIu64 ",%d]", (int)(p->last_reap - tv.tv_sec),
637 if (sl != NULL)
638 {
639 buf_printf(&out, " sl=[%d,%d,%d,%d]", sl->x_head, sl->x_size, sl->x_cap, sl->x_sizeof);
640 }
641
642
643 msg(msglevel, "%s", BSTR(&out));
644 gc_free(&gc);
645}
646
647#endif
648
649uint16_t
651{
652 uint64_t packet_id;
653
654
655 if (!buf_read(buf, &packet_id, sizeof(packet_id)))
656 {
657 return 0;
658 }
659
660 uint64_t id = ntohll(packet_id);
661 /* top most 16 bits */
662 uint16_t epoch = id >> 48;
663
664 pin->id = id & PACKET_ID_MASK;
665 return epoch;
666}
667
668#if defined(__GNUC__) || defined(__clang__)
669#pragma GCC diagnostic pop
670#endif
671
672bool
673packet_id_write_epoch(struct packet_id_send *p, uint16_t epoch, struct buffer *buf)
674{
676 {
677 return false;
678 }
679
680 /* Highest 16 bits of packet id is the epoch.
681 *
682 * The lower 48 bits are the per-epoch packet id counter. */
683 uint64_t net_id = ((uint64_t)epoch) << 48 | p->id;
684
685 /* convert to network order. This ensures that the highest bytes
686 * also become the first ones on the wire*/
687 net_id = htonll(net_id);
688
689 return buf_write(buf, &net_id, sizeof(net_id));
690}
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:1286
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:1474
static bool buf_write(struct buffer *dest, const void *src, size_t size)
Append data to a buffer.
Definition buffer.h:1262
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
Definition buffer.h:1976
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
Definition buffer.h:1960
#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:1735
#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:80
void packet_id_persist_save(struct packet_id_persist *p)
Definition packet_id.c:506
const char * packet_id_persist_print(const struct packet_id_persist *p, struct gc_arena *gc)
Definition packet_id.c:556
void packet_id_persist_load_obj(const struct packet_id_persist *p, struct packet_id *pid)
Definition packet_id.c:546
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:650
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:448
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:673
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:365
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:317
static bool packet_id_send_update(struct packet_id_send *p, bool long_form)
Definition packet_id.c:342
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:421
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:462
void packet_id_persist_init(struct packet_id_persist *p)
Definition packet_id.c:438
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:579
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:380
#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
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:122