mirror of
https://github.com/arampoire/onetun.git
synced 2026-01-16 12:20:23 -05:00
Move cbindgen.toml to ffi directory
This commit is contained in:
parent
c0bfdab175
commit
443d540025
2 changed files with 90 additions and 0 deletions
144
ffi/cbindgen.toml
Normal file
144
ffi/cbindgen.toml
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
language = "C"
|
||||
|
||||
|
||||
|
||||
############## Options for Wrapping the Contents of the Header #################
|
||||
|
||||
# header = "/* Text to put at the beginning of the generated file. Probably a license. */"
|
||||
# trailer = "/* Text to put at the end of the generated file */"
|
||||
# include_guard = "my_bindings_h"
|
||||
# pragma_once = true
|
||||
# autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */"
|
||||
include_version = false
|
||||
# namespace = "my_namespace"
|
||||
namespaces = []
|
||||
using_namespaces = []
|
||||
sys_includes = []
|
||||
includes = []
|
||||
no_includes = false
|
||||
after_includes = ""
|
||||
|
||||
|
||||
|
||||
|
||||
############################ Code Style Options ################################
|
||||
|
||||
braces = "SameLine"
|
||||
line_length = 100
|
||||
tab_width = 2
|
||||
documentation = true
|
||||
documentation_style = "auto"
|
||||
documentation_length = "full"
|
||||
line_endings = "LF" # also "CR", "CRLF", "Native"
|
||||
|
||||
|
||||
|
||||
|
||||
############################# Codegen Options ##################################
|
||||
|
||||
style = "both"
|
||||
sort_by = "Name" # default for `fn.sort_by` and `const.sort_by`
|
||||
usize_is_size_t = true
|
||||
|
||||
|
||||
|
||||
[defines]
|
||||
# "target_os = freebsd" = "DEFINE_FREEBSD"
|
||||
# "feature = serde" = "DEFINE_SERDE"
|
||||
|
||||
|
||||
|
||||
[export]
|
||||
include = []
|
||||
exclude = []
|
||||
# prefix = "CAPI_"
|
||||
item_types = []
|
||||
renaming_overrides_prefixing = false
|
||||
|
||||
|
||||
|
||||
[export.rename]
|
||||
|
||||
|
||||
|
||||
[export.body]
|
||||
|
||||
|
||||
[export.mangle]
|
||||
|
||||
|
||||
[fn]
|
||||
rename_args = "None"
|
||||
# must_use = "MUST_USE_FUNC"
|
||||
# no_return = "NO_RETURN"
|
||||
# prefix = "START_FUNC"
|
||||
# postfix = "END_FUNC"
|
||||
args = "auto"
|
||||
sort_by = "Name"
|
||||
|
||||
|
||||
|
||||
|
||||
[struct]
|
||||
rename_fields = "None"
|
||||
# must_use = "MUST_USE_STRUCT"
|
||||
derive_constructor = false
|
||||
derive_eq = false
|
||||
derive_neq = false
|
||||
derive_lt = false
|
||||
derive_lte = false
|
||||
derive_gt = false
|
||||
derive_gte = false
|
||||
|
||||
|
||||
|
||||
|
||||
[enum]
|
||||
rename_variants = "None"
|
||||
# must_use = "MUST_USE_ENUM"
|
||||
add_sentinel = false
|
||||
prefix_with_name = false
|
||||
derive_helper_methods = false
|
||||
derive_const_casts = false
|
||||
derive_mut_casts = false
|
||||
# cast_assert_name = "ASSERT"
|
||||
derive_tagged_enum_destructor = false
|
||||
derive_tagged_enum_copy_constructor = false
|
||||
enum_class = true
|
||||
private_default_tagged_enum_constructor = false
|
||||
|
||||
|
||||
|
||||
|
||||
[const]
|
||||
allow_static_const = true
|
||||
allow_constexpr = false
|
||||
sort_by = "Name"
|
||||
|
||||
|
||||
|
||||
|
||||
[macro_expansion]
|
||||
bitflags = false
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
############## Options for How Your Rust library Should Be Parsed ##############
|
||||
|
||||
[parse]
|
||||
parse_deps = false
|
||||
# include = []
|
||||
exclude = []
|
||||
clean = false
|
||||
extra_bindings = []
|
||||
|
||||
|
||||
|
||||
[parse.expand]
|
||||
crates = []
|
||||
all_features = false
|
||||
default_features = true
|
||||
features = []
|
||||
90
ffi/onetun.h
Normal file
90
ffi/onetun.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/**
|
||||
* The capacity of the channel for received IP packets.
|
||||
*/
|
||||
#define DISPATCH_CAPACITY 1000
|
||||
|
||||
typedef struct Bus Bus;
|
||||
|
||||
typedef struct Config Config;
|
||||
|
||||
typedef struct PortForwardConfig PortForwardConfig;
|
||||
|
||||
/**
|
||||
* Creates a new bus struct
|
||||
* # Arguments
|
||||
* *none*
|
||||
* # Returns
|
||||
* A pointer to a bus struct
|
||||
*/
|
||||
struct Bus *onetun_new_bus(void);
|
||||
|
||||
/**
|
||||
* Creates a new config struct for starting a tunnel
|
||||
* # Arguments
|
||||
* * `port_forwards` - A pointer to an array of pointers to port forwards, generated with `onetun_new_port_forward`
|
||||
* * `port_forwards_len` - The length of the array of pointers to port forwards
|
||||
* * `remote_forwards` - A pointer to an array of pointers to port forwards, generated with `onetun_new_port_forward`
|
||||
* * `remote_forwards_len` - The length of the array of pointers to port forwards
|
||||
* * `private_key` - A pointer to an array of chars containing the private key
|
||||
* * `public_key` - A pointer to an array of chars containing the public key
|
||||
* * `endpoint_addr` - A pointer to an array of chars containing the endpoint address
|
||||
* * `endpoint_bind_addr` - A pointer to an array of chars containing the endpoint bind address
|
||||
* * `source_peer_ip` - A pointer to an array of chars containing the source peer IP address
|
||||
* * `keepalive_seconds` - A number representing the keepalive interval, or -1 for None
|
||||
* * `max_transmission_unit` - A number representing the maximum transmission unit
|
||||
* * `log` - A pointer to an array of chars containing the log level (e.g. "INFO", "DEBUG", "TRACE")
|
||||
* * `pcap_file` - A pointer to an array of chars containing the pcap file path, or NULL for none
|
||||
* # Returns
|
||||
* A pointer to a config struct, or NULL on failure
|
||||
* # Safety
|
||||
* All pointers must be valid and not null, unless specified and expected to be NULL.
|
||||
*/
|
||||
struct Config *onetun_new_config(struct PortForwardConfig *const *port_forwards,
|
||||
unsigned int port_forwards_len,
|
||||
struct PortForwardConfig *const *remote_forwards,
|
||||
unsigned int remote_forwards_len,
|
||||
const char *private_key,
|
||||
const char *public_key,
|
||||
const char *endpoint_addr,
|
||||
const char *endpoint_bind_addr,
|
||||
const char *source_peer_ip,
|
||||
int keepalive_seconds,
|
||||
int max_transmission_unit,
|
||||
const char *log,
|
||||
const char *pcap_file);
|
||||
|
||||
/**
|
||||
* Creates a new port forward configuration
|
||||
* # Arguments
|
||||
* * `source` - A list of chars representing a socket address
|
||||
* * `destination` - A list of chars representing a socket address
|
||||
* * `protocol` - Either `tcp` or `udp`
|
||||
* * `port` - Whether this forward is remote: 1 for true, 0 for false
|
||||
* # Returns
|
||||
* A pointer to a port forward config struct, or NULL on failure
|
||||
* # Safety
|
||||
* All pointers must be valid. Strings may be freed after this function returns.
|
||||
*/
|
||||
struct PortForwardConfig *onetun_new_port_forward(const char *source,
|
||||
const char *destination,
|
||||
const char *protocol,
|
||||
unsigned int remote);
|
||||
|
||||
/**
|
||||
* Starts a new onetun tunnel
|
||||
* # Arguments
|
||||
* * `config` - The configuration for the tunnel, generated with `onetun_new_config`
|
||||
* * `bus` - The bus to publish events on, generated with `onetun_new_bus`
|
||||
* # Returns
|
||||
* 0 on success, non-zero on failure
|
||||
* # Safety
|
||||
* All pointers must be valid and not null.
|
||||
*/
|
||||
int32_t onetun_start_tunnels(struct Config *config, struct Bus *bus);
|
||||
Loading…
Add table
Add a link
Reference in a new issue