|
|
|
@ -767,6 +767,23 @@ static void send_conn_list(struct control_server* server, struct control_client* |
|
|
|
static void send_socket_list(struct control_server* server, struct control_client* client, uint8_t seq_id) { |
|
|
|
static void send_socket_list(struct control_server* server, struct control_client* client, uint8_t seq_id) { |
|
|
|
struct UTUN_INSTANCE* instance = server->instance; |
|
|
|
struct UTUN_INSTANCE* instance = server->instance; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!instance || !instance->etcp_sockets) { |
|
|
|
|
|
|
|
uint16_t rsp_size = ETCPMON_SOCKET_LIST_SIZE(0); |
|
|
|
|
|
|
|
uint8_t* buffer = (uint8_t*)u_malloc(rsp_size); |
|
|
|
|
|
|
|
if (!buffer) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct etcpmon_msg_header* hdr = (struct etcpmon_msg_header*)buffer; |
|
|
|
|
|
|
|
etcpmon_build_header(hdr, sizeof(struct etcpmon_rsp_socket_list), |
|
|
|
|
|
|
|
ETCPMON_RSP_SOCKET_LIST, seq_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct etcpmon_rsp_socket_list* rsp = (struct etcpmon_rsp_socket_list*)(buffer + sizeof(*hdr)); |
|
|
|
|
|
|
|
rsp->count = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
send(client->fd, buffer, rsp_size, 0); |
|
|
|
|
|
|
|
u_free(buffer); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint8_t count = 0; |
|
|
|
uint8_t count = 0; |
|
|
|
struct ETCP_SOCKET* sock = instance->etcp_sockets; |
|
|
|
struct ETCP_SOCKET* sock = instance->etcp_sockets; |
|
|
|
while (sock && count < ETCPMON_MAX_CONNECTIONS) { |
|
|
|
while (sock && count < ETCPMON_MAX_CONNECTIONS) { |
|
|
|
@ -774,6 +791,8 @@ static void send_socket_list(struct control_server* server, struct control_clien |
|
|
|
sock = sock->next; |
|
|
|
sock = sock->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (count > ETCPMON_MAX_CONNECTIONS) count = ETCPMON_MAX_CONNECTIONS; |
|
|
|
|
|
|
|
|
|
|
|
uint16_t rsp_size = ETCPMON_SOCKET_LIST_SIZE(count); |
|
|
|
uint16_t rsp_size = ETCPMON_SOCKET_LIST_SIZE(count); |
|
|
|
uint8_t* buffer = (uint8_t*)u_malloc(rsp_size); |
|
|
|
uint8_t* buffer = (uint8_t*)u_malloc(rsp_size); |
|
|
|
if (!buffer) { |
|
|
|
if (!buffer) { |
|
|
|
|