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