85 assert_int_equal(data->
pis.
id, 1);
97 assert_int_equal(data->
pis.
id, 1);
111 assert_int_equal(data->
pis.
id, 1);
124 assert_int_equal(data->
pis.
id, 1);
157 assert_int_equal(data->
pis.
id, 1);
167 assert_non_null(rel);
235 data->pis.id = 0xfa079ab9d2e8;
243 data->pis.id = 0xfffffffffffe;
256 assert_int_equal(pin.
id, 1);
259 assert_int_equal(pin.
id, 0xfa079ab9d2e9);
262 assert_int_equal(pin.
id, 0xffffffffffff);
377#define SANE_TIMEOUT_BOUND (10 * 1000 * 1000)
383 assert_non_null(rel);
412 for (
int i = 0; i < 40; ++i)
523 const struct CMUnitTest tests[] = {
548 return cmocka_run_group_tests_name(
"packet_id tests", tests, NULL, NULL);
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Allocate a buffer of the given size under garbage collection.
#define BPTR(buf)
Return a pointer to the start of the buffer content.
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
void reliable_free(struct reliable *rel)
Free allocated memory associated with a reliable structure and the pointer itself.
#define N_ACK_RETRANSMIT
We retry sending a packet early if this many later packets have been ACKed.
int validate_packet_id_window(struct reliable *rel, packet_id_type pid)
check that pid is inside the window of possible outstanding packets of size RELIABLE_CAPACITY,...
void reliable_send_purge(struct reliable *rel, const struct reliable_ack *ack)
Remove acknowledged packets from a reliable structure.
struct buffer * reliable_send(struct reliable *rel, int *opcode)
Get the next packet to send to the remote peer.
#define RELIABLE_CAPACITY
The maximum number of packets that the reliability layer for one VPN tunnel in one direction can stor...
void reliable_init(struct reliable *rel, int buf_size, int offset, int array_size, bool hold)
Initialize a reliable structure.
void copy_acks_to_mru(struct reliable_ack *ack, struct reliable_ack *ack_mru, int n)
Copies the first n acks from ack to ack_mru.
int reliable_get_num_output_sequenced_available(struct reliable *rel)
Counts the number of free buffers in output that can be potentially used for sending.
uint16_t packet_id_read_epoch(struct packet_id_net *pin, struct buffer *buf)
Reads the packet ID containing both the epoch and the per-epoch counter from the buf.
bool packet_id_write_epoch(struct packet_id_send *p, uint16_t epoch, struct buffer *buf)
Writes the packet ID containing both the epoch and the packet id to the buffer specified by buf.
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.
Reliability Layer module header file.
Wrapper structure for dynamically allocated memory.
int capacity
Size in bytes of memory allocated by malloc().
uint8_t * data
Pointer to the allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
int offset
Offset in bytes of the actual content within the allocated memory.
Garbage collection arena used to keep track of dynamically allocated memory.
Data structure for describing the packet id that is received/send to the network.
The acknowledgment structure in which packet IDs are stored for later acknowledgment.
The structure in which the reliability layer stores a single incoming or outgoing packet.
The reliability layer storage structure for one VPN tunnel's control channel in one direction.
struct reliable_entry array[RELIABLE_CAPACITY]
packet_id_type packet_id
Packet ID for the next packet to be sent out.
interval_t initial_timeout
struct packet_id_send pis
struct test_packet_id_write_data::@31 test_buf_data
static void openvpn_unit_test_setup(void)
Sets up the environment for unit tests like making both stderr and stdout non-buffered to avoid messa...
static int test_packet_id_write_setup(void **state)
static void test_packet_id_write_epoch(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_short_prepend(void **state)
static void test_packet_id_window(void **state)
static void test_reliable_backoff_is_bounded(void **state)
#define SANE_TIMEOUT_BOUND
static void test_reliable_purge_ignores_forged_acks(void **state)
static void test_packet_id_write_long(void **state)
static int test_packet_id_write_teardown(void **state)
static void test_reliable_purge_legitimate_ack(void **state)
static void test_get_num_output_sequenced_available(void **state)
static struct reliable * test_reliable_new(void)
static void test_copy_acks_to_lru(void **state)
static void test_packet_id_write_long_wrap(void **state)
static void test_packet_id_write_short(void **state)