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