QSMP: Quantum Secure Messaging Protocol 1.3.0.0a (A3)
A quantum secure encrypted tunneling protocol
server.h File Reference

QSMP Server functions. More...

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

Go to the source code of this file.

Macros

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

Functions

QSMP_EXPORT_API void qsmp_server_broadcast (const uint8_t *message, size_t msglen)
 Broadcast a message to all connected hosts.
 
QSMP_EXPORT_API void qsmp_server_pause (void)
 Pause the server.
 
QSMP_EXPORT_API void qsmp_server_quit (void)
 Quit the server.
 
QSMP_EXPORT_API void qsmp_server_resume (void)
 Resume the server listener.
 
QSMP_EXPORT_API qsmp_errors qsmp_server_start_ipv4 (qsc_socket *source, const qsmp_server_signature_key *kset, void(*receive_callback)(qsmp_connection_state *, const uint8_t *, size_t), void(*disconnect_callback)(qsmp_connection_state *))
 Start the IPv4 multi-threaded server.
 
QSMP_EXPORT_API qsmp_errors qsmp_server_start_ipv6 (qsc_socket *source, const qsmp_server_signature_key *kset, void(*receive_callback)(qsmp_connection_state *, const uint8_t *, size_t), void(*disconnect_callback)(qsmp_connection_state *))
 Start the IPv6 multi-threaded server.
 

Detailed Description

QSMP Server functions.

This header declares the functions used to implement the server component of the Quantum Secure Messaging Protocol (QSMP). The server functions manage client connections, broadcast messages, and control the server lifecycle through operations such as pausing, resuming, and quitting. QSMP employs a multi-threaded server design that supports both IPv4 and IPv6 connections.

The functions provided in this header include:

  • Broadcasting a message to all connected hosts.
  • Pausing the server to suspend acceptance of new connections.
  • Quitting the server by closing all active connections.
  • Resuming the server listener from a paused state.
  • Starting the multi-threaded server on IPv4 and IPv6 interfaces with support for callback functions to process incoming data and handle disconnect events.
Note
QSMP_EXPORT_API is used to ensure proper symbol visibility.

Macro Definition Documentation

◆ QSMP_SERVER_PAUSE_INTERVAL

#define QSMP_SERVER_PAUSE_INTERVAL   100

The pause interval used by the server pause function.

This macro defines the time interval (in milliseconds) that the server will pause before resuming operations or processing new connection requests.

Function Documentation

◆ qsmp_server_broadcast()

QSMP_EXPORT_API void qsmp_server_broadcast ( const uint8_t * message,
size_t msglen )

Broadcast a message to all connected hosts.

This function iterates over all active connections managed by the server and transmits the specified message to each connected host. It is useful for disseminating announcements or control messages across the network.

Parameters
message[const] A pointer to the message data to be broadcast.
msglenThe length (in bytes) of the message.

◆ qsmp_server_pause()

QSMP_EXPORT_API void qsmp_server_pause ( void )

Pause the server.

This function temporarily suspends the acceptance of new client connections. While paused, the server continues to service existing connections but does not allow any new joins until it is resumed.

◆ qsmp_server_quit()

QSMP_EXPORT_API void qsmp_server_quit ( void )

Quit the server.

This function gracefully shuts down the server by closing all active client connections and terminating the server's listener. It is used to perform a complete shutdown of the server operations.

◆ qsmp_server_resume()

QSMP_EXPORT_API void qsmp_server_resume ( void )

Resume the server listener.

This function resumes the server's listener functionality after it has been paused. Once resumed, the server will once again accept new incoming client connections.

◆ qsmp_server_start_ipv4()

QSMP_EXPORT_API qsmp_errors qsmp_server_start_ipv4 ( qsc_socket * source,
const qsmp_server_signature_key * kset,
void(* receive_callback )(qsmp_connection_state *, const uint8_t *, size_t),
void(* disconnect_callback )(qsmp_connection_state *) )

Start the IPv4 multi-threaded server.

This function initializes and starts the QSMP server for IPv4 connections using a multi-threaded architecture. It listens on the provided socket and uses the specified QSMP private key for secure key exchange and authentication. Two callback functions are provided:

  • A receive callback to process incoming client data streams.
  • A disconnect callback to handle cleanup and resource deallocation when a client disconnects.
Parameters
sourceA pointer to the listener socket used by the server.
kset[const] A pointer to the QSMP server private signature key used for key exchange.
receive_callbackA pointer to the function that processes incoming client data.
disconnect_callbackA pointer to the function that handles client disconnect events.
Returns
Returns a QSMP error code indicating the success or failure of starting the IPv4 server.

◆ qsmp_server_start_ipv6()

QSMP_EXPORT_API qsmp_errors qsmp_server_start_ipv6 ( qsc_socket * source,
const qsmp_server_signature_key * kset,
void(* receive_callback )(qsmp_connection_state *, const uint8_t *, size_t),
void(* disconnect_callback )(qsmp_connection_state *) )

Start the IPv6 multi-threaded server.

This function initializes and starts the QSMP server for IPv6 connections using a multi-threaded design. It listens on the provided IPv6 socket and employs the specified QSMP private key for secure communications. The server uses two callback functions to process incoming client data and handle disconnect events.

Parameters
sourceA pointer to the listener socket used by the server.
kset[const] A pointer to the QSMP server private signature key used for key exchange and authentication.
receive_callbackA pointer to the function that processes incoming client data.
disconnect_callbackA pointer to the function that handles client disconnect events.
Returns
Returns a QSMP error code indicating the outcome of starting the IPv6 server.