VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioTestServiceProtocol.h@ 89186

Last change on this file since 89186 was 89182, checked in by vboxsync, 4 years ago

Audio/ValKit: Started working on the audio test execution service (ATS) [SCM fixes]. bugref:10008

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* $Id: AudioTestServiceProtocol.h 89182 2021-05-19 15:59:03Z 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
31RT_C_DECLS_BEGIN
32
33/**
34 * Common Packet header (for requests and replies).
35 */
36typedef 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;
46AssertCompileSize(ATSPKTHDR, 16);
47/** Pointer to a packet header. */
48typedef ATSPKTHDR *PATSPKTHDR;
49/** Pointer to a packet header. */
50typedef ATSPKTHDR const *PCATSPKTHDR;
51/** Pointer to a packet header pointer. */
52typedef 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 */
62typedef 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;
74AssertCompileSizeAlignment(ATSPKTSTS, ATSPKT_ALIGNMENT);
75/** Pointer to a status packet header. */
76typedef 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 */
90typedef 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;
99AssertCompileSizeAlignment(ATSPKTREQHOWDY, ATSPKT_ALIGNMENT);
100/** Pointer to a HOWDY request structure. */
101typedef ATSPKTREQHOWDY *PATSPKTREQHOWDY;
102
103/**
104 * The HOWDY reply structure.
105 */
106typedef 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;
115AssertCompileSizeAlignment(ATSPKTREPHOWDY, ATSPKT_ALIGNMENT);
116/** Pointer to a HOWDY reply structure. */
117typedef 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 */
128typedef struct ATSPKTREQTONEPLAY
129{
130 /** Embedded packet header. */
131 ATSPKTHDR Hdr;
132 AUDIOTESTTONEPARMS Parms;
133 /** Packet opcode, an unterminated ASCII string. */
134 uint8_t achOpcode[8];
135 /** Packet opcode, an unterminated ASCII string. */
136 uint8_t au8Padding[2];
137} ATSPKTREQTONEPLAY;
138//AssertCompileSizeAlignment(ATSPKTREQTONEPLAY, ATSPKT_ALIGNMENT);
139/** Pointer to a ATSPKTREQTONEPLAY structure. */
140typedef ATSPKTREQTONEPLAY *PATSPKTREQTONEPLAY;
141
142/* No additional structure for the reply (just standard STATUS packet). */
143
144/**
145 * Checks if the two opcodes match.
146 *
147 * @returns true on match, false on mismatch.
148 * @param pPktHdr The packet header.
149 * @param pszOpcode2 The opcode we're comparing with. Does not have
150 * to be the whole 8 chars long.
151 */
152DECLINLINE(bool) atsIsSameOpcode(PCATSPKTHDR pPktHdr, const char *pszOpcode2)
153{
154 if (pPktHdr->achOpcode[0] != pszOpcode2[0])
155 return false;
156 if (pPktHdr->achOpcode[1] != pszOpcode2[1])
157 return false;
158
159 unsigned i = 2;
160 while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
161 && pszOpcode2[i] != '\0')
162 {
163 if (pPktHdr->achOpcode[i] != pszOpcode2[i])
164 break;
165 i++;
166 }
167
168 if ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
169 && pszOpcode2[i] == '\0')
170 {
171 while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
172 && pPktHdr->achOpcode[i] == ' ')
173 i++;
174 }
175
176 return i == RT_SIZEOFMEMB(ATSPKTHDR, achOpcode);
177}
178
179/**
180 * Converts a ATS request packet from host to network byte ordering.
181 *
182 * @returns nothing.
183 * @param pPktHdr The packet to convert.
184 */
185DECLHIDDEN(void) atsProtocolReqH2N(PATSPKTHDR pPktHdr);
186
187/**
188 * Converts a ATS request packet from network to host byte ordering.
189 *
190 * @returns nothing.
191 * @param pPktHdr The packet to convert.
192 */
193DECLHIDDEN(void) atsProtocolReqN2H(PATSPKTHDR pPktHdr);
194
195/**
196 * Converts a ATS reply packet from host to network byte ordering.
197 *
198 * @returns nothing.
199 * @param pPktHdr The packet to convert.
200 */
201DECLHIDDEN(void) atsProtocolRepH2N(PATSPKTHDR pPktHdr);
202
203/**
204 * Converts a ATS reply packet from network to host byte ordering.
205 *
206 * @returns nothing.
207 * @param pPktHdr The packet to convert.
208 */
209DECLHIDDEN(void) atsProtocolRepN2H(PATSPKTHDR pPktHdr);
210
211RT_C_DECLS_END
212
213#endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestServiceProtocol_h */
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