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**
25 Desc: This file contains the packing/unpacking functions
26 for the H.225 primitives on hct interface
30 *********************************************************************21*/
32 /* header include files (.h) */
34 #include "envopt.h" /* environment options */
35 #include "envdep.h" /* environment dependent */
36 #include "envind.h" /* environment independent */
38 #include "gen.h" /* general layer */
39 #include "ssi.h" /* system service interface */
43 /* header/extern include files (.x) */
45 #include "gen.x" /* general layer */
46 #include "ssi.x" /* system service interface */
48 /*#include "cm_tkns.x"*/
58 /* forward references */
60 /* local function definition */
62 /* functions in other modules */
64 /* public variable declarations */
66 /* control variables for testing */
68 /* private variable declarations */
74 /* cm_tpt_c_001.main_17 - Guarded under LCEGT and LCLEG */
75 /* cm_tpt_c_001.main_18 - Guarded under LWLCEGT */
77 #if ( defined(LCHCT) || defined (LWLCHCT) || defined(LCHIT) \
78 || defined(LCLHC) || defined(TRIL_HZ) \
79 || defined(LCHRT) || defined(LCLHR) \
80 || defined(LCLMG) || defined(LCMGT) \
81 || defined(LCLHG) || defined(LCHGT) \
82 || defined(LCSCT) || defined(LCLSB) \
83 || defined(LCLNT) || defined(LCLLN) \
84 || defined(LCLSO) || defined(LCSOT) \
85 || defined(LCEGT) || defined(LCLEG) || defined(LWLCEGT) \
86 || defined(CM_COMPRESS) \
92 /* Add prototypes here (MB) */
103 /* Moving IPv4 address packing functions from cm_inet.c */
106 * Fun: cmPkCmIpv4TptAddr
108 * Desc: This function packs the IPv4 address
117 S16 cmPkCmIpv4TptAddr
119 CmIpv4TptAddr *pkParam, /* IPv4 Address structure */
120 Buffer *mBuf /* message buffer */
124 CMCHKPK(cmPkCmIpv4NetAddr, pkParam->address, mBuf);
125 CMCHKPK(oduUnpackUInt16, pkParam->port, mBuf);
128 } /* cmPkCmIpv4TptAddr */
132 * Fun: cmPkCmIpv6NetAddr
134 * Desc: This function packs the 16 bytes of IPv6 address
143 static S16 cmPkCmIpv6NetAddr
145 CmIpv6NetAddr *pkParam,
146 Buffer *mBuf /* message buffer */
150 uint8_t *ptr = (uint8_t*)pkParam;
153 for(num = 0; num < CM_IPV6ADDR_SIZE; num++)
155 CMCHKPK(oduUnpackUInt8, *(ptr+num), mBuf);
159 } /* end of cmPkCmIpv6NetAddr */
164 * Fun: cmPkCmIpv6TptAddr
166 * Desc: This function packs the IPv6 transport address
175 static S16 cmPkCmIpv6TptAddr
177 CmIpv6TptAddr *pkParam, /* IPv6 transport address */
178 Buffer *mBuf /* message buffer */
182 CMCHKPK(cmPkCmIpv6NetAddr, &pkParam->ipv6NetAddr, mBuf);
183 CMCHKPK(oduUnpackUInt16, pkParam->port, mBuf);
186 } /* cmPkCmIpv6TptAddr */
191 * Fun: cmPkCmNetAddrTbl
193 * Desc: This function packs the
204 CmNetAddrTbl *pkParam, /* Network Address Table */
205 Buffer *mBuf /* message buffer */
208 uint16_t idx; /* Loop Index */
209 CmNetAddr *netAddr; /* Network Address */
212 if (pkParam->count > CM_MAX_NET_ADDR)
215 /* Pack All the addresses */
216 for (idx = pkParam->count; idx; idx--)
218 netAddr = &(pkParam->netAddr[idx - 1]);
220 if ((cmPkCmNetAddr(netAddr, mBuf)) != ROK)
224 /* Pack the total number of addresses present in the table */
225 CMCHKPK(oduUnpackUInt16, pkParam->count, mBuf);
229 } /* end of cmPkCmNetAddrTbl() */
235 * Desc: This function packs the
247 Buffer *mBuf /* message buffer */
251 switch (pkParam->type)
253 case CM_NETADDR_NOTPRSNT:
256 case CM_NETADDR_IPV4:
257 CMCHKPK(cmPkCmIpv4NetAddr, pkParam->u.ipv4NetAddr, mBuf);
260 case CM_NETADDR_IPV6:
261 CMCHKPK(cmPkCmIpv6NetAddr, &pkParam->u.ipv6NetAddr, mBuf);
267 CMCHKPK(oduUnpackUInt8, pkParam->type, mBuf);
270 } /* cmPkCmNetAddr */
277 * Desc: This function packs the
289 Buffer *mBuf /* message buffer */
293 switch (pkParam->type)
295 case CM_TPTADDR_NOTPRSNT:
298 case CM_TPTADDR_IPV4:
299 CMCHKPK(cmPkCmIpv4TptAddr, &pkParam->u.ipv4TptAddr, mBuf);
302 case CM_TPTADDR_IPV6:
303 CMCHKPK(cmPkCmIpv6TptAddr, &pkParam->u.ipv6TptAddr, mBuf);
309 CMCHKPK(oduUnpackUInt8, pkParam->type, mBuf);
312 } /* cmPkCmTptAddr */
314 /* added new packing functions */
318 * Fun: cmPkCmTptLocalInf
320 * Desc: This function packs the local interface info on which IPV4/IPV6
321 * packet was received on.
330 S16 cmPkCmTptLocalInf
332 CmTptLocalInf *pkParam, /* local interface info */
333 Buffer *mBuf /* message buffer */
337 if (pkParam->intfPrsnt == TRUE)
339 /* pack the actual interface address */
340 CMCHKPK(cmPkCmNetAddr, &pkParam->localIfAddr, mBuf);
341 /* pack the interface index value */
342 CMCHKPK(oduUnpackUInt32, pkParam->localIf, mBuf);
344 /* pack the boll which indicates if valid local intf is present or not */
345 CMCHKPK(oduUnpackUInt8, pkParam->intfPrsnt, mBuf);
347 } /* cmPkCmTptLocalInf */
348 #endif /* LOCAL_INTF */
350 /* Moving IPv6 multicast information packing functions from cm_inet.c */
351 #ifdef IPV6_SUPPORTED
354 * Fun: cmPkCmNetMCastInf6
356 * Desc: This function packs the IPv6 multicast information
365 S16 cmPkCmNetMCastInf6
367 CmNetMCastInf6 *pkParam, /* IPv6 multicast information */
368 Buffer *mBuf /* message buffer */
372 CMCHKPK(cmPkCmIpv6NetAddr, &pkParam->mCastAddr, mBuf);
373 CMCHKPK(oduUnpackUInt32, pkParam->localInf, mBuf);
376 } /* cmPkCmNetMCastInf6 */
377 #endif /* IPV6_SUPPORTED */
382 * Fun: cmPkCmSockOpts
384 * Desc: This function packs the
393 static S16 cmPkCmSockOpts
396 Buffer *mBuf /* message buffer */
400 switch (pkParam->option)
402 case CM_SOCKOPT_OPT_ADD_MCAST_MBR:
403 case CM_SOCKOPT_OPT_DRP_MCAST_MBR:
405 CMCHKPK(cmPkCmNetAddr, &pkParam->optVal.mCastInfo.mCastAddr, mBuf);
406 CMCHKPK(cmPkCmNetAddr, &pkParam->optVal.mCastInfo.localAddr, mBuf);
408 CMCHKPK(cmPkCmNetAddr, &pkParam->optVal.mCastAddr, mBuf);
409 #endif /* CM_INET2 */
412 case CM_SOCKOPT_OPT_MCAST_IF:
413 CMCHKPK(cmPkCmNetAddr, &pkParam->optVal.lclAddr, mBuf);
416 #ifdef IPV6_SUPPORTED
417 case CM_SOCKOPT_OPT_ADD_MCAST6_MBR:
418 case CM_SOCKOPT_OPT_DRP_MCAST6_MBR:
419 CMCHKPK(cmPkCmNetMCastInf6, &pkParam->optVal.mCastInfo6, mBuf);
422 case CM_SOCKOPT_OPT_MCAST6_IF:
423 CMCHKPK(oduUnpackUInt32, pkParam->optVal.infId, mBuf);
426 #endif /* IPV6_SUPPORTED */
429 CMCHKPK(oduUnpackUInt32, pkParam->optVal.value, mBuf);
432 CMCHKPK(oduUnpackUInt32, pkParam->option, mBuf);
433 CMCHKPK(oduUnpackUInt32, pkParam->level, mBuf);
436 } /* cmPkCmSockOpts */
441 * Fun: cmPkCmSockParam
443 * Desc: This function packs the
452 static S16 cmPkCmSockParam
454 CmSockParam *pkParam,
455 Buffer *mBuf /* message buffer */
461 if( pkParam->numOpts > CM_MAX_SOCK_OPTS)
465 for(num = 0; num < pkParam->numOpts; num++)
467 CMCHKPK(cmPkCmSockOpts, &pkParam->sockOpts[num], mBuf);
469 CMCHKPK(oduUnpackUInt8, pkParam->numOpts, mBuf);
470 CMCHKPK(oduUnpackUInt8, pkParam->listenQSize, mBuf);
473 } /* cmPkCmSockParam */
479 * Fun: cmPkTlsTptParam
481 * Desc: This function packs the
490 static S16 cmPkTlsTptParam
492 TlsTptParam *pkParam, /**/
493 Buffer *mBuf /* message buffer */
499 if( pkParam->numOpts > CM_MAX_SOCK_OPTS)
503 for(num = 0; num < pkParam->numOpts; num++)
505 CMCHKPK(cmPkCmSockOpts, &pkParam->sockOpts[num], mBuf);
507 CMCHKPK(oduUnpackUInt8, pkParam->numOpts, mBuf);
508 CMCHKPK(oduUnpackUInt8, pkParam->listenQSize, mBuf);
509 CMCHKPK(SPkS16, pkParam->ctxId, mBuf);
512 } /* cmPkTlsTptParam */
519 * Fun: cmPkCmTptParam
521 * Desc: This function packs the
533 Buffer *mBuf /* message buffer */
537 switch (pkParam->type)
539 case CM_TPTPARAM_NOTPRSNT:
542 case CM_TPTPARAM_SOCK:
543 CMCHKPK(cmPkCmSockParam, &pkParam->u.sockParam, mBuf);
547 case CM_TPTPARAM_AAL:
548 CMCHKPK(cmPkAalConParam, &pkParam->u.aalParam, mBuf);
553 case CM_TPTPARAM_TLS:
554 CMCHKPK(cmPkTlsTptParam, &pkParam->u.tlsParam, mBuf);
562 CMCHKPK(oduUnpackUInt8, pkParam->type, mBuf);
565 } /* cmPkCmTptParam */
569 * UNPACKING FUNCTIONS
572 /* Moving IPv4 address un-packing functions from cm_inet.c file */
576 * Fun: cmUnpkCmIpv4TptAddr
578 * Desc: This function unpacks the IPv4 address
587 S16 cmUnpkCmIpv4TptAddr
589 CmIpv4TptAddr *unpkParam, /* IPv4 Address */
590 Buffer *mBuf /* message buffer */
594 CMCHKUNPK(oduPackUInt16, &unpkParam->port, mBuf);
595 CMCHKUNPK(cmUnpkCmIpv4NetAddr, &unpkParam->address, mBuf);
598 } /* cmUnpkCmIpv4TptAddr */
603 * Fun: cmUnpkCmIpv6NetAddr
605 * Desc: This function unpacks the 16 bytes of IPv6 address
614 static S16 cmUnpkCmIpv6NetAddr
616 CmIpv6NetAddr *unpkParam, /* IPv6 address */
617 Buffer *mBuf /* message buffer */
621 uint8_t *ptr = (uint8_t*)unpkParam;
624 ptr += (CM_INET_IPV6ADDR_SIZE - 1);
626 for(num = 0; num < CM_IPV6ADDR_SIZE; num++)
628 CMCHKUNPK(oduPackUInt8, (ptr-num), mBuf);
632 } /* end of cmUnpkCmIpv6NetAddr */
637 * Fun: cmUnpkCmIpv6TptAddr
639 * Desc: This function unpacks the IPv6 transport address
648 static S16 cmUnpkCmIpv6TptAddr
650 CmIpv6TptAddr *unpkParam, /* IPv6 transport address */
651 Buffer *mBuf /* message buffer */
655 CMCHKUNPK(oduPackUInt16, &unpkParam->port, mBuf);
656 CMCHKUNPK(cmUnpkCmIpv6NetAddr, &unpkParam->ipv6NetAddr, mBuf);
659 } /* cmUnpkCmIpv6TptAddr */
664 * Fun: cmUnpkCmNetAddrTbl
666 * Desc: This function unpacks the
675 S16 cmUnpkCmNetAddrTbl
677 CmNetAddrTbl *unpkParam, /* Network Address Table */
678 Buffer *mBuf /* message buffer */
681 uint16_t idx; /* Loop Index */
682 CmNetAddr *netAddr; /* Network Address */
684 /* Unpack the count */
685 CMCHKUNPK(oduPackUInt16, &(unpkParam->count), mBuf);
687 /* Unpack the addresses */
688 for (idx = 0; idx < unpkParam->count; idx++)
690 netAddr = &(unpkParam->netAddr[idx]);
692 if ((cmUnpkCmNetAddr(netAddr, mBuf)) != ROK)
698 } /* end of cmUnpkCmNetAddrTbl() */
703 * Fun: cmUnpkCmNetAddr
705 * Desc: This function unpacks the network address
716 CmNetAddr *unpkParam,
717 Buffer *mBuf /* message buffer */
721 CMCHKUNPK(oduPackUInt8, &unpkParam->type, mBuf);
723 switch (unpkParam->type)
725 case CM_NETADDR_NOTPRSNT:
728 case CM_NETADDR_IPV4:
729 CMCHKUNPK(cmUnpkCmIpv4NetAddr, &unpkParam->u.ipv4NetAddr, mBuf);
732 case CM_NETADDR_IPV6:
733 CMCHKUNPK(cmUnpkCmIpv6NetAddr, &unpkParam->u.ipv6NetAddr, mBuf);
741 } /* cmUnpkCmNetAddr */
746 * Fun: cmUnpkCmTptAddr
748 * Desc: This function unpacks the
759 CmTptAddr *unpkParam,
760 Buffer *mBuf /* message buffer */
764 CMCHKUNPK(oduPackUInt8, &unpkParam->type, mBuf);
766 switch (unpkParam->type)
768 case CM_TPTADDR_NOTPRSNT:
771 case CM_TPTADDR_IPV4:
772 CMCHKUNPK(cmUnpkCmIpv4TptAddr, &unpkParam->u.ipv4TptAddr, mBuf);
775 case CM_TPTADDR_IPV6:
776 CMCHKUNPK(cmUnpkCmIpv6TptAddr, &unpkParam->u.ipv6TptAddr, mBuf);
784 } /* cmUnpkCmTptAddr */
786 /* Moving IPv6 multicast information unpacking functions from cm_inet.c */
787 #ifdef IPV6_SUPPORTED
791 * Fun: cmUnpkCmNetMCastInf6
793 * Desc: This function unpacks the IPv6 multicast information
802 S16 cmUnpkCmNetMCastInf6
804 CmNetMCastInf6 *unpkParam, /* IPv6 multicast information */
805 Buffer *mBuf /* message buffer */
809 CMCHKUNPK(oduPackUInt32, &unpkParam->localInf, mBuf);
810 CMCHKUNPK(cmUnpkCmIpv6NetAddr, &unpkParam->mCastAddr, mBuf);
813 } /* cmUnpkCmNetMCastInf6 */
814 #endif /* IPV6_SUPPORTED */
819 * Fun: cmUnpkCmSockOpts
821 * Desc: This function unpacks the socket options
830 static S16 cmUnpkCmSockOpts
832 CmSockOpts *unpkParam, /* socket options */
833 Buffer *mBuf /* message buffer */
837 CMCHKUNPK(oduPackUInt32, &unpkParam->level, mBuf);
838 CMCHKUNPK(oduPackUInt32, &unpkParam->option, mBuf);
840 switch (unpkParam->option)
842 case CM_SOCKOPT_OPT_ADD_MCAST_MBR:
843 case CM_SOCKOPT_OPT_DRP_MCAST_MBR:
845 CMCHKUNPK(cmUnpkCmNetAddr, &unpkParam->optVal.mCastInfo.localAddr,
847 CMCHKUNPK(cmUnpkCmNetAddr, &unpkParam->optVal.mCastInfo.mCastAddr,
850 CMCHKUNPK(cmUnpkCmNetAddr, &unpkParam->optVal.mCastAddr, mBuf);
851 #endif /* CM_INET2 */
854 case CM_SOCKOPT_OPT_MCAST_IF:
855 CMCHKUNPK(cmUnpkCmNetAddr, &unpkParam->optVal.lclAddr, mBuf);
858 #ifdef IPV6_SUPPORTED
859 case CM_SOCKOPT_OPT_ADD_MCAST6_MBR:
860 case CM_SOCKOPT_OPT_DRP_MCAST6_MBR:
861 CMCHKUNPK(cmUnpkCmNetMCastInf6, &unpkParam->optVal.mCastInfo6, mBuf);
864 case CM_SOCKOPT_OPT_MCAST6_IF:
865 CMCHKUNPK(oduPackUInt32, &unpkParam->optVal.infId, mBuf);
867 #endif /* IPV6_SUPPORTED */
870 CMCHKUNPK(oduPackUInt32, &unpkParam->optVal.value, mBuf);
875 } /* cmUnpkCmSockOpts */
880 * Fun: cmUnpkCmSockParam
882 * Desc: This function unpacks the socket parameters
891 static S16 cmUnpkCmSockParam
893 CmSockParam *unpkParam, /* socket parameters */
894 Buffer *mBuf /* message buffer */
900 CMCHKUNPK(oduPackUInt8, &unpkParam->listenQSize, mBuf);
901 CMCHKUNPK(oduPackUInt8, &unpkParam->numOpts, mBuf);
903 if( unpkParam->numOpts > CM_MAX_SOCK_OPTS)
908 for(num = 0; num < unpkParam->numOpts; num++)
910 CMCHKUNPK(cmUnpkCmSockOpts, &unpkParam->sockOpts[num], mBuf);
914 } /* cmUnpkCmSockParam */
920 * Fun: cmUnpkTlsTptParam
922 * Desc: This function unpacks the socket parameters
931 static S16 cmUnpkTlsTptParam
933 TlsTptParam *unpkParam, /* TLS parameters */
934 Buffer *mBuf /* message buffer */
940 CMCHKUNPK(SUnpkS16, &unpkParam->ctxId, mBuf);
941 CMCHKUNPK(oduPackUInt8, &unpkParam->listenQSize, mBuf);
942 CMCHKUNPK(oduPackUInt8, &unpkParam->numOpts, mBuf);
944 if( unpkParam->numOpts > CM_MAX_SOCK_OPTS)
949 for(num = 0; num < unpkParam->numOpts; num++)
951 CMCHKUNPK(cmUnpkCmSockOpts, &unpkParam->sockOpts[num], mBuf);
955 } /* cmUnpkTlsTptParam */
962 * Fun: cmUnpkCmTptParam
964 * Desc: This function unpacks the transport parameters
975 CmTptParam *unpkParam, /* transport parameters */
976 Buffer *mBuf /* message buffer */
980 CMCHKUNPK(oduPackUInt8, &unpkParam->type, mBuf);
982 switch (unpkParam->type)
984 case CM_TPTPARAM_NOTPRSNT:
987 case CM_TPTPARAM_SOCK:
988 CMCHKUNPK(cmUnpkCmSockParam, &unpkParam->u.sockParam, mBuf);
992 case CM_TPTPARAM_AAL:
993 CMCHKUNPK(cmUnpkAalConParam, &unpkParam->u.aalParam, mBuf);
998 case CM_TPTPARAM_TLS:
999 CMCHKUNPK(cmUnpkTlsTptParam, &unpkParam->u.tlsParam, mBuf);
1008 } /* cmUnpkCmTptParam */
1015 * Fun: cmPkCmIpHdrParm
1017 * Desc: This function packs the the IP hedear parameters for both
1029 CmIpHdrParm *pkParam, /* IP hdr parameters */
1030 Buffer *mBuf /* message buffer */
1034 switch (pkParam->type)
1036 case CM_HDRPARM_NOTPRSNT:
1037 case CM_HDRPARM_ICMP6:
1040 case CM_HDRPARM_IPV4:
1042 /* call to pack ipv4 options */
1043 #ifdef IPV4_OPTS_SUPPORTED
1044 /* ipv4 IP options */
1045 CMCHKPK(cmPkTknStr64, &pkParam->u.hdrParmIpv4.ipv4HdrOpt, mBuf);
1046 #endif /* IPV4_OPTS_SUPPORTED */
1048 CMCHKPK(cmPkTknUInt8, &pkParam->u.hdrParmIpv4.ttl, mBuf);
1049 CMCHKPK(cmPkTknUInt8, &pkParam->u.hdrParmIpv4.tos, mBuf);
1050 CMCHKPK(cmPkTknUInt8, &pkParam->u.hdrParmIpv4.dfBit, mBuf);
1051 CMCHKPK(cmPkTknUInt8, &pkParam->u.hdrParmIpv4.proto, mBuf);
1054 case CM_HDRPARM_IPV6:
1055 #ifdef IPV6_SUPPORTED
1056 /* call to pack ipv6 extn hdrs */
1057 #ifdef IPV6_OPTS_SUPPORTED
1058 /* pack IPV6 extension headers */
1059 CMCHKPK(cmPkCmIpv6ExtHdr, &pkParam->u.hdrParmIpv6.ipv6ExtHdr, mBuf);
1060 #endif /* IPV6_OPTS_SUPPORTED */
1061 CMCHKPK(cmPkCmNetAddr, &pkParam->u.hdrParmIpv6.srcAddr6, mBuf);
1062 CMCHKPK(cmPkTknUInt8, &pkParam->u.hdrParmIpv6.ttl, mBuf);
1063 #endif /* IPV6_SUPPORTED */
1069 CMCHKPK(oduUnpackUInt8, pkParam->type, mBuf);
1072 } /* End of cmPkCmIpHdrParm */
1075 /* added new unpack function for local interface */
1079 * Fun: cmUnpkCmTptLocalInf
1081 * Desc: This function unpacks the local interface info on which
1082 * IPV4/IPV6 packet was received on.
1091 S16 cmUnpkCmTptLocalInf
1093 CmTptLocalInf *unpkParam, /* local interface info */
1094 Buffer *mBuf /* message buffer */
1098 /* first unpack the bool intfPrsnt value which is always packed */
1099 CMCHKUNPK(oduUnpackBool, &unpkParam->intfPrsnt, mBuf);
1101 /* if the above unpacked bool is TRUE then we have to unpack further
1102 * to get the local intf index and intf address */
1103 if (unpkParam->intfPrsnt == TRUE)
1105 CMCHKUNPK(oduPackUInt32, &unpkParam->localIf, mBuf);
1106 CMCHKUNPK(cmUnpkCmNetAddr, &unpkParam->localIfAddr, mBuf);
1109 } /* cmUnpkCmTptLocalInf */
1110 #endif /* LOCAL_INTF */
1113 /* added new functions */
1114 #ifdef IPV6_OPTS_SUPPORTED
1116 * Fun: cmPkCmIpv6ExtHdr
1118 * Desc: This function packs the IPV6 extension headers
1127 S16 cmPkCmIpv6ExtHdr
1129 CmIpv6ExtHdr *pkParam, /* IPV6 extension hdrs */
1130 Buffer *mBuf /* message buffer */
1134 /* pack first Route hdr */
1135 if (pkParam->rtOptsPrsnt)
1136 CMCHKPK(cmPkCmIpv6RtHdr, &pkParam->rtOpts, mBuf);
1137 CMCHKPK(oduPackBool, pkParam->rtOptsPrsnt, mBuf);
1139 /* pack Dest Opt hdr */
1140 if (pkParam->destOptsPrsnt)
1141 CMCHKPK(cmPkCmIpv6DestOptsArr, &pkParam->destOptsArr, mBuf);
1142 CMCHKPK(oduPackBool, pkParam->destOptsPrsnt, mBuf);
1145 if (pkParam->hbhHdrPrsnt)
1146 CMCHKPK(cmPkCmIpv6HBHHdrArr, &pkParam->hbhOptsArr, mBuf);
1147 CMCHKPK(oduPackBool, pkParam->hbhHdrPrsnt, mBuf);
1150 } /* end of cmPkCmIpv6ExtHdr */
1155 * Fun: cmPkCmIpv6RtHdr
1157 * Desc: This function packs the IPV6 route header
1168 CmIpv6RtHdr *pkParam, /* IPV6 Route hdr */
1169 Buffer *mBuf /* message buffer */
1175 /* pack all IPV6 addrs in the route hdr */
1176 for(idx = 0; idx < pkParam->numAddrs; idx++)
1178 CMCHKPK(cmPkCmIpv6NetAddr, &pkParam->ipv6Addrs[idx], mBuf);
1180 /* pack reserve byte & strict/loose bit map */
1181 CMCHKPK(oduUnpackUInt32, pkParam->slMap, mBuf);
1182 CMCHKPK(oduUnpackUInt8, pkParam->numAddrs, mBuf);
1185 } /* end of cmPkCmIpv6RtHdr */
1190 * Fun: cmUnpkCmIpv6RtHdr
1192 * Desc: This function unpacks the IPV6 route header
1195 * ROUTRES - out of resources
1202 S16 cmUnpkCmIpv6RtHdr
1204 CmIpv6RtHdr *unpkParam, /* IPV6 Route hdr */
1205 Buffer *mBuf, /* message buffer */
1206 Mem *memInfo /* meminfo to allocate for Route hdr */
1209 uint8_t idx; /* array index */
1210 S32 retVal; /* temporary return value */
1213 CMCHKUNPK(oduPackUInt8, &unpkParam->numAddrs, mBuf);
1215 /* unpack reserve byte & strict/loose bit map */
1216 CMCHKUNPK(oduPackUInt32, &unpkParam->slMap, mBuf);
1218 retVal = SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,memInfo->region,
1220 (Data **)&unpkParam->ipv6Addrs,
1221 (unpkParam->numAddrs * 16));
1228 /* unpack all IPV6 addrs in the route hdr */
1229 for(idx = 0; idx < unpkParam->numAddrs; idx++)
1231 CMCHKUNPK(cmUnpkCmIpv6NetAddr, &unpkParam->ipv6Addrs[idx], mBuf);
1235 } /* end of cmUnpkCmIpv6RtHdr */
1240 * Fun: cmUnpkCmIpv6ExtHdr
1242 * Desc: This function unpacks the IPv6 extension header
1251 S16 cmUnpkCmIpv6ExtHdr
1253 CmIpv6ExtHdr *unpkParam, /* IPV6 extension hdrs */
1254 Buffer *mBuf, /* message buffer */
1255 Mem *memInfo /* meminfo to allocate for IPV6 ext hdr */
1259 /* unpack HBH hdr first */
1260 CMCHKUNPK(oduUnpackBool, &unpkParam->hbhHdrPrsnt, mBuf);
1261 if (unpkParam->hbhHdrPrsnt)
1262 cmUnpkCmIpv6HBHHdrArr(&unpkParam->hbhOptsArr, mBuf, memInfo);
1264 /* unpack DEST opt hdr */
1265 CMCHKUNPK(oduUnpackBool, &unpkParam->destOptsPrsnt, mBuf);
1266 if (unpkParam->destOptsPrsnt)
1267 cmUnpkCmIpv6DestOptsArr(&unpkParam->destOptsArr, mBuf, memInfo);
1269 /* unpack Route hdr last */
1270 CMCHKUNPK(oduUnpackBool, &unpkParam->rtOptsPrsnt, mBuf);
1271 if (unpkParam->rtOptsPrsnt)
1272 cmUnpkCmIpv6RtHdr(&unpkParam->rtOpts, mBuf, memInfo);
1275 } /* end of cmUnpkCmIpv6ExtHdr */
1280 * Fun: cmPkCmIpv6DestOptsArr
1282 * Desc: This function packs the IPV6 Destination Option array
1291 S16 cmPkCmIpv6DestOptsArr
1293 CmIpv6DestOptsArr *pkParam, /* IPV6 Dest hdr array */
1294 Buffer *mBuf /* message buffer */
1301 /* pack all HBH options */
1302 for(numOptions = 0; numOptions<pkParam->numDestOpts; numOptions++)
1303 CMCHKPK(cmPkCmIpv6DestOptsHdr, &pkParam->destOpts[numOptions], mBuf);
1304 CMCHKPK(oduUnpackUInt8, pkParam->numDestOpts, mBuf);
1307 } /* end of cmPkCmIpv6DestOptsArr */
1312 * Fun: cmPkCmIpv6DestOptsHdr
1314 * Desc: This function packs individua IPV6 Destination Option
1323 S16 cmPkCmIpv6DestOptsHdr
1325 CmIpv6DestOptsHdr *pkParam, /* IPV6 Dest opt */
1326 Buffer *mBuf /* message buffer */
1332 for(optLen = 0; optLen < pkParam->length; optLen++)
1334 CMCHKPK(oduUnpackUInt8, pkParam->value[optLen], mBuf);
1336 CMCHKPK(oduUnpackUInt8, pkParam->length, mBuf);
1337 CMCHKPK(oduUnpackUInt8, pkParam->type, mBuf);
1340 } /* end of cmPkCmIpv6DestOptsHdr */
1345 * Fun: cmUnpkCmIpv6DestOptsHdr
1347 * Desc: This function unpacks individual IPV6 Dest Option
1356 S16 cmUnpkCmIpv6DestOptsHdr
1358 CmIpv6DestOptsHdr *unpkParam,/* IPV6 Dest Option */
1359 Buffer *mBuf, /* message buffer */
1360 Mem *memInfo /* meminfo to allocate mem for dest opt */
1363 S32 retVal; /* temporary return value */
1364 uint8_t optLen; /* length of value field */
1367 /* unpack type, length */
1368 CMCHKUNPK(oduPackUInt8, &unpkParam->type, mBuf);
1369 CMCHKUNPK(oduPackUInt8, &unpkParam->length, mBuf);
1371 /* allocate static memory to hold the unpacked values */
1372 retVal = SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,memInfo->region,
1374 (Data **)&unpkParam->value, (Size)unpkParam->length);
1380 /* unpack value fieldof this option */
1381 for(optLen = 0; optLen<unpkParam->length; optLen++)
1383 CMCHKUNPK(oduPackUInt8, &unpkParam->value[optLen], mBuf);
1387 } /* end of cmUnpkCmIpv6DestOptsHdr */
1392 * Fun: cmUnpkCmIpv6DestOptsArr
1394 * Desc: This function unpacks the IPV6 Destination Option array
1403 S16 cmUnpkCmIpv6DestOptsArr
1405 CmIpv6DestOptsArr *unpkParam, /* all IPV6 Destination Options */
1406 Buffer *mBuf, /* message buffer */
1407 Mem *memInfo /* meminfo to allocate mem for dest opts */
1414 CMCHKUNPK(oduPackUInt8, &unpkParam->numDestOpts, mBuf);
1415 if (unpkParam->numDestOpts)
1417 /* allocate mem to hold all dest options */
1418 retVal = SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,memInfo->region,
1420 (Data **)&unpkParam->destOpts,
1421 (unpkParam->numDestOpts * sizeof(CmIpv6DestOptsHdr)));
1428 /* unpack all dest options */
1429 for(numOptions = 0; numOptions<unpkParam->numDestOpts; numOptions++)
1430 if ((retVal = cmUnpkCmIpv6DestOptsHdr(&unpkParam->destOpts[numOptions],
1431 mBuf, memInfo)) != ROK)
1436 } /* end of cmUnpkCmIpv6DestOptsArr */
1441 * Fun: cmPkCmIpv6HBHHdrArr
1443 * Desc: This function packs the all IPV6 HopByHop options
1452 S16 cmPkCmIpv6HBHHdrArr
1454 CmIpv6HBHHdrArr *pkParam, /* all IPV6 HopByHop options */
1455 Buffer *mBuf /* message buffer */
1461 for(numOptions = 0; numOptions<pkParam->numHBHOpts; numOptions++)
1462 CMCHKPK(cmPkCmIpv6HBHHdr, &pkParam->hbhOpts[numOptions], mBuf);
1464 CMCHKPK(oduUnpackUInt8, pkParam->numHBHOpts, mBuf);
1467 } /* end of cmPkCmIpv6HBHHdrArr */
1472 * Fun: cmPkCmIpv6HBHHdr
1474 * Desc: This function packs individual IPV6 HBH options
1483 S16 cmPkCmIpv6HBHHdr
1485 CmIpv6HBHHdr *pkParam, /* individual IPV6 HBH options */
1486 Buffer *mBuf /* message buffer */
1492 /* pack value field */
1493 for(optLen = 0; optLen<pkParam->length; optLen++)
1495 CMCHKPK(oduUnpackUInt8, pkParam->value[optLen], mBuf);
1498 /* pack type, length fields */
1499 CMCHKPK(oduUnpackUInt8, pkParam->length, mBuf);
1500 CMCHKPK(oduUnpackUInt8, pkParam->type, mBuf);
1503 } /* end of cmPkCmIpv6HBHHdr */
1508 * Fun: cmUnpkCmIpv6HBHHdr
1510 * Desc: This function unpacks individual IPV6 HBH Option
1519 S16 cmUnpkCmIpv6HBHHdr
1521 CmIpv6HBHHdr *unpkParam,/* individual IPV6 HBH Option */
1522 Buffer *mBuf, /* message buffer */
1523 Mem *memInfo /* meminfo to allocate mem for HBH opt */
1526 S32 retVal; /* temporary return value */
1527 uint8_t optLen; /* length of value field */
1529 CMCHKUNPK(oduPackUInt8, &unpkParam->type, mBuf);
1530 CMCHKUNPK(oduPackUInt8, &unpkParam->length, mBuf);
1532 /* allocate static memory to hold the unpacked values */
1533 if (unpkParam->length)
1535 retVal = SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,memInfo->region,
1537 (Data **)&unpkParam->value, (Size)unpkParam->length);
1543 for(optLen = 0; optLen<unpkParam->length; optLen++)
1544 CMCHKUNPK(oduPackUInt8, &unpkParam->value[optLen], mBuf);
1548 } /* end of cmUnpkCmIpv6HBHHdr */
1553 * Fun: cmUnpkCmIpv6HBHHdrArr
1555 * Desc: This function unpacks all IPV6 HopByHop options
1564 S16 cmUnpkCmIpv6HBHHdrArr
1566 CmIpv6HBHHdrArr *unpkParam, /* all HBH options */
1567 Buffer *mBuf, /* message buffer */
1568 Mem *memInfo /* meminfo to allocate space for HBH opt */
1575 CMCHKUNPK(oduPackUInt8, &unpkParam->numHBHOpts, mBuf);
1576 if (unpkParam->numHBHOpts)
1578 /* allocate space for all HBH options */
1579 retVal = SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,memInfo->region,
1581 (Data **)&unpkParam->hbhOpts,
1582 (unpkParam->numHBHOpts * sizeof(CmIpv6HBHHdr)));
1589 for(numOptions = 0; numOptions<unpkParam->numHBHOpts; numOptions++)
1590 cmUnpkCmIpv6HBHHdr(&unpkParam->hbhOpts[numOptions], mBuf, memInfo);
1593 } /* end of cmUnpkCmIpv6HBHHdrArr */
1594 #endif /* IPV6_OPTS_SUPPORTED */
1599 * Fun: cmUnpkCmIPHdrParm
1601 * Desc: This function unpacks the IP header parameters
1611 #ifdef IPV6_OPTS_SUPPORTED
1612 S16 cmUnpkCmIpHdrParm
1614 CmIpHdrParm *unpkParam,/* ip hdr parameters */
1615 Buffer *mBuf, /* message buffer */
1616 Mem *memInfo /* meminfo to allocate mem for ipHdrParam */
1619 S16 cmUnpkCmIpHdrParm
1621 CmIpHdrParm *unpkParam,/* ip hdr parameters */
1622 Buffer *mBuf /* message buffer */
1624 #endif /* IPV6_OPTS_SUPPORTED */
1627 CMCHKUNPK(oduPackUInt8, &unpkParam->type, mBuf);
1629 switch (unpkParam->type)
1631 case CM_HDRPARM_NOTPRSNT:
1632 case CM_HDRPARM_ICMP6:
1635 case CM_HDRPARM_IPV4:
1636 CMCHKUNPK(cmUnpkTknUInt8, &unpkParam->u.hdrParmIpv4.proto, mBuf);
1637 CMCHKUNPK(cmUnpkTknUInt8, &unpkParam->u.hdrParmIpv4.dfBit, mBuf);
1638 CMCHKUNPK(cmUnpkTknUInt8, &unpkParam->u.hdrParmIpv4.tos, mBuf);
1639 CMCHKUNPK(cmUnpkTknUInt8, &unpkParam->u.hdrParmIpv4.ttl, mBuf);
1640 #ifdef IPV4_OPTS_SUPPORTED
1641 CMCHKUNPK(cmUnpkTknStr64, &unpkParam->u.hdrParmIpv4.ipv4HdrOpt, mBuf);
1642 #endif /* IPV4_OPTS_SUPPORTED */
1645 case CM_HDRPARM_IPV6:
1646 #ifdef IPV6_SUPPORTED
1647 CMCHKUNPK(cmUnpkTknUInt8, &unpkParam->u.hdrParmIpv6.ttl, mBuf);
1649 CMCHKUNPK(cmUnpkCmNetAddr,
1650 &unpkParam->u.hdrParmIpv6.srcAddr6, mBuf);
1652 #ifdef IPV6_OPTS_SUPPORTED
1653 /* memInfo is passed forward to alloc mem to hold unpacked
1654 * IPV6 etx hdr data */
1655 cmUnpkCmIpv6ExtHdr(&unpkParam->u.hdrParmIpv6.ipv6ExtHdr,
1657 #endif /* IPV6_OPTS_SUPPORTED */
1658 #endif /* IPV6_SUPPORTED */
1666 } /* End of cmUnpkCmIpHdrParm */
1671 * Fun: cmPkCmIcmpFilter
1673 * Desc: This function packs the ICMP filter parameters
1682 S16 cmPkCmIcmpFilter
1684 CmIcmpFilter *pkParam,
1685 Buffer *mBuf /* message buffer */
1688 /* Variable declaration */
1692 switch (pkParam->type)
1694 case CM_ICMP_NO_FILTER:
1697 case CM_ICMPVER4_FILTER:
1698 for(idx = (pkParam->u.icmpv4Filter.num-1); idx >= 0; idx--)
1700 CMCHKPK(oduUnpackUInt32, pkParam->u.icmpv4Filter.icmpError[idx].errCodeMask,
1702 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv4Filter.icmpError[idx].errType,
1705 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv4Filter.num, mBuf);
1706 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv4Filter.protocol, mBuf);
1707 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv4Filter.allMsg, mBuf);
1708 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv4Filter.icmpMsgFlag, mBuf);
1711 case CM_ICMPVER6_FILTER:
1712 /* The structure is yet to be decided */
1713 /* CMCHKPK(cmPkCmIpv6HdrParm, &pkParam->u.ipv6HdrParm, mBuf); */
1714 #ifdef IPV6_SUPPORTED
1715 for(idx = (pkParam->u.icmpv6Filter.num - 1); idx >= 0; idx--)
1717 CMCHKPK(oduUnpackUInt32, pkParam->u.icmpv6Filter.icmpError[idx].errCodeMask,
1719 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv6Filter.icmpError[idx].errType,
1722 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv6Filter.num, mBuf);
1723 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv4Filter.allMsg, mBuf);
1724 CMCHKPK(oduUnpackUInt8, pkParam->u.icmpv4Filter.icmpMsgFlag, mBuf);
1725 #endif /* IPV6_SUPPORTED */
1731 CMCHKPK(oduUnpackUInt8, pkParam->type, mBuf);
1739 * Fun: cmUnpkCmIcmpFilter
1741 * Desc: This function unpacks the
1750 S16 cmUnpkCmIcmpFilter
1752 CmIcmpFilter *unpkParam,
1753 Buffer *mBuf /* message buffer */
1756 /* Variable declaration */
1759 CMCHKUNPK(oduPackUInt8, &unpkParam->type, mBuf);
1761 switch (unpkParam->type)
1763 case CM_ICMP_NO_FILTER:
1766 case CM_ICMPVER4_FILTER:
1767 CMCHKUNPK(oduPackUInt8, &unpkParam->u.icmpv4Filter.icmpMsgFlag, mBuf);
1768 CMCHKUNPK(oduPackUInt8, &unpkParam->u.icmpv4Filter.allMsg, mBuf);
1769 CMCHKUNPK(oduPackUInt8, &unpkParam->u.icmpv4Filter.protocol, mBuf);
1770 CMCHKUNPK(oduPackUInt8, &unpkParam->u.icmpv4Filter.num, mBuf);
1772 for(idx = 0; idx < (unpkParam->u.icmpv4Filter.num); idx++)
1774 CMCHKUNPK(oduPackUInt8,
1775 &unpkParam->u.icmpv4Filter.icmpError[idx].errType, mBuf);
1776 CMCHKUNPK(oduPackUInt32,
1777 &unpkParam->u.icmpv4Filter.icmpError[idx].errCodeMask,
1782 case CM_ICMPVER6_FILTER:
1783 #ifdef IPV6_SUPPORTED
1784 CMCHKUNPK(oduPackUInt8, &unpkParam->u.icmpv6Filter.icmpMsgFlag, mBuf);
1785 CMCHKUNPK(oduPackUInt8, &unpkParam->u.icmpv6Filter.allMsg, mBuf);
1786 CMCHKUNPK(oduPackUInt8, &unpkParam->u.icmpv6Filter.num, mBuf);
1788 for(idx = 0; idx < (unpkParam->u.icmpv6Filter.num); idx++)
1790 CMCHKUNPK(oduPackUInt8,
1791 &unpkParam->u.icmpv6Filter.icmpError[idx].errType, mBuf);
1792 CMCHKUNPK(oduPackUInt32,
1793 &unpkParam->u.icmpv6Filter.icmpError[idx].errCodeMask,
1796 #endif /* IPV6_SUPPORTED */
1805 } /* End of cmUnpkCmIcmpFilter */
1807 #endif /* CM_INET2 */
1810 #endif /* if(LCHCT || LCHIT || LCLHC || LCHRT || LCLHR) */
1813 /********************************************************************30**
1815 *********************************************************************31*/