24#include <freeradius-devel/util/test/acutest.h>
25#include <freeradius-devel/util/test/acutest_helpers.h>
33#define REQUEST ((request_t *) &dummy_request)
44 tt->current = current;
75#define RESERVE_OR_RETURN(_tt, _te) \
77 if (!track_reserve(_tt, &(_te))) { \
78 TEST_CHECK(!"track_reserve() failed"); \
88 TEST_CASE(
"Tokens come from the counter, and each Token finds its entry");
102 TEST_CASE(
"Tokens which were not issued are not found");
122 TEST_CASE(
"Releasing a middle entry removes only that entry");
129 TEST_CASE(
"Releasing the first entry issued, and then the last entry issued");
148 TEST_CASE(
"A released entry is not found");
157 TEST_CASE(
"The next reserve continues the counter, and the new Token finds the entry");
163 TEST_CASE(
"The released entry is reused, and the free list is empty while the entry is in use");
176 TEST_CASE(
"The epoch increases when the counter wraps to zero");
190 TEST_CASE(
"Entries from the previous epoch are still found");
195 TEST_CASE(
"Tokens which were not issued are not found across the wrap");
199 TEST_CASE(
"Releasing the entries from the previous epoch");
206 TEST_CASE(
"The counter continues in the new epoch");
223 TEST_CASE(
"A table in Token mode is not limited to 256 outstanding entries");
228 for (i = 0; i < 1024; i++) {
232 TEST_CASE(
"Releasing in the order of issue, and then reserving again");
236 for (i = 0; i < 1024; i++) {
250 TALLOC_CTX *ctx = talloc_new(NULL);
252 TEST_CASE(
"An entry which is released, and then reserved without a ctx, has no binding");
271 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
272 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
275 TEST_CASE(
"In ID mode, the vector is stored, and find matches on the ID and ignores the vector");
279 TEST_CHECK(memcmp(a->vector, vector,
sizeof(vector)) == 0);
288 TEST_CASE(
"In Token mode, the vector is not stored, and the Token and epoch are not changed");
306 TEST_CASE(
"A table which is not in Token mode finds entries by ID");
#define TEST_ASSERT(cond)
static unsigned int fr_dlist_num_elements(fr_dlist_head_t const *head)
Return the number of elements in the dlist.
static void fr_nbo_from_uint32(uint8_t out[static sizeof(uint32_t)], uint32_t num)
Write out an unsigned 32bit integer in wire format (big endian)
#define RADIUS_AUTH_VECTOR_LENGTH
Tracking RADUS client packets.
int radius_track_entry_update(radius_track_entry_t *te, uint8_t const *vector)
Update a tracking entry with the authentication vector.
radius_track_t * radius_track_alloc(TALLOC_CTX *ctx, bool radius_1_1)
Create an radius_track_t.
radius_track_entry_t * radius_track_entry_find(radius_track_t *tt, uint8_t packet_id, uint8_t const *vector)
Find a tracking entry from a request authenticator.
fr_dlist_head_t free_list
so we allocate by least recently used
#define radius_track_entry_release(_te)
unsigned int num_requests
number of requests in the allocation
#define radius_track_entry_reserve(_te_out, _ctx, _tt, _request, _code, _uctx)
radius_track_entry_t *** binding
Binding chunk we use to release the entry when its parent is freed.
Track one request to a response.
static char dummy_request
static void test_update(void)
static void test_id_mode(void)
static void test_token_many(void)
static void test_token_find(void)
static radius_track_entry_t * token_find(radius_track_t *tt, uint32_t token)
static void test_token_release(void)
#define RESERVE_OR_RETURN(_tt, _te)
static void test_binding(void)
static void test_token_epoch(void)
static radius_track_entry_t * track_reserve(radius_track_t *tt, radius_track_entry_t **te_p)
static radius_track_t * token_table(uint32_t epoch, uint32_t current)
static void test_token_reuse(void)