ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
establish.c File Reference

Go to the source code of this file.

Functions

asciichat_error_t network_connection_establish (const network_establish_config_t *config, network_connection_t **owner, network_establish_result_t *attempt)

Function Documentation

◆ network_connection_establish()

asciichat_error_t network_connection_establish ( const network_establish_config_t * config,
network_connection_t ** owner,
network_establish_result_t * attempt )

Definition at line 4 of file lib/network/establish.c.

6 {
7 if (!config || !owner || *owner || !attempt || !config->prepare ||
10 "Invalid connection establishment parameters");
11 *attempt = (network_establish_result_t){0};
13 config->name, config->address, config->default_port, config->connect,
14 owner, &attempt->endpoint);
15 if (result != ASCIICHAT_OK)
16 return result;
17 result = config->prepare(*owner, &attempt->endpoint, config->password,
18 config->context);
19 if (result != ASCIICHAT_OK)
20 return result;
22 handshake->defer_password_prompt = true;
24 if (config->authenticate)
25 mode |= ACIP_CRYPTO_AUTH;
27 handshake, mode, config->protocol);
28 attempt->password_failure = handshake->password_failure;
29 if (result == ASCIICHAT_OK)
31 return result;
32}
#define SET_ERRNO(code,...)
unsigned char uint8_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_INVALID_PARAM
#define ACIP_CRYPTO_AUTH
Authentication only (no payload encryption).
Definition packet.h:1163
asciichat_error_t network_connection_open(const char *name, const char *address, uint16_t port, const network_connect_config_t *settings, network_connection_t **out, connection_endpoint_t *resolved)
void network_connection_ready(network_connection_t *c)
crypto_handshake_context_t * network_connection_handshake(network_connection_t *c)
acip_transport_t * network_connection_transport(network_connection_t *c)
uint8_t network_connection_crypto_mode(network_connection_t *c)
asciichat_error_t network_client_negotiate(acip_transport_t *transport, crypto_handshake_context_t *ctx, uint8_t mode, network_protocol_t protocol)
@ NETWORK_PROTOCOL_DISCOVERY
Definition negotiation.h:11
Cryptographic handshake context structure.
network_protocol_t protocol
Definition establish.h:18
network_connection_prepare_fn prepare
Definition establish.h:20
const network_connect_config_t * connect
Definition establish.h:16
This is the handoff point for network establish config. Callers fill name, address,...
Definition establish.h:32
connection_endpoint_t endpoint
Definition establish.h:33

References ACIP_CRYPTO_AUTH, network_establish_config_t::address, ASCIICHAT_OK, network_establish_config_t::authenticate, network_establish_config_t::connect, network_establish_config_t::context, network_establish_config_t::default_port, crypto_handshake_context_t::defer_password_prompt, network_establish_result_t::endpoint, ERROR_INVALID_PARAM, network_establish_config_t::name, network_client_negotiate(), network_connection_crypto_mode(), network_connection_handshake(), network_connection_open(), network_connection_ready(), network_connection_transport(), NETWORK_PROTOCOL_DISCOVERY, network_establish_config_t::password, crypto_handshake_context_t::password_failure, network_establish_result_t::password_failure, network_establish_config_t::prepare, network_establish_config_t::protocol, and SET_ERRNO.

Referenced by session_connection_establish().