OpenVPN
test_packet_id.c File Reference
#include "syshead.h"
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "packet_id.h"
#include "reliable.h"
#include "test_common.h"
Include dependency graph for test_packet_id.c:

Go to the source code of this file.

Data Structures

struct  test_packet_id_write_data

Macros

#define SANE_TIMEOUT_BOUND   (10 * 1000 * 1000)
#define CHAR_N_SEND_BUFFERS   6
#define CHAR_OPCODE_CONTROL_V1   4

Enumerations

enum  recv_verdict { RECV_DROP , RECV_ACK_ONLY , RECV_STORE }

Functions

static int test_packet_id_write_setup (void **state)
static int test_packet_id_write_teardown (void **state)
static void test_packet_id_write_short (void **state)
static void test_packet_id_write_long (void **state)
static void test_packet_id_write_short_prepend (void **state)
static void test_packet_id_write_long_prepend (void **state)
static void test_packet_id_write_short_wrap (void **state)
static void test_packet_id_write_long_wrap (void **state)
static void test_get_num_output_sequenced_available (void **state)
static void test_packet_id_write_epoch (void **state)
static void test_copy_acks_to_lru (void **state)
static void test_packet_id_window (void **state)
static struct reliable * test_reliable_new (void)
static void test_reliable_backoff_is_bounded (void **state)
static void test_reliable_purge_ignores_forged_acks (void **state)
static void test_reliable_purge_legitimate_ack (void **state)
static bool ref_pid_min (packet_id_type p1, packet_id_type p2)
static bool ref_pid_in_send_window (const struct reliable *rel, packet_id_type pid)
static bool ref_wont_break_sequentiality (const struct reliable *rel, packet_id_type id)
static bool ref_not_replay (const struct reliable *rel, packet_id_type id)
static enum recv_verdict recv_filter (const struct reliable *rel, packet_id_type id)
static enum recv_verdict ref_recv_filter (const struct reliable *rel, packet_id_type id)
static void sweep_recv_filter (const packet_id_type *anchors, size_t n_anchors, enum recv_verdict(*oracle)(const struct reliable *, packet_id_type))
static void test_recv_window_bounded_at_wrap (void **state)
static void test_wont_break_sequentiality_accepts_next_id (void **state)
static void test_recv_filter_characterization (void **state)
static enum recv_verdict ref_recv_filter_bounded (const struct reliable *rel, packet_id_type id)
static void test_recv_filter_high_base (void **state)
static void sweep_send_window (const packet_id_type *anchors, size_t n_anchors)
static void test_send_window_characterization (void **state)
static void test_reliable_send_ignores_entry_ahead (void **state)
static void test_reliable_send_matches_can_send (void **state)
static void test_reliable_send_picks_oldest (void **state)
static void test_get_buf_output_sequenced_boundary (void **state)
static void test_mark_active_incoming_accepts_window (void **state)
static void test_mark_active_incoming_rejects_past_ids (void **state)
int main (void)

Variables

static const packet_id_type char_anchors []
static const packet_id_type char_anchors_high []
static const packet_id_type char_offsets []

Macro Definition Documentation

◆ CHAR_N_SEND_BUFFERS

◆ CHAR_OPCODE_CONTROL_V1

#define CHAR_OPCODE_CONTROL_V1   4

◆ SANE_TIMEOUT_BOUND

#define SANE_TIMEOUT_BOUND   (10 * 1000 * 1000)

Definition at line 383 of file test_packet_id.c.

Referenced by test_reliable_backoff_is_bounded().

Enumeration Type Documentation

◆ recv_verdict

Enumerator
RECV_DROP 
RECV_ACK_ONLY 
RECV_STORE 

Definition at line 593 of file test_packet_id.c.

Function Documentation

◆ main()

◆ recv_filter()

enum recv_verdict recv_filter ( const struct reliable * rel,
packet_id_type id )
static

◆ ref_not_replay()

bool ref_not_replay ( const struct reliable * rel,
packet_id_type id )
static

◆ ref_pid_in_send_window()

bool ref_pid_in_send_window ( const struct reliable * rel,
packet_id_type pid )
static

Definition at line 550 of file test_packet_id.c.

References reliable::packet_id, and RELIABLE_CAPACITY.

Referenced by sweep_send_window().

◆ ref_pid_min()

bool ref_pid_min ( packet_id_type p1,
packet_id_type p2 )
static

Definition at line 537 of file test_packet_id.c.

Referenced by ref_not_replay().

◆ ref_recv_filter()

enum recv_verdict ref_recv_filter ( const struct reliable * rel,
packet_id_type id )
static

◆ ref_recv_filter_bounded()

enum recv_verdict ref_recv_filter_bounded ( const struct reliable * rel,
packet_id_type id )
static

◆ ref_wont_break_sequentiality()

bool ref_wont_break_sequentiality ( const struct reliable * rel,
packet_id_type id )
static

Definition at line 559 of file test_packet_id.c.

References reliable::packet_id, and reliable::size.

Referenced by ref_recv_filter().

◆ sweep_recv_filter()

void sweep_recv_filter ( const packet_id_type * anchors,
size_t n_anchors,
enum recv_verdict(* oracle )(const struct reliable *, packet_id_type) )
static

◆ sweep_send_window()

void sweep_send_window ( const packet_id_type * anchors,
size_t n_anchors )
static

◆ test_copy_acks_to_lru()

void test_copy_acks_to_lru ( void ** state)
static

Definition at line 266 of file test_packet_id.c.

References copy_acks_to_mru(), reliable_ack::len, and reliable_ack::packet_id.

Referenced by main().

◆ test_get_buf_output_sequenced_boundary()

void test_get_buf_output_sequenced_boundary ( void ** state)
static

◆ test_get_num_output_sequenced_available()

void test_get_num_output_sequenced_available ( void ** state)
static

◆ test_mark_active_incoming_accepts_window()

void test_mark_active_incoming_accepts_window ( void ** state)
static

◆ test_mark_active_incoming_rejects_past_ids()

void test_mark_active_incoming_rejects_past_ids ( void ** state)
static

◆ test_packet_id_window()

void test_packet_id_window ( void ** state)
static

Definition at line 329 of file test_packet_id.c.

References reliable::packet_id, RELIABLE_CAPACITY, and reliable_pid_in_send_window().

Referenced by main().

◆ test_packet_id_write_epoch()

void test_packet_id_write_epoch ( void ** state)
static

◆ test_packet_id_write_long()

◆ test_packet_id_write_long_prepend()

◆ test_packet_id_write_long_wrap()

◆ test_packet_id_write_setup()

int test_packet_id_write_setup ( void ** state)
static

◆ test_packet_id_write_short()

◆ test_packet_id_write_short_prepend()

◆ test_packet_id_write_short_wrap()

void test_packet_id_write_short_wrap ( void ** state)
static

◆ test_packet_id_write_teardown()

int test_packet_id_write_teardown ( void ** state)
static

Definition at line 70 of file test_packet_id.c.

References test_packet_id_write_data::gc, and gc_free().

Referenced by main().

◆ test_recv_filter_characterization()

void test_recv_filter_characterization ( void ** state)
static

Definition at line 754 of file test_packet_id.c.

References char_anchors, ref_recv_filter(), SIZE, and sweep_recv_filter().

Referenced by main().

◆ test_recv_filter_high_base()

void test_recv_filter_high_base ( void ** state)
static

Definition at line 781 of file test_packet_id.c.

References char_anchors_high, ref_recv_filter_bounded(), SIZE, and sweep_recv_filter().

Referenced by main().

◆ test_recv_window_bounded_at_wrap()

void test_recv_window_bounded_at_wrap ( void ** state)
static

Definition at line 708 of file test_packet_id.c.

References reliable::packet_id, RECV_ACK_ONLY, recv_filter(), RECV_STORE, RELIABLE_CAPACITY, and reliable::size.

Referenced by main().

◆ test_reliable_backoff_is_bounded()

◆ test_reliable_new()

◆ test_reliable_purge_ignores_forged_acks()

void test_reliable_purge_ignores_forged_acks ( void ** state)
static

◆ test_reliable_purge_legitimate_ack()

void test_reliable_purge_legitimate_ack ( void ** state)
static

◆ test_reliable_send_ignores_entry_ahead()

◆ test_reliable_send_matches_can_send()

◆ test_reliable_send_picks_oldest()

◆ test_send_window_characterization()

void test_send_window_characterization ( void ** state)
static

Definition at line 813 of file test_packet_id.c.

References char_anchors, char_anchors_high, SIZE, and sweep_send_window().

Referenced by main().

◆ test_wont_break_sequentiality_accepts_next_id()

void test_wont_break_sequentiality_accepts_next_id ( void ** state)
static

Variable Documentation

◆ char_anchors

const packet_id_type char_anchors[]
static
Initial value:
= {
0x00000000,
0x00000001,
0x00000005,
0x0000000B,
0x0000000C,
0x0000000D,
0x000001F4,
0x7FFFFFF4,
0x7FFFFFFF,
0x80000000,
}

Definition at line 627 of file test_packet_id.c.

Referenced by test_recv_filter_characterization(), and test_send_window_characterization().

◆ char_anchors_high

const packet_id_type char_anchors_high[]
static
Initial value:
= {
0x80000001,
0x8000000C,
0xFFFFFFF0,
0xFFFFFFF3,
}

Definition at line 640 of file test_packet_id.c.

Referenced by test_recv_filter_high_base(), and test_send_window_characterization().

◆ char_offsets

const packet_id_type char_offsets[]
static
Initial value:
= {
0,
1,
2,
10,
11,
12,
13,
14,
100,
0x3FFFFFFF,
0x40000000,
0x7FFFFFFE,
0x7FFFFFFF,
0x80000000,
0x80000001,
0x80000002,
0xFFFFFFF4,
0xFFFFFFFE,
0xFFFFFFFF,
}

Definition at line 648 of file test_packet_id.c.

Referenced by sweep_recv_filter(), and sweep_send_window().