Go to the documentation of this file.
37 #ifdef HE_ENABLE_MULTITHREADED
38 #include <stdatomic.h>
48 #ifndef WOLFSSL_USER_SETTINGS
49 #include <wolfssl/options.h>
51 #include <wolfssl/ssl.h>
52 #include <wolfssl/wolfcrypt/settings.h>
53 #include <wolfssl/wolfcrypt/random.h>
55 #ifdef HE_ENABLE_MULTITHREADED
56 # define HE_ATOMIC _Atomic
63 #ifndef HE_THREAD_LOCAL
64 # if __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
65 # define HE_THREAD_LOCAL _Thread_local
67 # define HE_THREAD_LOCAL __declspec(thread)
68 # elif defined __APPLE__
69 # define HE_THREAD_LOCAL __thread
71 # error "Cannot define HE_THREAD_LOCAL"
88 uint8_t major_version;
89 uint8_t minor_version;
103 char const *server_cert;
105 char const *server_key;
163 uint16_t probing_size;
164 bool is_using_big_step;
165 uint16_t probe_pending_id;
193 uint16_t auth_buffer_length;
269 HE_ATOMIC uint64_t pending_session_id;
277 bool renegotiation_in_progress;
278 bool renegotiation_due;
291 #ifndef HE_ENABLE_MULTITHREADED
365 uint8_t username_length;
366 uint8_t password_length;
373 uint16_t token_length;
379 uint16_t buffer_length;
385 uint16_t buffer_length;
403 #define HE_FRAG_MF_MASK 0x2000
404 #define HE_FRAG_OFF_MASK 0x1FFF
405 #define HE_FRAG_TTL 64
420 #define HE_AUTH_STATUS_SUCCESS 0
421 #define HE_AUTH_STATUS_FAILURE 1
426 uint8_t status_msg_length;
443 #define HE_EXT_TYPE_REQUEST 1
444 #define HE_EXT_TYPE_RESPONSE 2
446 #define HE_EXT_ID_BLOCK_DNS_OVER_TLS 1
448 #define HE_EXT_PAYLOAD_TYPE_MSGPACK 1
449 #define HE_EXT_PAYLOAD_TYPE_BINARY 2
450 #define HE_EXT_PAYLOAD_TYPE_INT16 3
454 uint16_t extension_id;
456 uint8_t payload_type;
457 uint16_t payload_length;
462 #define HE_WOLF_MAX_HEADER_SIZE 37
463 #define HE_IPV4_HEADER_SIZE 20
464 #define HE_TCP_HEADER_SIZE 20
465 #define HE_UDP_HEADER_SIZE 8
468 #define HE_HEADER_SAFE_GAP 28
470 HE_IPV4_HEADER_SIZE + HE_UDP_HEADER_SIZE +
471 HE_WOLF_MAX_HEADER_SIZE + HE_HEADER_SAFE_GAP;
473 #define HE_MSS_OVERHEAD (HE_IPV4_HEADER_SIZE + HE_TCP_HEADER_SIZE)
Definition: he_internal.h:340
@ HE_MSGID_AUTH_RESPONSE
Auth response.
Definition: he_internal.h:317
Definition: he_internal.h:75
uint16_t length
Length of the payload.
Definition: he_internal.h:345
he_network_config_ipv4_cb_t network_config_ipv4_cb
Network config callback.
Definition: he_internal.h:115
enum he_pmtud_state he_pmtud_state_t
Lightway Path MTU Discovery states.
Definition: he_internal.h:86
Definition: he_internal.h:389
he_return_code_t(* he_inside_write_cb_t)(he_conn_t *conn, uint8_t *packet, size_t length, void *context)
The prototype for the inside write callback function.
Definition: he.h:372
@ HE_MSGID_EXTENSION
Helium Extension message.
Definition: he_internal.h:321
Definition: he_internal.h:423
bool is_server
Definition: he_internal.h:176
he_return_code_t(* he_populate_network_config_ipv4_cb_t)(he_conn_t *conn, he_network_config_ipv4_t *config, void *context)
The prototype for the population of the network config.
Definition: he.h:507
char sni_hostname[HE_MAX_HOSTNAME_LENGTH+1]
SNI Hostname.
Definition: he_internal.h:189
he_padding_type_t padding_type
Which padding type to use.
Definition: he_internal.h:204
bool use_pqc
Use PQC Keyshares.
Definition: he_internal.h:138
he_return_code_t(* he_state_change_cb_t)(he_conn_t *conn, he_conn_state_t new_state, void *context)
The prototype for the state callback function.
Definition: he.h:358
he_version_info_t protocol_version
Connection version – set on client side, accepted on server side.
Definition: he_internal.h:237
@ HE_MSGID_DEPRECATED_13
Deprecated message - same as Data packet with an unused int flag.
Definition: he_internal.h:329
The internal plugin API definitions.
he_return_code_t(* he_nudge_time_cb_t)(he_conn_t *conn, int timeout, void *context)
The prototype for the nudge time callback function.
Definition: he.h:449
HE_ATOMIC uint16_t frag_next_id
UDP Fragmentation.
Definition: he_internal.h:288
he_pmtud_state_t state
Path MTU Discovery state.
Definition: he_internal.h:155
@ HE_MSGID_SESSION_REQUEST
Session Request.
Definition: he_internal.h:323
he_inside_write_cb_t inside_write_cb
Callback for writing to the inside (i.e. a TUN device)
Definition: he_internal.h:111
enum he_conn_state he_conn_state_t
Status codes for a Helium connection.
HE_ATOMIC bool first_message_received
Has the first message been received?
Definition: he_internal.h:272
@ HE_MSGID_AUTH_RESPONSE_WITH_CONFIG
Auth response with config (fast login)
Definition: he_internal.h:319
@ HE_MSGID_NOOP
NOOP - nothing to do.
Definition: he_internal.h:305
Definition: he_internal.h:398
char password[HE_CONFIG_TEXT_FIELD_LENGTH+1]
VPN password – room for a null on the end.
Definition: he_internal.h:186
bool disable_roaming_connections
Don't send session ID in packet header.
Definition: he_internal.h:202
uint16_t id
Identifier for matching the reply message.
Definition: he_internal.h:343
uint8_t * incoming_data
Pointer to incoming data buffer.
Definition: he_internal.h:254
Definition: he_internal.h:383
@ HE_MSGID_SERVER_CONFIG
Server configuration data pushed to the client by the server.
Definition: he_internal.h:331
bool use_aggressive_mode
Use aggressive mode.
Definition: he_internal.h:206
enum he_padding_type he_padding_type_t
Helium supports numerous padding levels, from none to full. This enum defines which options can be ch...
Definition: he_internal.h:358
@ HE_MSGID_DATA
Data packet - contains data to be sent to the tun device.
Definition: he_internal.h:313
he_return_code_t(* he_server_config_cb_t)(he_conn_t *conn, uint8_t *buffer, size_t length, void *context)
The prototype for the server config callback function.
Definition: he.h:415
@ HE_MSGID_DATA_WITH_FRAG
Fragmented Data Packet.
Definition: he_internal.h:333
he_outside_write_cb_t outside_write_cb
Callback for writing to the outside (i.e. a socket)
Definition: he_internal.h:219
he_return_code_t(* he_pmtud_time_cb_t)(he_conn_t *conn, int timeout, void *context)
The prototype for the Path MTU Discovery (PMTUD) time callback function.
Definition: he.h:528
he_server_config_cb_t server_config_cb
Server config callback.
Definition: he_internal.h:223
Data structure of a helium plugin.
Definition: he_plugin.h:76
@ HE_MSGID_GOODBYE
Tell the other side that we're closing down.
Definition: he_internal.h:327
he_state_change_cb_t state_change_cb
State callback.
Definition: he_internal.h:109
@ HE_MSGID_AUTH
Authentication Request (only server should see this)
Definition: he_internal.h:311
he_outside_write_cb_t outside_write_cb
Callback for writing to the outside (i.e. a socket)
Definition: he_internal.h:113
@ HE_MSGID_PONG
Pong - response to a Ping request.
Definition: he_internal.h:309
uint16_t base
PMTUD internal data.
Definition: he_internal.h:161
he_version_info_t minimum_supported_version
Supported versions for this context.
Definition: he_internal.h:146
Definition: he_internal.h:377
bool(* he_auth_buf_cb_t)(he_conn_t *conn, uint8_t auth_type, uint8_t *buffer, uint16_t length, void *context)
The prototype for the authentication buffer callback.
Definition: he.h:493
size_t incoming_data_length
Length of the data in the.
Definition: he_internal.h:256
he_inside_write_cb_t inside_write_cb
Callback for writing to the inside (i.e. a TUN device)
Definition: he_internal.h:217
uint8_t auth_buffer[HE_MAX_MTU]
Authentication data for either HE_AUTH_TYPE_TOKEN or HE_AUTH_TYPE_CB.
Definition: he_internal.h:192
uint8_t * incoming_data_read_offset_ptr
Index into the incoming data buffer.
Definition: he_internal.h:262
#define HE_MAX_IPV4_STRING_LENGTH
Maximum size of an IPV4 String.
Definition: he.h:61
Definition: he_internal.h:371
uint16_t outside_mtu
MTU Helium should use for the outside connection (i.e. Internet)
Definition: he_internal.h:196
HE_ATOMIC he_conn_state_t state
Client State.
Definition: he_internal.h:248
WOLFSSL * wolf_ssl
WolfSSL stuff.
Definition: he_internal.h:243
size_t max_frag_entries
Maximum Fragment Entries.
Definition: he_internal.h:150
bool(* he_auth_cb_t)(he_conn_t *conn, char const *username, char const *password, void *context)
The prototype for the authentication callback.
Definition: he.h:463
he_state_change_cb_t state_change_cb
State callback.
Definition: he_internal.h:213
#define HE_MAX_HOSTNAME_LENGTH
Maximum size of a hostname.
Definition: he.h:63
he_connection_type_t connection_type
TCP or UDP?
Definition: he_internal.h:210
Definition: he_internal.h:363
bool use_pqc
Use PQC Keyshares.
Definition: he_internal.h:208
he_padding_type_t padding_type
Which padding type to use.
Definition: he_internal.h:134
WOLFSSL_CTX * wolf_ctx
WolfSSL global context.
Definition: he_internal.h:141
Definition: he_internal.h:430
he_nudge_time_cb_t nudge_time_cb
Nudge timer.
Definition: he_internal.h:119
bool use_aggressive_mode
Use aggressive mode.
Definition: he_internal.h:136
RNG wolf_rng
Random number generator.
Definition: he_internal.h:240
he_nudge_time_cb_t nudge_time_cb
Nudge timer.
Definition: he_internal.h:215
Core public header file for libhelium.
msg_ids
Definition: he_internal.h:303
enum he_connection_type he_connection_type_t
Helium can operate in datagram or stream modes. This enum defines these two modes.
bool disable_roaming_connections
Don't send session ID in packet header.
Definition: he_internal.h:132
bool(* he_auth_token_cb_t)(he_conn_t *conn, const uint8_t *token, size_t len, void *context)
The prototype for the authentication token callback.
Definition: he.h:478
The wire header format It is strongly discouraged to interact with this header structure,...
Definition: he.h:564
@ HE_MSGID_SESSION_RESPONSE
Session Response.
Definition: he_internal.h:325
Definition: he_internal.h:92
HE_ATOMIC uint64_t session_id
Session ID.
Definition: he_internal.h:268
he_return_code_t(* he_pmtud_state_change_cb_t)(he_conn_t *conn, he_pmtud_state_t state, void *context)
The prototype for Lightway PMTUD state callback function.
Definition: he.h:546
Definition: he_internal.h:297
HE_ATOMIC bool is_nudge_timer_running
Do we already have a timer running? If so, we don't want to generate new callbacks.
Definition: he_internal.h:275
bool use_chacha
Whether or not to use the CHACHA20 cipher.
Definition: he_internal.h:96
@ HE_MSGID_CONFIG_IPV4
Config.
Definition: he_internal.h:315
uint16_t id
Identifier of the matching ping message.
Definition: he_internal.h:353
Definition: he_internal.h:336
Definition: he_internal.h:439
he_return_code_t(* he_outside_write_cb_t)(he_conn_t *conn, uint8_t *packet, size_t length, void *context)
The prototype for the outside write callback function.
Definition: he.h:386
uint16_t ping_next_id
Identifier of the next ping message.
Definition: he_internal.h:281
size_t incoming_data_left_to_read
Bytes left to read in the packet buffer (Streaming only)
Definition: he_internal.h:260
Definition: he_internal.h:434
char server_dn[HE_CONFIG_TEXT_FIELD_LENGTH+1]
Server Distinguished Name – room for a null on the end.
Definition: he_internal.h:94
char username[HE_CONFIG_TEXT_FIELD_LENGTH+1]
VPN username – room for a null on the end.
Definition: he_internal.h:184
bool packet_seen
Packet seen.
Definition: he_internal.h:258
uint8_t write_buffer[HE_MAX_WIRE_MTU]
Write buffer.
Definition: he_internal.h:265
HE_ATOMIC uint16_t effective_pmtu
Current effective PMTU.
Definition: he_internal.h:158
uint16_t ping_pending_id
Identifier of the ping message pending reply.
Definition: he_internal.h:283
Definition: he_internal.h:153
Definition: he_internal.h:452
he_return_code_t(* he_event_cb_t)(he_conn_t *conn, he_conn_event_t event, void *context)
The prototype for the event callback function.
Definition: he.h:427
he_return_code_t(* he_network_config_ipv4_cb_t)(he_conn_t *conn, he_network_config_ipv4_t *config, void *context)
The prototype for the network config callback function.
Definition: he.h:399
int wolf_error
Last wolfssl error.
Definition: he_internal.h:293
HE_ATOMIC int wolf_timeout
Wolf Timeout.
Definition: he_internal.h:251
uint16_t reserved
Reserved for backward-compatibility.
Definition: he_internal.h:355
Definition: he_internal.h:170
@ HE_MSGID_PING
Ping request.
Definition: he_internal.h:307
he_server_config_cb_t server_config_cb
Server config callback.
Definition: he_internal.h:117
Definition: he_internal.h:350
size_t cert_buffer_size
The size of the Client CA certificate chain.
Definition: he_internal.h:100
uint8_t payload[]
Payload.
Definition: he_internal.h:347
he_network_config_ipv4_cb_t network_config_ipv4_cb
Network config callback.
Definition: he_internal.h:221
#define HE_MAX_WIRE_MTU
Default MTU sizes.
Definition: he.h:41
Path MTU Discovery functions.
Definition: he_internal.h:414
#define HE_CONFIG_TEXT_FIELD_LENGTH
Helpful deprecation macro.
Definition: he.h:59
Definition: he_internal.h:407