PQS: Post Quantum Shell 1.0.0.0a (A1)
A quantum safe shell application
server.h File Reference

PQS Server functions. More...

#include "pqs.h"
#include "../../QSC/QSC/rcs.h"
#include "../../QSC/QSC/socketserver.h"

Go to the source code of this file.

Macros

#define PQS_SERVER_PAUSE_INTERVAL   100
 The pause interval used by the server pause function.
 

Functions

PQS_EXPORT_API void pqs_server_pause (void)
 Pause the server, suspending new joins.
 
PQS_EXPORT_API void pqs_server_quit (qsc_socket *source)
 Quit the server, closing all connections.
 
PQS_EXPORT_API void pqs_server_resume (void)
 Resume the server listener function from a paused state.
 
PQS_EXPORT_API pqs_errors pqs_server_start_ipv4 (qsc_socket *source, const pqs_server_signature_key *kset, void(*receive_callback)(pqs_connection_state *, const uint8_t *, size_t), void(*disconnect_callback)(pqs_connection_state *))
 Start the IPv4 multi-threaded server.
 
PQS_EXPORT_API pqs_errors pqs_server_start_ipv6 (qsc_socket *source, const pqs_server_signature_key *kset, void(*receive_callback)(pqs_connection_state *, const uint8_t *, size_t), void(*disconnect_callback)(pqs_connection_state *))
 Start the IPv6 multi-threaded server.
 

Detailed Description

PQS Server functions.

This header defines the functions used to implement the Post Quantum Shell (PQS) server. These functions enable the server to pause accepting new connections, resume listening, shut down (quitting) by closing all active connections, and to start the multi-threaded server on both IPv4 and IPv6 networks.

The multi-threaded server functions require a pointer to the listener socket as well as a pointer to the server's private key (QSMP private key) used for secure communications. Callback functions are provided to process incoming client data streams and to handle client disconnections.

Macro Definition Documentation

◆ PQS_SERVER_PAUSE_INTERVAL

#define PQS_SERVER_PAUSE_INTERVAL   100

The pause interval used by the server pause function.

This macro defines the time interval (in milliseconds) during which the server will pause accepting new connection requests.

Function Documentation

◆ pqs_server_pause()

PQS_EXPORT_API void pqs_server_pause ( void )

Pause the server, suspending new joins.

This function temporarily suspends the server listener so that no new client connections will be accepted. This is useful during maintenance or when shutting down the server.

DOXYGEN_IGNORE

◆ pqs_server_quit()

PQS_EXPORT_API void pqs_server_quit ( qsc_socket * source)

Quit the server, closing all connections.

This function terminates the server by closing all active client connections. The provided socket (source) is used as the listener or reference socket which is closed as part of the shutdown process.

Parameters
sourceA pointer to the server listener socket.

◆ pqs_server_resume()

PQS_EXPORT_API void pqs_server_resume ( void )

Resume the server listener function from a paused state.

This function resumes the server's listening operations if it was previously paused. New client connections will again be accepted after this function is called.

◆ pqs_server_start_ipv4()

PQS_EXPORT_API pqs_errors pqs_server_start_ipv4 ( qsc_socket * source,
const pqs_server_signature_key * kset,
void(* receive_callback )(pqs_connection_state *, const uint8_t *, size_t),
void(* disconnect_callback )(pqs_connection_state *) )

Start the IPv4 multi-threaded server.

This function starts the PQS server in a multi-threaded mode for IPv4. It initializes the listener socket, performs necessary key exchange operations using the provided server private key, and then spawns threads to handle incoming client data streams and disconnections.

Parameters
sourceA pointer to the listener server socket.
kset[const] A pointer to the QSMP private key (server signature key) used for the key exchange.
receive_callbackA pointer to the callback function that processes client data streams.
disconnect_callbackA pointer to the callback function invoked upon client disconnection.
Returns
Returns a pqs_errors value indicating the success or failure of the server startup and key exchange process.

◆ pqs_server_start_ipv6()

PQS_EXPORT_API pqs_errors pqs_server_start_ipv6 ( qsc_socket * source,
const pqs_server_signature_key * kset,
void(* receive_callback )(pqs_connection_state *, const uint8_t *, size_t),
void(* disconnect_callback )(pqs_connection_state *) )

Start the IPv6 multi-threaded server.

This function starts the PQS server in a multi-threaded mode for IPv6. It initializes the listener socket, performs the key exchange using the provided server private key, and spawns threads to handle incoming client data streams.

Parameters
sourceA pointer to the listener server socket.
kset[const] A pointer to the QSMP private key (server signature key) used for the key exchange.
receive_callbackA pointer to the callback function that processes client data streams.
disconnect_callbackA pointer to the callback function invoked upon client disconnection.
Returns
Returns a pqs_errors value indicating the success or failure of the server startup and key exchange process.