OpenVPN
Macros | Functions
packet_id.c File Reference
#include "syshead.h"
#include <stddef.h>
#include "packet_id.h"
#include "misc.h"
#include "integer.h"
#include "memdbg.h"
Include dependency graph for packet_id.c:

Go to the source code of this file.

Macros

#define SEQ_UNSEEN   ((time_t)0)
 
#define SEQ_EXPIRED   ((time_t)1)
 

Functions

static void packet_id_debug (int msglevel, const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, uint64_t value)
 
static void packet_id_init_recv (struct packet_id_rec *rec, int seq_backtrack, int time_backtrack, const char *name, int unit)
 
void packet_id_init (struct packet_id *p, int seq_backtrack, int time_backtrack, const char *name, int unit)
 
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.
 
void packet_id_free (struct packet_id *p)
 
void packet_id_add (struct packet_id_rec *p, const struct packet_id_net *pin)
 
void packet_id_reap (struct packet_id_rec *p)
 
bool packet_id_test (struct packet_id_rec *p, const struct packet_id_net *pin)
 
bool packet_id_read (struct packet_id_net *pin, struct buffer *buf, bool long_form)
 
static bool packet_id_send_update (struct packet_id_send *p, bool long_form)
 
static bool packet_id_send_update_epoch (struct packet_id_send *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.
 
const char * packet_id_net_print (const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
 
void packet_id_persist_init (struct packet_id_persist *p)
 
void packet_id_persist_close (struct packet_id_persist *p)
 
void packet_id_persist_load (struct packet_id_persist *p, const char *filename)
 
void packet_id_persist_save (struct packet_id_persist *p)
 
void packet_id_persist_load_obj (const struct packet_id_persist *p, struct packet_id *pid)
 
const char * packet_id_persist_print (const struct packet_id_persist *p, struct gc_arena *gc)
 

Macro Definition Documentation

◆ SEQ_EXPIRED

#define SEQ_EXPIRED   ((time_t)1)

Definition at line 54 of file packet_id.c.

◆ SEQ_UNSEEN

#define SEQ_UNSEEN   ((time_t)0)

Definition at line 53 of file packet_id.c.

Function Documentation

◆ packet_id_add()

void packet_id_add ( struct packet_id_rec p,
const struct packet_id_net pin 
)

◆ packet_id_debug()

static void packet_id_debug ( int  msglevel,
const struct packet_id_rec p,
const struct packet_id_net pin,
const char *  message,
uint64_t  value 
)
inlinestatic

Definition at line 66 of file packet_id.c.

References check_debug_level(), and unlikely.

Referenced by packet_id_test().

◆ packet_id_free()

void packet_id_free ( struct packet_id p)

◆ packet_id_init()

void packet_id_init ( struct packet_id p,
int  seq_backtrack,
int  time_backtrack,
const char *  name,
int  unit 
)

◆ packet_id_init_recv()

static void packet_id_init_recv ( struct packet_id_rec rec,
int  seq_backtrack,
int  time_backtrack,
const char *  name,
int  unit 
)
static

◆ packet_id_move_recv()

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.

src will be reinitialised. dest will be freed before the move.

Definition at line 109 of file packet_id.c.

References ASSERT, CLEAR, packet_id_rec::name, packet_id_init_recv(), packet_id_rec::seq_backtrack, packet_id_rec::seq_list, packet_id_rec::time_backtrack, and packet_id_rec::unit.

Referenced by epoch_replace_update_recv_key().

◆ packet_id_net_print()

const char * packet_id_net_print ( const struct packet_id_net pin,
bool  print_timestamp,
struct gc_arena gc 
)

Definition at line 428 of file packet_id.c.

References alloc_buf_gc(), BSTR, buf_printf(), gc, buffer::len, packet_id_format, and time_string().

Referenced by crypto_check_replay(), and protocol_dump().

◆ packet_id_persist_close()

void packet_id_persist_close ( struct packet_id_persist p)

◆ packet_id_persist_init()

void packet_id_persist_init ( struct packet_id_persist p)

Definition at line 446 of file packet_id.c.

References buffer::len.

Referenced by packet_id_persist_close().

◆ packet_id_persist_load()

void packet_id_persist_load ( struct packet_id_persist p,
const char *  filename 
)

◆ packet_id_persist_load_obj()

void packet_id_persist_load_obj ( const struct packet_id_persist p,
struct packet_id pid 
)

◆ packet_id_persist_print()

const char * packet_id_persist_print ( const struct packet_id_persist p,
struct gc_arena gc 
)

◆ packet_id_persist_save()

void packet_id_persist_save ( struct packet_id_persist p)

◆ packet_id_read()

bool packet_id_read ( struct packet_id_net pin,
struct buffer buf,
bool  long_form 
)

◆ packet_id_reap()

void packet_id_reap ( struct packet_id_rec p)

◆ packet_id_send_update()

static bool packet_id_send_update ( struct packet_id_send p,
bool  long_form 
)
static

Definition at line 348 of file packet_id.c.

References packet_id_send::id, now, PACKET_ID_MAX, and packet_id_send::time.

Referenced by packet_id_write().

◆ packet_id_send_update_epoch()

static bool packet_id_send_update_epoch ( struct packet_id_send p)
static

Definition at line 371 of file packet_id.c.

References packet_id_send::id, now, PACKET_ID_EPOCH_MAX, and packet_id_send::time.

◆ packet_id_test()

bool packet_id_test ( struct packet_id_rec p,
const struct packet_id_net pin 
)

◆ packet_id_write()

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.

Parameters
pPacket ID state.
bufBuffer to write the packet ID too
long_formIf true, also update and write time_t to buf
prependIf true, prepend to buffer, otherwise append.
Returns
true if successful, false otherwise.

Definition at line 386 of file packet_id.c.

References buf_write(), buf_write_prepend(), htonpid, htontime, packet_id_send::id, packet_id_send_update(), and packet_id_send::time.

Referenced by openvpn_encrypt_aead(), openvpn_encrypt_v1(), test_packet_id_write_long(), test_packet_id_write_long_prepend(), test_packet_id_write_long_wrap(), test_packet_id_write_short(), test_packet_id_write_short_prepend(), test_packet_id_write_short_wrap(), and tls_crypt_wrap().