Helium
|
Core public header file for libhelium. More...
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "he_plugin.h"
Go to the source code of this file.
Data Structures | |
struct | he_client |
Data structure to hold all the state needed as a Helium client. More... | |
struct | he_network_config_ipv4 |
struct | he_wire_hdr |
The wire header format It is strongly discouraged to interact with this header structure, however, it is provided for specific use cases (such as a server rejecting a session, where by definition we don't have a connection object). More... | |
Macros | |
#define | HE_MAX_WIRE_MTU 1500 |
Default MTU sizes. | |
#define | HE_MAX_MTU 1350 |
#define | HE_MAX_MTU_STR "1350" |
#define | HE_WIRE_MINIMUM_PROTOCOL_MAJOR_VERSION 1 |
Default minimum and maximum wire protocol versions. | |
#define | HE_WIRE_MINIMUM_PROTOCOL_MINOR_VERSION 0 |
#define | HE_WIRE_MAXIMUM_PROTOCOL_MAJOR_VERSION 1 |
#define | HE_WIRE_MAXIMUM_PROTOCOL_MINOR_VERSION 2 |
#define | HE_CONFIG_TEXT_FIELD_LENGTH 50 |
Helpful deprecation macro. More... | |
#define | HE_MAX_IPV4_STRING_LENGTH 24 |
Maximum size of an IPV4 String. | |
#define | HE_MAX_HOSTNAME_LENGTH 255 |
Maximum size of a hostname. | |
Typedefs | |
typedef enum he_return_code | he_return_code_t |
All possible return codes for helium. | |
typedef enum he_conn_state | he_conn_state_t |
Status codes for a Helium connection. | |
typedef enum he_conn_event | he_conn_event_t |
typedef enum he_padding_type | he_padding_type_t |
Helium supports numerous padding levels, from none to full. This enum defines which options can be chosen. | |
typedef enum he_connection_type | he_connection_type_t |
Helium can operate in datagram or stream modes. This enum defines these two modes. | |
typedef enum he_connection_protocol | he_connection_protocol_t |
Lightway can use different underlying protocols. This enum defines those protocols. | |
typedef enum he_pmtud_state | he_pmtud_state_t |
Lightway Path MTU Discovery states. More... | |
typedef struct he_ssl_ctx | he_ssl_ctx_t |
typedef struct he_conn | he_conn_t |
typedef struct he_plugin_chain | he_plugin_chain_t |
typedef struct he_network_config_ipv4 | he_network_config_ipv4_t |
typedef struct he_client | he_client_t |
Data structure to hold all the state needed as a Helium client. | |
typedef void *(* | he_malloc_t) (size_t size) |
typedef void *(* | he_calloc_t) (size_t nmemb, size_t size) |
typedef void *(* | he_realloc_t) (void *ptr, size_t size) |
typedef void(* | he_free_t) (void *ptr) |
typedef enum he_auth_type | he_auth_type_t |
Lightway can use different authentication types. This enum defines those types. | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef bool(* | he_auth_cb_t) (he_conn_t *conn, char const *username, char const *password, void *context) |
The prototype for the authentication callback. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef struct he_wire_hdr | he_wire_hdr_t |
The wire header format It is strongly discouraged to interact with this header structure, however, it is provided for specific use cases (such as a server rejecting a session, where by definition we don't have a connection object). | |
Core public header file for libhelium.
Lightway Core Copyright (C) 2021 Express VPN International Ltd.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
This file includes common type definitions and useful constants for ensuring consistency across the code files for libhelium. It should be included by every header file.
#define HE_CONFIG_TEXT_FIELD_LENGTH 50 |
Helpful deprecation macro.
Maximum size of a text based config option.
typedef 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.
conn | A pointer to the connection that triggered this callback |
auth_type | the authentication type |
buffer | An opaque buffer object |
length | The length of the buffer parameter |
context | A pointer to the user defined context |
The host is expected to interpret this buffer and return whether it considers this connection authenticated.
typedef bool(* he_auth_cb_t) (he_conn_t *conn, char const *username, char const *password, void *context) |
The prototype for the authentication callback.
conn | A pointer to the connection that triggered this callback |
username | A pointer to the username |
password | A pointer to the password |
context | A pointer to the user defined context |
The host is expected to return whether this username and password is valid for the connection. Note that username and password are not guaranteed to be null terminated, but will be less than or equal in length to HE_CONFIG_TEXT_FIELD_LENGTH.
typedef 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.
conn | A pointer to the connection that triggered this callback |
token | A pointer to buffer containing the auth token |
len | Length of the token in bytes |
context | A pointer to the user defined context |
The host is expected to return whether this auth token is valid for the connection. Note that the token is not guaranteed to be null terminated, but will be less than in length to HE_MAX_MTU.
typedef 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.
conn | A pointer to the connection that triggered this callback |
event | The event to trigger |
context | A pointer to the user defined context |
Whenever Helium generates an event, this function will be called.
typedef 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.
conn | A pointer to the connection that triggered this callback |
packet | A pointer to the packet data |
length | The length of the entire packet in bytes |
context | A pointer to the user defined context |
Whenever Helium needs to do an inside write this function will be called. On Linux this would usually be writing decrypted packets to a tun device.
typedef 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.
conn | A pointer to the connection that triggered this callback |
config | The network config data such as local IP, peer IP, DNS IP and MTU |
context | A pointer to the user defined context |
When network configuration data is sent to Helium from the server, this callback will be triggered to allow to host application to configure its network accordingly.
typedef 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.
conn | A pointer to the connection that triggered this callback |
timeout | The number of milliseconds to wait before nudging Helium |
context | A pointer to the user defined context |
Helium uses D/TLS which needs to be able to resend certain messages if they are not received in time. As Helium does not have its own threads or timers, it is up to the host application to tell Helium when a certain amount of time has passed. Because D/TLS implements exponential back off, the amount of waiting time can change after every read.
To avoid the host application having to remember to ask Helium after every read with he_conn_get_nudge_time(), the host application can register this callback instead.
typedef 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.
conn | A pointer to the connection that triggered this callback |
packet | A pointer to the packet data |
length | The length of the entire packet in bytes |
context | A pointer to the user defined context |
Whenever Helium needs to do an outside write this function will be called. On Linux this would usually be writing to a UDP socket to send encrypted data over the Internet.
typedef 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.
conn | A pointer to the connection that triggered this callback |
state | The state that Lightway PMTUD has just entered |
context | A pointer to the user defined context |
Whenever Lightway PMTUD changes state, this function will be called. This callback is mostly for informational only, there's no hard expectation for the callback to do anything. However, this callback may be useful for certain application logic which is triggered by the state changes.
The host application must register this callback to enable Path MTU discovery.
typedef enum he_pmtud_state he_pmtud_state_t |
Lightway Path MTU Discovery states.
typedef 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.
conn | A pointer to the connection that triggered this callback |
timeout | The number of milliseconds to wait before calling the he_conn_pmtud_probe_timeout function. If the timeout value is 0, the host application should cancel the timer. |
context | A pointer to the user defined context |
Lightway Path MTU Discovery needs to be able to resend probe messages if they are not received in time. As Lightway Core does not have its own threads or timers, it is up to the host application to tell Lightway Core when a certain amount of time has passed.
The host application must register this callback to enable Path MTU discovery.
typedef 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.
conn | A pointer to the connection that triggered this callback | |
[out] | config | A valid pointer to a network_config_ipv4_t, to be populated by the host |
context | A pointer to the user defined context |
The host is expected to populate the provided he_network_config_ipv4_t* object with the correct values so that the client can successfully connect.
typedef 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.
conn | A pointer to the connection that triggered this callback |
buffer | A pointer to the buffer containing the server configuration data |
length | The length of the buffer in bytes |
context | A pointer to the user defined context |
Whenever the client receives the server configuration data (pushed by the Helium server), this callback will be triggered. The host application is responsible for parsing the data using implementation specific format.
typedef 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.
conn | A pointer to the connection that triggered this callback |
new_state | The state that the context has just entered |
context | A pointer to the user defined context |
Whenever Helium changes state, this function will be called.
enum he_auth_type |
enum he_conn_event |
enum he_conn_state |
Status codes for a Helium connection.
enum he_connection_type |
enum he_padding_type |
Helium supports numerous padding levels, from none to full. This enum defines which options can be chosen.
enum he_pmtud_state |
Lightway Path MTU Discovery states.
enum he_return_code |
All possible return codes for helium.