VirtualBox

source: vbox/trunk/include/VBox/HostServices/VBoxHostChannel.h@ 76507

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

/include: scm --fix-header-guards. bugref:9344

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.8 KB
Line 
1/** @file
2 *
3 * Host Channel: the service definition.
4 */
5
6/*
7 * Copyright (C) 2012-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___VBox_HostService_VBoxHostChannel_h
28#define ___VBox_HostService_VBoxHostChannel_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <VBox/VMMDevCoreTypes.h>
34#include <VBox/VBoxGuestCoreTypes.h>
35#include <VBox/hgcmsvc.h>
36
37/*
38 * Host calls.
39 */
40#define VBOX_HOST_CHANNEL_HOST_FN_REGISTER 1
41#define VBOX_HOST_CHANNEL_HOST_FN_UNREGISTER 2
42
43/*
44 * Guest calls.
45 */
46#define VBOX_HOST_CHANNEL_FN_ATTACH 1 /* Attach to a channel. */
47#define VBOX_HOST_CHANNEL_FN_DETACH 2 /* Detach from the channel. */
48#define VBOX_HOST_CHANNEL_FN_SEND 3 /* Send data to the host. */
49#define VBOX_HOST_CHANNEL_FN_RECV 4 /* Receive data from the host. */
50#define VBOX_HOST_CHANNEL_FN_CONTROL 5 /* Generic data exchange using a channel instance. */
51#define VBOX_HOST_CHANNEL_FN_EVENT_WAIT 6 /* Blocking wait for a host event. */
52#define VBOX_HOST_CHANNEL_FN_EVENT_CANCEL 7 /* Cancel the blocking wait. */
53#define VBOX_HOST_CHANNEL_FN_QUERY 8 /* Generic data exchange using a channel name. */
54
55/*
56 * The host event ids for the guest.
57 */
58#define VBOX_HOST_CHANNEL_EVENT_CANCELLED 0 /* Event was cancelled by FN_EVENT_CANCEL. */
59#define VBOX_HOST_CHANNEL_EVENT_UNREGISTERED 1 /* Channel was unregistered on host. */
60#define VBOX_HOST_CHANNEL_EVENT_RECV 2 /* Data is available for receiving. */
61#define VBOX_HOST_CHANNEL_EVENT_USER 1000 /* Base of channel specific events. */
62
63/*
64 * The common control code ids for the VBOX_HOST_CHANNEL_FN_[CONTROL|QUERY]
65 */
66#define VBOX_HOST_CHANNEL_CTRL_EXISTS 0 /* Whether the channel instance or provider exists. */
67#define VBOX_HOST_CHANNEL_CTRL_USER 1000 /* Base of channel specific events. */
68
69#pragma pack(1)
70
71/* Parameter of VBOX_HOST_CHANNEL_EVENT_RECV */
72typedef struct VBOXHOSTCHANNELEVENTRECV
73{
74 uint32_t u32SizeAvailable; /* How many bytes can be read from the channel. */
75} VBOXHOSTCHANNELEVENTRECV;
76
77/*
78 * Guest calls.
79 */
80
81typedef struct VBoxHostChannelAttach
82{
83 VBGLIOCHGCMCALL hdr;
84 HGCMFunctionParameter name; /* IN linear ptr: Channel name utf8 nul terminated. */
85 HGCMFunctionParameter flags; /* IN uint32_t: Channel specific flags. */
86 HGCMFunctionParameter handle; /* OUT uint32_t: The channel handle. */
87} VBoxHostChannelAttach;
88
89typedef struct VBoxHostChannelDetach
90{
91 VBGLIOCHGCMCALL hdr;
92 HGCMFunctionParameter handle; /* IN uint32_t: The channel handle. */
93} VBoxHostChannelDetach;
94
95typedef struct VBoxHostChannelSend
96{
97 VBGLIOCHGCMCALL hdr;
98 HGCMFunctionParameter handle; /* IN uint32_t: The channel handle. */
99 HGCMFunctionParameter data; /* IN linear pointer: Data to be sent. */
100} VBoxHostChannelSend;
101
102typedef struct VBoxHostChannelRecv
103{
104 VBGLIOCHGCMCALL hdr;
105 HGCMFunctionParameter handle; /* IN uint32_t: The channel handle. */
106 HGCMFunctionParameter data; /* OUT linear pointer: Buffer for data to be received. */
107 HGCMFunctionParameter sizeReceived; /* OUT uint32_t: Bytes received. */
108 HGCMFunctionParameter sizeRemaining; /* OUT uint32_t: Bytes remaining in the channel. */
109} VBoxHostChannelRecv;
110
111typedef struct VBoxHostChannelControl
112{
113 VBGLIOCHGCMCALL hdr;
114 HGCMFunctionParameter handle; /* IN uint32_t: The channel handle. */
115 HGCMFunctionParameter code; /* IN uint32_t: The channel specific control code. */
116 HGCMFunctionParameter parm; /* IN linear pointer: Parameters of the function. */
117 HGCMFunctionParameter data; /* OUT linear pointer: Buffer for results. */
118 HGCMFunctionParameter sizeDataReturned; /* OUT uint32_t: Bytes returned in the 'data' buffer. */
119} VBoxHostChannelControl;
120
121typedef struct VBoxHostChannelEventWait
122{
123 VBGLIOCHGCMCALL hdr;
124 HGCMFunctionParameter handle; /* OUT uint32_t: The channel which generated the event. */
125 HGCMFunctionParameter id; /* OUT uint32_t: The event VBOX_HOST_CHANNEL_EVENT_*. */
126 HGCMFunctionParameter parm; /* OUT linear pointer: Parameters of the event. */
127 HGCMFunctionParameter sizeReturned; /* OUT uint32_t: Size of the parameters. */
128} VBoxHostChannelEventWait;
129
130typedef struct VBoxHostChannelEventCancel
131{
132 VBGLIOCHGCMCALL hdr;
133} VBoxHostChannelEventCancel;
134
135typedef struct VBoxHostChannelQuery
136{
137 VBGLIOCHGCMCALL hdr;
138 HGCMFunctionParameter name; /* IN linear ptr: Channel name utf8 nul terminated. */
139 HGCMFunctionParameter code; /* IN uint32_t: The control code. */
140 HGCMFunctionParameter parm; /* IN linear pointer: Parameters of the function. */
141 HGCMFunctionParameter data; /* OUT linear pointer: Buffer for results. */
142 HGCMFunctionParameter sizeDataReturned; /* OUT uint32_t: Bytes returned in the 'data' buffer. */
143} VBoxHostChannelQuery;
144
145
146/*
147 * Host calls
148 */
149
150typedef struct VBoxHostChannelHostRegister
151{
152 VBOXHGCMSVCPARM name; /* IN ptr: Channel name utf8 nul terminated. */
153 VBOXHGCMSVCPARM iface; /* IN ptr: VBOXHOSTCHANNELINTERFACE. */
154} VBoxHostChannelHostRegister;
155
156typedef struct VBoxHostChannelHostUnregister
157{
158 VBOXHGCMSVCPARM name; /* IN ptr: Channel name utf8 nul terminated */
159} VBoxHostChannelHostUnregister;
160
161/* The channel provider will invoke this callback to report channel events. */
162typedef struct VBOXHOSTCHANNELCALLBACKS
163{
164 /* A channel event occured.
165 *
166 * @param pvCallbacks The callback context specified in HostChannelAttach.
167 * @param pvChannel The channel instance returned by HostChannelAttach.
168 * @param u32Id The event id.
169 * @param pvEvent The event parameters.
170 * @param cbEvent The size of event parameters.
171 */
172 DECLR3CALLBACKMEMBER(void, HostChannelCallbackEvent, (void *pvCallbacks, void *pvChannel,
173 uint32_t u32Id, const void *pvEvent, uint32_t cbEvent));
174
175 /* The channel has been deleted by the provider. pvCallback will not be used anymore.
176 *
177 * @param pvCallbacks The callback context specified in HostChannelAttach.
178 * @param pvChannel The channel instance returned by HostChannelAttach.
179 */
180 DECLR3CALLBACKMEMBER(void, HostChannelCallbackDeleted, (void *pvCallbacks, void *pvChannel));
181} VBOXHOSTCHANNELCALLBACKS;
182
183typedef struct VBOXHOSTCHANNELINTERFACE
184{
185 /* The channel provider context. */
186 void *pvProvider;
187
188 /* A new channel is requested.
189 *
190 * @param pvProvider The provider context VBOXHOSTCHANNELINTERFACE::pvProvider.
191 * @param ppvChannel Where to store pointer to the channel instance created by the provider.
192 * @param u32Flags Channel specific flags.
193 * @param pCallbacks Callbacks to be invoked by the channel provider.
194 * @param pvCallbacks The context of callbacks.
195 */
196 DECLR3CALLBACKMEMBER(int, HostChannelAttach, (void *pvProvider, void **ppvChannel, uint32_t u32Flags,
197 VBOXHOSTCHANNELCALLBACKS *pCallbacks, void *pvCallbacks));
198
199 /* The channel is closed. */
200 DECLR3CALLBACKMEMBER(void, HostChannelDetach, (void *pvChannel));
201
202 /* The guest sends data to the channel. */
203 DECLR3CALLBACKMEMBER(int, HostChannelSend, (void *pvChannel, const void *pvData, uint32_t cbData));
204
205 /* The guest reads data from the channel. */
206 DECLR3CALLBACKMEMBER(int, HostChannelRecv, (void *pvChannel, void *pvData, uint32_t cbData,
207 uint32_t *pcbReceived, uint32_t *pcbRemaining));
208
209 /* The guest talks to the provider of the channel.
210 * @param pvChannel The channel instance. NULL if the target is the provider, rather than a channel.
211 */
212 DECLR3CALLBACKMEMBER(int, HostChannelControl, (void *pvChannel, uint32_t u32Code,
213 const void *pvParm, uint32_t cbParm,
214 const void *pvData, uint32_t cbData, uint32_t *pcbDataReturned));
215} VBOXHOSTCHANNELINTERFACE;
216
217#pragma pack()
218
219#endif
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