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 oduPackBool(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Bool */
51 #define cmPkStatus(x, mBuf) SPkS16(x, mBuf) /* pack Status */
52 #define cmPkTicks(x, mBuf) oduUnpackUInt32(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) oduUnpackUInt8(x, mBuf) /* pack Data */
56 #define cmPkRandom(x, mBuf) oduUnpackUInt16(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) oduUnpackUInt16(x, mBuf) /* pack ProcId */
60 #define cmPkVectNmb(x, mBuf) SPkS16(x, mBuf) /* pack VectNmb */
61 #define cmPkPrior(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Prior*/
62 #define cmPkPriority(x, mBuf) cmPkPrior(x, mBuf) /* pack Priority */
63 #define cmPkRoute(x, mBuf) oduUnpackUInt8(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) oduUnpackUInt8(x, mBuf) /* pack Ent */
68 #define cmPkInst(x, mBuf) oduUnpackUInt8(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) oduUnpackUInt8(x, mBuf) /* pack Region */
74 #define cmPkPool(x, mBuf) oduUnpackUInt8(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) oduUnpackUInt16(x, mBuf) /* pack Size */
83 #define cmPkSize(x, mBuf) oduUnpackUInt32(x, mBuf) /* pack Size */
86 /* general typedefs */
88 #define cmPkSelector(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Selector */
89 #define cmPkEvent(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Event */
90 #define cmPkCntr(x, mBuf) SPkS32(x, mBuf) /* pack Cntr */
91 #define cmPkStsCntr(x, mBuf) oduUnpackUInt32(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) oduUnpackUInt8(x, mBuf) /* pack Sapi */
98 #define cmPkTei(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Tei */
99 #define cmPkCes(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Ces */
100 #define cmPkDlci(x, mBuf) oduUnpackUInt32(x, mBuf) /* pack Dlci */
101 #define cmPkCalRef(x, mBuf) oduUnpackUInt16(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) oduUnpackUInt8(x, mBuf) /* pack Cause */
105 #define cmPkDgn(x, mBuf) oduUnpackUInt8(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 cmPkSeqUInt16(x, mBuf) oduUnpackUInt16(x, mBuf) /* pack SeqUInt16 */
109 #define cmPkSeqS24(x, mBuf) SPkS32(x, mBuf) /* pack SeqS24 */
110 #define cmPkSeqUInt24(x, mBuf) oduUnpackUInt32(x, mBuf) /* pack SeqUInt24 */
111 #define cmPkSetUpArb(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack SetUpArb */
112 #define cmPkEvntType(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack EvntType */
113 #define cmPkState(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack State */
114 #define cmPkMode(x, mBuf) oduUnpackUInt8(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) oduUnpackUInt32(x, mBuf) /* pack IpAddr */
129 #define cmPkPort(x, mBuf) oduUnpackUInt16(x, mBuf) /* pack Port */
130 #define cmPkCmd(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Cmd */
131 #define cmPkFlags(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Flags */
132 #define cmPkTtl(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Ttl */
133 #define cmPkPrec(x, mBuf) oduUnpackUInt8(x, mBuf) /* pack Prec */
134 #define cmPkWindow(x, mBuf) oduUnpackUInt32(x, mBuf) /* pack Window */
136 /* ISUP specific typedefs */
138 #define cmPkCirId(x, mBuf) oduUnpackUInt16(x, mBuf) /* pack CirId */
139 #define cmPkCic(x, mBuf) oduUnpackUInt16(x, mBuf) /* pack Cic */
140 #define cmPkSiInstId(x, mBuf) oduUnpackUInt32(x, mBuf) /* pack SiInstId */
142 /* TUP specific typedefs */
144 #define cmPkTpInstId(x, mBuf) oduUnpackUInt32(x, mBuf) /* pack TpInstId */
146 /* PNNI specific typedefs */
147 #define cmPkPnPortId(x, mBuf) oduUnpackUInt32(x, mBuf)
150 /* unpacking macros */
152 /* system services typedefs */
154 #define oduUnpackBool(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Bool */
155 #define cmUnpkStatus(x, mBuf) SUnpkS16(x, mBuf) /* unpack Status */
156 #define cmUnpkTicks(x, mBuf) oduPackUInt32(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) oduPackUInt8(x, mBuf) /* unpack Data */
160 #define cmUnpkRandom(x, mBuf) oduPackUInt16(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) oduPackUInt16(x, mBuf) /* unpack ProcId */
164 #define cmUnpkVectNmb(x, mBuf) SUnpkS16(x, mBuf) /* unpack VectNmb */
165 #define cmUnpkPrior(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Prior */
166 #define cmUnpkPriority(x, mBuf) cmUnpkPrior(x, mBuf) /* unpack Priority */
167 #define cmUnpkRoute(x, mBuf) oduPackUInt8(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) oduPackUInt8(x, mBuf) /* unpack Ent */
172 #define cmUnpkInst(x, mBuf) oduPackUInt8(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) oduPackUInt8(x, mBuf) /* unpack Region */
178 #define cmUnpkPool(x, mBuf) oduPackUInt8(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) oduPackUInt16(x, mBuf) /* unpack Size */
187 #define cmUnpkSize(x, mBuf) oduPackUInt32(x, mBuf) /* unpack Size */
190 /* general typedefs */
192 #define cmUnpkSelector(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Selector */
193 #define cmUnpkEvent(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Event */
194 #define cmUnpkCntr(x, mBuf) SUnpkS32(x, mBuf) /* unpack Cntr */
195 #define cmUnpkStsCntr(x, mBuf) oduPackUInt32(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) oduPackUInt8(x, mBuf) /* unpack Sapi */
202 #define cmUnpkTei(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Tei */
203 #define cmUnpkCes(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Ces */
204 #define cmUnpkDlci(x, mBuf) oduPackUInt32(x, mBuf) /* unpack Dlci */
205 #define cmUnpkCalRef(x, mBuf) oduPackUInt16(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) oduPackUInt8(x, mBuf) /* unpack Cause */
209 #define cmUnpkDgn(x, mBuf) oduPackUInt8(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 cmUnpkSeqUInt16(x, mBuf) oduPackUInt16(x, mBuf) /* unpack SeqUInt16 */
213 #define cmUnpkSeqS24(x, mBuf) SUnpkS32(x, mBuf) /* unpack SeqS24 */
214 #define cmUnpkSeqUInt24(x, mBuf) oduPackUInt32(x, mBuf) /* unpack SeqUInt24 */
215 #define cmUnpkSetUpArb(x, mBuf) oduPackUInt8(x, mBuf) /* unpack SetUpArb */
216 #define cmUnpkEvntType(x, mBuf) oduPackUInt8(x, mBuf) /* unpack EvntType */
217 #define cmUnpkState(x, mBuf) oduPackUInt8(x, mBuf) /* unpack State */
218 #define cmUnpkMode(x, mBuf) oduPackUInt8(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) oduPackUInt32(x, mBuf) /* unpack IpAddr */
233 #define cmUnpkPort(x, mBuf) oduPackUInt16(x, mBuf) /* unpack Port */
234 #define cmUnpkCmd(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Cmd */
235 #define cmUnpkFlags(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Flags */
236 #define cmUnpkTtl(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Ttl */
237 #define cmUnpkPrec(x, mBuf) oduPackUInt8(x, mBuf) /* unpack Prec */
238 #define cmUnpkWindow(x, mBuf) oduPackUInt32(x, mBuf) /* unpack Window */
240 /* ISUP specific typedefs */
242 #define cmUnpkCirId(x, mBuf) oduPackUInt16(x, mBuf) /* unpack CirId */
243 #define cmUnpkCic(x, mBuf) oduPackUInt16(x, mBuf) /* unpack Cic */
244 #define cmUnpkSiInstId(x, mBuf) oduPackUInt32(x, mBuf) /* unpack SiInstId */
246 /* TUP specific typedefs */
248 #define cmUnpkTpInstId(x, mBuf) oduPackUInt32(x, mBuf) /* unpack TpInstId */
250 /* PNNI specific typedefs */
251 #define cmUnpkPnPortId(x, mBuf) oduPackUInt32(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) oduUnpackUInt8(x, mBuf) /* pack ProfileId */
259 #define cmUnpkProfileId(x, mBuf) oduPackUInt8(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(oduUnpackUInt8, tknStr->val[i], mBuf); \
276 CMCHKPK(oduUnpackUInt8, tknStr->len, mBuf); \
280 CMCHKPK(oduUnpackUInt8, tknStr->pres, mBuf); \
283 #define CMUNPKTKNSTR(tknStr, mBuf) \
288 CMCHKUNPK(oduPackUInt8, &tknStr->pres, mBuf); \
293 CMCHKUNPK(oduPackUInt8, &tknStr->len, mBuf); \
296 for (i = 1; i <= (S16) tknStr->len; i++) \
298 CMCHKUNPK(oduPackUInt8, &tknStr->val[tknStr->len - i], mBuf); \
304 #endif /* __CMGENH__ */
306 /**********************************************************************
308 **********************************************************************/