OpenVPN
Macros | Functions
packet_id.c File Reference
#include "syshead.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, int value)
 
void packet_id_init (struct packet_id *p, int seq_backtrack, int time_backtrack, const char *name, int unit)
 
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)
 
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. More...
 
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 52 of file packet_id.c.

◆ SEQ_UNSEEN

#define SEQ_UNSEEN   ((time_t)0)

Definition at line 51 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,
int  value 
)
inlinestatic

Definition at line 64 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_net_print()

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

◆ 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)

◆ 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 324 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_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 347 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().