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.
59 lines
1.9 KiB
59 lines
1.9 KiB
// etcp.h - Расширенный протокол управления передачей (ETCP Protocol) |
|
#ifndef ETCP_H |
|
#define ETCP_H |
|
|
|
#include "etcp_sockets.h" |
|
#include "etcp_connections.h" |
|
#include "packet_pool.h" |
|
#include "ll_queue.h" |
|
#include <stdint.h> |
|
|
|
#ifdef __cplusplus |
|
extern "C" { |
|
#endif |
|
|
|
// Forward declarations |
|
typedef struct utun_instance utun_instance_t; |
|
typedef struct ETCP_CONN etcp_t; |
|
|
|
struct ETCP_CONN { |
|
// Node ID (64-bit, генерируется при первом запуске) |
|
uint64_t node_id; |
|
int mtu; |
|
|
|
utun_instance_t *instance; |
|
|
|
// Каналы (соединения) - linked list |
|
struct ETCP_LINK* channels; |
|
|
|
// Пул пакетов (общий для всего ETCP instance) |
|
packet_pool_t packet_pool; |
|
|
|
uint8_t state; // 0 - just created, 1 - initialized, 2 - connection established |
|
|
|
// Криптография и состояние (TODO: определить sc_context_t) |
|
// void* crypto_ctx; |
|
|
|
ll_queue_t* input_queue;// отправитель -> input_queue -> etcp -> etcp_channel -> отправка (etcp_sockets) |
|
ll_queue_t* output_queue;// etcp_sockets -> etcp_channel -> etcp -> output_queue -> получатель |
|
|
|
}; |
|
|
|
// Создание пустого ETCP instance (после надо добавить ключи, каналы) |
|
struct ETCP_CONN* etcp_create(utun_instance_t *instance); |
|
|
|
// Уничтожение ETCP instance |
|
void etcp_destroy(struct ETCP_CONN* etcp); |
|
|
|
// Обработать входящий пакет (вызывается из etcp_connections) |
|
void etcp_conn_input(struct ETCP_CONN* etcp, packet_buffer_t* pkt); |
|
|
|
// Получение статистики |
|
void etcp_get_stats(struct ETCP_CONN* etcp, size_t* packets_sent, size_t* packets_recv, |
|
size_t* pool_allocs, size_t* pool_reuse); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
|
|
#endif // ETCP_H
|