ECCE @ EIC Software
 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 
58 
62 
66 
69 
74 
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 
137 
147 
151 
157 
161 
162 #endif
163 
164 
165 /*
166 ** ==================================================================
167 ** Inlined GENERIC routines that do not need the indirection arrays
168 ** ==================================================================
169 */
170 
172 {
173  return getBitsMACRO(packet_ptr,
177 }
178 
179 
181 {
183 
184 #ifdef STRONGCHECK
185  if ((length&(1<<32))!=0) return valueFailure;
186 #endif
187 
188  return length;
189 }
190 
192 {
193  BYTE hdrVersion = (BYTE)getBitsMACRO(packet_ptr,
197 
198  if ((hdrVersion >= numPacketVersions)||(hdrVersion==0)) {
200  packet_ptr, hdrVersion);
201  return valueFailure;
202  }
203 
204  return hdrVersion;
205 }
206 
208 {
209 #ifdef CHECK
210  if ((hdrVersion >= numPacketVersions)||(hdrVersion==0)) {
212  packet_ptr, hdrVersion);
213  return valueFailure;
214  }
215 #endif
216  setBitsMACRO(packet_ptr,
219  PACKET_HDR_VERSION_MASK, hdrVersion);
220  return TRUE;
221 }
222 
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 
240 {
241 #ifdef CHECK
242  if (hdrLength >= ) {
243  setPacketError(FORMAT_ERR_INVALID_HDRLENGTH, packet_ptr, hdrLength);
244  return FALSE;
245  }
246 #endif
247 
250  PACKET_HDR_LENGTH_MASK, hdrLength);
251  return TRUE;
252 }
253 
254 
256 {
257  UINT version = getPacketHdrVersion(packet_ptr);
258  return (version == currentPacketHdrVersion);
259 }
260 
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