1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /********************************************************************20**
21 Name: common general functions
25 Desc: Defines required by common functions.
26 Macros for packing and unpacking coomon scalar typedefs.
30 Sid: cm_gen.h@@/main/6 - Fri Sep 16 02:55:20 2005
34 *********************************************************************21*/
48 /* system services typedefs */
50 #define cmPkBool(x, mBuf) SPkU8(x, mBuf) /* pack Bool */
51 #define cmPkStatus(x, mBuf) SPkS16(x, mBuf) /* pack Status */
52 #define cmPkTicks(x, mBuf) SPkU32(x, mBuf) /* pack Ticks */
53 #define cmPkQLen(x, mBuf) SPkS16(x, mBuf) /* pack QLen */
54 #define cmPkOrder(x, mBuf) SPkS16(x, mBuf) /* pack Order */
55 #define cmPkData(x, mBuf) SPkU8(x, mBuf) /* pack Data */
56 #define cmPkRandom(x, mBuf) SPkU16(x, mBuf) /* pack Random */
57 #define cmPkSeq(x, mBuf) SPkS16(x, mBuf) /* pack Seq */
58 #define cmPkReason(x, mBuf) SPkS16(x, mBuf) /* pack Reason */
59 #define cmPkProcId(x, mBuf) SPkU16(x, mBuf) /* pack ProcId */
60 #define cmPkVectNmb(x, mBuf) SPkS16(x, mBuf) /* pack VectNmb */
61 #define cmPkPrior(x, mBuf) SPkU8(x, mBuf) /* pack Prior*/
62 #define cmPkPriority(x, mBuf) cmPkPrior(x, mBuf) /* pack Priority */
63 #define cmPkRoute(x, mBuf) SPkU8(x, mBuf) /* pack Route */
64 #define cmPkTtype(x, mBuf) SPkS16(x, mBuf) /* pack Ttype */
65 #define cmPkSema(x, mBuf) SPkS8(x, mBuf) /* pack Sema */
66 #define cmPkTxt(x, mBuf) SPkS8(x, mBuf) /* pack Txt */
67 #define cmPkEnt(x, mBuf) SPkU8(x, mBuf) /* pack Ent */
68 #define cmPkInst(x, mBuf) SPkU8(x, mBuf) /* pack Inst */
69 #define cmPkElmnt(x, mBuf) SPkS16(x, mBuf) /* pack Elmnt */
70 #define cmPkElmntInst1(x, mBuf) SPkS16(x, mBuf) /* pack ElmntInst1 */
71 #define cmPkElmntInst2(x, mBuf) SPkS16(x, mBuf) /* pack ElmntInst2 */
72 #define cmPkElmntInst3(x, mBuf) SPkS16(x, mBuf) /* pack ElmntInst3 */
73 #define cmPkRegion(x, mBuf) SPkU8(x, mBuf) /* pack Region */
74 #define cmPkPool(x, mBuf) SPkU8(x, mBuf) /* pack Pool */
76 #define cmPkMsgLen(x, mBuf) SPkS32(x, mBuf) /* pack MsgLen */
78 #define cmPkMsgLen(x, mBuf) SPkS16(x, mBuf) /* pack MsgLen */
81 #define cmPkSize(x, mBuf) SPkU16(x, mBuf) /* pack Size */
83 #define cmPkSize(x, mBuf) SPkU32(x, mBuf) /* pack Size */
86 /* general typedefs */
88 #define cmPkSelector(x, mBuf) SPkU8(x, mBuf) /* pack Selector */
89 #define cmPkEvent(x, mBuf) SPkU8(x, mBuf) /* pack Event */
90 #define cmPkCntr(x, mBuf) SPkS32(x, mBuf) /* pack Cntr */
91 #define cmPkStsCntr(x, mBuf) SPkU32(x, mBuf) /* pack StsCntr */
92 #define cmPkLnkNmb(x, mBuf) SPkS16(x, mBuf) /* pack LnkNmb */
93 #define cmPkSuId(x, mBuf) SPkS16(x, mBuf) /* pack SuId */
94 #define cmPkSpId(x, mBuf) SPkS16(x, mBuf) /* pack SpId */
95 #define cmPkSuInstId(x, mBuf) SPkS16(x, mBuf) /* pack SuInstId */
96 #define cmPkSpInstInd(x, mBuf) SPkS16(x, mBuf) /* pack SpInstInd */
97 #define cmPkSapi(x, mBuf) SPkU8(x, mBuf) /* pack Sapi */
98 #define cmPkTei(x, mBuf) SPkU8(x, mBuf) /* pack Tei */
99 #define cmPkCes(x, mBuf) SPkU8(x, mBuf) /* pack Ces */
100 #define cmPkDlci(x, mBuf) SPkU32(x, mBuf) /* pack Dlci */
101 #define cmPkCalRef(x, mBuf) SPkU16(x, mBuf) /* pack CalRef */
102 #define cmPkOrigin(x, mBuf) SPkS16(x, mBuf) /* pack Origin */
103 #define cmPkSwtch(x, mBuf) SPkS16(x, mBuf) /* pack Swtch */
104 #define cmPkCause(x, mBuf) SPkU8(x, mBuf) /* pack Cause */
105 #define cmPkDgn(x, mBuf) SPkU8(x, mBuf) /* pack Dgn */
106 #define cmPkAction(x, mBuf) SPkS16(x, mBuf) /* pack Action */
107 #define cmPkSeqS16(x, mBuf) SPkS16(x, mBuf) /* pack SeqS16 */
108 #define cmPkSeqU16(x, mBuf) SPkU16(x, mBuf) /* pack SeqU16 */
109 #define cmPkSeqS24(x, mBuf) SPkS32(x, mBuf) /* pack SeqS24 */
110 #define cmPkSeqU24(x, mBuf) SPkU32(x, mBuf) /* pack SeqU24 */
111 #define cmPkSetUpArb(x, mBuf) SPkU8(x, mBuf) /* pack SetUpArb */
112 #define cmPkEvntType(x, mBuf) SPkU8(x, mBuf) /* pack EvntType */
113 #define cmPkState(x, mBuf) SPkU8(x, mBuf) /* pack State */
114 #define cmPkMode(x, mBuf) SPkU8(x, mBuf) /* pack Mode */
115 #define cmPkConnId(x, mBuf) SPkS32(x, mBuf) /* pack ConnId */
117 /* scc specific typedefs */
119 #define cmPkBaud(x, mBuf) SPkS16(x, mBuf) /* pack Baud */
120 #define cmPkPhysIntType(x, mBuf) SPkS16(x, mBuf) /* pack PhysIntType */
121 #define cmPkPathConnType(x, mBuf) SPkS16(x, mBuf) /* pack PathConnType */
122 #define cmPkParity(x, mBuf) SPkS16(x, mBuf) /* pack Parity */
123 #define cmPkCharLength(x, mBuf) SPkS16(x, mBuf) /* pack CharLength */
124 #define cmPkStopBits(x, mBuf) SPkS16(x, mBuf) /* pack StopBits */
126 /* tcp/ip specific typedefs */
128 #define cmPkIpAddr(x, mBuf) SPkU32(x, mBuf) /* pack IpAddr */
129 #define cmPkPort(x, mBuf) SPkU16(x, mBuf) /* pack Port */
130 #define cmPkCmd(x, mBuf) SPkU8(x, mBuf) /* pack Cmd */
131 #define cmPkFlags(x, mBuf) SPkU8(x, mBuf) /* pack Flags */
132 #define cmPkTtl(x, mBuf) SPkU8(x, mBuf) /* pack Ttl */
133 #define cmPkPrec(x, mBuf) SPkU8(x, mBuf) /* pack Prec */
134 #define cmPkWindow(x, mBuf) SPkU32(x, mBuf) /* pack Window */
136 /* ISUP specific typedefs */
138 #define cmPkCirId(x, mBuf) SPkU16(x, mBuf) /* pack CirId */
139 #define cmPkCic(x, mBuf) SPkU16(x, mBuf) /* pack Cic */
140 #define cmPkSiInstId(x, mBuf) SPkU32(x, mBuf) /* pack SiInstId */
142 /* TUP specific typedefs */
144 #define cmPkTpInstId(x, mBuf) SPkU32(x, mBuf) /* pack TpInstId */
146 /* PNNI specific typedefs */
147 #define cmPkPnPortId(x, mBuf) SPkU32(x, mBuf)
150 /* unpacking macros */
152 /* system services typedefs */
154 #define cmUnpkBool(x, mBuf) SUnpkU8(x, mBuf) /* unpack Bool */
155 #define cmUnpkStatus(x, mBuf) SUnpkS16(x, mBuf) /* unpack Status */
156 #define cmUnpkTicks(x, mBuf) SUnpkU32(x, mBuf) /* unpack Ticks */
157 #define cmUnpkQLen(x, mBuf) SUnpkS16(x, mBuf) /* unpack QLen */
158 #define cmUnpkOrder(x, mBuf) SUnpkS16(x, mBuf) /* unpack Order */
159 #define cmUnpkData(x, mBuf) SUnpkU8(x, mBuf) /* unpack Data */
160 #define cmUnpkRandom(x, mBuf) SUnpkU16(x, mBuf) /* unpack Random */
161 #define cmUnpkSeq(x, mBuf) SUnpkS16(x, mBuf) /* unpack Seq */
162 #define cmUnpkReason(x, mBuf) SUnpkS16(x, mBuf) /* unpack Reason */
163 #define cmUnpkProcId(x, mBuf) SUnpkU16(x, mBuf) /* unpack ProcId */
164 #define cmUnpkVectNmb(x, mBuf) SUnpkS16(x, mBuf) /* unpack VectNmb */
165 #define cmUnpkPrior(x, mBuf) SUnpkU8(x, mBuf) /* unpack Prior */
166 #define cmUnpkPriority(x, mBuf) cmUnpkPrior(x, mBuf) /* unpack Priority */
167 #define cmUnpkRoute(x, mBuf) SUnpkU8(x, mBuf) /* unpack Route */
168 #define cmUnpkTtype(x, mBuf) SUnpkS16(x, mBuf) /* unpack Ttype */
169 #define cmUnpkSema(x, mBuf) SUnpkS8(x, mBuf) /* unpack Sema */
170 #define cmUnpkTxt(x, mBuf) SUnpkS8(x, mBuf) /* unpack Txt */
171 #define cmUnpkEnt(x, mBuf) SUnpkU8(x, mBuf) /* unpack Ent */
172 #define cmUnpkInst(x, mBuf) SUnpkU8(x, mBuf) /* unpack Inst */
173 #define cmUnpkElmnt(x, mBuf) SUnpkS16(x, mBuf) /* unpack Elmnt */
174 #define cmUnpkElmntInst1(x, mBuf) SUnpkS16(x, mBuf) /* unpack ElmntInst1 */
175 #define cmUnpkElmntInst2(x, mBuf) SUnpkS16(x, mBuf) /* unpack ElmntInst2 */
176 #define cmUnpkElmntInst3(x, mBuf) SUnpkS16(x, mBuf) /* unpack ElmntInst3 */
177 #define cmUnpkRegion(x, mBuf) SUnpkU8(x, mBuf) /* unpack Region */
178 #define cmUnpkPool(x, mBuf) SUnpkU8(x, mBuf) /* unpack Pool */
180 #define cmUnpkMsgLen(x, mBuf) SUnpkS32(x, mBuf) /* unpack MsgLen */
182 #define cmUnpkMsgLen(x, mBuf) SUnpkS16(x, mBuf) /* unpack MsgLen */
185 #define cmUnpkSize(x, mBuf) SUnpkU16(x, mBuf) /* unpack Size */
187 #define cmUnpkSize(x, mBuf) SUnpkU32(x, mBuf) /* unpack Size */
190 /* general typedefs */
192 #define cmUnpkSelector(x, mBuf) SUnpkU8(x, mBuf) /* unpack Selector */
193 #define cmUnpkEvent(x, mBuf) SUnpkU8(x, mBuf) /* unpack Event */
194 #define cmUnpkCntr(x, mBuf) SUnpkS32(x, mBuf) /* unpack Cntr */
195 #define cmUnpkStsCntr(x, mBuf) SUnpkU32(x, mBuf) /* unpack StsCntr */
196 #define cmUnpkLnkNmb(x, mBuf) SUnpkS16(x, mBuf) /* unpack LnkNmb */
197 #define cmUnpkSuId(x, mBuf) SUnpkS16(x, mBuf) /* unpack SuId */
198 #define cmUnpkSpId(x, mBuf) SUnpkS16(x, mBuf) /* unpack SpId */
199 #define cmUnpkSuInstId(x, mBuf) SUnpkS16(x, mBuf) /* unpack SuInstId */
200 #define cmUnpkSpInstInd(x, mBuf) SUnpkS16(x, mBuf) /* unpack SpInstInd */
201 #define cmUnpkSapi(x, mBuf) SUnpkU8(x, mBuf) /* unpack Sapi */
202 #define cmUnpkTei(x, mBuf) SUnpkU8(x, mBuf) /* unpack Tei */
203 #define cmUnpkCes(x, mBuf) SUnpkU8(x, mBuf) /* unpack Ces */
204 #define cmUnpkDlci(x, mBuf) SUnpkU32(x, mBuf) /* unpack Dlci */
205 #define cmUnpkCalRef(x, mBuf) SUnpkU16(x, mBuf) /* unpack CalRef */
206 #define cmUnpkOrigin(x, mBuf) SUnpkS16(x, mBuf) /* unpack Origin */
207 #define cmUnpkSwtch(x, mBuf) SUnpkS16(x, mBuf) /* unpack Swtch */
208 #define cmUnpkCause(x, mBuf) SUnpkU8(x, mBuf) /* unpack Cause */
209 #define cmUnpkDgn(x, mBuf) SUnpkU8(x, mBuf) /* unpack Dgn */
210 #define cmUnpkAction(x, mBuf) SUnpkS16(x, mBuf) /* unpack Action */
211 #define cmUnpkSeqS16(x, mBuf) SUnpkS16(x, mBuf) /* unpack SeqS16 */
212 #define cmUnpkSeqU16(x, mBuf) SUnpkU16(x, mBuf) /* unpack SeqU16 */
213 #define cmUnpkSeqS24(x, mBuf) SUnpkS32(x, mBuf) /* unpack SeqS24 */
214 #define cmUnpkSeqU24(x, mBuf) SUnpkU32(x, mBuf) /* unpack SeqU24 */
215 #define cmUnpkSetUpArb(x, mBuf) SUnpkU8(x, mBuf) /* unpack SetUpArb */
216 #define cmUnpkEvntType(x, mBuf) SUnpkU8(x, mBuf) /* unpack EvntType */
217 #define cmUnpkState(x, mBuf) SUnpkU8(x, mBuf) /* unpack State */
218 #define cmUnpkMode(x, mBuf) SUnpkU8(x, mBuf) /* unpack Mode */
219 #define cmUnpkConnId(x, mBuf) SUnpkS32(x, mBuf) /* unpack ConnId */
221 /* scc specific typedefs */
223 #define cmUnpkBaud(x, mBuf) SUnpkS16(x, mBuf) /* unpack Baud */
224 #define cmUnpkPhysIntType(x, mBuf) SUnpkS16(x, mBuf) /* unpack PhysIntType */
225 #define cmUnpkPathConnType(x, mBuf) SUnpkS16(x, mBuf) /* unpack PathConnType */
226 #define cmUnpkParity(x, mBuf) SUnpkS16(x, mBuf) /* unpack Parity */
227 #define cmUnpkCharLength(x, mBuf) SUnpkS16(x, mBuf) /* unpack CharLength */
228 #define cmUnpkStopBits(x, mBuf) SUnpkS16(x, mBuf) /* unpack StopBits */
230 /* tcp/ip specific typedefs */
232 #define cmUnpkIpAddr(x, mBuf) SUnpkU32(x, mBuf) /* unpack IpAddr */
233 #define cmUnpkPort(x, mBuf) SUnpkU16(x, mBuf) /* unpack Port */
234 #define cmUnpkCmd(x, mBuf) SUnpkU8(x, mBuf) /* unpack Cmd */
235 #define cmUnpkFlags(x, mBuf) SUnpkU8(x, mBuf) /* unpack Flags */
236 #define cmUnpkTtl(x, mBuf) SUnpkU8(x, mBuf) /* unpack Ttl */
237 #define cmUnpkPrec(x, mBuf) SUnpkU8(x, mBuf) /* unpack Prec */
238 #define cmUnpkWindow(x, mBuf) SUnpkU32(x, mBuf) /* unpack Window */
240 /* ISUP specific typedefs */
242 #define cmUnpkCirId(x, mBuf) SUnpkU16(x, mBuf) /* unpack CirId */
243 #define cmUnpkCic(x, mBuf) SUnpkU16(x, mBuf) /* unpack Cic */
244 #define cmUnpkSiInstId(x, mBuf) SUnpkU32(x, mBuf) /* unpack SiInstId */
246 /* TUP specific typedefs */
248 #define cmUnpkTpInstId(x, mBuf) SUnpkU32(x, mBuf) /* unpack TpInstId */
250 /* PNNI specific typedefs */
251 #define cmUnpkPnPortId(x, mBuf) SUnpkU32(x, mBuf)
252 #define cmCmpPnNodeId(nodeId1, nodeId2) \
253 cmCmpStr(&(nodeId1)->id[0], PN_NODEID_LEN, \
254 &(nodeId2)->id[0], PN_NODEID_LEN)
256 /* PLOA - HCC profileId */
257 #define cmPkProfileId(x, mBuf) SPkU8(x, mBuf) /* pack ProfileId */
259 #define cmUnpkProfileId(x, mBuf) SUnpkU8(x, mBuf) /* unpack ProfileId */
261 /* packing and unpacking for token strings */
263 #define CMPKTKNSTR(tknStr, mBuf) \
270 for (i = 0; i < (S16) tknStr->len; i++) \
272 CMCHKPK(SPkU8, tknStr->val[i], mBuf); \
276 CMCHKPK(SPkU8, tknStr->len, mBuf); \
280 CMCHKPK(SPkU8, tknStr->pres, mBuf); \
283 #define CMUNPKTKNSTR(tknStr, mBuf) \
288 CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); \
293 CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf); \
296 for (i = 1; i <= (S16) tknStr->len; i++) \
298 CMCHKUNPK(SUnpkU8, &tknStr->val[tknStr->len - i], mBuf); \
304 #endif /* __CMGENH__ */
306 /**********************************************************************
308 **********************************************************************/