- Fixed incorrect init_connections() call in test_etcp_simple_traffic.c (was calling server_instance instead of client_instance) - Fixed double free in timeout_heap_pop() when handling deleted elements - Enhanced NULL pointer safety in uasync_print_resources() by removing complex heap manipulation - Added debug logging to timeout_heap_pop() for better error tracking Test results: test_etcp_simple_traffic now passes without double free errors
42 lines
1.4 KiB
C
Executable File
42 lines
1.4 KiB
C
Executable File
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <arpa/inet.h>
|
|
#include <netinet/in.h>
|
|
|
|
// Packet dump function for debugging
|
|
static void dump_packet(const char* direction, const uint8_t* data, size_t len, struct sockaddr_storage* addr) {
|
|
printf("[DUMP] %s packet: %zd bytes ", direction, len);
|
|
|
|
// Print address if provided
|
|
if (addr) {
|
|
if (addr->ss_family == AF_INET) {
|
|
struct sockaddr_in* sin = (struct sockaddr_in*)addr;
|
|
printf("to/from %s:%d ",
|
|
inet_ntoa(sin->sin_addr),
|
|
ntohs(sin->sin_port));
|
|
}
|
|
}
|
|
|
|
// Print first 64 bytes
|
|
printf("data: ");
|
|
for (size_t i = 0; i < len && i < 64; i++) {
|
|
printf("%02x", data[i]);
|
|
if (i % 4 == 3) printf(" ");
|
|
}
|
|
if (len > 64) printf("...");
|
|
|
|
// If it's INIT packet, parse fields
|
|
if (len > 0 && data[0] == 0x02) { // ETCP_INIT_REQUEST
|
|
if (len >= 15) { // Minimum INIT size: code(1) + node_id(8) + mtu(2) + keepalive(2) + pubkey(2 at least)
|
|
uint64_t node_id = 0;
|
|
memcpy(&node_id, data + 1, 8);
|
|
uint16_t mtu = (data[9] << 8) | data[10];
|
|
uint16_t keepalive = (data[11] << 8) | data[12];
|
|
printf(" | INIT: node_id=%llu mtu=%d keepalive=%d",
|
|
(unsigned long long)node_id, mtu, keepalive);
|
|
}
|
|
}
|
|
|
|
printf("\n");
|
|
} |