VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceInternal.h@ 107044

Last change on this file since 107044 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1/* $Id: UsbTestServiceInternal.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * UsbTestServ - Remote USB test configuration and execution server, Internal Header.
4 */
5
6/*
7 * Copyright (C) 2016-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef VBOX_INCLUDED_SRC_usb_UsbTestServiceInternal_h
38#define VBOX_INCLUDED_SRC_usb_UsbTestServiceInternal_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/getopt.h>
44#include <iprt/stream.h>
45
46#include "UsbTestServiceProtocol.h"
47
48RT_C_DECLS_BEGIN
49
50/** Opaque UTS transport layer specific client data. */
51typedef struct UTSTRANSPORTCLIENT *PUTSTRANSPORTCLIENT;
52typedef PUTSTRANSPORTCLIENT *PPUTSTRANSPORTCLIENT;
53
54/**
55 * Transport layer descriptor.
56 */
57typedef struct UTSTRANSPORT
58{
59 /** The name. */
60 char szName[16];
61 /** The description. */
62 const char *pszDesc;
63 /** Pointer to an array of options. */
64 PCRTGETOPTDEF paOpts;
65 /** The number of options in the array. */
66 size_t cOpts;
67
68 /**
69 * Print the usage information for this transport layer.
70 *
71 * @param pStream The stream to print the usage info to.
72 *
73 * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
74 */
75 DECLR3CALLBACKMEMBER(void, pfnUsage, (PRTSTREAM pStream));
76
77 /**
78 * Handle an option.
79 *
80 * When encountering an options that is not part of the base options, we'll call
81 * this method for each transport layer until one handles it.
82 *
83 * @retval VINF_SUCCESS if handled.
84 * @retval VERR_TRY_AGAIN if not handled.
85 * @retval VERR_INVALID_PARAMETER if we should exit with a non-zero status.
86 *
87 * @param ch The short option value.
88 * @param pVal Pointer to the value union.
89 *
90 * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
91 */
92 DECLR3CALLBACKMEMBER(int, pfnOption, (int ch, PCRTGETOPTUNION pVal));
93
94 /**
95 * Initializes the transport layer.
96 *
97 * @returns IPRT status code. On errors, the transport layer shall call
98 * RTMsgError to display the error details to the user.
99 */
100 DECLR3CALLBACKMEMBER(int, pfnInit, (void));
101
102 /**
103 * Terminate the transport layer, closing and freeing resources.
104 *
105 * On errors, the transport layer shall call RTMsgError to display the error
106 * details to the user.
107 */
108 DECLR3CALLBACKMEMBER(void, pfnTerm, (void));
109
110 /**
111 * Waits for a new client to connect and returns the client specific data on
112 * success.
113 */
114 DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PPUTSTRANSPORTCLIENT ppClientNew));
115
116 /**
117 * Polls for incoming packets.
118 *
119 * @returns true if there are pending packets, false if there isn't.
120 * @param pClient The client to poll for data.
121 */
122 DECLR3CALLBACKMEMBER(bool, pfnPollIn, (PUTSTRANSPORTCLIENT pClient));
123
124 /**
125 * Adds any pollable handles to the poll set.
126 *
127 * @returns IPRT status code.
128 * @param hPollSet The poll set to add them to.
129 * @param pClient The transport client structure.
130 * @param idStart The handle ID to start at.
131 */
132 DECLR3CALLBACKMEMBER(int, pfnPollSetAdd, (RTPOLLSET hPollSet, PUTSTRANSPORTCLIENT pClient, uint32_t idStart));
133
134 /**
135 * Removes the given client frmo the given pollset.
136 *
137 * @returns IPRT status code.
138 * @param hPollSet The poll set to remove from.
139 * @param pClient The transport client structure.
140 * @param idStart The handle ID to remove.
141 */
142 DECLR3CALLBACKMEMBER(int, pfnPollSetRemove, (RTPOLLSET hPollSet, PUTSTRANSPORTCLIENT pClient, uint32_t idStart));
143
144 /**
145 * Receives an incoming packet.
146 *
147 * This will block until the data becomes available or we're interrupted by a
148 * signal or something.
149 *
150 * @returns IPRT status code. On error conditions other than VERR_INTERRUPTED,
151 * the current operation will be aborted when applicable. When
152 * interrupted, the transport layer will store the data until the next
153 * receive call.
154 *
155 * @param pClient The transport client structure.
156 * @param ppPktHdr Where to return the pointer to the packet we've
157 * read. This is allocated from the heap using
158 * RTMemAlloc (w/ UTSPKT_ALIGNMENT) and must be
159 * free by calling RTMemFree.
160 */
161 DECLR3CALLBACKMEMBER(int, pfnRecvPkt, (PUTSTRANSPORTCLIENT pClient, PPUTSPKTHDR ppPktHdr));
162
163 /**
164 * Sends an outgoing packet.
165 *
166 * This will block until the data has been written.
167 *
168 * @returns IPRT status code.
169 * @retval VERR_INTERRUPTED if interrupted before anything was sent.
170 *
171 * @param pClient The transport client structure.
172 * @param pPktHdr The packet to send. The size is given by
173 * aligning the size in the header by
174 * UTSPKT_ALIGNMENT.
175 */
176 DECLR3CALLBACKMEMBER(int, pfnSendPkt, (PUTSTRANSPORTCLIENT pClient, PCUTSPKTHDR pPktHdr));
177
178 /**
179 * Sends a babble packet and disconnects the client (if applicable).
180 *
181 * @param pClient The transport client structure.
182 * @param pPktHdr The packet to send. The size is given by
183 * aligning the size in the header by
184 * UTSPKT_ALIGNMENT.
185 * @param cMsSendTimeout The send timeout measured in milliseconds.
186 */
187 DECLR3CALLBACKMEMBER(void, pfnBabble, (PUTSTRANSPORTCLIENT pClient, PCUTSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout));
188
189 /**
190 * Notification about a client HOWDY.
191 *
192 * @param pClient The transport client structure.
193 */
194 DECLR3CALLBACKMEMBER(void, pfnNotifyHowdy, (PUTSTRANSPORTCLIENT pClient));
195
196 /**
197 * Notification about a client BYE.
198 *
199 * For connection oriented transport layers, it would be good to disconnect the
200 * client at this point.
201 *
202 * @param pClient The transport client structure.
203 */
204 DECLR3CALLBACKMEMBER(void, pfnNotifyBye, (PUTSTRANSPORTCLIENT pClient));
205
206 /**
207 * Notification about a REBOOT or SHUTDOWN.
208 *
209 * For connection oriented transport layers, stop listening for and
210 * accepting at this point.
211 */
212 DECLR3CALLBACKMEMBER(void, pfnNotifyReboot, (void));
213
214 /** Non-zero end marker. */
215 uint32_t u32EndMarker;
216} UTSTRANSPORT;
217/** Pointer to a const transport layer descriptor. */
218typedef const struct UTSTRANSPORT *PCUTSTRANSPORT;
219
220
221extern UTSTRANSPORT const g_TcpTransport;
222
223RT_C_DECLS_END
224
225#endif /* !VBOX_INCLUDED_SRC_usb_UsbTestServiceInternal_h */
226
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