VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_net.h@ 79241

Last change on this file since 79241 was 78190, checked in by vboxsync, 6 years ago

Merge first stage of the Chromium cleanup from the branch:

  • r129818 (Remove VBOX_WITH_CR_DISPLAY_LISTS and accompanying code as it was disabled since r108676 and was never brought back (see ​bugref:3456 and ​bugref:8485))
  • r129819 (HostServices/SharedOpenGL: Remove unused main entry point from upstream server process based implementation)
  • r129820 (HostServices/SharedOpenGL: Started eliminating all backends other than HGCM. They are not used and probably wouldn't work anymore anyway)
  • r129821 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crTimer* API as it is not used anywhere)
  • r129822 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill most from cr_process.h apart from two used methods)
  • r129823 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crList* API as it is unused)
  • r129824 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crHullInteriorBox API as it is unused)
  • r129825 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crWarpPoint API as it is unused)
  • r129826 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill CrSa* API as it is unused and not even compiled in)
  • r129827 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill cr_bbox.h as it is unused)
  • r129828 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove a few crParseUrl() two uses)
  • r129829 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove last crParseURL() use)
  • r129830 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove crParseURL())
  • r129831 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove VBOX_WITH_COCOA_QT and related code when not set as it is the default for years now and we don't support anything else anymore)
  • r129832 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_logo.h)
  • r129833 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused crut_api.h and crut_clientapi.h)
  • r129834 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_dmx.h)
  • r129835 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_perf.h)
  • r129836 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove cr_rand.h and friends as it is not actively used anywhere)
  • r129837 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of all the swapped versions in the packer SPU, we never change endianess from guest to host and don't need it)
  • r129838 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129839 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129840 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused pack_pica.c)
  • r129841 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129842 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_endianess.h and friends)
  • r129843 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused lowercase.py)
  • r129844 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_calllists.h and friends)
  • r129845 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of completely unused idpool.c, not even compiled in)
  • r129846 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_debugopcodes.h and friends)
  • r129847 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the cr_mem.h API inline and get rid of the implementation in the util library)
  • r129848 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of SPUOptions and related code as it is of no use for us)
  • r129849 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_environment.h and friends and convert usage to RTEnv* APIs)
  • r129850 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused renderspu_agl.c)
  • r129851 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused code in cr_htable.h)
  • r129853 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Introduce a state paremeter for the unpacker workers instead of reyling on global variables, work in progress)
  • r129854 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Let the caller of crUnpack set up the initial state. This allows to get rid of the global return_ptr and writeback_ptr as they get supplied in the unpacker state by the server)
  • r129855 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the cr_lastDispatch and cr_unpackDispatch as they are of no use now)
  • r129856 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the global cr_unpackData and cr_unpackDataEnd symbols by indtroducing another hack to make it possible for certail server dispatch callbacks to access the data buffer)
  • r129857 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: build fix for release builds)
  • r129858 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the pointer to the unpacker state non const (is required for the access verification))
  • r129859 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: First iteration of the buffer size validation to prevent out of bound read access + added todos for places where additional checks are needed)
  • r129860 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129861 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129871 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129872 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Stop as soon as the unpacker encountered an error)
  • r129876 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129880 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129882 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Fixed some offsets in unpack_texture.c, 3DMark03 renders correctly again)
  • r130013 (HostServices/SharedOpenGL: Convert files to C++ so we can use C99 featuers on Windows with cl.exe)
  • r130014 (HostServices/SharedOpenGL,GuestHost/OpenGL: WIndows build fixes)
  • r130015 (HostServices/SharedOpenGL,GuestHost/OpenGL: More Windows build fixes)
  • r130036 (Config.kmk: Fix linker error on Windows by temporarily disabling the use of VBoxGuestR3DllMinW2K)
  • r130094 (src/VBox/GuestHost/OpenGL: Revert inlining the allocation/free functions in R3 completely as it doesn't work on Windows if memory is allocated and freed across different DLLs which don't share a common CRT, causes crashes in RtlValidtaeHeap())
  • r130095 (src/VBox/GuestHost/OpenGL,src/VBox/Additions/common/crOpenGL/pack: Don't use floating point specifiers in packspu_GetString() to avoid R6002 errors (couldn't fully understand why they occur suddenly after the rework but this gets rid of it))
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 8.9 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved.
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#ifndef CR_NET_H
8#define CR_NET_H
9
10#ifdef RT_OS_WINDOWS
11# include <iprt/win/winsock.h>
12#endif
13
14#include "cr_protocol.h"
15#include "cr_threads.h"
16
17#include <iprt/types.h>
18#include <iprt/thread.h>
19#include <iprt/list.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25typedef struct CRConnection CRConnection;
26
27typedef enum {
28 CR_NO_CONNECTION,
29 CR_VBOXHGCM,
30 CR_DROP_PACKETS
31} CRConnectionType;
32
33typedef void (*CRVoidFunc)( void );
34typedef int (*CRNetReceiveFunc)( CRConnection *conn, CRMessage *msg, unsigned int len );
35typedef int (*CRNetConnectFunc)( CRConnection *conn );
36typedef void (*CRNetCloseFunc)( unsigned int sender_id );
37
38typedef struct __recvFuncList {
39 CRNetReceiveFunc recv;
40 struct __recvFuncList *next;
41} CRNetReceiveFuncList;
42
43typedef struct __closeFuncList {
44 CRNetCloseFunc close;
45 struct __closeFuncList *next;
46} CRNetCloseFuncList;
47
48typedef struct __messageListNode {
49 CRMessage *mesg; /* the actual message (header + payload) */
50 unsigned int len; /* length of message (header + payload) */
51 CRConnection *conn; /* some messages are assoc. with specific connections*/
52 struct __messageListNode *next; /* next in list */
53} CRMessageListNode;
54
55typedef struct {
56 CRMessageListNode *head, *tail;
57 int numMessages;
58 CRmutex lock;
59 CRcondition nonEmpty;
60} CRMessageList;
61
62
63/**
64 * Used to accumulate CR_MESSAGE_MULTI_BODY/TAIL chunks into one big buffer.
65 */
66typedef struct CRMultiBuffer {
67 unsigned int len; /* current length (<= max) (with sizeof_buffer_header) */
68 unsigned int max; /* size in bytes of data buffer */
69 void *buf; /* data buffer */
70} CRMultiBuffer;
71
72#ifdef VBOX_WITH_CRHGSMI
73# ifdef IN_GUEST
74typedef struct CRVBOXHGSMI_CLIENT {
75 struct VBOXUHGSMI *pHgsmi;
76 struct VBOXUHGSMI_BUFFER *pCmdBuffer;
77 struct VBOXUHGSMI_BUFFER *pHGBuffer;
78 void *pvHGBuffer;
79 struct CRBufferPool_t *bufpool;
80} CRVBOXHGSMI_CLIENT, *PCRVBOXHGSMI_CLIENT;
81#endif /* IN_GUEST */
82#endif /* #ifdef VBOX_WITH_CRHGSMI */
83/**
84 * Chromium network connection (bidirectional).
85 */
86struct CRConnection {
87 int ignore;
88 CRConnectionType type;
89 unsigned int id; /* obtained from the mothership (if brokered) */
90
91 /* List of messages that we've received on the network connection but
92 * nobody has yet consumed.
93 */
94 CRMessageList messageList;
95
96 CRMultiBuffer multi;
97
98 unsigned int mtu; /* max transmission unit size (in bytes) */
99 unsigned int buffer_size;
100 unsigned int krecv_buf_size;
101 int broker; /* is connection brokered through mothership? */
102 int threaded; /* is this a threaded connection? */
103 int swap;
104 int actual_network; /* is this a real network? */
105
106 unsigned char *userbuf;
107 int userbuf_len;
108
109 /* To allocate a data buffer of size conn->buffer_size bytes */
110 void *(*Alloc)( CRConnection *conn );
111 /* To indicate the client's done with a data buffer */
112 void (*Free)( CRConnection *conn, void *buf );
113 /* To send a data buffer. If bufp is non-null, it must have been obtained
114 * from Alloc() and it'll be freed when Send() returns.
115 */
116 void (*Send)( CRConnection *conn, void **buf, const void *start, unsigned int len );
117 /* To send a data buffer than can optionally be dropped on the floor */
118 void (*Barf)( CRConnection *conn, void **buf, const void *start, unsigned int len );
119 /* To send 'len' bytes from buffer at 'start', no funny business */
120 void (*SendExact)( CRConnection *conn, const void *start, unsigned int len );
121 /* To receive data. 'len' bytes will be placed into 'buf'. */
122 void (*Recv)( CRConnection *conn, void *buf, unsigned int len );
123 /* To receive one message on the connection */
124 void (*RecvMsg)( CRConnection *conn );
125 /* What's this??? */
126 void (*InstantReclaim)( CRConnection *conn, CRMessage *mess );
127 /* Called when a full CR_MESSAGE_MULTI_HEAD/TAIL message has been received */
128 void (*HandleNewMessage)( CRConnection *conn, CRMessage *mess, unsigned int len );
129 /* To accept a new connection from a client */
130 void (*Accept)( CRConnection *conn);
131 /* To connect to a server (return 0 if error, 1 if success) */
132 int (*Connect)( CRConnection *conn );
133 /* To disconnect from a server */
134 void (*Disconnect)( CRConnection *conn );
135
136 unsigned int sizeof_buffer_header;
137
138 /* logging */
139 int total_bytes_sent;
140 int total_bytes_recv;
141 int recv_count;
142 int opcodes_count;
143
144 /* credits for flow control */
145 int send_credits;
146 int recv_credits;
147
148 /* VBox HGCM */
149 int index;
150 uint32_t u32ClientID;
151 uint8_t *pBuffer;
152 uint32_t cbBuffer;
153 uint8_t *pHostBuffer;
154 uint32_t cbHostBufferAllocated;
155 uint32_t cbHostBuffer;
156#ifdef IN_GUEST
157 uint32_t u32InjectClientID;
158# ifdef VBOX_WITH_CRHGSMI
159 CRVBOXHGSMI_CLIENT HgsmiClient;
160 struct VBOXUHGSMI *pExternalHgsmi;
161# endif
162#else
163# ifdef VBOX_WITH_CRHGSMI
164 struct _crclient *pClient; /* back reference, just for simplicity */
165 CRVBOXHGSMI_CMDDATA CmdData;
166# endif
167 RTLISTANCHOR PendingMsgList;
168#endif
169 /* Used on host side to indicate that we are not allowed to store above pointers for later use
170 * in crVBoxHGCMReceiveMessage. As those messages are going to be processed after the corresponding
171 * HGCM call is finished and memory is freed. So we have to store a copy.
172 * This happens when message processing for client associated with this connection
173 * is blocked by another client, which has send us glBegin call and we're waiting to receive glEnd.
174 */
175 uint8_t allow_redir_ptr;
176
177 uint32_t vMajor, vMinor; /*Protocol version*/
178};
179
180
181/*
182 * Network functions
183 */
184extern DECLEXPORT(int) crGetHostname( char *buf, unsigned int len );
185
186extern DECLEXPORT(void) crNetInit( CRNetReceiveFunc recvFunc, CRNetCloseFunc closeFunc );
187extern DECLEXPORT(void) crNetTearDown(void);
188
189extern DECLEXPORT(void) *crNetAlloc( CRConnection *conn );
190extern DECLEXPORT(void) crNetFree( CRConnection *conn, void *buf );
191
192extern DECLEXPORT(void) crNetAccept( CRConnection *conn );
193extern DECLEXPORT(int) crNetConnect( CRConnection *conn );
194extern DECLEXPORT(void) crNetDisconnect( CRConnection *conn );
195extern DECLEXPORT(void) crNetFreeConnection( CRConnection *conn );
196
197extern DECLEXPORT(void) crNetSend( CRConnection *conn, void **bufp, const void *start, unsigned int len );
198extern DECLEXPORT(void) crNetBarf( CRConnection *conn, void **bufp, const void *start, unsigned int len );
199extern DECLEXPORT(void) crNetSendExact( CRConnection *conn, const void *start, unsigned int len );
200extern DECLEXPORT(void) crNetSingleRecv( CRConnection *conn, void *buf, unsigned int len );
201extern DECLEXPORT(unsigned int) crNetGetMessage( CRConnection *conn, CRMessage **message );
202extern DECLEXPORT(unsigned int) crNetPeekMessage( CRConnection *conn, CRMessage **message );
203extern DECLEXPORT(int) crNetNumMessages(CRConnection *conn);
204extern DECLEXPORT(void) crNetReadline( CRConnection *conn, void *buf );
205extern DECLEXPORT(int) crNetRecv(
206#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
207 CRConnection *conn
208#else
209 void
210#endif
211 );
212#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
213#define CR_WRITEBACK_WAIT(_conn, _writeback) do { \
214 while (_writeback) { \
215 RTThreadYield(); \
216 crNetRecv(_conn); \
217 } \
218 } while (0)
219#else
220#define CR_WRITEBACK_WAIT(_conn, _writeback) do { \
221 while (_writeback) { \
222 RTThreadYield(); \
223 crNetRecv(); \
224 } \
225 } while (0)
226
227#endif
228#ifdef IN_GUEST
229extern DECLEXPORT(uint32_t) crNetHostCapsGet(void);
230#endif
231extern DECLEXPORT(void) crNetDefaultRecv( CRConnection *conn, CRMessage *msg, unsigned int len );
232extern DECLEXPORT(void) crNetDispatchMessage( CRNetReceiveFuncList *rfl, CRConnection *conn, CRMessage *msg, unsigned int len );
233
234extern DECLEXPORT(CRConnection *) crNetConnectToServer( const char *server, int mtu, int broker
235#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
236 , struct VBOXUHGSMI *pHgsmi
237#endif
238);
239extern DECLEXPORT(CRConnection *) crNetAcceptClient( const char *protocol, const char *hostname, unsigned short port, unsigned int mtu, int broker );
240
241
242extern DECLEXPORT(void) crInitMessageList(CRMessageList *list);
243extern DECLEXPORT(void) crEnqueueMessage(CRMessageList *list, CRMessage *msg, unsigned int len, CRConnection *conn);
244extern DECLEXPORT(void) crDequeueMessage(CRMessageList *list, CRMessage **msg, unsigned int *len, CRConnection **conn);
245
246extern DECLEXPORT(void) crNetRecvReadPixels( const CRMessageReadPixels *rp, unsigned int len );
247
248
249/*
250 * Socket callback facility
251 */
252#define CR_SOCKET_CREATE 1
253#define CR_SOCKET_DESTROY 2
254typedef void (*CRSocketCallbackProc)(int mode, int socket);
255extern DECLEXPORT(void) crRegisterSocketCallback(int mode, CRSocketCallbackProc proc);
256
257
258#ifdef __cplusplus
259}
260#endif
261
262#endif /* CR_NET_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette