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

Local endpoint creation and configuration. More...

Data Structures

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

Functions

ct_local_endpoint_tct_local_endpoint_new (void)
 Create a new heap-allocated local endpoint.
 
int ct_local_endpoint_with_interface (ct_local_endpoint_t *local_endpoint, const char *interface_name)
 Set the network interface for a local endpoint.
 
void ct_local_endpoint_with_port (ct_local_endpoint_t *local_endpoint, uint16_t port)
 Set the port number for a local endpoint.
 
int ct_local_endpoint_with_service (ct_local_endpoint_t *local_endpoint, const char *service)
 Set the service name for a local endpoint.
 
int ct_local_endpoint_with_ipv4 (ct_local_endpoint_t *local_endpoint, in_addr_t ipv4_addr)
 Set the IPv4 address for a local endpoint.
 
int ct_local_endpoint_with_ipv6 (ct_local_endpoint_t *local_endpoint, struct in6_addr ipv6_addr)
 Set the IPv6 address for a local endpoint.
 
int ct_local_endpoint_from_sockaddr (ct_local_endpoint_t *local_endpoint, const struct sockaddr_storage *addr)
 Initialize a local endpoint from a sockaddr structure.
 
void ct_local_endpoint_free (ct_local_endpoint_t *local_endpoint)
 Free all resources in a local endpoint including the structure itself.
 
ct_local_endpoint_tct_local_endpoint_deep_copy (const ct_local_endpoint_t *local_endpoint)
 Create a heap-allocated copy of a local endpoint.
 
const char * ct_local_endpoint_get_service (const ct_local_endpoint_t *local_endpoint)
 Get the service for a local endpoint.
 
uint16_t ct_local_endpoint_get_resolved_port (const ct_local_endpoint_t *local_endpoint)
 Get the resolved port for a local endpoint after binding.
 

Detailed Description

Local endpoint creation and configuration.

Function Documentation

◆ ct_local_endpoint_deep_copy()

ct_local_endpoint_t * ct_local_endpoint_deep_copy ( const ct_local_endpoint_t local_endpoint)

Create a heap-allocated copy of a local endpoint.

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

◆ ct_local_endpoint_free()

void ct_local_endpoint_free ( ct_local_endpoint_t local_endpoint)

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

Parameters
[in]local_endpointEndpoint to free

◆ ct_local_endpoint_from_sockaddr()

int ct_local_endpoint_from_sockaddr ( ct_local_endpoint_t local_endpoint,
const struct sockaddr_storage *  addr 
)

Initialize a local endpoint from a sockaddr structure.

CTaps does not take ownership of the passed addr pointer, so it can be safely freed after return.

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

◆ ct_local_endpoint_get_resolved_port()

uint16_t ct_local_endpoint_get_resolved_port ( const ct_local_endpoint_t local_endpoint)

Get the resolved port for a local endpoint after binding.

Returns
Port number assigned to the local endpoint in host order

◆ ct_local_endpoint_get_service()

const char * ct_local_endpoint_get_service ( const ct_local_endpoint_t local_endpoint)

Get the service for a local endpoint.

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

◆ ct_local_endpoint_new()

ct_local_endpoint_t * ct_local_endpoint_new ( void  )

Create a new heap-allocated local endpoint.

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

Returns
Pointer to newly allocated endpoint, or NULL on error

◆ ct_local_endpoint_with_interface()

int ct_local_endpoint_with_interface ( ct_local_endpoint_t local_endpoint,
const char *  interface_name 
)

Set the network interface for a local endpoint.

Parameters
[in,out]local_endpointEndpoint to modify
[in]interface_nameInterface name (e.g., "eth0", "wlan0")
Returns
0 on success, negative error code on failure

◆ ct_local_endpoint_with_ipv4()

int ct_local_endpoint_with_ipv4 ( ct_local_endpoint_t local_endpoint,
in_addr_t  ipv4_addr 
)

Set the IPv4 address for a local endpoint.

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

◆ ct_local_endpoint_with_ipv6()

int ct_local_endpoint_with_ipv6 ( ct_local_endpoint_t local_endpoint,
struct in6_addr  ipv6_addr 
)

Set the IPv6 address for a local endpoint.

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

◆ ct_local_endpoint_with_port()

void ct_local_endpoint_with_port ( ct_local_endpoint_t local_endpoint,
uint16_t  port 
)

Set the port number for a local endpoint.

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

◆ ct_local_endpoint_with_service()

int ct_local_endpoint_with_service ( ct_local_endpoint_t local_endpoint,
const char *  service 
)

Set the service name for a local endpoint.

Takes a deep copy of the provided string.

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