- Add tun_route_del_all() to delete routes from config - Use netsh for route deletion on Windows (like add) - Store route_subnets in UTUN_INSTANCE for cleanup - Delete routes in utun_instance_destroy() before tun_close()
79 lines
2.2 KiB
C
79 lines
2.2 KiB
C
#ifndef UTUN_INSTANCE_H
|
|
#define UTUN_INSTANCE_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include "../lib/memory_pool.h"
|
|
#include "secure_channel.h"
|
|
#include "etcp_api.h"
|
|
#include "config_parser.h"
|
|
|
|
// Forward declarations
|
|
struct utun_config;
|
|
struct uasync_s;
|
|
struct ROUTE_TABLE;
|
|
struct ETCP_CONN;
|
|
struct ETCP_SOCKET;
|
|
struct tun_if;
|
|
struct ETCP_BINDINGS;
|
|
struct ROUTE_BGP;
|
|
struct control_server;
|
|
|
|
// uTun instance configuration
|
|
struct UTUN_INSTANCE {
|
|
// Configuration (moved from utun_state)
|
|
struct utun_config *config;
|
|
|
|
// TUN interface
|
|
struct tun_if* tun;
|
|
|
|
// Route subnets (for cleanup on shutdown)
|
|
struct CFG_ROUTE_ENTRY* route_subnets;
|
|
|
|
struct ROUTE_TABLE* rt;
|
|
struct ROUTE_BGP* bgp; // BGP module for route exchange
|
|
|
|
// Identification
|
|
uint64_t node_id;
|
|
|
|
struct SC_MYKEYS my_keys;
|
|
|
|
// Main async context
|
|
struct UASYNC* ua;
|
|
|
|
// State
|
|
int running;
|
|
|
|
// Connections (список всех подключений для instance)
|
|
struct ETCP_CONN* connections;// linked-list
|
|
int connections_count; // Number of connections
|
|
|
|
struct memory_pool* data_pool;// для входных-выходных данных пакета
|
|
struct memory_pool* pkt_pool;
|
|
struct memory_pool* ack_pool;
|
|
|
|
// Active sockets
|
|
struct ETCP_SOCKET* etcp_sockets;// linked-list
|
|
|
|
// ETCP API bindings (per-instance)
|
|
struct ETCP_BINDINGS api_bindings;
|
|
|
|
// Control server for monitoring
|
|
struct control_server* control_srv;
|
|
};
|
|
|
|
// Functions
|
|
struct UTUN_INSTANCE* utun_instance_create(struct UASYNC* ua, const char* config_file);
|
|
struct UTUN_INSTANCE* utun_instance_create_from_config(struct UASYNC* ua, struct utun_config* config);
|
|
void utun_instance_destroy(struct UTUN_INSTANCE* instance);
|
|
int utun_instance_init(struct UTUN_INSTANCE *instance);
|
|
void utun_instance_run(struct UTUN_INSTANCE *instance);
|
|
void utun_instance_stop(struct UTUN_INSTANCE *instance);
|
|
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);
|
|
|
|
#endif // UTUN_INSTANCE_H
|