Implements the accept/close logic for vsock

master
Justin Terry (VM) 7 years ago committed by jsorg71
parent 929a7c359d
commit d7d14d7462

@ -669,6 +669,9 @@ g_sck_close(int sck)
struct sockaddr_in sock_addr_in; struct sockaddr_in sock_addr_in;
#if defined(XRDP_ENABLE_IPV6) #if defined(XRDP_ENABLE_IPV6)
struct sockaddr_in6 sock_addr_in6; struct sockaddr_in6 sock_addr_in6;
#endif
#if defined(XRDP_ENABLE_VSOCK)
struct sockaddr_vm sock_addr_vm;
#endif #endif
} sock_info; } sock_info;
socklen_t sock_len = sizeof(sock_info); socklen_t sock_len = sizeof(sock_info);
@ -709,6 +712,22 @@ g_sck_close(int sck)
g_snprintf(sockname, sizeof(sockname), "AF_UNIX"); g_snprintf(sockname, sizeof(sockname), "AF_UNIX");
break; break;
#if defined(XRDP_ENABLE_VSOCK)
case AF_VSOCK:
{
struct sockaddr_vm *sock_addr_vm = &sock_info.sock_addr_vm;
g_snprintf(sockname,
sizeof(sockname),
"AF_VSOCK cid %d port %d",
sock_addr_vm->svm_cid,
sock_addr_vm->svm_port);
break;
}
#endif
default: default:
g_snprintf(sockname, sizeof(sockname), "unknown family %d", g_snprintf(sockname, sizeof(sockname), "unknown family %d",
sock_info.sock_addr.sa_family); sock_info.sock_addr.sa_family);
@ -1258,6 +1277,9 @@ g_sck_accept(int sck, char *addr, int addr_bytes, char *port, int port_bytes)
struct sockaddr_in6 sock_addr_in6; struct sockaddr_in6 sock_addr_in6;
#endif #endif
struct sockaddr_un sock_addr_un; struct sockaddr_un sock_addr_un;
#if defined(XRDP_ENABLE_VSOCK)
struct sockaddr_vm sock_addr_vm;
#endif
} sock_info; } sock_info;
socklen_t sock_len = sizeof(sock_info); socklen_t sock_len = sizeof(sock_info);
@ -1305,6 +1327,26 @@ g_sck_accept(int sck, char *addr, int addr_bytes, char *port, int port_bytes)
g_snprintf(msg, sizeof(msg), "AF_UNIX connection received"); g_snprintf(msg, sizeof(msg), "AF_UNIX connection received");
break; break;
} }
#if defined(XRDP_ENABLE_VSOCK)
case AF_VSOCK:
{
struct sockaddr_vm *sock_addr_vm = &sock_info.sock_addr_vm;
g_snprintf(addr, addr_bytes - 1, "%d", sock_addr_vm->svm_cid);
g_snprintf(port, addr_bytes - 1, "%d", sock_addr_vm->svm_port);
g_snprintf(msg,
sizeof(msg),
"AF_VSOCK connection received from cid: %s port: %s",
addr,
port);
break;
}
#endif
default: default:
{ {
g_strncpy(addr, "", addr_bytes - 1); g_strncpy(addr, "", addr_bytes - 1);

Loading…
Cancel
Save