Refactor: Rename utun param to instance, increment connections_count
This commit is contained in:
1 parent
9b417e054a
commit
d48d81f490
1 file changed
+9
-7
+9
-7
@@ -47,15 +47,15 @@ static void etcp_update_window(struct ETCP_CONN* etcp) {
|
||||
|
||||
// Creating ETCP instance
|
||||
// после создания надо добавить peer bublic key.
|
||||
struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* utun) {
|
||||
if (!utun) return NULL;
|
||||
struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* instance) {
|
||||
if (!instance) return NULL;
|
||||
|
||||
struct ETCP_CONN* etcp = calloc(1, sizeof(struct ETCP_CONN));
|
||||
if (!etcp) return NULL;
|
||||
|
||||
etcp->mtu = 1500; // Default MTU
|
||||
|
||||
etcp->instance = utun;
|
||||
etcp->instance = instance;
|
||||
etcp->state = 0;
|
||||
|
||||
// Initialize crypto context
|
||||
@@ -65,8 +65,8 @@ struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* utun) {
|
||||
}
|
||||
|
||||
// Initialize queues (tx_queue is input_queue)
|
||||
etcp->input_queue = queue_new(utun->ua,NULL);
|
||||
etcp->output_queue = queue_new(utun->ua,NULL);
|
||||
etcp->input_queue = queue_new(instance->ua,NULL);
|
||||
etcp->output_queue = queue_new(instance->ua,NULL);
|
||||
if (!etcp->input_queue || !etcp->output_queue) {
|
||||
if (etcp->input_queue) queue_free(etcp->input_queue);
|
||||
if (etcp->output_queue) queue_free(etcp->output_queue);
|
||||
@@ -135,8 +135,10 @@ struct ETCP_CONN* etcp_connection_create(struct UTUN_INSTANCE* utun) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "etcp_create: created instance with node_id=%llu, mtu=%d",
|
||||
(unsigned long long)etcp->instance->node_id, etcp->mtu);
|
||||
|
||||
etcp->next=utun->connections;
|
||||
utun->connections=etcp;
|
||||
etcp->next=instance->connections;
|
||||
instance->connections=etcp;
|
||||
|
||||
instance->connections_count++;
|
||||
|
||||
return etcp;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user