CTaps 0.3.0
A C implementation of the Transport Services API (RFC 9621 - 9623)
Loading...
Searching...
No Matches
Endpoints

Remote endpoint creation and configuration. More...

Data Structures

struct  ct_remote_endpoint_t
 Opaque handle representing a remote endpoint (generic or resolved to specific ip address and port). More...
 

Functions

ct_remote_endpoint_tct_remote_endpoint_new (void)
 Create a new heap-allocated remote endpoint.
 
int ct_remote_endpoint_with_hostname (ct_remote_endpoint_t *remote_endpoint, const char *hostname)
 Set the hostname for a remote endpoint.
 
void ct_remote_endpoint_with_port (ct_remote_endpoint_t *remote_endpoint, uint16_t port)
 Set the port number for a remote endpoint.
 
int ct_remote_endpoint_with_service (ct_remote_endpoint_t *remote_endpoint, const char *service)
 Set the service name for a remote endpoint.
 
void ct_remote_endpoint_free (ct_remote_endpoint_t *remote_endpoint)
 Free all resources in a remote endpoint including the structure itself.
 
int ct_remote_endpoint_from_sockaddr (ct_remote_endpoint_t *remote_endpoint, const struct sockaddr_storage *addr)
 Initialize a remote endpoint from a sockaddr structure.
 
ct_remote_endpoint_tct_remote_endpoint_deep_copy (const ct_remote_endpoint_t *remote_endpoint)
 Create a heap-allocated copy of a remote endpoint.
 
int ct_remote_endpoint_with_ipv4 (ct_remote_endpoint_t *remote_endpoint, in_addr_t ipv4_addr)
 Set the IPv4 address for a remote endpoint.
 
int ct_remote_endpoint_with_ipv6 (ct_remote_endpoint_t *remote_endpoint, struct in6_addr ipv6_addr)
 Set the IPv6 address for a remote endpoint.
 
const char * ct_remote_endpoint_get_service (const ct_remote_endpoint_t *remote_endpoint)
 Get the service for a remote endpoint.
 

Detailed Description

Remote endpoint creation and configuration.

Function Documentation

◆ ct_remote_endpoint_deep_copy()

ct_remote_endpoint_t * ct_remote_endpoint_deep_copy ( const ct_remote_endpoint_t remote_endpoint)

Create a heap-allocated copy of a remote endpoint.

Parameters
[in]remote_endpointSource endpoint
Returns
Pointer to newly allocated copy, or NULL on error

◆ ct_remote_endpoint_free()

void ct_remote_endpoint_free ( ct_remote_endpoint_t remote_endpoint)

Free all resources in a remote endpoint including the structure itself.

Parameters
[in]remote_endpointEndpoint to free

◆ ct_remote_endpoint_from_sockaddr()

int ct_remote_endpoint_from_sockaddr ( ct_remote_endpoint_t remote_endpoint,
const struct sockaddr_storage *  addr 
)

Initialize a remote endpoint from a sockaddr structure.

Parameters
[out]remote_endpointEndpoint to initialize
[in]addrSocket address structure
Returns
0 on success, negative error code on failure

◆ ct_remote_endpoint_get_service()

const char * ct_remote_endpoint_get_service ( const ct_remote_endpoint_t remote_endpoint)

Get the service for a remote endpoint.

Parameters
[in]remote_endpointendpoint to get service for
Returns
char* pointer to service name, NULL if endpoint is null, or if service is not set

◆ ct_remote_endpoint_new()

ct_remote_endpoint_t * ct_remote_endpoint_new ( void  )

Create a new heap-allocated remote endpoint.

The caller owns the returned endpoint and must free it with ct_remote_endpoint_free() when done.

Returns
Pointer to newly allocated endpoint, or NULL on error

◆ ct_remote_endpoint_with_hostname()

int ct_remote_endpoint_with_hostname ( ct_remote_endpoint_t remote_endpoint,
const char *  hostname 
)

Set the hostname for a remote endpoint.

Parameters
[in,out]remote_endpointEndpoint to modify
[in]hostnameHostname or IP address string
Returns
0 on success, negative error code on failure

◆ ct_remote_endpoint_with_ipv4()

int ct_remote_endpoint_with_ipv4 ( ct_remote_endpoint_t remote_endpoint,
in_addr_t  ipv4_addr 
)

Set the IPv4 address for a remote endpoint.

Parameters
[in,out]remote_endpointEndpoint to modify
[in]ipv4_addrIPv4 address in network byte order
Returns
0 on success, negative error code on failure

◆ ct_remote_endpoint_with_ipv6()

int ct_remote_endpoint_with_ipv6 ( ct_remote_endpoint_t remote_endpoint,
struct in6_addr  ipv6_addr 
)

Set the IPv6 address for a remote endpoint.

Parameters
[in,out]remote_endpointEndpoint to modify
[in]ipv6_addrIPv6 address structure
Returns
0 on success, negative error code on failure

◆ ct_remote_endpoint_with_port()

void ct_remote_endpoint_with_port ( ct_remote_endpoint_t remote_endpoint,
uint16_t  port 
)

Set the port number for a remote endpoint.

Parameters
[in,out]remote_endpointEndpoint to modify
[in]portPort number

◆ ct_remote_endpoint_with_service()

int ct_remote_endpoint_with_service ( ct_remote_endpoint_t remote_endpoint,
const char *  service 
)

Set the service name for a remote endpoint.

Parameters
[in,out]remote_endpointEndpoint to modify
[in]serviceService name (e.g., "http", "https")
Returns
0 on success, negative error code on failure