Browse Source

headers: add extern "C" guards for C++ interop (chatgui)

Added #ifdef __cplusplus / extern "C" { ... } / #endif to ~65 headers
in src/ and lib/, enabling the C library to be linked into C++ code (chatgui).
Fixed packet_dump.h (added missing header guard) and etcp_bbr.h
(#pragma once guard).
chatgui
Evgeny 3 months ago
parent
commit
797c0736a7
  1. 9
      lib/ll_queue.h
  2. 9
      lib/memory_pool.h
  3. 9
      lib/platform_compat.h
  4. 9
      lib/radix.h
  5. 9
      lib/serialize.h
  6. 9
      lib/sha256.h
  7. 9
      lib/socket_compat.h
  8. 9
      lib/tcp_io.h
  9. 9
      lib/timeout_heap.h
  10. 149
      lib/u_async.h
  11. 9
      src/conn_mgr.h
  12. 9
      src/crc32.h
  13. 9
      src/db_sync.h
  14. BIN
      src/dnsmasq/dnsmasq-2.93.tar.xz
  15. 9
      src/dummynet.h
  16. 9
      src/eim_nat.h
  17. 9
      src/etcp_api.h
  18. 8
      src/etcp_bbr.h
  19. 9
      src/etcp_connections.h
  20. 9
      src/etcp_debug.h
  21. 9
      src/etcp_dump.h
  22. 9
      src/etcp_router.h
  23. 9
      src/lwip_tcp/lwip_pbuf.h
  24. 9
      src/lwip_tcp/lwip_tcp.h
  25. 9
      src/lwip_tcp/lwip_tcp_opts.h
  26. 9
      src/lwip_tcp/lwip_tcp_priv.h
  27. 9
      src/nat_transport.h
  28. 13
      src/packet_dump.h
  29. 9
      src/pkt_normalizer.h
  30. 9
      src/proxy/icmp_proxy.h
  31. 9
      src/proxy/socks_proxy.h
  32. 9
      src/proxy/tcp_proxy_client.h
  33. 9
      src/proxy/tcp_proxy_server.h
  34. 9
      src/proxy/udp_proxy.h
  35. 9
      src/route6_lib.h
  36. 9
      src/route_bgp.h
  37. 9
      src/route_connectivity.h
  38. 9
      src/route_lib.h
  39. 8
      src/route_node.h
  40. 9
      src/route_node_lmdb.h
  41. 9
      src/route_ping.h
  42. 9
      src/routing.h
  43. 9
      src/secure_channel.h
  44. 9
      src/stcp.h
  45. 9
      src/stcp_client.h
  46. 9
      src/stcp_link.h
  47. 9
      src/stcp_server.h
  48. 9
      src/utun_instance.h

9
lib/ll_queue.h

@ -1,6 +1,11 @@
#ifndef LL_QUEUE_H
#define LL_QUEUE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h> // для size_t
#include <stdint.h> // для uint64_t
#include "memory_pool.h" // для struct memory_pool
@ -412,4 +417,8 @@ static inline size_t queue_total_bytes(struct ll_queue* q) {
return q->total_bytes;
}
#ifdef __cplusplus
}
#endif
#endif // LL_QUEUE_H

9
lib/memory_pool.h

@ -2,6 +2,11 @@
#ifndef MEMORY_POOL_H
#define MEMORY_POOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include "debug_config.h"
@ -37,4 +42,8 @@ size_t memory_pool_get_total_free_blocks(void);
int memory_pool_is_freed(struct memory_pool* pool, void* obj);
#ifdef __cplusplus
}
#endif
#endif // MEMORY_POOL_H

9
lib/platform_compat.h

@ -5,6 +5,11 @@
#ifndef PLATFORM_COMPAT_H
#define PLATFORM_COMPAT_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
@ -186,4 +191,8 @@ int get_interface_ipv6_by_index(uint32_t netif_index, int temporary, uint8_t* ad
// family: AF_INET or AF_INET6, returns ifindex (0 on failure)
uint32_t get_default_route_netif_index(int family);
#ifdef __cplusplus
}
#endif
#endif // PLATFORM_COMPAT_H

9
lib/radix.h

@ -32,6 +32,15 @@
#ifndef _RADIX_H_
#define _RADIX_H_
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
}
#endif
#endif
#include <stdint.h>
#include "mem.h"

9
lib/serialize.h

@ -76,6 +76,11 @@
*/
#ifndef SERIALIZE_H
#define SERIALIZE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "../lib/mem.h"
@ -127,4 +132,8 @@ int serialize_decode(const uint8_t* in_buf, size_t in_len,
void serialize_free(const struct SerializeSchema* schema, void** structure);
#ifdef __cplusplus
}
#endif
#endif // SERIALIZE_H

9
lib/sha256.h

@ -9,6 +9,11 @@
#ifndef SC_SHA256_H
#define SC_SHA256_H
#ifdef __cplusplus
extern "C" {
#endif
/*************************** HEADER FILES ***************************/
#include <stddef.h>
#include <stdint.h>
@ -29,4 +34,8 @@ void sc_sha256_init(SC_SHA256_CTX *ctx);
void sc_sha256_update(SC_SHA256_CTX *ctx, const uint8_t data[], size_t len);
void sc_sha256_final(SC_SHA256_CTX *ctx, uint8_t hash[]);
#ifdef __cplusplus
}
#endif
#endif // SC_SHA256_H

9
lib/socket_compat.h

@ -5,6 +5,11 @@
#ifndef SOCKET_COMPAT_H
#define SOCKET_COMPAT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#ifdef _WIN32
@ -73,4 +78,8 @@ const char* socket_strerror(int err);
// взять порт из sockaddr_storage
uint16_t ss_get_port(const struct sockaddr_storage *addr);
#ifdef __cplusplus
}
#endif
#endif // SOCKET_COMPAT_H

9
lib/tcp_io.h

@ -22,6 +22,11 @@
#ifndef TCP_IO_H
#define TCP_IO_H
#ifdef __cplusplus
extern "C" {
#endif
#include "u_async.h"
#include "socket_compat.h"
#include "ll_queue.h"
@ -108,4 +113,8 @@ void tcp_conn_set_flushed(struct tcp_conn* tc, void (*on_flushed)(struct tcp_con
// Принудительная остановка чтения: убирает EPOLLIN и отменяет read_waiter.
void tcp_conn_pause_read(struct tcp_conn* tc);
#ifdef __cplusplus
}
#endif
#endif

9
lib/timeout_heap.h

@ -3,6 +3,11 @@
#ifndef TIMEOUT_HEAP_H
#define TIMEOUT_HEAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h> // For uint64_t
#include <stddef.h> // For size_t
@ -94,4 +99,8 @@ size_t timeout_heap_get_freed_count(TimeoutHeap *h);
size_t timeout_heap_get_size(TimeoutHeap *h);
#ifdef __cplusplus
}
#endif
#endif // TIMEOUT_HEAP_H

149
lib/u_async.h

@ -5,18 +5,23 @@
#ifndef UASYNC_H
#define UASYNC_H
#include "platform_compat.h"
#include <stddef.h>
#include <signal.h>
#include "timeout_heap.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "platform_compat.h"
#include <stddef.h>
#include <signal.h>
#include "timeout_heap.h"
#include "socket_compat.h"
typedef void (*timeout_callback_t)(void* user_arg);// передаёт user_arg из uasync_set_timeout
typedef void (*socket_callback_t)(int fd, void* user_arg);// передаёт user_arg из uasync_add_socket (for pipe/file)
typedef void (*socket_t_callback_t)(socket_t sock, void* user_arg);// передаёт user_arg из uasync_add_socket_t (for sockets)
// user_arg полезен если нужно передать управляющую структуру. Ее можно выделить в памяти и в ней хранить всё что надо. т.е. при set_timeout передаём и получаем ее в callback-е
// Error type
typedef int err_t;
#define ERR_OK 0
@ -28,21 +33,21 @@ typedef int err_t;
typedef void (*uasync_post_callback_t)(void* user_arg);
#include "memory_pool.h"
struct timeout_node; // Forward declaration
#include "memory_pool.h"
struct timeout_node; // Forward declaration
struct posted_task {
uasync_post_callback_t callback;
void* arg;
struct posted_task* next;
};
// Uasync instance structure
struct UASYNC {
struct memory_pool* timeout_pool; // Pool for timeout_node allocation
struct timeout_node* immediate_queue_head; // FIFO queue for immediate execution
struct timeout_node* immediate_queue_tail;
// Uasync instance structure
struct UASYNC {
struct memory_pool* timeout_pool; // Pool for timeout_node allocation
struct timeout_node* immediate_queue_head; // FIFO queue for immediate execution
struct timeout_node* immediate_queue_tail;
TimeoutHeap* timeout_heap; // Heap for timeout management
struct socket_array* sockets; // Array-based socket management
// Debug counters for memory allocation tracking
@ -67,55 +72,55 @@ struct UASYNC {
#ifdef _WIN32
CRITICAL_SECTION posted_lock;
#else
pthread_mutex_t posted_lock;
#endif
volatile sig_atomic_t stop;
pthread_mutex_t posted_lock;
#endif
volatile sig_atomic_t stop;
};
// Type definitions
typedef struct UASYNC uasync_t;
typedef struct UASYNC UASYNC_t;
// Instance API - основной API для работы с uasync
struct UASYNC* uasync_create(void);
void uasync_destroy(struct UASYNC* ua, int close_fds);
// текущее время (timebase 0.1ms)
uint64_t get_time_tb(void);
// текущее время в микросекундах (для burst-измерений)
uint64_t get_time_us(void);
// Timeouts, timebase = 0.1 mS
// Как работать с таймаутами если таймаут может быть использован несколько раз:
// 1. заводим дескриптор таймаута и обнуляем
// 2. перед активацией таймаута проверяем дескриптор (t_id) на null
// 3. при cancel или срабатывании дескриптор обнуляем
// это обеспечит отсутствие утечек и задвоений таймаутов
void* uasync_set_timeout(struct UASYNC* ua, int timeout_tb, void* user_arg, timeout_callback_t callback, const char* name);
err_t uasync_cancel_timeout(struct UASYNC* ua, void* t_id);
// Immediate execution in next mainloop (FIFO order)
void* uasync_call_soon(struct UASYNC* ua, void* user_arg, timeout_callback_t callback);
err_t uasync_call_soon_cancel(struct UASYNC* ua, void* t_id);
// Type definitions
typedef struct UASYNC uasync_t;
typedef struct UASYNC UASYNC_t;
// Instance API - основной API для работы с uasync
struct UASYNC* uasync_create(void);
void uasync_destroy(struct UASYNC* ua, int close_fds);
// текущее время (timebase 0.1ms)
uint64_t get_time_tb(void);
// текущее время в микросекундах (для burst-измерений)
uint64_t get_time_us(void);
// Timeouts, timebase = 0.1 mS
// Как работать с таймаутами если таймаут может быть использован несколько раз:
// 1. заводим дескриптор таймаута и обнуляем
// 2. перед активацией таймаута проверяем дескриптор (t_id) на null
// 3. при cancel или срабатывании дескриптор обнуляем
// это обеспечит отсутствие утечек и задвоений таймаутов
void* uasync_set_timeout(struct UASYNC* ua, int timeout_tb, void* user_arg, timeout_callback_t callback, const char* name);
err_t uasync_cancel_timeout(struct UASYNC* ua, void* t_id);
// Immediate execution in next mainloop (FIFO order)
void* uasync_call_soon(struct UASYNC* ua, void* user_arg, timeout_callback_t callback);
err_t uasync_call_soon_cancel(struct UASYNC* ua, void* t_id);
// Sockets - for regular file descriptors (pipe, file)
void* uasync_add_socket(struct UASYNC* ua, int fd, socket_callback_t read_cbk, socket_callback_t write_cbk, socket_callback_t except_cbk, void* user_arg);
// Sockets - for socket_t (cross-platform sockets)
void* uasync_add_socket_t(struct UASYNC* ua, socket_t sock, socket_t_callback_t read_cbk, socket_t_callback_t write_cbk, socket_t_callback_t except_cbk, void* user_arg);
err_t uasync_remove_socket(struct UASYNC* ua, void* s_id);
err_t uasync_remove_socket_t(struct UASYNC* ua, socket_t sock);
// Динамическое управление мониторингом чтения/записи для сокета
err_t uasync_set_socket_read(struct UASYNC* ua, void* s_id, int enable);
err_t uasync_remove_socket(struct UASYNC* ua, void* s_id);
err_t uasync_remove_socket_t(struct UASYNC* ua, socket_t sock);
// Динамическое управление мониторингом чтения/записи для сокета
err_t uasync_set_socket_read(struct UASYNC* ua, void* s_id, int enable);
err_t uasync_set_socket_write(struct UASYNC* ua, void* s_id, int enable);
// Single iteration of event loop with timeout (timebase units)
void uasync_poll(struct UASYNC* ua, int timeout_tb);
// Mainloop (бесконечный цикл, __noreturn)
void uasync_mainloop(struct UASYNC* ua);
void uasync_stop(struct UASYNC* ua);
// Single iteration of event loop with timeout (timebase units)
void uasync_poll(struct UASYNC* ua, int timeout_tb);
// Mainloop (бесконечный цикл, __noreturn)
void uasync_mainloop(struct UASYNC* ua);
void uasync_stop(struct UASYNC* ua);
// Debug statistics
void uasync_get_stats(struct UASYNC* ua, size_t* timer_alloc, size_t* timer_free, size_t* socket_alloc, size_t* socket_free);
@ -124,15 +129,19 @@ int uasync_lookup_socket(struct UASYNC* ua, int fd, void** socket_id);
// Print all resources (timers, sockets) for debugging
void uasync_print_resources(struct UASYNC* ua, const char* prefix);
// Wakeup mechanism for interrupting poll
int uasync_wakeup(struct UASYNC* ua);
int uasync_get_wakeup_fd(struct UASYNC* ua); // returns write fd for wakeup pipe (for signal handlers)
// сообщить async (из другого thread) чтобы он вызвал callback с аргументом
void uasync_post(struct UASYNC* ua, uasync_post_callback_t callback, void* user_arg);
// синхронизация памяти (для доступности из других потоков)
void uasync_memsync(struct UASYNC* ua);
#endif // UASYNC_H
// Wakeup mechanism for interrupting poll
int uasync_wakeup(struct UASYNC* ua);
int uasync_get_wakeup_fd(struct UASYNC* ua); // returns write fd for wakeup pipe (for signal handlers)
// сообщить async (из другого thread) чтобы он вызвал callback с аргументом
void uasync_post(struct UASYNC* ua, uasync_post_callback_t callback, void* user_arg);
// синхронизация памяти (для доступности из других потоков)
void uasync_memsync(struct UASYNC* ua);
#ifdef __cplusplus
}
#endif
#endif // UASYNC_H

9
src/conn_mgr.h

@ -1,6 +1,11 @@
#ifndef CONN_MGR_H
#define CONN_MGR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "../lib/ll_queue.h"
@ -436,4 +441,8 @@ int conn_mgr_send(struct CONN_MGR* mgr, uint64_t node_id, struct ll_entry* entry
*/
void conn_mgr_update_best_candidates(struct CONN_MGR* mgr, uint64_t node_id, uint16_t rtt);
#ifdef __cplusplus
}
#endif
#endif

9
src/crc32.h

@ -1,6 +1,11 @@
#ifndef CRC32_H
#define CRC32_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
@ -16,4 +21,8 @@ uint32_t crc32_calc_ex(const uint8_t *data, size_t len, uint32_t initial_crc);
// Update CRC32 incrementally
uint32_t crc32_update(uint32_t crc, const uint8_t *data, size_t len);
#ifdef __cplusplus
}
#endif
#endif // CRC32_H

9
src/db_sync.h

@ -2,6 +2,11 @@
#ifndef DB_SYNC_H
#define DB_SYNC_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
@ -38,4 +43,8 @@ int db_sync_insert(struct UTUN_INSTANCE* inst, const char* json_data);
int db_sync_insert_len(struct UTUN_INSTANCE* inst, const char* json_data, size_t len);
uint32_t db_sync_count(struct UTUN_INSTANCE* inst);
#ifdef __cplusplus
}
#endif
#endif // DB_SYNC_H

BIN
src/dnsmasq/dnsmasq-2.93.tar.xz

Binary file not shown.

9
src/dummynet.h

@ -21,6 +21,11 @@
#ifndef DUMMYNET_H
#define DUMMYNET_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
@ -179,4 +184,8 @@ const struct dummynet_stats* dummynet_filter_get_stats(struct dummynet_filter* d
void dummynet_filter_block_addr(struct dummynet_filter* df, uint32_t ip, uint16_t port);
void dummynet_filter_unblock_addr(struct dummynet_filter* df, uint32_t ip, uint16_t port);
#ifdef __cplusplus
}
#endif
#endif // DUMMYNET_H

9
src/eim_nat.h

@ -1,6 +1,11 @@
#ifndef EIM_NAT_H
#define EIM_NAT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
@ -51,4 +56,8 @@ int eim_nat_add_forward(struct eim_nat_ctx* ctx, uint8_t proto,
uint32_t internal_ip_host, uint16_t internal_port_net,
uint16_t external_port);
#ifdef __cplusplus
}
#endif
#endif

9
src/etcp_api.h

@ -17,6 +17,11 @@
#ifndef ETCP_API_H
#define ETCP_API_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "../lib/ll_queue.h"
@ -157,4 +162,8 @@ void etcp_set_routing_exchange_state(struct ETCP_CONN* conn, uint8_t new_state);
*/
void etcp_int_recv(struct ll_queue* queue, void* arg);
#ifdef __cplusplus
}
#endif
#endif // ETCP_API_H

8
src/etcp_bbr.h

@ -1,6 +1,10 @@
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BBR_SCALE 8
#define BBR_UNIT (1 << BBR_SCALE)
#define BW_SCALE 24
@ -110,3 +114,7 @@ void bbr_main(struct bbr* bbr, const struct bbr_rate_sample* rs,
uint32_t mss, uint32_t inflight_bytes, int is_cwnd_limited);
void bbr_note_loss(struct bbr* bbr);
void bbr_tx_start(struct bbr* bbr);
#ifdef __cplusplus
}
#endif

9
src/etcp_connections.h

@ -1,6 +1,11 @@
#ifndef ETCP_CONNECTIONS_H
#define ETCP_CONNECTIONS_H
#ifdef __cplusplus
extern "C" {
#endif
// подмодуль ETCP который обслуживает сокеты ETCP для приёма-передачи пакетов и одно ETCP подключение через несколько каналов связи (failover)
#include "secure_channel.h"
@ -334,4 +339,8 @@ int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET*
void etcp_connections_read_callback_socket(socket_t sock, void* arg);
#ifdef __cplusplus
}
#endif
#endif // ETCP_CONNECTIONS_H

9
src/etcp_debug.h

@ -1,6 +1,11 @@
#ifndef ETCP_DEBUG_H
#define ETCP_DEBUG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "etcp_connections.h"
typedef struct { char a[16]; } IP_STR;
@ -9,4 +14,8 @@ IP_STR ip_to_string(uint32_t ip);
void etcp_dump_pkt_sections(struct ETCP_DGRAM* pkt, struct ETCP_LINK* link, int is_send);
#ifdef __cplusplus
}
#endif
#endif

9
src/etcp_dump.h

@ -1,10 +1,19 @@
#ifndef ETCP_DUMP_H
#define ETCP_DUMP_H
#ifdef __cplusplus
extern "C" {
#endif
#include "etcp.h"
#include "utun_instance.h"
void etcp_dump_conn_state(struct ETCP_CONN* conn);
void etcp_dump_all_conns(struct UTUN_INSTANCE* instance);
#ifdef __cplusplus
}
#endif
#endif

9
src/etcp_router.h

@ -9,6 +9,11 @@
#ifndef ETCP_ROUTER_H
#define ETCP_ROUTER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "etcp_api.h"
@ -219,4 +224,8 @@ void etcp_router_conn_restart(struct UTUN_INSTANCE* inst, uint64_t remote_node_i
// Удалить все транзитные очереди соединения (вызывается при закрытии ETCP_CONN)
void etcp_router_transit_queues_destroy(struct ETCP_CONN* conn);
#ifdef __cplusplus
}
#endif
#endif // ETCP_ROUTER_H

9
src/lwip_tcp/lwip_pbuf.h

@ -2,6 +2,11 @@
#ifndef LWIP_PBUF_H
#define LWIP_PBUF_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
@ -38,4 +43,8 @@ int pbuf_take(struct pbuf *p, const void *data, uint16_t len);
int pbuf_take_at(struct pbuf *p, const void *data, uint16_t len, uint16_t offset);
void* pbuf_get_contiguous(const struct pbuf *p, void *buf, size_t len, size_t offset);
#ifdef __cplusplus
}
#endif
#endif

9
src/lwip_tcp/lwip_tcp.h

@ -2,6 +2,11 @@
#ifndef LWIP_TCP_H
#define LWIP_TCP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "lwip_pbuf.h"
@ -270,4 +275,8 @@ void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, uint8_t interval);
#define tcp_clear_flags(pcb, clr_flags) ((pcb)->flags &= (tcpflags_t)~(clr_flags))
#define tcp_is_flag_set(pcb, flag) (((pcb)->flags & (flag)) != 0)
#ifdef __cplusplus
}
#endif
#endif

9
src/lwip_tcp/lwip_tcp_opts.h

@ -2,6 +2,11 @@
#ifndef LWIP_TCP_OPTS_H
#define LWIP_TCP_OPTS_H
#ifdef __cplusplus
extern "C" {
#endif
#define TCP_MSS 1460
#define TCP_SND_BUF (16 * TCP_MSS)
#define TCP_WND (8 * TCP_MSS)
@ -47,4 +52,8 @@
#define TCP_PRIO_NORMAL 64
#define TCP_PRIO_MAX 127
#ifdef __cplusplus
}
#endif
#endif

9
src/lwip_tcp/lwip_tcp_priv.h

@ -2,6 +2,11 @@
#ifndef LWIP_TCP_PRIV_H
#define LWIP_TCP_PRIV_H
#ifdef __cplusplus
extern "C" {
#endif
#include "lwip_tcp.h"
#include "lwip_tcp_opts.h"
#include <string.h>
@ -245,4 +250,8 @@ void lwip_tcp_stats_clear(struct lwip_tcp_ctx *ctx);
#define TCP_REG_ACTIVE(ctx, npcb) TCP_REG(&(ctx)->active_pcbs, npcb)
#define TCP_RMV_ACTIVE(ctx, npcb) TCP_RMV(&(ctx)->active_pcbs, npcb)
#ifdef __cplusplus
}
#endif
#endif

9
src/nat_transport.h

@ -2,6 +2,11 @@
#ifndef NAT_TRANSPORT_H
#define NAT_TRANSPORT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
struct tun_if;
@ -19,4 +24,8 @@ struct UTUN_INSTANCE;
int nat_transport_init(struct UTUN_INSTANCE* inst);
void nat_transport_destroy(struct UTUN_INSTANCE* inst);
#ifdef __cplusplus
}
#endif
#endif

13
src/packet_dump.h

@ -1,6 +1,19 @@
#ifndef PACKET_DUMP_H
#define PACKET_DUMP_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "../lib/platform_compat.h"
#ifdef __cplusplus
extern "C" {
#endif
char* dump_ip_packet_to_buffer(const uint8_t* data, size_t len);
#ifdef __cplusplus
}
#endif
#endif // PACKET_DUMP_H

9
src/pkt_normalizer.h

@ -2,6 +2,11 @@
#ifndef PKT_NORMALIZER_H
#define PKT_NORMALIZER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../lib/ll_queue.h"
#include "../lib/u_async.h"
#include <stdint.h>
@ -67,4 +72,8 @@ void pn_unpacker_reset_state(struct PKTNORM* pn);
// создаёт malloc data, копирует, помещает в input.
//void pn_packer_send(struct PKTNORM* pn, uint8_t* data, uint16_t len);
#ifdef __cplusplus
}
#endif
#endif // PKT_NORMALIZER_H

9
src/proxy/icmp_proxy.h

@ -2,6 +2,11 @@
#ifndef ICMP_PROXY_H
#define ICMP_PROXY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "../lib/socket_compat.h"
@ -62,4 +67,8 @@ int icmp_proxy_deliver_reply(struct UTUN_INSTANCE* inst,
void icmp_proxy_set_test_loopback(struct UTUN_INSTANCE* inst, int enabled);
#ifdef __cplusplus
}
#endif
#endif // ICMP_PROXY_H

9
src/proxy/socks_proxy.h

@ -2,6 +2,11 @@
#ifndef SOCKS_PROXY_H
#define SOCKS_PROXY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "../lib/socket_compat.h"
#include "../lib/ll_queue.h"
@ -80,4 +85,8 @@ void socks_proxy_conn_free(struct socks_proxy_conn* c);
// Освободить все соединения в списке
void socks_proxy_conn_free_all(struct socks_proxy_conn** head, int* count);
#ifdef __cplusplus
}
#endif
#endif // SOCKS_PROXY_H

9
src/proxy/tcp_proxy_client.h

@ -2,6 +2,11 @@
#ifndef TCP_PROXY_CLIENT_H
#define TCP_PROXY_CLIENT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "../lib/socket_compat.h"
@ -82,4 +87,8 @@ struct tcp_proxy_client* tcp_proxy_client_create(struct UTUN_INSTANCE* inst, str
void tcp_proxy_client_destroy(struct tcp_proxy_client* p);
void tcp_proxy_client_router_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry);
#ifdef __cplusplus
}
#endif
#endif // TCP_PROXY_CLIENT_H

9
src/proxy/tcp_proxy_server.h

@ -2,6 +2,11 @@
#ifndef TCP_PROXY_SERVER_H
#define TCP_PROXY_SERVER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "../lib/socket_compat.h"
#include "../lib/ll_queue.h"
@ -73,4 +78,8 @@ void tcp_proxy_server_handle_close(struct UTUN_INSTANCE* inst, uint32_t stream_i
void tcp_proxy_server_handle_error(struct UTUN_INSTANCE* inst, uint32_t stream_id);
void tcp_proxy_server_handle_fin(struct UTUN_INSTANCE* inst, uint32_t stream_id);
#ifdef __cplusplus
}
#endif
#endif

9
src/proxy/udp_proxy.h

@ -2,6 +2,11 @@
#ifndef UDP_PROXY_H
#define UDP_PROXY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "../lib/socket_compat.h"
@ -62,4 +67,8 @@ int udp_proxy_deliver_reply(struct UTUN_INSTANCE* inst,
uint32_t dst_ip, uint16_t dst_port,
const uint8_t* payload, size_t payload_len);
#ifdef __cplusplus
}
#endif
#endif // UDP_PROXY_H

9
src/route6_lib.h

@ -1,5 +1,10 @@
#ifndef ROUTE6_LIB_H
#define ROUTE6_LIB_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
@ -65,4 +70,8 @@ bool route6_insert(struct ROUTE6_TABLE *table, struct NODEINFO_Q *node);
void route6_delete(struct ROUTE6_TABLE *table, struct NODEINFO_Q *node);
const struct ROUTE6_DATA *route6_lookup(struct ROUTE6_TABLE *table, const uint8_t addr[16]);
#ifdef __cplusplus
}
#endif
#endif

9
src/route_bgp.h

@ -1,6 +1,11 @@
#ifndef ROUTE_BGP_H
#define ROUTE_BGP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "../lib/ll_queue.h"
@ -224,4 +229,8 @@ struct nat_check_arg {
uint16_t nat_port;
};
#ifdef __cplusplus
}
#endif
#endif // ROUTE_BGP_H

9
src/route_connectivity.h

@ -1,6 +1,11 @@
#ifndef ROUTE_CONNECTIVITY_H
#define ROUTE_CONNECTIVITY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "route_node.h"
@ -17,4 +22,8 @@ void route_connectivity_cancel_node(struct UTUN_INSTANCE* instance,
// Отменяет все pending пробы для всех узлов (при destroy)
void route_connectivity_cancel_all(struct UTUN_INSTANCE* instance);
#ifdef __cplusplus
}
#endif
#endif // ROUTE_CONNECTIVITY_H

9
src/route_lib.h

@ -1,5 +1,10 @@
#ifndef ROUTE_LIB_H
#define ROUTE_LIB_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
@ -120,4 +125,8 @@ bool route_add_local_subnet(struct ROUTE_TABLE *table, uint32_t network, uint8_t
*/
int is_local_subnet(uint32_t ip);
#ifdef __cplusplus
}
#endif
#endif // ROUTE_LIB_H

8
src/route_node.h

@ -1,6 +1,10 @@
#ifndef ROUTE_NODE_H
#define ROUTE_NODE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "../lib/ll_queue.h"
@ -199,4 +203,8 @@ struct NODEINFO_Q* nodeinfo_find_by_id(struct ROUTE_BGP* bgp, uint64_t node_id);
void route_node_dump_all(struct ROUTE_BGP* bgp);
int route_node_format_all(struct ROUTE_BGP* bgp, char* buf, size_t buf_size);
#ifdef __cplusplus
}
#endif
#endif // ROUTE_NODE_H

9
src/route_node_lmdb.h

@ -1,6 +1,11 @@
#ifndef ROUTE_NODE_LMDB_H
#define ROUTE_NODE_LMDB_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "route_node.h"
@ -11,4 +16,8 @@ void route_node_lmdb_destroy(struct ROUTE_BGP* bgp);
int route_node_lmdb_put(struct ROUTE_BGP* bgp, struct NODEINFO_Q* nq);
int route_node_lmdb_del(struct ROUTE_BGP* bgp, uint64_t node_id);
#ifdef __cplusplus
}
#endif
#endif

9
src/route_ping.h

@ -1,6 +1,11 @@
#ifndef ROUTE_PING_H
#define ROUTE_PING_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "route_bgp.h"
@ -53,4 +58,8 @@ void route_ping_cancel_for_conn(struct ROUTE_BGP* bgp, struct ETCP_CONN* conn);
void route_ping_handle_req(struct ROUTE_BGP* bgp, struct ETCP_CONN* from_conn, const uint8_t* data, size_t len);
void route_ping_handle_resp(struct ROUTE_BGP* bgp, struct ETCP_CONN* from_conn, const uint8_t* data, size_t len);
#ifdef __cplusplus
}
#endif
#endif // ROUTE_PING_H

9
src/routing.h

@ -2,6 +2,11 @@
#ifndef ROUTING_H
#define ROUTING_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
@ -56,4 +61,8 @@ void routing_set_tun(struct UTUN_INSTANCE* instance);
*/
void route_pkt(struct UTUN_INSTANCE* instance, struct ll_entry* entry, uint64_t src_node_id);
#ifdef __cplusplus
}
#endif
#endif // ROUTING_H

9
src/secure_channel.h

@ -2,6 +2,11 @@
#ifndef SECURE_CHANNEL_H
#define SECURE_CHANNEL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
@ -106,4 +111,8 @@ void sc_stream_sign_cleanup(struct sc_stream_sign_state *state);
sc_status_t sc_derive_ed25519_pubkey(const uint8_t *x25519_privkey, uint8_t *ed25519_pubkey_out);
#ifdef __cplusplus
}
#endif
#endif // SECURE_CHANNEL_H

9
src/stcp.h

@ -2,6 +2,11 @@
#ifndef STCP_H
#define STCP_H
#ifdef __cplusplus
extern "C" {
#endif
#include "secure_channel.h"
#include "crc32.h"
#include "../lib/u_async.h"
@ -77,4 +82,8 @@ void stcp_conn_set_tx_queue(struct stcp_conn *c, struct ll_queue *q);
void stcp_conn_set_rx_queue(struct stcp_conn *c, struct ll_queue *q);
void stcp_conn_set_on_close(struct stcp_conn *c, void (*cb)(struct stcp_conn *conn, int err, void *arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif

9
src/stcp_client.h

@ -2,6 +2,11 @@
#ifndef STCP_CLIENT_H
#define STCP_CLIENT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stcp.h"
typedef void (*stcp_ready_cb)(struct stcp_conn *conn, void *arg);
@ -12,4 +17,8 @@ struct stcp_client *stcp_client_connect(struct UASYNC *ua, const char *addr, uin
void stcp_client_destroy(struct stcp_client *cli);
struct stcp_conn *stcp_client_get_conn(struct stcp_client *cli);
#ifdef __cplusplus
}
#endif
#endif

9
src/stcp_link.h

@ -2,6 +2,11 @@
#ifndef STCP_LINK_H
#define STCP_LINK_H
#ifdef __cplusplus
extern "C" {
#endif
#include "secure_channel.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
@ -45,4 +50,8 @@ typedef void (*stcp_link_cb)(struct stcp_link *link, void *arg);
void stcp_link_set_on_ready(struct stcp_link *link, stcp_link_cb cb, void *arg);
void stcp_link_set_on_close(struct stcp_link *link, void (*cb)(struct stcp_link *link, int err, void *arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif

9
src/stcp_server.h

@ -2,6 +2,11 @@
#ifndef STCP_SERVER_H
#define STCP_SERVER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stcp.h"
typedef void (*stcp_connect_cb)(struct stcp_conn *conn, void *arg);
@ -11,4 +16,8 @@ struct stcp_server *stcp_server_create(struct UASYNC *ua, uint16_t port,
stcp_connect_cb connect_cb, void *arg);
void stcp_server_destroy(struct stcp_server *srv);
#ifdef __cplusplus
}
#endif
#endif

9
src/utun_instance.h

@ -1,6 +1,11 @@
#ifndef UTUN_INSTANCE_H
#define UTUN_INSTANCE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
@ -150,4 +155,8 @@ void utun_instance_set_tun_init_enabled(int enabled);
// Diagnostic function for memory leak analysis
void utun_instance_diagnose_leaks(struct UTUN_INSTANCE* instance, const char* phase);
#ifdef __cplusplus
}
#endif
#endif // UTUN_INSTANCE_H

Loading…
Cancel
Save