OpenVPN
|
#include "syshead.h"
#include "packet_id.h"
#include "misc.h"
#include "integer.h"
#include "memdbg.h"
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) |
#define SEQ_EXPIRED ((time_t)1) |
Definition at line 52 of file packet_id.c.
#define SEQ_UNSEEN ((time_t)0) |
Definition at line 51 of file packet_id.c.
void packet_id_add | ( | struct packet_id_rec * | p, |
const struct packet_id_net * | pin | ||
) |
Definition at line 113 of file packet_id.c.
References CIRC_LIST_ITEM, CIRC_LIST_PUSH, CIRC_LIST_RESET, CIRC_LIST_SIZE, get_random(), packet_id_rec::id, packet_id_net::id, now, packet_id_rec::seq_backtrack, SEQ_EXPIRED, packet_id_rec::seq_list, SEQ_UNSEEN, packet_id_rec::time, and packet_id_net::time.
Referenced by crypto_check_replay().
|
inlinestatic |
Definition at line 64 of file packet_id.c.
References check_debug_level(), and unlikely.
Referenced by packet_id_test().
void packet_id_free | ( | struct packet_id * | p | ) |
Definition at line 102 of file packet_id.c.
References CLEAR, D_PID_DEBUG, dmsg, packet_id::rec, and packet_id_rec::seq_list.
Referenced by do_close_packet_id(), key_state_free(), test_crypto_thread(), test_generate_reset_packet_tls_auth(), tls_auth_standalone_free(), tls_wrap_free(), and uninit_crypto_options().
void packet_id_init | ( | struct packet_id * | p, |
int | seq_backtrack, | ||
int | time_backtrack, | ||
const char * | name, | ||
int | unit | ||
) |
Definition at line 79 of file packet_id.c.
References ASSERT, CIRC_LIST_ALLOC, CLEAR, D_PID_DEBUG, dmsg, packet_id_rec::initialized, MAX_SEQ_BACKTRACK, MAX_TIME_BACKTRACK, MIN_SEQ_BACKTRACK, MIN_TIME_BACKTRACK, packet_id_rec::name, packet_id::rec, packet_id_rec::seq_backtrack, packet_id_rec::seq_list, packet_id_rec::time_backtrack, and packet_id_rec::unit.
Referenced by do_init_crypto_static(), init_crypto_options(), key_state_init(), test_generate_reset_packet_tls_auth(), test_tls_crypt_setup(), tls_auth_standalone_init(), tls_session_generate_dynamic_tls_crypt_key(), and tls_session_init().
const char* packet_id_net_print | ( | const struct packet_id_net * | pin, |
bool | print_timestamp, | ||
struct gc_arena * | gc | ||
) |
Definition at line 389 of file packet_id.c.
References alloc_buf_gc(), BSTR, buf_printf(), packet_id_net::id, packet_id_format, packet_id_net::time, and time_string().
Referenced by crypto_check_replay(), and protocol_dump().
void packet_id_persist_close | ( | struct packet_id_persist * | p | ) |
Definition at line 417 of file packet_id.c.
References D_PID_PERSIST, packet_id_persist::fd, packet_id_persist::filename, M_ERRNO, msg, packet_id_persist_enabled(), and packet_id_persist_init().
Referenced by do_close_packet_id().
void packet_id_persist_init | ( | struct packet_id_persist * | p | ) |
Definition at line 407 of file packet_id.c.
References packet_id_persist::fd, packet_id_persist::filename, packet_id_persist::id, packet_id_persist::id_last_written, packet_id_persist::time, and packet_id_persist::time_last_written.
Referenced by packet_id_persist_close().
void packet_id_persist_load | ( | struct packet_id_persist * | p, |
const char * | filename | ||
) |
Definition at line 431 of file packet_id.c.
References D_PID_PERSIST, D_PID_PERSIST_DEBUG, dmsg, packet_id_persist::fd, packet_id_persist::filename, gc_free(), gc_new(), packet_id_persist::id, packet_id_persist_file_image::id, packet_id_persist::id_last_written, M_ERR, M_ERRNO, msg, O_BINARY, packet_id_persist_enabled(), packet_id_persist_print(), platform_open(), read, packet_id_persist::time, packet_id_persist_file_image::time, and packet_id_persist::time_last_written.
Referenced by init_crypto_pre().
void packet_id_persist_load_obj | ( | const struct packet_id_persist * | p, |
struct packet_id * | pid | ||
) |
Definition at line 522 of file packet_id.c.
References packet_id_rec::id, packet_id_persist::id, packet_id_persist_enabled(), packet_id::rec, packet_id_rec::time, and packet_id_persist::time.
Referenced by do_init_crypto_static(), and tls_session_init().
const char* packet_id_persist_print | ( | const struct packet_id_persist * | p, |
struct gc_arena * | gc | ||
) |
Definition at line 532 of file packet_id.c.
References alloc_buf_gc(), buf_printf(), buffer::data, packet_id_persist::id, packet_id_format, packet_id_persist_enabled(), packet_id_persist::time, and time_string().
Referenced by packet_id_persist_load(), and packet_id_persist_save().
void packet_id_persist_save | ( | struct packet_id_persist * | p | ) |
Definition at line 480 of file packet_id.c.
References D_PID_PERSIST, D_PID_PERSIST_DEBUG, dmsg, packet_id_persist::fd, packet_id_persist::filename, gc_free(), gc_new(), packet_id_persist::id, packet_id_persist_file_image::id, packet_id_persist::id_last_written, M_ERRNO, msg, packet_id_persist_enabled(), packet_id_persist_print(), packet_id_persist::time, packet_id_persist_file_image::time, packet_id_persist::time_last_written, and write.
Referenced by do_close_packet_id(), and process_coarse_timers().
bool packet_id_read | ( | struct packet_id_net * | pin, |
struct buffer * | buf, | ||
bool | long_form | ||
) |
Definition at line 299 of file packet_id.c.
References buf_read(), packet_id_net::id, ntohpid, ntohtime, and packet_id_net::time.
Referenced by do_pre_decrypt_check(), openvpn_decrypt_aead(), openvpn_decrypt_v1(), protocol_dump(), and tls_crypt_unwrap().
void packet_id_reap | ( | struct packet_id_rec * | p | ) |
Definition at line 168 of file packet_id.c.
References CIRC_LIST_ITEM, CIRC_LIST_SIZE, packet_id_rec::last_reap, now, SEQ_EXPIRED, packet_id_rec::seq_list, and packet_id_rec::time_backtrack.
Referenced by packet_id_reap_test().
|
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().
bool packet_id_test | ( | struct packet_id_rec * | p, |
const struct packet_id_net * | pin | ||
) |
Definition at line 200 of file packet_id.c.
References ASSERT, CIRC_LIST_ITEM, CIRC_LIST_SIZE, D_PID_DEBUG, D_PID_DEBUG_LOW, D_PID_DEBUG_MEDIUM, packet_id_rec::id, packet_id_net::id, packet_id_rec::initialized, packet_id_rec::max_backtrack_stat, packet_id_debug(), packet_id_rec::seq_backtrack, packet_id_rec::seq_list, packet_id_rec::time, and packet_id_net::time.
Referenced by crypto_check_replay().
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.
p | Packet ID state. |
buf | Buffer to write the packet ID too |
long_form | If true, also update and write time_t to buf |
prepend | If true, prepend to buffer, otherwise append. |
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().