PQS: Post Quantum Shell 1.0.0.0a (A1)
A quantum safe shell application
|
The server connection collection. More...
Go to the source code of this file.
Functions | |
bool | pqs_connections_active (size_t index) |
Check if a collection member is set to active. | |
pqs_connection_state * | pqs_connections_add (void) |
Add an item to the connection collection and set it to active. | |
size_t | pqs_connections_available (void) |
Get the number of available (inactive) connection states in the collection. | |
pqs_connection_state * | pqs_connections_get (uint32_t instance) |
Get a connection state pointer from a given instance number. | |
void | pqs_connections_initialize (size_t count, size_t maximum) |
Initialize the connection collection. | |
void | pqs_connections_clear (void) |
Erase (clear) all the connection collection members. | |
void | pqs_connections_dispose (void) |
Dispose of the connection collection state. | |
pqs_connection_state * | pqs_connections_index (size_t index) |
Get a connection state pointer by its collection index. | |
bool | pqs_connections_full (void) |
Check if the connection collection is full. | |
pqs_connection_state * | pqs_connections_next (void) |
Get the next available connection state. | |
void | pqs_connections_reset (uint32_t instance) |
Reset a connection in the collection. | |
size_t | pqs_connections_size (void) |
Get the total number of connection state items in the collection. | |
void | pqs_connections_self_test (void) |
Run the self-test for the connection collection. | |
The server connection collection.
This header defines a collection of functions for managing the server connection states in the PQS implementation. These functions are internal (non-exportable) and are used to maintain an array (or collection) of connection state objects. The functions allow for initialization, addition, retrieval, reset, and disposal of connection states, as well as performing a self-test of the collection functionality.
The collection is implemented as a dynamically allocated array of connection state structures along with a parallel array of booleans to indicate which entries are active.
bool pqs_connections_active | ( | size_t | index | ) |
Check if a collection member is set to active.
This function checks if the connection state at the given index in the collection is marked as active. If the index is within bounds, the function returns the boolean flag from the internal active array. Otherwise, it returns false.
index | The socket index number within the collection. |
pqs_connection_state * pqs_connections_add | ( | void | ) |
Add an item to the connection collection and set it to active.
This function adds a new connection state to the collection if the current number of entries plus one does not exceed the maximum allowed. It reallocates the internal arrays as needed, initializes the new connection state, sets its connection identifier (cid) to its index, and marks it as active.
size_t pqs_connections_available | ( | void | ) |
Get the number of available (inactive) connection states in the collection.
This function iterates through the connection collection and counts the number of entries that are currently marked as inactive.
void pqs_connections_clear | ( | void | ) |
Erase (clear) all the connection collection members.
This function clears the memory for all connection state structures in the collection and resets each active flag to false. It also resets the connection identifier (cid) of each state to its index.
void pqs_connections_dispose | ( | void | ) |
Dispose of the connection collection state.
This function frees all memory allocated for the connection state array and the corresponding active flag array. It also resets the collection length and maximum capacity to zero.
bool pqs_connections_full | ( | void | ) |
Check if the connection collection is full.
The function iterates through the active flags in the connection collection. If every entry is marked as active, the collection is considered full.
pqs_connection_state * pqs_connections_get | ( | uint32_t | instance | ) |
Get a connection state pointer from a given instance number.
The function searches through the connection collection for a connection state whose connection identifier (cid) matches the provided instance number.
instance | The socket instance number. |
pqs_connection_state * pqs_connections_index | ( | size_t | index | ) |
Get a connection state pointer by its collection index.
This function returns a pointer to the connection state located at the specified index in the internal connection collection, provided the index is within bounds.
index | The index number within the connection collection. |
void pqs_connections_initialize | ( | size_t | count, |
size_t | maximum ) |
Initialize the connection collection.
This function allocates and initializes the internal connection collection with the specified number of connection states. A minimum of one connection state is created, and the maximum number of connection states is set to the provided value. Each connection state is initialized by setting its connection identifier (cid) to its index and marking it as inactive.
count | The number of initial connection states to allocate (minimum of one). |
maximum | The maximum number of connection states allowed (must be greater than or equal to count). |
pqs_connection_state * pqs_connections_next | ( | void | ) |
Get the next available connection state.
This function searches for the first inactive connection state in the collection and marks it as active. If the collection is already full, it attempts to add a new connection state (subject to the maximum capacity).
void pqs_connections_reset | ( | uint32_t | instance | ) |
Reset a connection in the collection.
This function finds the connection state with the specified connection identifier (cid) and resets it. The connection state is cleared, its connection identifier is reset to its index, and its active flag is set to false.
instance | The socket instance number (connection identifier) of the connection to reset. |
void pqs_connections_self_test | ( | void | ) |
Run the self-test for the connection collection.
This function performs a series of tests on the connection collection to verify correct behavior:
This self-test is intended for internal diagnostic purposes to ensure the integrity and proper operation of the connection management functions.
size_t pqs_connections_size | ( | void | ) |
Get the total number of connection state items in the collection.
This function returns the current number of connection state items in the internal connection collection.