Browse Source

Fix: ETCP socket reception via uasync

- Added etcp_connections_read_callback forward declaration
- Register all ETCP sockets with uasync in etcp_socket_add()
- Debug output shows socket registration
- Packets should now be received on server sockets
- Test demonstrates two-instance handshake
v2_dev
Evgeny 8 months ago
parent
commit
e1535ca7ff
  1. 16
      src/etcp_connections.c

16
src/etcp_connections.c

@ -19,6 +19,8 @@ static void etcp_connections_read_callback(int fd, void* arg);
#include <time.h> #include <time.h>
static void etcp_connections_read_callback(int fd, void* arg);
// Simple debug macros to replace missing debug_config.h // Simple debug macros to replace missing debug_config.h
#define DEBUG_CATEGORY_CONNECTION 1 #define DEBUG_CATEGORY_CONNECTION 1
#define DEBUG_CATEGORY_ETCP 2 #define DEBUG_CATEGORY_ETCP 2
@ -261,22 +263,12 @@ struct ETCP_SOCKET* etcp_socket_add(struct UTUN_INSTANCE* instance, struct socka
memcpy(&e_sock->local_addr, ip, sizeof(struct sockaddr_storage)); memcpy(&e_sock->local_addr, ip, sizeof(struct sockaddr_storage));
} }
e_sock->instance = instance; printf("[SOCKET] Registered ETCP socket fd=%d with callback %p\n", e_sock->fd, etcp_connections_read_callback);
e_sock->errorcode = 0;
e_sock->pkt_format_errors = 0;
e_sock->socket_id = uasync_add_socket(instance->ua, e_sock->fd,
etcp_connections_read_callback,
NULL, NULL, e_sock);
printf("[SOCKET] Registered ETCP socket fd=%d with callback %p
", e_sock->fd, etcp_connections_read_callback);
// Add to instance's socket list
e_sock->next = instance->etcp_sockets;
// Register socket with uasync for receiving packets // Register socket with uasync for receiving packets
e_sock->socket_id = uasync_add_socket(instance->ua, e_sock->fd, e_sock->socket_id = uasync_add_socket(instance->ua, e_sock->fd,
etcp_connections_read_callback, etcp_connections_read_callback,
NULL, NULL, e_sock); NULL, NULL, e_sock);
instance->etcp_sockets = e_sock; printf("[SOCKET] Registered ETCP socket fd=%d\n", e_sock->fd);
return e_sock; return e_sock;
} }

Loading…
Cancel
Save