diff --git a/src/etcp.c b/src/etcp.c index a32d367a6..2d00fab23 100644 --- a/src/etcp.c +++ b/src/etcp.c @@ -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; }