From 1a171d5a24912d9dc5d5ccb8aaa6a2b7d001a8cf Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 15 Apr 2026 12:32:40 +0300 Subject: [PATCH] 1 --- src/etcp_connections.c | 30 +++++++++++++++--------------- src/route_bgp.c | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/etcp_connections.c b/src/etcp_connections.c index b55c18bd..3f1fbdaa 100644 --- a/src/etcp_connections.c +++ b/src/etcp_connections.c @@ -892,12 +892,12 @@ es_err: static int etcp_send_ping_raw(struct ETCP_DGRAM* dgram, socket_t fd, sc_context_t* sc, const struct sockaddr_storage* addr, int loss_rate) { if (!dgram || !sc || !addr) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "Null pointer in ping send"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "Null pointer in ping send"); return -1; } int len = dgram->data_len - dgram->noencrypt_len; if (len < 0 || len > 1472) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "ping packet data invalid len=%d", len); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "ping packet data invalid len=%d", len); return -1; } uint8_t enc_buf[1600]; @@ -906,11 +906,11 @@ static int etcp_send_ping_raw(struct ETCP_DGRAM* dgram, socket_t fd, sc_context_ dgram->flag_up = 1; sc_encrypt(sc, (uint8_t*)&dgram->timestamp, 3 + len, enc_buf, &enc_buf_len); if (enc_buf_len == 0) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "encryption failed for ping"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "encryption failed for ping"); return -1; } if (enc_buf_len + dgram->noencrypt_len > 1472) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "ping packet too long enc=%zu ne=%d", enc_buf_len, dgram->noencrypt_len); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "ping packet too long enc=%zu ne=%d", enc_buf_len, dgram->noencrypt_len); return -1; } memcpy(enc_buf + enc_buf_len, dgram->data + len, dgram->noencrypt_len); @@ -920,13 +920,13 @@ static int etcp_send_ping_raw(struct ETCP_DGRAM* dgram, socket_t fd, sc_context_ if (loss_rate == 0 || rnd >= loss_rate) { sent = socket_sendto(fd, enc_buf, enc_buf_len + dgram->noencrypt_len, (struct sockaddr*)addr, addr_len); } else { - DEBUG_WARN(DEBUG_CATEGORY_CONNECTION, "ping packet dropped by loss_rate (rnd=%d, loss_rate=%d%%)", rnd, loss_rate); + DEBUG_WARN(DEBUG_CATEGORY_BGP, "ping packet dropped by loss_rate (rnd=%d, loss_rate=%d%%)", rnd, loss_rate); } if (sent < 0) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "sendto failed for ping, err=%d", socket_get_error()); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "sendto failed for ping, err=%d", socket_get_error()); return -1; } - DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "ping sendto succeeded, sent=%zd bytes", sent); + DEBUG_TRACE(DEBUG_CATEGORY_BGP, "ping sendto succeeded, sent=%zd bytes", sent); return (int)sent; } @@ -961,16 +961,16 @@ int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET* int timeout_ms, etcp_ping_callback_t cb, void* user_arg, const uint8_t* user_data, size_t user_data_len) { if (!instance || !e_sock || !peer_pubkey_bin || !addr || timeout_ms <= 0 || !cb) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "bad args"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "bad args"); return -1; } if (user_data_len > PACKET_DATA_SIZE - 24 - 2 - SC_PUBKEY_ENC_SIZE) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "user_data too long"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "user_data too long"); return -2; } struct PING_CONTEXT* ctx = u_malloc(sizeof(struct PING_CONTEXT)); if (!ctx) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "malloc ctx"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "malloc ctx"); return -3; } ctx->next = NULL; @@ -986,7 +986,7 @@ int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET* ctx->user_data = u_malloc(user_data_len); if (!ctx->user_data) { u_free(ctx); - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "malloc user_data"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "malloc user_data"); return -3; } memcpy(ctx->user_data, user_data, user_data_len); @@ -996,7 +996,7 @@ int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET* if (!dgram) { if (ctx->user_data) u_free(ctx->user_data); u_free(ctx); - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "malloc dgram"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "malloc dgram"); return -4; } dgram->link = NULL; @@ -1040,7 +1040,7 @@ int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET* last->next = ctx; } ctx->timeout_timer = uasync_set_timeout(instance->ua, timeout_ms * 10, ctx, ping_timeout_cbk); - DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "ping sent nonce=%016llx timeout=%d ulen=%zu", + DEBUG_INFO(DEBUG_CATEGORY_BGP, "ping sent nonce=%016llx timeout=%d ulen=%zu", (unsigned long long)ctx->nonce, timeout_ms, user_data_len); return 0; } @@ -1050,13 +1050,13 @@ int etcp_send_ping(struct UTUN_INSTANCE* instance, const uint8_t* peer_pubkey_bi etcp_ping_callback_t cb, void* user_arg, const uint8_t* user_data, size_t user_data_len) { if (!instance || !peer_pubkey_bin || !addr || timeout_ms <= 0 || !cb) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "bad args"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "bad args"); return -1; } struct ETCP_SOCKET* e_sock = instance->etcp_sockets; while (e_sock && e_sock->local_addr.ss_family != addr->ss_family) e_sock = e_sock->next; if (!e_sock) { - DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "no socket"); + DEBUG_ERROR(DEBUG_CATEGORY_BGP, "no socket"); return -2; } return etcp_send_ping_to_socket(instance, e_sock, peer_pubkey_bin, addr, timeout_ms, diff --git a/src/route_bgp.c b/src/route_bgp.c index aa5b803f..421448b2 100644 --- a/src/route_bgp.c +++ b/src/route_bgp.c @@ -223,7 +223,7 @@ static void route_bgp_receive_cbk(struct ETCP_CONN* from_conn, struct ll_entry* from_conn->log_name, socket_id, info->nat_type == NAT_TYPE_OPEN ? "OPEN" : "RESTRICTED", (info->nat_ip[0]), (info->nat_ip[1]), - (info->nat_ip[2]), (info->nat_ip[3]), ip_to_str(&nat_ip, AF_INET).str, + (info->nat_ip[2]), (info->nat_ip[3]), ip_to_str(&info->nat_ip, AF_INET).str, (unsigned)nat_port); } } else if (subcmd == ROUTE_SUBCMD_NAT_CHECK_REQ) {