You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

84 lines
2.6 KiB

/*
* android_jni_bridge.h — JNI bridge API (C side)
*
* Provides lifecycle management and callbacks between C core and Kotlin.
* For Android, compiled via NDK into libutun_lite.so.
*/
#ifndef ANDROID_JNI_BRIDGE_H
#define ANDROID_JNI_BRIDGE_H
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ── Callback types (C → Kotlin) ── */
typedef void (*utun_log_fn)(int level, const char* category, const char* message);
typedef void (*utun_event_fn)(int event_type, const char* json_data);
typedef const char* (*utun_config_string_fn)(const char* key);
typedef int64_t (*utun_config_int64_fn)(const char* key);
typedef int (*utun_config_int_fn)(const char* key);
struct utun_bridge_config {
utun_config_string_fn get_string;
utun_config_int64_fn get_int64;
utun_config_int_fn get_int;
};
/* ── Initialize uTun core (legacy stub — use start for real init) ── */
bool utun_bridge_init(const char* db_path, int control_port,
utun_log_fn on_log,
utun_event_fn on_event,
const struct utun_bridge_config* config);
/* ── Start full uTun stack from INI config text ── */
int utun_bridge_start(const char* config_text);
/* ── Shutdown uTun core ── */
void utun_bridge_destroy(void);
/* ── Actions (Kotlin → C) ── */
void utun_bridge_send_message(const char* channel_id, const char* text);
void utun_bridge_create_channel(const char* name, const char* channel_id);
void utun_bridge_connect_node(const char* address, int port, const char* pubkey_hex);
/* Join channel via invite link.
addr_data format: family(1) + socketId(1) + address(4|16) + port(2 BE) per addr */
void utun_bridge_join_channel(uint64_t channel_id, uint64_t node_id,
const uint8_t* pubkey_bin,
const uint8_t* addrs_data, int addr_count);
/* Connect to all peers of a channel (auto-connect on select) */
void utun_bridge_connect_channel(const char* channel_id);
/* ── Queries ── */
char* utun_bridge_get_channels_json(void);
char* utun_bridge_get_messages_json(const char* channel_id, int limit);
uint64_t utun_bridge_get_my_node_id(void);
/* ── Restart (config update, key regen, DB clear) ── */
void utun_bridge_restart(const char* config_text);
/* ── Health check ── */
void utun_bridge_ping(void);
int utun_bridge_is_responsive(void);
/* ── Debug ── */
void utun_bridge_set_debug_level(const char* category, const char* level);
#ifdef __cplusplus
}
#endif
#endif /* ANDROID_JNI_BRIDGE_H */