keepalive handshake: device_type + keepalive negotiation in UDP/TCP INIT
- Добавлен device_type (1 байт, CLIENT_TYPE_*) в INIT_REQUEST и INIT_RESPONSE - Добавлен keepalive_interval (2 байта) в INIT_RESPONSE - STCP handshake расширен с 43 до 46 байт (device_type+keepalive) - negotiate_keepalive(): оба desktop/server → min, иначе (есть mobile) → max - keepalive_interval вынесен в UTUN_INSTANCE для использования в handshake - stcp_client_connect() принимает device_type и keepalive_interval - peer_device_type/peer_keepalive_interval передаются через stcp_link в ETCP_LINK
This commit is contained in:
1 parent
43aca4a41b
commit
0f1bd3d120
37 files changed
+535
-309
No files matched your search
@@ -410,8 +410,9 @@ static void remove_iface_sockets(struct AUTO_SOCKET* as, uint32_t ifindex) {
|
||||
if (ifa->v4_tcp) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_AS, "[as] removing v4 TCP socket ifidx=%u", ifindex);
|
||||
{ uint16_t v4_port = load_port_from_db(as, ifname, AF_INET, AS_PROTO_TCP);
|
||||
struct ETCP_SOCKET** tsp = &as->instance->tcp_sockets;
|
||||
struct ETCP_SOCKET** tsp = &as->instance->etcp_sockets;
|
||||
while (*tsp) {
|
||||
if (!(*tsp)->is_tcp) { tsp = &(*tsp)->next; continue; }
|
||||
uint16_t tsp_port = 0;
|
||||
const struct sockaddr_storage* addr = (*tsp)->interface_addr.ss_family ? &(*tsp)->interface_addr : &(*tsp)->local_addr;
|
||||
if (addr->ss_family == AF_INET) tsp_port = ntohs(((struct sockaddr_in*)addr)->sin_port);
|
||||
@@ -426,8 +427,9 @@ static void remove_iface_sockets(struct AUTO_SOCKET* as, uint32_t ifindex) {
|
||||
if (ifa->v6_tcp) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_AS, "[as] removing v6 TCP socket ifidx=%u", ifindex);
|
||||
{ uint16_t v6_port = load_port_from_db(as, ifname, AF_INET6, AS_PROTO_TCP);
|
||||
struct ETCP_SOCKET** tsp = &as->instance->tcp_sockets;
|
||||
struct ETCP_SOCKET** tsp = &as->instance->etcp_sockets;
|
||||
while (*tsp) {
|
||||
if (!(*tsp)->is_tcp) { tsp = &(*tsp)->next; continue; }
|
||||
uint16_t tsp_port = 0;
|
||||
const struct sockaddr_storage* addr = (*tsp)->interface_addr.ss_family ? &(*tsp)->interface_addr : &(*tsp)->local_addr;
|
||||
if (addr->ss_family == AF_INET6) tsp_port = ntohs(((struct sockaddr_in6*)addr)->sin6_port);
|
||||
@@ -708,8 +710,8 @@ static void reconcile_iface(struct AUTO_SOCKET* as, uint32_t ifindex, const char
|
||||
DEBUG_INFO(DEBUG_CATEGORY_AS, "[as] v4 TCP removed: %s ifidx=%u", ifname, ifindex);
|
||||
{ char buf[IFNAMSIZ]; const char* nm = if_indextoname(ifindex, buf) ? buf : ifname;
|
||||
uint16_t p = load_port_from_db(as, nm, AF_INET, AS_PROTO_TCP);
|
||||
struct ETCP_SOCKET** tsp = &as->instance->tcp_sockets;
|
||||
while (*tsp) { uint16_t tp = 0; const struct sockaddr_storage* a = (*tsp)->interface_addr.ss_family ? &(*tsp)->interface_addr : &(*tsp)->local_addr;
|
||||
struct ETCP_SOCKET** tsp = &as->instance->etcp_sockets;
|
||||
while (*tsp) { if (!(*tsp)->is_tcp) { tsp = &(*tsp)->next; continue; } uint16_t tp = 0; const struct sockaddr_storage* a = (*tsp)->interface_addr.ss_family ? &(*tsp)->interface_addr : &(*tsp)->local_addr;
|
||||
if (a->ss_family == AF_INET) tp = ntohs(((struct sockaddr_in*)a)->sin_port);
|
||||
if (tp == p && p > 0) { struct ETCP_SOCKET* rm = *tsp; *tsp = rm->next; u_free(rm); break; } tsp = &(*tsp)->next; }
|
||||
}
|
||||
@@ -731,8 +733,8 @@ static void reconcile_iface(struct AUTO_SOCKET* as, uint32_t ifindex, const char
|
||||
DEBUG_INFO(DEBUG_CATEGORY_AS, "[as] v6 TCP removed: %s ifidx=%u", ifname, ifindex);
|
||||
{ char buf[IFNAMSIZ]; const char* nm = if_indextoname(ifindex, buf) ? buf : ifname;
|
||||
uint16_t p = load_port_from_db(as, nm, AF_INET6, AS_PROTO_TCP);
|
||||
struct ETCP_SOCKET** tsp = &as->instance->tcp_sockets;
|
||||
while (*tsp) { uint16_t tp = 0; const struct sockaddr_storage* a = (*tsp)->interface_addr.ss_family ? &(*tsp)->interface_addr : &(*tsp)->local_addr;
|
||||
struct ETCP_SOCKET** tsp = &as->instance->etcp_sockets;
|
||||
while (*tsp) { if (!(*tsp)->is_tcp) { tsp = &(*tsp)->next; continue; } uint16_t tp = 0; const struct sockaddr_storage* a = (*tsp)->interface_addr.ss_family ? &(*tsp)->interface_addr : &(*tsp)->local_addr;
|
||||
if (a->ss_family == AF_INET6) tp = ntohs(((struct sockaddr_in6*)a)->sin6_port);
|
||||
if (tp == p && p > 0) { struct ETCP_SOCKET* rm = *tsp; *tsp = rm->next; u_free(rm); break; } tsp = &(*tsp)->next; }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user