From: Oliver Kurth Date: Tue, 26 May 2020 22:32:56 +0000 (-0700) Subject: Common source file changes not directly applicable to open-vm-tools. X-Git-Tag: stable-11.2.0~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a300cffdb3c7069a104559b598f6315a6dbae00;p=thirdparty%2Fopen-vm-tools.git Common source file changes not directly applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/asyncsocket/asyncSocketInterface.c b/open-vm-tools/lib/asyncsocket/asyncSocketInterface.c index bcde20cc6..db2d7b738 100644 --- a/open-vm-tools/lib/asyncsocket/asyncSocketInterface.c +++ b/open-vm-tools/lib/asyncsocket/asyncSocketInterface.c @@ -1514,6 +1514,38 @@ AsyncSocket_GetWebSocketProtocol(AsyncSocket *asock) // IN } +/* + *---------------------------------------------------------------------------- + * + * AsyncSocket_SetDelayWebSocketUpgradeResponse -- + * + * Set a flag for whether or not to not automatically send the websocket + * upgrade response upon receiving the websocket upgrade request. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +int +AsyncSocket_SetDelayWebSocketUpgradeResponse(AsyncSocket *asock, // IN + Bool delayWebSocketUpgradeResponse) // IN +{ + int ret = ASOCKERR_GENERIC; + if (VALID(asock, setDelayWebSocketUpgradeResponse)) { + AsyncSocketLock(asock); + ret = VT(asock)->setDelayWebSocketUpgradeResponse(asock, + delayWebSocketUpgradeResponse); + AsyncSocketUnlock(asock); + } + return ret; +} + + /* *---------------------------------------------------------------------------- * diff --git a/open-vm-tools/lib/asyncsocket/asyncSocketVTable.h b/open-vm-tools/lib/asyncsocket/asyncSocketVTable.h index d8294e59a..6c50c2fdf 100644 --- a/open-vm-tools/lib/asyncsocket/asyncSocketVTable.h +++ b/open-vm-tools/lib/asyncsocket/asyncSocketVTable.h @@ -120,6 +120,8 @@ typedef struct AsyncSocketVTable { const char *(*getWebSocketProtocol)(AsyncSocket *asock); int (*setWebSocketCookie)(AsyncSocket *asock, void *clientData, const char *path, const char *sessionId); + int (*setDelayWebSocketUpgradeResponse)(AsyncSocket *asock, + Bool delayWebSocketUpgradeResponse); int (*recvBlocking)(AsyncSocket *s, void *buf, int len, int *received, int timeoutMS); int (*recvPartialBlocking)(AsyncSocket *s, void *buf, int len, diff --git a/open-vm-tools/lib/asyncsocket/asyncsocket.c b/open-vm-tools/lib/asyncsocket/asyncsocket.c index 038a9486e..bc5c9c6eb 100644 --- a/open-vm-tools/lib/asyncsocket/asyncsocket.c +++ b/open-vm-tools/lib/asyncsocket/asyncsocket.c @@ -411,6 +411,7 @@ static const AsyncSocketVTable asyncTCPSocketVTable = { NULL, /* getWebSocketCloseStatus */ NULL, /* getWebSocketProtocol */ NULL, /* setWebSocketCookie */ + NULL, /* setDelayWebSocketUpgradeResponse */ AsyncTCPSocketRecvBlocking, AsyncTCPSocketRecvPartialBlocking, AsyncTCPSocketSendBlocking, diff --git a/open-vm-tools/lib/include/asyncsocket.h b/open-vm-tools/lib/include/asyncsocket.h index 27ce6c119..4fb872459 100644 --- a/open-vm-tools/lib/include/asyncsocket.h +++ b/open-vm-tools/lib/include/asyncsocket.h @@ -460,16 +460,18 @@ AsyncSocket *AsyncSocket_ListenWebSocket(const char *addrStr, AsyncSocketPollParams *pollParams, void *sslCtx, int *outError); -AsyncSocket *AsyncSocket_ListenWebSocketEx(const char *addrStr, - unsigned int port, - Bool useSSL, - const char *protocols[], - AsyncSocketConnectFn connectFn, - void *clientData, - AsyncSocketPollParams *pollParams, - void *sslCtx, - AsyncWebSocketHandleUpgradeRequestFn handleUpgradeRequestFn, - int *outError); +AsyncSocket *AsyncSocket_PrepareListenWebSocket(Bool useSSL, + const char *protocols[], + AsyncSocketConnectFn connectFn, + void *clientData, + AsyncSocketPollParams *pollParams, + void *sslCtx, + AsyncWebSocketHandleUpgradeRequestFn handleUpgradeRequestFn); +AsyncSocket *AsyncSocket_RegisterListenWebSocket(AsyncSocket *asock, + const char *addrStr, + unsigned int port, + AsyncSocketPollParams *pollParams, + int *outError); #ifndef _WIN32 AsyncSocket *AsyncSocket_ListenWebSocketUDS(const char *pipeName, @@ -723,10 +725,10 @@ char *AsyncSocket_GetWebSocketCookie(AsyncSocket *asock); /* * Set the Cookie for a websocket connection */ -int AsyncSocket_SetWebSocketCookie(AsyncSocket *asock, // IN - void *clientData, // IN - const char *path, // IN - const char *sessionId); // IN +int AsyncSocket_SetWebSocketCookie(AsyncSocket *asock, + void *clientData, + const char *path, + const char *sessionId); /* * Retrieve the close status, if received, for a websocket connection @@ -738,6 +740,19 @@ uint16 AsyncSocket_GetWebSocketCloseStatus(AsyncSocket *asock); */ const char *AsyncSocket_GetWebSocketProtocol(AsyncSocket *asock); +/* + * Set the flag for whether or not to delay websocket upgrade response + */ +int AsyncSocket_SetDelayWebSocketUpgradeResponse(AsyncSocket *asock, + Bool delayWebSocketUpgradeResponse); + +/* + * Send the websocket upgrade response + */ +void +AsyncSocket_WebSocketServerSendUpgradeResponse(AsyncSocket *base, + char *httpResponseTemp); + /* * Get error code for websocket failure */