Helium
conn.h
Go to the documentation of this file.
1 
26 #ifndef CONN_H
27 #define CONN_H
28 
29 #include "he_internal.h"
30 
48 #define HE_WOLF_TIMEOUT_MULTIPLIER 100
49 #define HE_WOLF_RENEGOTIATION_TIMEOUT_MULTIPLIER 100
50 
56 #define HE_WOLF_QUICK_TIMEOUT_DIVIDER 4
57 
67 
76 void he_conn_destroy(he_conn_t *conn);
77 
94 
109 
118 int he_conn_set_username(he_conn_t *conn, const char *username);
119 
126 const char *he_conn_get_username(const he_conn_t *conn);
127 
136 bool he_conn_is_username_set(const he_conn_t *conn);
137 
147 he_return_code_t he_conn_set_password(he_conn_t *conn, const char *password);
148 
157 bool he_conn_is_password_set(const he_conn_t *conn);
158 
172 he_return_code_t he_conn_set_auth_token(he_conn_t *conn, const uint8_t *token, size_t len);
173 
182 bool he_conn_is_auth_token_set(const he_conn_t *conn);
183 
193 he_return_code_t he_conn_set_auth_buffer2(he_conn_t *conn, const uint8_t *buffer, uint16_t length);
194 
203 bool he_conn_is_auth_buffer_set(const he_conn_t *conn);
204 
216 
222 uint16_t he_conn_get_outside_mtu(he_conn_t *conn);
223 
233 
244 
250 void *he_conn_get_context(he_conn_t *conn);
251 
260 he_return_code_t he_conn_set_sni_hostname(he_conn_t *conn, const char *hostname);
261 
287  he_plugin_chain_t *inside_plugins,
288  he_plugin_chain_t *outside_plugins);
289 
312  he_plugin_chain_t *inside_plugins,
313  he_plugin_chain_t *outside_plugins);
314 
328 
340 
349 he_return_code_t he_conn_send_server_config(he_conn_t *conn, uint8_t *buffer, size_t length);
350 
361 
371 
379 
388 
392 uint64_t he_conn_get_session_id(he_conn_t *conn);
393 
397 he_return_code_t he_conn_set_session_id(he_conn_t *conn, uint64_t session_id);
398 
407 
415 bool he_conn_is_error_fatal(he_conn_t *conn, he_return_code_t error_msg);
416 
436 he_return_code_t he_conn_rotate_session_id(he_conn_t *conn, uint64_t *new_session_id);
437 
444 
454 he_return_code_t he_conn_set_protocol_version(he_conn_t *conn, uint8_t major_version,
455  uint8_t minor_version);
456 
464 he_return_code_t he_conn_get_protocol_version(he_conn_t *conn, uint8_t *major_version,
465  uint8_t *minor_version);
466 
472 const char *he_conn_get_current_cipher(he_conn_t *conn);
473 
480 
486 const char *he_conn_get_curve_name(he_conn_t *conn);
487 
496 
503 uint16_t he_conn_get_effective_pmtu(he_conn_t *conn);
504 
511 
519 
520 
521 void he_conn_set_ssl_error(he_conn_t *conn, int error);
522 
523 #endif // CONN_H
he_conn_send_server_config
he_return_code_t he_conn_send_server_config(he_conn_t *conn, uint8_t *buffer, size_t length)
Tell Helium to send a server config message to client.
Definition: conn.c:550
he_conn_pmtud_probe_timeout
he_return_code_t he_conn_pmtud_probe_timeout(he_conn_t *conn)
Called when a PMTUD probe timer expired.
Definition: conn.c:1232
he_conn_get_curve_name
const char * he_conn_get_curve_name(he_conn_t *conn)
Returns the name of the curve used by the ssl context.
Definition: conn.c:1199
he_internal.h
Core internal header file for libhelium.
he_conn_get_current_cipher
const char * he_conn_get_current_cipher(he_conn_t *conn)
Returns the name of the cipher used by the ssl context.
Definition: conn.c:1169
he_conn_get_session_id
uint64_t he_conn_get_session_id(he_conn_t *conn)
Returns the session ID for this connection.
Definition: conn.c:1138
he_conn_get_ssl_error
int he_conn_get_ssl_error(he_conn_t *conn)
Returns detailed SSL error that corresponds to WolfSSL's detailed errors.
Definition: conn.c:1254
he_conn_set_outside_mtu
he_return_code_t he_conn_set_outside_mtu(he_conn_t *conn, uint16_t mtu)
Set the MTU for the outside transport mechanism. Usually this will be the MTU of the device's interne...
Definition: conn.c:1049
he_conn_get_outside_mtu
uint16_t he_conn_get_outside_mtu(he_conn_t *conn)
Get the MTU value for the outside transport mechanism.
Definition: conn.c:1065
he_conn_state_t
enum he_conn_state he_conn_state_t
Status codes for a Helium connection.
he_return_code_t
enum he_return_code he_return_code_t
All possible return codes for helium.
he_conn_create
he_conn_t * he_conn_create(void)
Creates a Helium connection struct.
Definition: conn.c:143
he_conn_send_keepalive
he_return_code_t he_conn_send_keepalive(he_conn_t *conn)
Tell Helium to send a keepalive message. This can be used to avoid NAT timing out.
Definition: conn.c:503
he_conn_is_error_fatal
bool he_conn_is_error_fatal(he_conn_t *conn, he_return_code_t error_msg)
Returns true if a given error (a return from libhelium where he_return_code_t != HE_SUCCESS) is obvio...
Definition: conn.c:35
he_conn_server_connect
he_return_code_t he_conn_server_connect(he_conn_t *conn, he_ssl_ctx_t *ssl_ctx, he_plugin_chain_t *inside_plugins, he_plugin_chain_t *outside_plugins)
Tries to establish a connection with a Helium client.
Definition: conn.c:343
he_conn_supports_renegotiation
bool he_conn_supports_renegotiation(he_conn_t *conn)
Whether this particular connection supports renegotiation.
Definition: conn.c:909
he_conn_is_username_set
bool he_conn_is_username_set(const he_conn_t *conn)
Check if the password has been set.
Definition: conn.c:964
he_conn_rotate_session_id
he_return_code_t he_conn_rotate_session_id(he_conn_t *conn, uint64_t *new_session_id)
Rotate the session ID for this connection.
Definition: conn.c:883
he_conn_get_context
void * he_conn_get_context(he_conn_t *conn)
Retrieve the pointer to the user supplied context.
Definition: conn.c:1129
he_conn_set_username
int he_conn_set_username(he_conn_t *conn, const char *username)
Set the username to authenticate with.
Definition: conn.c:945
he_conn_is_valid_server
he_return_code_t he_conn_is_valid_server(he_ssl_ctx_t *ssl_ctx, he_conn_t *conn)
Checks whether the client conn has the basic values to allow Helium to connect.
Definition: conn.c:115
he_conn_get_nudge_time
int he_conn_get_nudge_time(he_conn_t *conn)
Returns the number of milliseconds that host application should wait before nudging Helium.
Definition: conn.c:795
he_conn_set_sni_hostname
he_return_code_t he_conn_set_sni_hostname(he_conn_t *conn, const char *hostname)
Set SNI hostname.
Definition: conn.c:133
he_conn_get_state
he_conn_state_t he_conn_get_state(he_conn_t *conn)
Returns the state that the conn is currently in.
Definition: conn.c:847
he_conn_set_auth_token
he_return_code_t he_conn_set_auth_token(he_conn_t *conn, const uint8_t *token, size_t len)
Sets the authentication token the Lightway client should use to authenticate with.
Definition: conn.c:992
he_conn_client_connect
he_return_code_t he_conn_client_connect(he_conn_t *conn, he_ssl_ctx_t *ssl_ctx, he_plugin_chain_t *inside_plugins, he_plugin_chain_t *outside_plugins)
Tries to establish a connection with a Helium server.
Definition: conn.c:324
he_conn_set_password
he_return_code_t he_conn_set_password(he_conn_t *conn, const char *password)
Sets the password Helium should use to authenticate with.
Definition: conn.c:973
he_conn_start_pmtu_discovery
he_return_code_t he_conn_start_pmtu_discovery(he_conn_t *conn)
Tell Helium to start a PMTU discovery.
Definition: conn.c:1206
he_conn_set_auth_buffer2
he_return_code_t he_conn_set_auth_buffer2(he_conn_t *conn, const uint8_t *buffer, uint16_t length)
Sets the opaque buffer Helium should use to authenticate with.
Definition: conn.c:1020
he_conn_is_auth_buffer_set
bool he_conn_is_auth_buffer_set(const he_conn_t *conn)
Check if the auth buffer has been set.
Definition: conn.c:1040
he_ssl_ctx
Definition: he_internal.h:92
he_plugin_chain
Definition: he_internal.h:297
he_conn_is_auth_token_set
bool he_conn_is_auth_token_set(const he_conn_t *conn)
Check if the auth token has been set.
Definition: conn.c:1011
he_conn_is_outside_mtu_set
bool he_conn_is_outside_mtu_set(he_conn_t *conn)
Check if the outside MTU has been set.
Definition: conn.c:1074
he_conn_is_password_set
bool he_conn_is_password_set(const he_conn_t *conn)
Check if the password has been set.
Definition: conn.c:983
he_conn_set_context
he_return_code_t he_conn_set_context(he_conn_t *conn, void *data)
Store a pointer in the context that will be made available in all Helium callbacks.
Definition: conn.c:1118
he_conn_get_protocol_version
he_return_code_t he_conn_get_protocol_version(he_conn_t *conn, uint8_t *major_version, uint8_t *minor_version)
On the server, get the current major/minor version number for this connection.
Definition: conn.c:932
he_conn_destroy
void he_conn_destroy(he_conn_t *conn)
Releases all memory allocate by Helium for this connection.
Definition: conn.c:147
he_conn_set_protocol_version
he_return_code_t he_conn_set_protocol_version(he_conn_t *conn, uint8_t major_version, uint8_t minor_version)
On the server, sets the major/minor version number for this connection.
Definition: conn.c:921
he_conn_get_pending_session_id
uint64_t he_conn_get_pending_session_id(he_conn_t *conn)
Returns the pending session ID for this connection, if there is one.
Definition: conn.c:1147
he_conn_set_session_id
he_return_code_t he_conn_set_session_id(he_conn_t *conn, uint64_t session_id)
Sets the session ID for this connection.
Definition: conn.c:1156
he_conn_schedule_renegotiation
he_return_code_t he_conn_schedule_renegotiation(he_conn_t *conn)
Tell Helium to schedule a renegotiation.
Definition: conn.c:696
he_conn_is_valid_client
he_return_code_t he_conn_is_valid_client(he_ssl_ctx_t *ssl_ctx, he_conn_t *conn)
Checks whether the client conn has the basic values to allow Helium to connect.
Definition: conn.c:85
he_conn
Definition: he_internal.h:170
he_conn_get_current_protocol
he_connection_protocol_t he_conn_get_current_protocol(he_conn_t *conn)
Returns the current connection protocol.
Definition: conn.c:1180
he_connection_protocol_t
enum he_connection_protocol he_connection_protocol_t
Lightway can use different underlying protocols. This enum defines those protocols.
he_conn_disconnect
he_return_code_t he_conn_disconnect(he_conn_t *conn)
Try to cleanly disconnect from the remote Helium instance (client or server).
Definition: conn.c:378
he_conn_get_effective_pmtu
uint16_t he_conn_get_effective_pmtu(he_conn_t *conn)
Get current effective PMTU of the connection.
Definition: conn.c:1225
he_conn_get_username
const char * he_conn_get_username(const he_conn_t *conn)
Get the username that Helium will authenticate with, previously set by he_conn_set_username.
Definition: conn.c:955
he_conn_nudge
he_return_code_t he_conn_nudge(he_conn_t *conn)
Nudges Helium.
Definition: conn.c:807