|
CTaps 0.3.0
A C implementation of the Transport Services API (RFC 9621 - 9623)
|
Connection lifecycle, state queries, cloning, and group management. More...
Data Structures | |
| struct | ct_receive_callbacks_t |
| Callback functions for receiving messages on a connection. More... | |
| struct | ct_connection_callbacks_t |
| Callback functions for connection lifecycle events. More... | |
| struct | ct_connection_t |
| Opaque handle representing a connection. More... | |
Enumerations | |
| enum | ct_protocol_enum_t { CT_PROTOCOL_ERROR = -1 , CT_PROTOCOL_TCP , CT_PROTOCOL_UDP , CT_PROTOCOL_QUIC } |
| Enumeration of currently supported transport protocols. More... | |
Functions | |
| int | ct_send_message (ct_connection_t *connection, const ct_message_t *message) |
| Send a message over a connection with default properties. | |
| int | ct_send_message_full (ct_connection_t *connection, const ct_message_t *message, const ct_message_context_t *message_context) |
| Send a message with custom message context and properties. | |
| int | ct_receive_message (ct_connection_t *connection, const ct_receive_callbacks_t *receive_callbacks) |
| Register callbacks to receive messages on a connection. | |
| const ct_transport_properties_t * | ct_connection_get_transport_properties (const ct_connection_t *connection) |
| Get shared connection properties for a connection. | |
| uint8_t | ct_connection_get_priority (const ct_connection_t *connection) |
| Get relative priority when compared to other connections in the same group. | |
| int | ct_connection_set_priority (ct_connection_t *connection, uint8_t priority) |
| Set relative priority for a connection compared to other connections in the same group. | |
| void * | ct_connection_get_callback_context (const ct_connection_t *connection) |
| Get the connection's callback context. | |
| const char * | ct_connection_get_uuid (const ct_connection_t *connection) |
| Get the UUID of a connection. | |
| const char * | ct_connection_get_protocol_name (const ct_connection_t *connection) |
| Get the name of the underlying protocol. | |
| const ct_remote_endpoint_t * | ct_connection_get_active_remote_endpoint (const ct_connection_t *connection) |
| Get the currently active remote endpoint for the connection. | |
| const ct_local_endpoint_t * | ct_connection_get_active_local_endpoint (const ct_connection_t *connection) |
| Get the currently active local endpoint. | |
| ct_connection_state_enum_t | ct_connection_get_state (const ct_connection_t *connection) |
| Get the current state of a connection. | |
| bool | ct_connection_is_closed (const ct_connection_t *connection) |
| Check if a connection's state is CT_CONN_STATE_CLOSED. | |
| bool | ct_connection_is_established (const ct_connection_t *connection) |
| Check if a connection's state is CT_CONN_STATE_ESTABLISHED. | |
| bool | ct_connection_is_establishing (const ct_connection_t *connection) |
| Check if a connection's state is CT_CONN_STATE_ESTABLISHING. | |
| bool | ct_connection_is_closing (const ct_connection_t *connection) |
| Check if a connection's state is CT_CONN_STATE_CLOSING. | |
| bool | ct_connection_is_closed_or_closing (const ct_connection_t *connection) |
| Check if a connection's state is CT_CONN_STATE_CLOSED or CT_CONN_STATE_CLOSING. | |
| bool | ct_connection_is_client (const ct_connection_t *connection) |
| Check if a connection is a client connection. | |
| bool | ct_connection_is_server (const ct_connection_t *connection) |
| Check if a connection is a server connection. | |
| bool | ct_connection_can_send (const ct_connection_t *connection) |
| Check the value of the canSend connection property. | |
| bool | ct_connection_can_receive (const ct_connection_t *connection) |
| Check the value of the canReceive connection property. | |
| void | ct_connection_free (ct_connection_t *connection) |
| Free resources in a connection. | |
| void | ct_connection_close (ct_connection_t *connection) |
| Close a connection gracefully. | |
| void | ct_connection_abort (ct_connection_t *connection) |
| Forcefully abort a connection without graceful shutdown. | |
| int | ct_connection_clone_full (const ct_connection_t *source_connection, const ct_framer_impl_t *framer, const ct_transport_properties_t *connection_properties) |
| Clone a connection to create a new connection in the same connection group. | |
| int | ct_connection_clone (ct_connection_t *source_connection) |
| Clone a connection with only mandatory parameters. | |
| size_t | ct_connection_get_total_num_grouped_connections (const ct_connection_t *connection) |
| Get the total number of connections in a connection group (including closed ones). | |
| size_t | ct_connection_get_num_open_grouped_connections (const ct_connection_t *connection) |
| Get the number of open connections in a connection group. | |
| void | ct_connection_close_group (ct_connection_t *connection) |
| Close all connections in the same connection group gracefully. | |
| void | ct_connection_abort_group (ct_connection_t *connection) |
| Forcefully abort all connections in the same connection group. | |
| ct_protocol_enum_t | ct_connection_get_transport_protocol (const ct_connection_t *connection) |
| Get the transport protocol used by a connection. | |
| bool | ct_connection_sent_early_data (const ct_connection_t *connection) |
| Check if a connection has sent early data (e.g., 0-RTT). | |
Connection lifecycle, state queries, cloning, and group management.
| enum ct_protocol_enum_t |
| void ct_connection_abort | ( | ct_connection_t * | connection | ) |
Forcefully abort a connection without graceful shutdown.
Unlike ct_connection_close() which performs a graceful shutdown (e.g., FIN), this immediately terminates the connection (e.g., RST). Use when an error condition requires immediate termination.
| [in] | connection | Connection to abort |
| void ct_connection_abort_group | ( | ct_connection_t * | connection | ) |
Forcefully abort all connections in the same connection group.
Immediately terminates all connections in the group without graceful shutdown. This is equivalent to calling ct_connection_abort() on each connection in the group.
| [in] | connection | Any connection in the group to abort |
| bool ct_connection_can_receive | ( | const ct_connection_t * | connection | ) |
Check the value of the canReceive connection property.
| [in] | connection | The connection to check |
| bool ct_connection_can_send | ( | const ct_connection_t * | connection | ) |
Check the value of the canSend connection property.
| [in] | connection | The connection to check |
| int ct_connection_clone | ( | ct_connection_t * | source_connection | ) |
Clone a connection with only mandatory parameters.
| int ct_connection_clone_full | ( | const ct_connection_t * | source_connection, |
| const ct_framer_impl_t * | framer, | ||
| const ct_transport_properties_t * | connection_properties | ||
| ) |
Clone a connection to create a new connection in the same connection group.
Creates a new connection that shares the same transport session as the parent connection. This enables a multi-streaming protocols like QUIC to create multiple logical connections (streams) over a single transport session.
The callbacks of the source connection are copied into the cloned connection. The ready callback is invoked with the cloned connection as a parameter, when connection succeeds.
| [in] | source_connection | The connection to clone |
| [in] | framer | Optional framer for the cloned connection (NULL to inherit) |
| [in] | connection_properties | Optional properties for cloned connection (Not implemented) |
| void ct_connection_close | ( | ct_connection_t * | connection | ) |
Close a connection gracefully.
Exact behaviour depends on the underlying transport protocol. For TCP, this performs a graceful shutdown (e.g., FIN). For UDP this simply stops further sends and receives and closes the socket. For QUIC it closes the connection, if the connection it is invoked on is the last open connection in the connection group. Otherwise it closes the connection one way (sending a FIN), stopping sending but allowing receives to continue until the remote also closes.
| [in] | connection | Connection to close |
| void ct_connection_close_group | ( | ct_connection_t * | connection | ) |
Close all connections in the same connection group gracefully.
Performs graceful shutdown of all connections in the group (the connection and all its clones). This is equivalent to calling ct_connection_close() on each connection in the group.
| [in] | connection | Any connection in the group to close |
| void ct_connection_free | ( | ct_connection_t * | connection | ) |
Free resources in a connection.
| [in] | connection | Connection to free |
| const ct_local_endpoint_t * ct_connection_get_active_local_endpoint | ( | const ct_connection_t * | connection | ) |
Get the currently active local endpoint.
| [in] | connection | connection to get local endpoint for |
| const ct_remote_endpoint_t * ct_connection_get_active_remote_endpoint | ( | const ct_connection_t * | connection | ) |
Get the currently active remote endpoint for the connection.
| [in] | connection | connection to get remote endpoint for |
| void * ct_connection_get_callback_context | ( | const ct_connection_t * | connection | ) |
Get the connection's callback context.
| [in] | connection | connection to get callback context for |
| size_t ct_connection_get_num_open_grouped_connections | ( | const ct_connection_t * | connection | ) |
Get the number of open connections in a connection group.
| [in] | connection | The connection to query |
| uint8_t ct_connection_get_priority | ( | const ct_connection_t * | connection | ) |
Get relative priority when compared to other connections in the same group.
Lower values are higher priority.
Defaults to 100.
| const char * ct_connection_get_protocol_name | ( | const ct_connection_t * | connection | ) |
Get the name of the underlying protocol.
| [in] | connection | connection to get protocol name for |
| ct_connection_state_enum_t ct_connection_get_state | ( | const ct_connection_t * | connection | ) |
Get the current state of a connection.
| [in] | connection | The connection to query |
| size_t ct_connection_get_total_num_grouped_connections | ( | const ct_connection_t * | connection | ) |
Get the total number of connections in a connection group (including closed ones).
| [in] | connection | The connection to query |
| const ct_transport_properties_t * ct_connection_get_transport_properties | ( | const ct_connection_t * | connection | ) |
Get shared connection properties for a connection.
| [in] | connection | The connection to query |
| ct_protocol_enum_t ct_connection_get_transport_protocol | ( | const ct_connection_t * | connection | ) |
Get the transport protocol used by a connection.
| [in] | connection | The connection to query |
| const char * ct_connection_get_uuid | ( | const ct_connection_t * | connection | ) |
Get the UUID of a connection.
| [in] | connection | connection to get uuid for |
| bool ct_connection_is_client | ( | const ct_connection_t * | connection | ) |
Check if a connection is a client connection.
| [in] | connection | The connection to check |
| bool ct_connection_is_closed | ( | const ct_connection_t * | connection | ) |
Check if a connection's state is CT_CONN_STATE_CLOSED.
| [in] | connection | The connection to check |
| bool ct_connection_is_closed_or_closing | ( | const ct_connection_t * | connection | ) |
Check if a connection's state is CT_CONN_STATE_CLOSED or CT_CONN_STATE_CLOSING.
| [in] | connection | The connection to check |
| bool ct_connection_is_closing | ( | const ct_connection_t * | connection | ) |
Check if a connection's state is CT_CONN_STATE_CLOSING.
| [in] | connection | The connection to check |
| bool ct_connection_is_established | ( | const ct_connection_t * | connection | ) |
Check if a connection's state is CT_CONN_STATE_ESTABLISHED.
| [in] | connection | The connection to check |
| bool ct_connection_is_establishing | ( | const ct_connection_t * | connection | ) |
Check if a connection's state is CT_CONN_STATE_ESTABLISHING.
| [in] | connection | The connection to check |
| bool ct_connection_is_server | ( | const ct_connection_t * | connection | ) |
Check if a connection is a server connection.
| [in] | connection | The connection to check |
| bool ct_connection_sent_early_data | ( | const ct_connection_t * | connection | ) |
Check if a connection has sent early data (e.g., 0-RTT).
| [in] | connection | The connection to check |
| int ct_connection_set_priority | ( | ct_connection_t * | connection, |
| uint8_t | priority | ||
| ) |
Set relative priority for a connection compared to other connections in the same group.
| int ct_receive_message | ( | ct_connection_t * | connection, |
| const ct_receive_callbacks_t * | receive_callbacks | ||
| ) |
Register callbacks to receive messages on a connection.
CTaps does not take ownership of the passed receive_callbacks pointer, so it can be safely freed after return.
| [in] | connection | The connection to receive on |
| [in] | receive_callbacks | Callbacks for receive events |
| int ct_send_message | ( | ct_connection_t * | connection, |
| const ct_message_t * | message | ||
| ) |
Send a message over a connection with default properties.
Takes a deep copy of the sent message, application can free or reuse the original message after this function returns.
| [in] | connection | The connection to send on |
| [in] | message | The message to send |
| int ct_send_message_full | ( | ct_connection_t * | connection, |
| const ct_message_t * | message, | ||
| const ct_message_context_t * | message_context | ||
| ) |
Send a message with custom message context and properties.
Takes a deep copy of the sent message, application can free or reuse the original message after this function returns.
| [in] | connection | The connection to send on |
| [in] | message | The message to send |
| [in] | message_context | Message properties and context |