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.
69 lines
2.3 KiB
69 lines
2.3 KiB
// tcp_proxy_client.h — TCP прокси-клиент: стек lwIP TCP → ETCP → удалённый exit узел |
|
#ifndef TCP_PROXY_CLIENT_H |
|
#define TCP_PROXY_CLIENT_H |
|
|
|
#include <stdint.h> |
|
#include <stddef.h> |
|
#include "../lib/socket_compat.h" |
|
#include "../lib/ll_queue.h" |
|
|
|
struct UASYNC; |
|
struct UTUN_INSTANCE; |
|
struct ETCP_CONN; |
|
struct tun_if; |
|
struct ll_queue; |
|
struct ll_entry; |
|
struct memory_pool; |
|
struct tcp_proxy_client_mapping_config; |
|
struct tcp_proxy_server; |
|
struct lwip_tcp_ctx; |
|
|
|
struct tcp_pcb; |
|
|
|
struct tcp_proxy_client_conn { |
|
struct tcp_proxy_client_conn* next; |
|
struct tcp_proxy_client* proxy; |
|
struct tcp_pcb* pcb; |
|
|
|
uint32_t stream_id; |
|
|
|
struct ll_queue* to_lwip; // DATA от exit → lwIP (управление потоком) |
|
|
|
uint8_t fin_local; // локальная сторона отправила FIN (lwIP) |
|
uint8_t fin_remote; // exit отправил FIN (назначение закрылось) |
|
uint8_t rem_closed; // exit отправил CLOSE |
|
uint8_t error; // ошибка, немедленная очистка |
|
uint8_t close_sent; // отправили CLOSE/ERROR в exit |
|
uint8_t close_pending; // CLOSE/ERROR не доставлен, ждём повтора |
|
|
|
uint8_t* tx_buf; // буфер при backpressure (lwIP→ETCP send fail) |
|
uint16_t tx_len; |
|
struct queue_waiter_handle tx_waiter; |
|
|
|
uint8_t dest_ip[4]; |
|
uint16_t dest_port; |
|
}; |
|
|
|
struct tcp_proxy_client { |
|
struct UTUN_INSTANCE* inst; |
|
struct UASYNC* ua; |
|
struct tun_if* tun; |
|
struct tcp_proxy_client_conn* conns; |
|
int conn_count; |
|
struct memory_pool* entry_pool; |
|
uint32_t next_stream_id; |
|
uint64_t via_node_id; |
|
struct lwip_tcp_ctx* lwip; |
|
|
|
struct tcp_proxy_client_mapping_config* mappings; // указатель на конфиг |
|
int mapping_count; |
|
}; |
|
|
|
struct tcp_proxy_client* tcp_proxy_client_create(struct UTUN_INSTANCE* inst, struct UASYNC* ua, |
|
const char* tun_name, const char* tun_ip, int mtu, int test_mode, |
|
struct tcp_proxy_client_mapping_config* mappings, int mapping_count, |
|
uint64_t via_node_id); |
|
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); |
|
|
|
#endif // TCP_PROXY_CLIENT_H
|
|
|