1 | /* $Id: UsbTestServiceInternal.h 69111 2017-10-17 14:26:02Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * UsbTestServ - Remote USB test configuration and execution server, Internal Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2016-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 ___UsbTestServiceInternal_h___
|
---|
28 | #define ___UsbTestServiceInternal_h___
|
---|
29 |
|
---|
30 | #include <iprt/getopt.h>
|
---|
31 | #include <iprt/stream.h>
|
---|
32 |
|
---|
33 | #include "UsbTestServiceProtocol.h"
|
---|
34 |
|
---|
35 | RT_C_DECLS_BEGIN
|
---|
36 |
|
---|
37 | /** Opaque UTS transport layer specific client data. */
|
---|
38 | typedef struct UTSTRANSPORTCLIENT *PUTSTRANSPORTCLIENT;
|
---|
39 | typedef PUTSTRANSPORTCLIENT *PPUTSTRANSPORTCLIENT;
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Transport layer descriptor.
|
---|
43 | */
|
---|
44 | typedef struct UTSTRANSPORT
|
---|
45 | {
|
---|
46 | /** The name. */
|
---|
47 | char szName[16];
|
---|
48 | /** The description. */
|
---|
49 | const char *pszDesc;
|
---|
50 | /** Pointer to an array of options. */
|
---|
51 | PCRTGETOPTDEF paOpts;
|
---|
52 | /** The number of options in the array. */
|
---|
53 | size_t cOpts;
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Print the usage information for this transport layer.
|
---|
57 | *
|
---|
58 | * @param pStream The stream to print the usage info to.
|
---|
59 | *
|
---|
60 | * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
|
---|
61 | */
|
---|
62 | DECLR3CALLBACKMEMBER(void, pfnUsage, (PRTSTREAM pStream));
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Handle an option.
|
---|
66 | *
|
---|
67 | * When encountering an options that is not part of the base options, we'll call
|
---|
68 | * this method for each transport layer until one handles it.
|
---|
69 | *
|
---|
70 | * @retval VINF_SUCCESS if handled.
|
---|
71 | * @retval VERR_TRY_AGAIN if not handled.
|
---|
72 | * @retval VERR_INVALID_PARAMETER if we should exit with a non-zero status.
|
---|
73 | *
|
---|
74 | * @param ch The short option value.
|
---|
75 | * @param pVal Pointer to the value union.
|
---|
76 | *
|
---|
77 | * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
|
---|
78 | */
|
---|
79 | DECLR3CALLBACKMEMBER(int, pfnOption, (int ch, PCRTGETOPTUNION pVal));
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Initializes the transport layer.
|
---|
83 | *
|
---|
84 | * @returns IPRT status code. On errors, the transport layer shall call
|
---|
85 | * RTMsgError to display the error details to the user.
|
---|
86 | */
|
---|
87 | DECLR3CALLBACKMEMBER(int, pfnInit, (void));
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Terminate the transport layer, closing and freeing resources.
|
---|
91 | *
|
---|
92 | * On errors, the transport layer shall call RTMsgError to display the error
|
---|
93 | * details to the user.
|
---|
94 | */
|
---|
95 | DECLR3CALLBACKMEMBER(void, pfnTerm, (void));
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Waits for a new client to connect and returns the client specific data on
|
---|
99 | * success.
|
---|
100 | */
|
---|
101 | DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PPUTSTRANSPORTCLIENT ppClientNew));
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * Polls for incoming packets.
|
---|
105 | *
|
---|
106 | * @returns true if there are pending packets, false if there isn't.
|
---|
107 | * @param pClient The client to poll for data.
|
---|
108 | */
|
---|
109 | DECLR3CALLBACKMEMBER(bool, pfnPollIn, (PUTSTRANSPORTCLIENT pClient));
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * Adds any pollable handles to the poll set.
|
---|
113 | *
|
---|
114 | * @returns IPRT status code.
|
---|
115 | * @param hPollSet The poll set to add them to.
|
---|
116 | * @param pClient The transport client structure.
|
---|
117 | * @param idStart The handle ID to start at.
|
---|
118 | */
|
---|
119 | DECLR3CALLBACKMEMBER(int, pfnPollSetAdd, (RTPOLLSET hPollSet, PUTSTRANSPORTCLIENT pClient, uint32_t idStart));
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * Removes the given client frmo the given pollset.
|
---|
123 | *
|
---|
124 | * @returns IPRT status code.
|
---|
125 | * @param hPollSet The poll set to remove from.
|
---|
126 | * @param pClient The transport client structure.
|
---|
127 | * @param idStart The handle ID to remove.
|
---|
128 | */
|
---|
129 | DECLR3CALLBACKMEMBER(int, pfnPollSetRemove, (RTPOLLSET hPollSet, PUTSTRANSPORTCLIENT pClient, uint32_t idStart));
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * Receives an incoming packet.
|
---|
133 | *
|
---|
134 | * This will block until the data becomes available or we're interrupted by a
|
---|
135 | * signal or something.
|
---|
136 | *
|
---|
137 | * @returns IPRT status code. On error conditions other than VERR_INTERRUPTED,
|
---|
138 | * the current operation will be aborted when applicable. When
|
---|
139 | * interrupted, the transport layer will store the data until the next
|
---|
140 | * receive call.
|
---|
141 | *
|
---|
142 | * @param pClient The transport client structure.
|
---|
143 | * @param ppPktHdr Where to return the pointer to the packet we've
|
---|
144 | * read. This is allocated from the heap using
|
---|
145 | * RTMemAlloc (w/ UTSPKT_ALIGNMENT) and must be
|
---|
146 | * free by calling RTMemFree.
|
---|
147 | */
|
---|
148 | DECLR3CALLBACKMEMBER(int, pfnRecvPkt, (PUTSTRANSPORTCLIENT pClient, PPUTSPKTHDR ppPktHdr));
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Sends an outgoing packet.
|
---|
152 | *
|
---|
153 | * This will block until the data has been written.
|
---|
154 | *
|
---|
155 | * @returns IPRT status code.
|
---|
156 | * @retval VERR_INTERRUPTED if interrupted before anything was sent.
|
---|
157 | *
|
---|
158 | * @param pClient The transport client structure.
|
---|
159 | * @param pPktHdr The packet to send. The size is given by
|
---|
160 | * aligning the size in the header by
|
---|
161 | * UTSPKT_ALIGNMENT.
|
---|
162 | */
|
---|
163 | DECLR3CALLBACKMEMBER(int, pfnSendPkt, (PUTSTRANSPORTCLIENT pClient, PCUTSPKTHDR pPktHdr));
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * Sends a babble packet and disconnects the client (if applicable).
|
---|
167 | *
|
---|
168 | * @param pClient The transport client structure.
|
---|
169 | * @param pPktHdr The packet to send. The size is given by
|
---|
170 | * aligning the size in the header by
|
---|
171 | * UTSPKT_ALIGNMENT.
|
---|
172 | * @param cMsSendTimeout The send timeout measured in milliseconds.
|
---|
173 | */
|
---|
174 | DECLR3CALLBACKMEMBER(void, pfnBabble, (PUTSTRANSPORTCLIENT pClient, PCUTSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout));
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Notification about a client HOWDY.
|
---|
178 | *
|
---|
179 | * @param pClient The transport client structure.
|
---|
180 | */
|
---|
181 | DECLR3CALLBACKMEMBER(void, pfnNotifyHowdy, (PUTSTRANSPORTCLIENT pClient));
|
---|
182 |
|
---|
183 | /**
|
---|
184 | * Notification about a client BYE.
|
---|
185 | *
|
---|
186 | * For connection oriented transport layers, it would be good to disconnect the
|
---|
187 | * client at this point.
|
---|
188 | *
|
---|
189 | * @param pClient The transport client structure.
|
---|
190 | */
|
---|
191 | DECLR3CALLBACKMEMBER(void, pfnNotifyBye, (PUTSTRANSPORTCLIENT pClient));
|
---|
192 |
|
---|
193 | /**
|
---|
194 | * Notification about a REBOOT or SHUTDOWN.
|
---|
195 | *
|
---|
196 | * For connection oriented transport layers, stop listening for and
|
---|
197 | * accepting at this point.
|
---|
198 | */
|
---|
199 | DECLR3CALLBACKMEMBER(void, pfnNotifyReboot, (void));
|
---|
200 |
|
---|
201 | /** Non-zero end marker. */
|
---|
202 | uint32_t u32EndMarker;
|
---|
203 | } UTSTRANSPORT;
|
---|
204 | /** Pointer to a const transport layer descriptor. */
|
---|
205 | typedef const struct UTSTRANSPORT *PCUTSTRANSPORT;
|
---|
206 |
|
---|
207 |
|
---|
208 | extern UTSTRANSPORT const g_TcpTransport;
|
---|
209 |
|
---|
210 | RT_C_DECLS_END
|
---|
211 |
|
---|
212 | #endif
|
---|
213 |
|
---|