Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
Cpacket.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Cpacket.h
1
/*
2
** Cpacket.h
3
**
4
** Author: $Author: purschke $
5
** Date: $Date: 2000/07/21 01:51:10 $
6
**
7
** $Log: Cpacket.h,v $
8
** Revision 1.1.1.1 2000/07/21 01:51:10 purschke
9
** mlp -- adding the new automakified "basic" module to CVS.
10
**
11
**
12
** Revision 1.6 1998/12/17 21:57:06 phoncs
13
** (stephen markacs) better bounds checking in version gets
14
**
15
** Revision 1.5 1998/12/11 22:01:13 markacs
16
** (stephen markacs) adding log into cvs tags
17
**
18
*/
19
/*
20
** Cpacket.h
21
**
22
** Defines prototypes for all public functions in Cpacket.C.
23
**
24
** These routines provide access to information in the header, allow
25
** modification of data in the header and provide various logical
26
** tests of packet integrity, etc. The version independent
27
** routines contained here are inlined. Version independent
28
** routines which are not inlined are defined in Cpacket.C.
29
**
30
** In addition to the packet header, there is a small data
31
** descriptor of one or two dwords which immediately follows the
32
** packet header at the head of the data block. The data descriptor
33
** contains information specific to the data block and has a format which
34
** varies depending on the type of data structure used in the data
35
** block. The descriptor is defined in dataBlock.h and is placed
36
** after the packet in packetRoutines.C.
37
**
38
*/
39
#ifndef _CPACKET_
40
#define _CPACKET_
41
42
#ifdef __cplusplus
43
extern
"C"
{
44
#endif
45
46
#include "
phenixOnline.h
"
47
#include "
packetPublic.h
"
48
#include "
packetHdr.h
"
49
#include "
formatError.h
"
50
51
/*
52
** The following routines are GENERIC and do not depend on packet
53
** header version. They are either inlined in this file or coded in
54
** Cpacket.C
55
*/
56
57
INLINE_P
LOGIC_ret
currentPacket
(
PACKET_ptr
);
58
59
INLINE_P
VALUE_ret
getPacketLength
(
PACKET_ptr
);
60
INLINE_P
VALUE_ret
getPacketHdrLength
(
PACKET_ptr
);
61
INLINE_P
VALUE_ret
getPacketHdrVersion
(
PACKET_ptr
);
62
63
INLINE_P
LOGIC_ret
setPacketHdrVersion
(
PACKET_ptr
,
UINT
);
64
INLINE_P
LOGIC_ret
setPacketHdrLength
(
PACKET_ptr
,
UINT
);
65
INLINE_P
LOGIC_ret
setPacketLength
(
PACKET_ptr
,
PHDWORD
);
66
67
PTR_ret
findPacketEnd
(
PACKET_ptr
);
68
PTR_ret
findPacketDataStart
(
PACKET_ptr
);
69
70
VALUE_ret
extendPacketDataBlock
(
const
PACKET_ptr
,
UINT
,
int
);
71
VALUE_ret
extendPacketDebugBlock
(
const
PACKET_ptr
,
UINT
,
int
);
72
VALUE_ret
extendPacketErrorBlock
(
const
PACKET_ptr
,
UINT
,
int
);
73
VALUE_ret
extendPacketLength
(
const
PACKET_ptr
,
UINT
,
int
);
74
75
LOGIC_ret
removePacketPadding
(
PACKET_ptr
);
76
77
INLINE_P
void
endianSwapError
(
PACKETERROR
* outError,
PACKETERROR
* inError);
78
79
/*
80
** The following routines execute functions that will depend on the
81
** version of the packet header. Outside the DCM's these routines
82
** use pointer tables defined below to execute a version-specific
83
** function with identical definition. For use in the DCM's the
84
** generic function names are #defined to be the version-specific
85
** for the "current" packet header version being created in the DAQ.
86
*/
87
88
#ifdef DCM
89
90
#define makePacketHdr makePacketHdrV1
91
92
#define getPacketDebugLength getPacketV1DebugLength
93
#define getPacketErrorLength getPacketV1ErrorLength
94
#define getPacketNumErrors getPacketV1NumErrors
95
#define getPacketEndianism getPacketV1Endianism
96
#define getPacketId getPacketV1Id
97
#define getPacketPadding getPacketV1Padding
98
#define getPacketStructure getPacketV1Structure
99
#define getPacketStatus getPacketV1Status
100
#define getPacketDataDescrLength getPacketDataDescrLengthV1
101
102
#define setPacketDebugLength setPacketV1DebugLength
103
#define setPacketNumErrors setPacketV1NumErrors
104
#define setPacketEndianism setPacketV1Endianism
105
#define setPacketId setPacketV1Id
106
#define setPacketPadding setPacketV1Padding
107
#define setPacketStructure setPacketV1Structure
108
#define setPacketStatus setPacketV1Status
109
#define setPacketErrorLength setPacketV1ErrorLength
110
111
#define orPacketStatus orPacketV1Status
112
#define adjustPacketDataLength adjustPacketV1DataLength
113
#define adjustPacketDebugLength adjustPacketV1DebugLength
114
#define adjustPacketErrorLength adjustPacketV1ErrorLength
115
116
#define findPacketErrorStart findPacketV1ErrorStart
117
#define findPacketDebugStart findPacketV1DebugStart
118
#define findPacketDataStart findPacketV1DataStart
119
#define findPacketDataEnd findPacketV1DataEnd
120
121
#define validPacketHdr validPacketV1Hdr
122
#define emptyPacket emptyPacketV1
123
124
#else
125
126
VALUE_ret
makePacketHdr
(
const
PACKET_ptr
,
UINT
);
127
VALUE_ret
getPacketDataLength
(
const
PACKET_ptr
);
128
VALUE_ret
getPacketDebugLength
(
const
PACKET_ptr
);
129
VALUE_ret
getPacketErrorLength
(
const
PACKET_ptr
);
130
VALUE_ret
getPacketNumErrors
(
const
PACKET_ptr
);
131
VALUE_ret
getPacketPadding
(
const
PACKET_ptr
);
132
VALUE_ret
getPacketId
(
const
PACKET_ptr
);
133
VALUE_ret
getPacketStatus
(
PACKET_ptr
);
134
VALUE_ret
getPacketStructure
(
const
PACKET_ptr
);
135
VALUE_ret
getPacketEndianism
(
const
PACKET_ptr
);
136
VALUE_ret
getPacketDataDescrLength
(
const
PACKET_ptr
);
137
138
LOGIC_ret
setPacketDebugLength
(
PACKET_ptr
,
UINT
);
139
LOGIC_ret
setPacketNumErrors
(
PACKET_ptr
,
UINT
);
140
LOGIC_ret
setPacketEndianism
(
PACKET_ptr
,
UINT
);
141
LOGIC_ret
setPacketId
(
PACKET_ptr
,
UINT
);
142
LOGIC_ret
setPacketPadding
(
PACKET_ptr
,
UINT
);
143
LOGIC_ret
setPacketStructure
(
PACKET_ptr
,
UINT
);
144
LOGIC_ret
setPacketStatus
(
PACKET_ptr
,
UINT
);
145
LOGIC_ret
setPacketErrorLength
(
PACKET_ptr
,
UINT
);
146
LOGIC_ret
setPacketDataDescrLength
(
PACKET_ptr
,
UINT
);
147
148
VALUE_ret
orPacketStatus
(
PACKET_ptr
,
UINT
);
149
LOGIC_ret
validPacketHdr
(
PACKET_ptr
);
150
LOGIC_ret
emptyPacket
(
PACKET_ptr
);
151
152
PTR_ret
findPacketDataDescr
(
PACKET_ptr
);
153
PTR_ret
findPacketDataStart
(
PACKET_ptr
);
154
PTR_ret
findPacketDataEnd
(
PACKET_ptr
);
155
PTR_ret
findPacketDebugStart
(
PACKET_ptr
);
156
PTR_ret
findPacketErrorStart
(
PACKET_ptr
);
157
158
VALUE_ret
adjustPacketDataLength
(
PACKET_ptr
,
int
);
159
VALUE_ret
adjustPacketErrorLength
(
PACKET_ptr
,
int
);
160
VALUE_ret
adjustPacketDebugLength
(
PACKET_ptr
,
int
);
161
162
#endif
163
164
165
/*
166
** ==================================================================
167
** Inlined GENERIC routines that do not need the indirection arrays
168
** ==================================================================
169
*/
170
171
INLINE_D
VALUE_ret
getPacketHdrLength
(
PACKET_ptr
packet_ptr)
172
{
173
return
getBitsMACRO
(packet_ptr,
174
PACKET_HDR_LENGTH_OFFSET_OF_DWORD
,
175
PACKET_HDR_LENGTH_OFFSET_IN_DWORD
,
176
PACKET_HDR_LENGTH_MASK
);
177
}
178
179
180
INLINE_D
VALUE_ret
getPacketLength
(
PACKET_ptr
packet_ptr)
181
{
182
PHDWORD
length
=
getWordMACRO
(packet_ptr,
PACKET_LENGTH_OFFSET_OF_DWORD
);
183
184
#ifdef STRONGCHECK
185
if
((length&(1<<32))!=0)
return
valueFailure
;
186
#endif
187
188
return
length
;
189
}
190
191
INLINE_D
VALUE_ret
getPacketHdrVersion
(
PACKET_ptr
packet_ptr)
192
{
193
BYTE
hdrVersion = (
BYTE
)
getBitsMACRO
(packet_ptr,
194
PACKET_HDR_VERSION_OFFSET_OF_DWORD
,
195
PACKET_HDR_VERSION_OFFSET_IN_DWORD
,
196
PACKET_HDR_VERSION_MASK
);
197
198
if
((hdrVersion >=
numPacketVersions
)||(hdrVersion==0)) {
199
setPacketError
(
FORMAT_ERR_INVALID_PACKET_HDRVERSION
,
200
packet_ptr, hdrVersion);
201
return
valueFailure
;
202
}
203
204
return
hdrVersion;
205
}
206
207
INLINE_D
LOGIC_ret
setPacketHdrVersion
(
PACKET_ptr
packet_ptr,
UINT
hdrVersion)
208
{
209
#ifdef CHECK
210
if
((hdrVersion >=
numPacketVersions
)||(hdrVersion==0)) {
211
setPacketError
(
FORMAT_ERR_INVALID_PACKET_HDRVERSION
,
212
packet_ptr, hdrVersion);
213
return
valueFailure
;
214
}
215
#endif
216
setBitsMACRO
(packet_ptr,
217
PACKET_HDR_VERSION_OFFSET_OF_DWORD
,
218
PACKET_HDR_VERSION_OFFSET_IN_DWORD
,
219
PACKET_HDR_VERSION_MASK
, hdrVersion);
220
return
TRUE
;
221
}
222
223
INLINE_D
LOGIC_ret
setPacketLength
(
PACKET_ptr
packet_ptr,
PHDWORD
length
)
224
{
225
/*
226
** Currently we do no checking -- return "true"
227
*/
228
#ifdef CHECK
229
if
(length >= MAX_DWORD_VALUE) {
230
setPacketError
(
FORMAT_ERR_LENGTH_OVERFLOW
, packet_ptr, length);
231
return
FALSE
;
232
}
233
#endif
234
setWordMACRO
(packet_ptr,
PACKET_LENGTH_OFFSET_OF_DWORD
, length);
235
return
TRUE
;
236
}
237
238
239
INLINE_D
LOGIC_ret
setPacketHdrLength
(
PACKET_ptr
packet_ptr,
UINT
hdrLength)
240
{
241
#ifdef CHECK
242
if
(hdrLength >= ) {
243
setPacketError
(
FORMAT_ERR_INVALID_HDRLENGTH
, packet_ptr, hdrLength);
244
return
FALSE
;
245
}
246
#endif
247
248
setBitsMACRO
(packet_ptr,
PACKET_HDR_LENGTH_OFFSET_OF_DWORD
,
249
PACKET_HDR_LENGTH_OFFSET_IN_DWORD
,
250
PACKET_HDR_LENGTH_MASK
, hdrLength);
251
return
TRUE
;
252
}
253
254
255
INLINE_D
LOGIC_ret
currentPacket
(
PACKET_ptr
packet_ptr)
256
{
257
UINT
version =
getPacketHdrVersion
(packet_ptr);
258
return
(version ==
currentPacketHdrVersion
);
259
}
260
261
INLINE_D
void
endianSwapError
(
PACKETERROR
* outError,
PACKETERROR
* inError)
262
{
263
/*
264
** Execute the swap function provided in the V1 error routines
265
*/
266
endianSwapErrorV1
(outError, inError);
267
}
268
269
#ifdef __cplusplus
270
}
271
#endif
272
/* end of extern "C" */
273
274
#endif
275
/* end of ifndef _CPACKET_ */
276
277
278
279
280
281
282
283
284
285
online_distribution
blob
master
newbasic
Cpacket.h
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:27
using
1.8.2 with
sPHENIX GitHub integration