Changeset 77857 in vbox for trunk/src/VBox
- Timestamp:
- Mar 23, 2019 5:41:55 PM (6 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MediumImpl.h
r76562 r77857 352 352 static DECLCALLBACK(int) i_vdConfigQuery(void *pvUser, const char *pszName, 353 353 char *pszValue, size_t cchValue); 354 static DECLCALLBACK(int) i_vdTcpSocketCreate(uint32_t fFlags, PVDSOCKET pSock);355 static DECLCALLBACK(int) i_vdTcpSocketDestroy(VDSOCKET Sock);356 static DECLCALLBACK(int) i_vdTcpClientConnect(VDSOCKET Sock, const char *pszAddress, uint32_t uPort,357 RTMSINTERVAL cMillies);358 static DECLCALLBACK(int) i_vdTcpClientClose(VDSOCKET Sock);359 static DECLCALLBACK(bool) i_vdTcpIsClientConnected(VDSOCKET Sock);360 static DECLCALLBACK(int) i_vdTcpSelectOne(VDSOCKET Sock, RTMSINTERVAL cMillies);361 static DECLCALLBACK(int) i_vdTcpRead(VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead);362 static DECLCALLBACK(int) i_vdTcpWrite(VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer);363 static DECLCALLBACK(int) i_vdTcpSgWrite(VDSOCKET Sock, PCRTSGBUF pSgBuf);364 static DECLCALLBACK(int) i_vdTcpFlush(VDSOCKET Sock);365 static DECLCALLBACK(int) i_vdTcpSetSendCoalescing(VDSOCKET Sock, bool fEnable);366 static DECLCALLBACK(int) i_vdTcpGetLocalAddress(VDSOCKET Sock, PRTNETADDR pAddr);367 static DECLCALLBACK(int) i_vdTcpGetPeerAddress(VDSOCKET Sock, PRTNETADDR pAddr);368 354 369 355 static DECLCALLBACK(bool) i_vdCryptoConfigAreKeysValid(void *pvUser, -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r77606 r77857 37 37 #include <iprt/path.h> 38 38 #include <iprt/file.h> 39 #include <iprt/tcp.h>40 39 #include <iprt/cpp/utils.h> 41 40 #include <iprt/memsafer.h> … … 190 189 VDINTERFACECONFIG vdIfConfig; 191 190 192 VDINTERFACETCPNET vdIfTcpNet; 191 /** The handle to the default VD TCP/IP interface. */ 192 VDIFINST hTcpNetInst; 193 193 194 194 PVDINTERFACE vdDiskIfaces; … … 899 899 m->vdIfConfig.pfnQueryBytes = NULL; 900 900 901 /* Initialize the callbacks of the VD TCP interface (we always use the host902 * IP stack for now) */903 m->vdIfTcpNet.pfnSocketCreate = i_vdTcpSocketCreate;904 m->vdIfTcpNet.pfnSocketDestroy = i_vdTcpSocketDestroy;905 m->vdIfTcpNet.pfnClientConnect = i_vdTcpClientConnect;906 m->vdIfTcpNet.pfnClientClose = i_vdTcpClientClose;907 m->vdIfTcpNet.pfnIsClientConnected = i_vdTcpIsClientConnected;908 m->vdIfTcpNet.pfnSelectOne = i_vdTcpSelectOne;909 m->vdIfTcpNet.pfnRead = i_vdTcpRead;910 m->vdIfTcpNet.pfnWrite = i_vdTcpWrite;911 m->vdIfTcpNet.pfnSgWrite = i_vdTcpSgWrite;912 m->vdIfTcpNet.pfnFlush = i_vdTcpFlush;913 m->vdIfTcpNet.pfnSetSendCoalescing = i_vdTcpSetSendCoalescing;914 m->vdIfTcpNet.pfnGetLocalAddress = i_vdTcpGetLocalAddress;915 m->vdIfTcpNet.pfnGetPeerAddress = i_vdTcpGetPeerAddress;916 m->vdIfTcpNet.pfnSelectOneEx = NULL;917 m->vdIfTcpNet.pfnPoke = NULL;918 919 901 /* Initialize the per-disk interface chain (could be done more globally, 920 902 * but it's not wasting much time or space so it's not worth it). */ … … 933 915 AssertRCReturn(vrc, E_FAIL); 934 916 935 vrc = VDInterfaceAdd(&m->vdIfTcpNet.Core, 936 "Medium::vdInterfaceTcpNet", 937 VDINTERFACETYPE_TCPNET, this, 938 sizeof(VDINTERFACETCPNET), &m->vdImageIfaces); 917 /* Initialize the callbacks of the VD TCP interface (we always use the host 918 * IP stack for now) */ 919 vrc = VDIfTcpNetInstDefaultCreate(&m->hTcpNetInst, &m->vdImageIfaces); 939 920 AssertRCReturn(vrc, E_FAIL); 940 921 … … 946 927 uninit(); 947 928 929 VDIfTcpNetInstDefaultDestroy(m->hTcpNetInst); 948 930 delete m; 949 931 … … 8022 8004 8023 8005 return VINF_SUCCESS; 8024 }8025 8026 DECLCALLBACK(int) Medium::i_vdTcpSocketCreate(uint32_t fFlags, PVDSOCKET pSock)8027 {8028 PVDSOCKETINT pSocketInt = NULL;8029 8030 if ((fFlags & VD_INTERFACETCPNET_CONNECT_EXTENDED_SELECT) != 0)8031 return VERR_NOT_SUPPORTED;8032 8033 pSocketInt = (PVDSOCKETINT)RTMemAllocZ(sizeof(VDSOCKETINT));8034 if (!pSocketInt)8035 return VERR_NO_MEMORY;8036 8037 pSocketInt->hSocket = NIL_RTSOCKET;8038 *pSock = pSocketInt;8039 return VINF_SUCCESS;8040 }8041 8042 DECLCALLBACK(int) Medium::i_vdTcpSocketDestroy(VDSOCKET Sock)8043 {8044 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8045 8046 if (pSocketInt->hSocket != NIL_RTSOCKET)8047 RTTcpClientCloseEx(pSocketInt->hSocket, false /*fGracefulShutdown*/);8048 8049 RTMemFree(pSocketInt);8050 8051 return VINF_SUCCESS;8052 }8053 8054 DECLCALLBACK(int) Medium::i_vdTcpClientConnect(VDSOCKET Sock, const char *pszAddress, uint32_t uPort,8055 RTMSINTERVAL cMillies)8056 {8057 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8058 8059 return RTTcpClientConnectEx(pszAddress, uPort, &pSocketInt->hSocket, cMillies, NULL);8060 }8061 8062 DECLCALLBACK(int) Medium::i_vdTcpClientClose(VDSOCKET Sock)8063 {8064 int rc = VINF_SUCCESS;8065 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8066 8067 rc = RTTcpClientCloseEx(pSocketInt->hSocket, false /*fGracefulShutdown*/);8068 pSocketInt->hSocket = NIL_RTSOCKET;8069 return rc;8070 }8071 8072 DECLCALLBACK(bool) Medium::i_vdTcpIsClientConnected(VDSOCKET Sock)8073 {8074 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8075 return pSocketInt->hSocket != NIL_RTSOCKET;8076 }8077 8078 DECLCALLBACK(int) Medium::i_vdTcpSelectOne(VDSOCKET Sock, RTMSINTERVAL cMillies)8079 {8080 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8081 return RTTcpSelectOne(pSocketInt->hSocket, cMillies);8082 }8083 8084 DECLCALLBACK(int) Medium::i_vdTcpRead(VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead)8085 {8086 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8087 return RTTcpRead(pSocketInt->hSocket, pvBuffer, cbBuffer, pcbRead);8088 }8089 8090 DECLCALLBACK(int) Medium::i_vdTcpWrite(VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer)8091 {8092 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8093 return RTTcpWrite(pSocketInt->hSocket, pvBuffer, cbBuffer);8094 }8095 8096 DECLCALLBACK(int) Medium::i_vdTcpSgWrite(VDSOCKET Sock, PCRTSGBUF pSgBuf)8097 {8098 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8099 return RTTcpSgWrite(pSocketInt->hSocket, pSgBuf);8100 }8101 8102 DECLCALLBACK(int) Medium::i_vdTcpFlush(VDSOCKET Sock)8103 {8104 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8105 return RTTcpFlush(pSocketInt->hSocket);8106 }8107 8108 DECLCALLBACK(int) Medium::i_vdTcpSetSendCoalescing(VDSOCKET Sock, bool fEnable)8109 {8110 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8111 return RTTcpSetSendCoalescing(pSocketInt->hSocket, fEnable);8112 }8113 8114 DECLCALLBACK(int) Medium::i_vdTcpGetLocalAddress(VDSOCKET Sock, PRTNETADDR pAddr)8115 {8116 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8117 return RTTcpGetLocalAddress(pSocketInt->hSocket, pAddr);8118 }8119 8120 DECLCALLBACK(int) Medium::i_vdTcpGetPeerAddress(VDSOCKET Sock, PRTNETADDR pAddr)8121 {8122 PVDSOCKETINT pSocketInt = (PVDSOCKETINT)Sock;8123 return RTTcpGetPeerAddress(pSocketInt->hSocket, pAddr);8124 8006 } 8125 8007
Note:
See TracChangeset
for help on using the changeset viewer.