diff options
| author | Emīls <emils@mullvad.net> | 2024-09-23 14:18:12 +0200 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2024-09-25 16:03:52 +0200 |
| commit | 9604d1ae258032da1f53267aaf1e361aeb562e66 (patch) | |
| tree | 100a56e6c8000c0da9da7657cfa7842327f31efa /ios/MullvadRustRuntime/include | |
| parent | 9c0f7d7c583fcab63efc94fd2a591d1ac605637d (diff) | |
| download | mullvadvpn-9604d1ae258032da1f53267aaf1e361aeb562e66.tar.xz mullvadvpn-9604d1ae258032da1f53267aaf1e361aeb562e66.zip | |
Add FFI for encrypted-dns-proxy for iOS
Diffstat (limited to 'ios/MullvadRustRuntime/include')
| -rw-r--r-- | ios/MullvadRustRuntime/include/mullvad_rust_runtime.h | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h index c42d2ae840..7aa7cbb3e8 100644 --- a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h +++ b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h @@ -5,18 +5,56 @@ #include <stdint.h> #include <stdlib.h> -typedef struct EphemeralPeerCancelToken { - void *context; -} EphemeralPeerCancelToken; +typedef struct EncryptedDnsProxyState EncryptedDnsProxyState; typedef struct ProxyHandle { void *context; uint16_t port; } ProxyHandle; +typedef struct EphemeralPeerCancelToken { + void *context; +} EphemeralPeerCancelToken; + extern const uint16_t CONFIG_SERVICE_PORT; /** + * Initializes a valid pointer to an instance of `EncryptedDnsProxyState`. + */ +struct EncryptedDnsProxyState *encrypted_dns_proxy_init(void); + +/** + * This must be called only once to deallocate `EncryptedDnsProxyState`. + * + * # Safety + * `ptr` must be a valid, exclusive pointer to `EncryptedDnsProxyState`, initialized + * by `encrypted_dns_proxy_init`. This function is not thread safe, and should only be called + * once. + */ +void encrypted_dns_proxy_free(struct EncryptedDnsProxyState *ptr); + +/** + * # Safety + * encrypted_dns_proxy must be a valid, exclusive pointer to `EncryptedDnsProxyState`, initialized + * by `encrypted_dns_proxy_init`. This function is not thread safe. + * `proxy_handle` must be pointing to a valid memory region for the size of a `ProxyHandle`. This + * function is not thread safe, but it can be called repeatedly. Each successful invocation should + * clean up the resulting proxy via `[encrypted_dns_proxy_stop]`. + * + * `proxy_handle` will only contain valid values if the return value is zero. It is still valid to + * deallocate the memory. + */ +int32_t encrypted_dns_proxy_start(struct EncryptedDnsProxyState *encrypted_dns_proxy, + struct ProxyHandle *proxy_handle); + +/** + * # Safety + * `proxy_config` must be a valid pointer to a `ProxyHandle` as initialized by + * [`encrypted_dns_proxy_start`]. It should only ever be called once. + */ +int32_t encrypted_dns_proxy_stop(struct ProxyHandle *proxy_config); + +/** * Called by the Swift side to signal that the ephemeral peer exchange should be cancelled. * After this call, the cancel token is no longer valid. * |
