1 | /* $Id: AudioTestServiceProtocol.h 89174 2021-05-19 15:05:29Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * AudioTestServiceProtocol - Audio test execution server, Protocol Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021 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_INCLUDED_SRC_AudioTestServiceProtocol_h
|
---|
28 | #define VBOX_INCLUDED_SRC_AudioTestServiceProtocol_h
|
---|
29 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
30 | # pragma once
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #include <iprt/cdefs.h>
|
---|
34 | #include <iprt/list.h>
|
---|
35 |
|
---|
36 | #include <VBox/vmm/pdmaudioifs.h>
|
---|
37 |
|
---|
38 | #include "AudioTest.h"
|
---|
39 |
|
---|
40 | RT_C_DECLS_BEGIN
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Common Packet header (for requests and replies).
|
---|
44 | */
|
---|
45 | typedef struct ATSPKTHDR
|
---|
46 | {
|
---|
47 | /** The unpadded packet length. This include this header. */
|
---|
48 | uint32_t cb;
|
---|
49 | /** The CRC-32 for the packet starting from the opcode field. 0 if the packet
|
---|
50 | * hasn't been CRCed. */
|
---|
51 | uint32_t uCrc32;
|
---|
52 | /** Packet opcode, an unterminated ASCII string. */
|
---|
53 | uint8_t achOpcode[8];
|
---|
54 | } ATSPKTHDR;
|
---|
55 | AssertCompileSize(ATSPKTHDR, 16);
|
---|
56 | /** Pointer to a packet header. */
|
---|
57 | typedef ATSPKTHDR *PATSPKTHDR;
|
---|
58 | /** Pointer to a packet header. */
|
---|
59 | typedef ATSPKTHDR const *PCATSPKTHDR;
|
---|
60 | /** Pointer to a packet header pointer. */
|
---|
61 | typedef PATSPKTHDR *PPATSPKTHDR;
|
---|
62 |
|
---|
63 | /** Packet alignment. */
|
---|
64 | #define ATSPKT_ALIGNMENT 16
|
---|
65 | /** Max packet size. */
|
---|
66 | #define ATSPKT_MAX_SIZE _256K
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Status packet.
|
---|
70 | */
|
---|
71 | typedef struct ATSPKTSTS
|
---|
72 | {
|
---|
73 | /** Embedded common packet header. */
|
---|
74 | ATSPKTHDR Hdr;
|
---|
75 | /** The IPRT status code of the request. */
|
---|
76 | int32_t rcReq;
|
---|
77 | /** Size of the optional status message following this structure -
|
---|
78 | * only for errors. */
|
---|
79 | uint32_t cchStsMsg;
|
---|
80 | /** Padding - reserved. */
|
---|
81 | uint8_t au8Padding[8];
|
---|
82 | } ATSPKTSTS;
|
---|
83 | AssertCompileSizeAlignment(ATSPKTSTS, ATSPKT_ALIGNMENT);
|
---|
84 | /** Pointer to a status packet header. */
|
---|
85 | typedef ATSPKTSTS *PATSPKTSTS;
|
---|
86 |
|
---|
87 | #define ATSPKT_OPCODE_HOWDY "HOWDY "
|
---|
88 |
|
---|
89 | /** 32bit protocol version consisting of a 16bit major and 16bit minor part. */
|
---|
90 | #define ATS_PROTOCOL_VS (ATS_PROTOCOL_VS_MAJOR | ATS_PROTOCOL_VS_MINOR)
|
---|
91 | /** The major version part of the protocol version. */
|
---|
92 | #define ATS_PROTOCOL_VS_MAJOR (1 << 16)
|
---|
93 | /** The minor version part of the protocol version. */
|
---|
94 | #define ATS_PROTOCOL_VS_MINOR (0)
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * The HOWDY request structure.
|
---|
98 | */
|
---|
99 | typedef struct ATSPKTREQHOWDY
|
---|
100 | {
|
---|
101 | /** Embedded packet header. */
|
---|
102 | ATSPKTHDR Hdr;
|
---|
103 | /** Version of the protocol the client wants to use. */
|
---|
104 | uint32_t uVersion;
|
---|
105 | /** Alignment. */
|
---|
106 | uint8_t au8Padding[12];
|
---|
107 | } ATSPKTREQHOWDY;
|
---|
108 | AssertCompileSizeAlignment(ATSPKTREQHOWDY, ATSPKT_ALIGNMENT);
|
---|
109 | /** Pointer to a HOWDY request structure. */
|
---|
110 | typedef ATSPKTREQHOWDY *PATSPKTREQHOWDY;
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * The HOWDY reply structure.
|
---|
114 | */
|
---|
115 | typedef struct ATSPKTREPHOWDY
|
---|
116 | {
|
---|
117 | /** Status packet. */
|
---|
118 | ATSPKTSTS Sts;
|
---|
119 | /** Version to use for the established connection. */
|
---|
120 | uint32_t uVersion;
|
---|
121 | /** Padding - reserved. */
|
---|
122 | uint8_t au8Padding[12];
|
---|
123 | } ATSPKTREPHOWDY;
|
---|
124 | AssertCompileSizeAlignment(ATSPKTREPHOWDY, ATSPKT_ALIGNMENT);
|
---|
125 | /** Pointer to a HOWDY reply structure. */
|
---|
126 | typedef ATSPKTREPHOWDY *PATSPKTREPHOWDY;
|
---|
127 |
|
---|
128 | #define ATSPKT_OPCODE_BYE "BYE "
|
---|
129 |
|
---|
130 | /* No additional structures for BYE. */
|
---|
131 |
|
---|
132 | #define ATSPKT_OPCODE_TONE_PLAY "TNPLY "
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * The TONE PLAY request structure.
|
---|
136 | */
|
---|
137 | typedef struct ATSPKTREQTONEPLAY
|
---|
138 | {
|
---|
139 | /** Embedded packet header. */
|
---|
140 | ATSPKTHDR Hdr;
|
---|
141 | AUDIOTESTTONEPARMS Parms;
|
---|
142 | /** Packet opcode, an unterminated ASCII string. */
|
---|
143 | uint8_t achOpcode[8];
|
---|
144 | /** Packet opcode, an unterminated ASCII string. */
|
---|
145 | uint8_t au8Padding[2];
|
---|
146 | } ATSPKTREQTONEPLAY;
|
---|
147 | //AssertCompileSizeAlignment(ATSPKTREQTONEPLAY, ATSPKT_ALIGNMENT);
|
---|
148 | /** Pointer to a ATSPKTREQTONEPLAY structure. */
|
---|
149 | typedef ATSPKTREQTONEPLAY *PATSPKTREQTONEPLAY;
|
---|
150 |
|
---|
151 | /* No additional structure for the reply (just standard STATUS packet). */
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Checks if the two opcodes match.
|
---|
155 | *
|
---|
156 | * @returns true on match, false on mismatch.
|
---|
157 | * @param pPktHdr The packet header.
|
---|
158 | * @param pszOpcode2 The opcode we're comparing with. Does not have
|
---|
159 | * to be the whole 8 chars long.
|
---|
160 | */
|
---|
161 | DECLINLINE(bool) atsIsSameOpcode(PCATSPKTHDR pPktHdr, const char *pszOpcode2)
|
---|
162 | {
|
---|
163 | if (pPktHdr->achOpcode[0] != pszOpcode2[0])
|
---|
164 | return false;
|
---|
165 | if (pPktHdr->achOpcode[1] != pszOpcode2[1])
|
---|
166 | return false;
|
---|
167 |
|
---|
168 | unsigned i = 2;
|
---|
169 | while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
|
---|
170 | && pszOpcode2[i] != '\0')
|
---|
171 | {
|
---|
172 | if (pPktHdr->achOpcode[i] != pszOpcode2[i])
|
---|
173 | break;
|
---|
174 | i++;
|
---|
175 | }
|
---|
176 |
|
---|
177 | if ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
|
---|
178 | && pszOpcode2[i] == '\0')
|
---|
179 | {
|
---|
180 | while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
|
---|
181 | && pPktHdr->achOpcode[i] == ' ')
|
---|
182 | i++;
|
---|
183 | }
|
---|
184 |
|
---|
185 | return i == RT_SIZEOFMEMB(ATSPKTHDR, achOpcode);
|
---|
186 | }
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * Converts a ATS request packet from host to network byte ordering.
|
---|
190 | *
|
---|
191 | * @returns nothing.
|
---|
192 | * @param pPktHdr The packet to convert.
|
---|
193 | */
|
---|
194 | DECLHIDDEN(void) atsProtocolReqH2N(PATSPKTHDR pPktHdr);
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Converts a ATS request packet from network to host byte ordering.
|
---|
198 | *
|
---|
199 | * @returns nothing.
|
---|
200 | * @param pPktHdr The packet to convert.
|
---|
201 | */
|
---|
202 | DECLHIDDEN(void) atsProtocolReqN2H(PATSPKTHDR pPktHdr);
|
---|
203 |
|
---|
204 | /**
|
---|
205 | * Converts a ATS reply packet from host to network byte ordering.
|
---|
206 | *
|
---|
207 | * @returns nothing.
|
---|
208 | * @param pPktHdr The packet to convert.
|
---|
209 | */
|
---|
210 | DECLHIDDEN(void) atsProtocolRepH2N(PATSPKTHDR pPktHdr);
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * Converts a ATS reply packet from network to host byte ordering.
|
---|
214 | *
|
---|
215 | * @returns nothing.
|
---|
216 | * @param pPktHdr The packet to convert.
|
---|
217 | */
|
---|
218 | DECLHIDDEN(void) atsProtocolRepN2H(PATSPKTHDR pPktHdr);
|
---|
219 |
|
---|
220 | RT_C_DECLS_END
|
---|
221 |
|
---|
222 | #endif /* !VBOX_INCLUDED_SRC_AudioTestServiceProtocol_h */
|
---|