/*=========================================*/
/* 								 	      */
/* 									      */
/* 	Author:     Zane Yi				      */
/* 	Date:       2007.02.01			      */
/* 									      */
/*=========================================*/
#include "./include/inc.h"
#include "./include/isup_if.h"
#include "./include/isup_struct.h"
#include "./include/isup_debug.h"
#include "./include/isup_def.h"
#include "./include/isup_const.h"


int siSelUnpkFun(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length, u8 variant);
int siSelPkFun(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type,u8 variant);
void isup_send_cvr(u32 pid);

extern int isup_transit_msg(u8 *raw_dst, u8 *raw_add, u8 len_add, u8 *raw_org, u8 len_org, u8 variant);
extern u8	isup_msg_test;
extern	up_message isup_raw_msg;


static int find_port_by_sp(u8 ni, u32 dpc, u32 opc, u32 cic, u32* pid)
{	
	const pal_circuit_struct* circuit_str;

	circuit_str = pal_ss7_find_circuit(ni, dpc, opc, cic);
	
	if(circuit_str == NULL)
	{
		isup_log_err(0,"illegal cic value! ni=%d,dpc=%d,opc=%d,cic=%d\r\n",ni,opc,dpc,cic);
		return -1;		
	}	
		
	if(isup_db.attrib.isup_run_mode == ISUP_DUAL_MODE && 
		circuit_str->attrib.plat_id != isup_db.attrib.systemID)
		*pid = 0xFFFFFFFF;
	else	
		*pid = ISUP_CIRCUIT_CIC*circuit_str->id + 
			(cic - circuit_str->attrib.head_cic);			
	return 1;
}

static void isup_transmit_func(u32 remote_ip, up_message *upmsg_ptr)
{
	if(isup_rv_msg.cic[1]&0xF0)
	upmsg_ptr->cic[1] |= 0x80;
	upmsg_ptr->dest_ip = remote_ip;
	isup_redirect(upmsg_ptr);
	return;
}

int isup_mdsc_proc()
{
	int					ret,circuit_id,cg_id,variant;
	u32 				pid,cic_val;
	u8					msg_type;
	u8					*flw_ptr;	//message flow pointer
	
	ISUP_Port_struct	*port_ptr;
	const pal_circuit_struct* circuit_str; 
	const pal_cg_struct* cg_str;				
	
	memset(&isup_rv_msg,0,sizeof(isup_rv_msg));
	if(isup_GetMsg(&isup_rv_msg) == 0)
		return 0;

	isup_msg_csta(isup_rv_msg.msgList[0],0);

	cic_val = ((isup_rv_msg.cic[1]&0x0F)<<8) + isup_rv_msg.cic[0];	
	
	if(find_port_by_sp(isup_rv_msg.sio >>6,isup_rv_msg.opc, isup_rv_msg.dpc, cic_val,&pid)==-1)
	{	
		monitor_isup_msg(0,"RV=>",&isup_rv_msg,COL_YELLOW);		
		return -1;
	}
	if(pid >= ISUP_MAX_PORT)
	{
		monitor_isup_msg(0,"RV=>",&isup_rv_msg,COL_YELLOW);				
		if((isup_rv_msg.cic[1]&0x80) == 0)
		{
			isup_transmit_func(isup_db.attrib.isup_remote_ip, &isup_rv_msg);
		}
		else
		{
			isup_log_err(0,"isup_redirect discard.\r\n");
		}
		return -1;
	}	
	monitor_isup_msg(pid,"RV=>",&isup_rv_msg,COL_YELLOW);
	port_ptr = &isup_db.port_pond[pid];
	
	flw_ptr = isup_rv_msg.msgList;
	msg_type = isup_rv_msg.msgList[0];
	flw_ptr++;	
	memset(&isup_rv_pdus,0,sizeof(isup_rv_pdus));
	
	circuit_id = pid/ISUP_CIRCUIT_CIC;
	
	circuit_str = pal_circuit_ptr(circuit_id);
	if(circuit_str == NULL)
	{
		isup_log_err(pid,"circuit_str==NULL\r\n");
		return -1;
	}	
		
	cg_str = pal_cg_ptr(circuit_str->cg_id);
	if(cg_str == NULL)
	{
		isup_log_err(pid,"cg_str==NULL\r\n");
		return -1;
	}	
	
	variant = cg_str->attrib.variant;
	
	ret = siSelUnpkFun(&isup_rv_pdus,flw_ptr,msg_type,isup_rv_msg.len-1,variant);
	if(ret == -2)
	{	
		isup_log_err(pid,"[variant:%d]decode nonsupport message,message type=0x%x\r\n",variant,msg_type);
		return -1;
	}
	else if(ret == -1)
	{
		isup_log_err(pid,"[variant:%d]decode error,message type=0x%x\r\n",variant,msg_type);
		return -1;
	}	

	if(isup_msg_test)
	{
		test_isup_msg(msg_type,1);
		return 1;
	}
			
	port_ptr->sprc_cmd = msg_type;
	
	switch(msg_type)
	{
		case M_ACM:
		case M_ANM:
		case M_CPG:
		case M_CON:
		case M_REL:
		case M_SUS:
		case M_RES:
		case M_SAM:
		case M_IAM:
		case M_RLC:			
			if((msg_type==M_RLC)&&isup_check_crs_waiting(pid))
			{
				isup_crs_proc(pid);
			}
			else
			{		
				if(port_ptr->cic_state.call_state == START_RESET)
				{
					port_ptr->sprc_cmd	=	0;
					isup_log_err(pid,"Discard message, pid=%ld,call_state = Reset\r\n",pid);
				}
				else if(port_ptr->cic_state.call_state == CALLOUT_FLAG)
					isup_cpco_proc(pid);
				else
				{	
					port_ptr->cic_state.call_state = CALLIN_FLAG;
					isup_cpci_proc(pid);
				}
			}
			break;
		case M_BLO:
		case M_UBL:
			isup_blr_proc(pid);
			break;			
		case M_BLA:		
		case M_UBA:			
			isup_bls_proc(pid);
			break;
		case M_CGB:
		case M_CGU:			
			isup_mgbr_proc(pid);
			break;
		case M_CGBA:
		case M_CGUA:
			isup_mgbs_proc(pid);
			break;
		case M_GRS:
			isup_cgrr_proc(pid);
			break;
		case M_GRA:
			isup_cgrs_proc(pid);
			break;
		case M_RSC:
			isup_crr_proc(pid);
			break;
		case M_UCIC:
			isup_event_handle(pid, ISUP_DATA_IND,msg_type);			
			isup_log_err(pid,"Idle port=%d.\r\n",pid);
			memset(port_ptr,0,sizeof(port_ptr));
			break;
		case M_CVT:
			port_ptr->sprc_cmd = 0;			
			isup_send_cvr(pid);//send resp
			break;
		default:
			isup_event_handle(pid, ISUP_DATA_IND,msg_type);
			port_ptr->sprc_cmd = 0;
			break;
	}
	if(port_ptr->sprc_cmd != 0)
		isup_log_err(pid,"ignore the message,message type=0x%x,cg_id=%d,circuit=%d,cic=%d,port=%d\r\n",msg_type,cg_id,circuit_id,cic_val,pid);
	port_ptr->sprc_cmd = 0;
	monitor_port_state(cic_val,pid);
	return 1;		
}


void isup_msdc_proc(u32 pid, up_message *upmsg_ptr)
{
	u32		circuit_id,offset;
	u32		cic_val;
	const pal_circuit_struct* circuit_str; 
	const pal_cg_struct* cg_str;				
	up_message	temp_ptr;	
	
	circuit_id = pid/ISUP_CIRCUIT_CIC;
	offset = pid%ISUP_CIRCUIT_CIC;

	circuit_str = pal_circuit_ptr(circuit_id);
	if(circuit_str == NULL)
	{
		isup_log_err(pid,"circuit_str==NULL\r\n");
		return;
	}	
		
	cg_str = pal_cg_ptr(circuit_str->cg_id);
	if(cg_str == NULL)
	{
		isup_log_err(pid,"cg_str==NULL\r\n");
		return;
	}	
	
	if(offset > circuit_str->attrib.cic_range)
	{
		isup_log_err(pid,"CIC out of range.(pid=%d)\n",pid);
		return;
	}

	cic_val = circuit_str->attrib.head_cic+offset;
	
	upmsg_ptr->dest_ip = 0xffffffff;
	upmsg_ptr->dpc = cg_str->attrib.dpc;
	upmsg_ptr->opc = cg_str->attrib.opc;
	upmsg_ptr->cic[0] = cic_val & 0xff;
	upmsg_ptr->cic[1] = (cic_val >> 8) & 0xff;
	upmsg_ptr->sio = (cg_str->attrib.network_id << 6) | ISUP_SI;
	
	if(isup_raw_msg.msgList != NULL &&	isup_raw_msg.len	> 1)
	{	
		if(upmsg_ptr->msgList[0]==M_PAM)
		{			
			upmsg_ptr->len	=	isup_raw_msg.len;
			memcpy(upmsg_ptr->msgList,isup_raw_msg.msgList,MAX_SS7_MSG_LEN);			
			monitor_isup_msg(pid,"SD<=(pam)",upmsg_ptr,COL_WHITE);
		}
		else
		{		
			memset(&temp_ptr,0,sizeof(up_message));	
			temp_ptr.len = isup_transit_msg(temp_ptr.msgList,upmsg_ptr->msgList,upmsg_ptr->len,isup_raw_msg.msgList,isup_raw_msg.len,cg_str->attrib.variant);
			if(temp_ptr.len)
			{	
				upmsg_ptr->len	=	temp_ptr.len;
				memcpy(upmsg_ptr->msgList,temp_ptr.msgList,MAX_SS7_MSG_LEN);
				monitor_isup_msg(pid,"SD<=(t)",upmsg_ptr,COL_WHITE);
			}
			else
				monitor_isup_msg(pid,"SD<=(f)",upmsg_ptr,COL_WHITE);
		}
		memset(&isup_raw_msg,0,sizeof(up_message));	
	}
	else
		monitor_isup_msg(pid,"SD<=(i)",upmsg_ptr,COL_WHITE);
	
	isup_msg_csta(upmsg_ptr->msgList[0],1);
	if(isup_to_mtp3(upmsg_ptr)<0)
		isup_log_err(pid,"send to mtp3 failed.\r\n");
	return;
}


int isup_send_msg(u32 pid, u8 msg_type)
{
	int ret,circuit_id,variant;	
	const pal_circuit_struct* circuit_str; 
	const pal_cg_struct* cg_str;			
	up_message	*upmsg_ptr = &isup_sd_msg;

	memset(&isup_sd_msg,0,sizeof(isup_sd_msg));
	
	circuit_id = pid/ISUP_CIRCUIT_CIC;
	
	circuit_str = pal_circuit_ptr(circuit_id);
	if(circuit_str == NULL)
	{
		isup_log_err(pid,"circuit_str==NULL\r\n");
		return -1;
	}	
		
	cg_str = pal_cg_ptr(circuit_str->cg_id);
	if(cg_str == NULL)
	{
		isup_log_err(pid,"cg_str==NULL\r\n");
		return -1;
	}	

	variant = cg_str->attrib.variant;

	ret = siSelPkFun(&isup_sd_pdus,upmsg_ptr->msgList+1,msg_type,variant);
	if(ret == -2)
	{	
		isup_log_err(pid,"[variant:%d]encode nonsupport message failed,MSG=0x%x\r\n",variant,msg_type);
		return -1;
	}	
	else if(ret == -1)
	{
		isup_log_err(pid,"[variant:%d]encode error,message type=0x%x\r\n",variant,msg_type);
		return -1;
	}		
	upmsg_ptr->msgList[0] = msg_type;
	upmsg_ptr->len = ret+1;
	isup_msdc_proc(pid, upmsg_ptr);
	return 1;
}

/* unpacking functions for ISUP information elements */
int siUnpkSiAccDelInfo (SiAccDelInfo *pAccDelInfo,u8 *mBuf, u8 length)
{
	pAccDelInfo->pres		=	1;
	pAccDelInfo->delInd		=	mBuf[0] & 0x01;
	return 1;
}




int siUnpkAccTrnspt   (SiAccTrnspt *pAccTrnspt,u8 *mBuf, u8 length)
{
	pAccTrnspt->pres		=	1;
	pAccTrnspt->infoLen		=	length;
	memcpy(pAccTrnspt->infoElmts,mBuf,pAccTrnspt->infoLen);
	return 1;
}




int siUnpkAutoCongLvl (SiAutoCongLvl *pAutoCongLvl,u8 *mBuf, u8 length)
{
	pAutoCongLvl->pres		=	1;
	pAutoCongLvl->auCongLvl	=	mBuf[0];
	return 1;
}

int siUnpkBckCalInd   (SiBckCalInd *pBckCalInd,u8 *mBuf, u8 length)
{
	pBckCalInd->pres			=	1;
	pBckCalInd->chrgInd			=	mBuf[0] & 0x03 ;
	pBckCalInd->cadPtyStatInd	=	(mBuf[0]>>2) & 0x03;
	pBckCalInd->cadPtyCatInd	=	(mBuf[0]>>4) & 0x03;
	pBckCalInd->end2EndMethInd	=	(mBuf[0]>>6) & 0x03;
	pBckCalInd->intInd			=	mBuf[1] & 0x01 ;
	pBckCalInd->end2EndInfoInd	=	(mBuf[1]>>1) & 0x01;
	pBckCalInd->isdnUsrPrtInd	=	(mBuf[1]>>2) & 0x01;
	pBckCalInd->holdInd			=	(mBuf[1]>>3) & 0x01;
	pBckCalInd->isdnAccInd		=	(mBuf[1]>>4) & 0x01;
	pBckCalInd->echoCtrlDevInd	=	(mBuf[1]>>5) & 0x01;
	pBckCalInd->sccpMethInd		= 	(mBuf[1]>>6) & 0x03;
	return 1;
}




int siUnpkSiCllDiverInfo (SiCllDiverInfo *pCllDivr,u8 *mBuf, u8 length)
{
	pCllDivr->pres			=	1;
	pCllDivr->notSuscr		=	mBuf[0] & 0x07;
	pCllDivr->redirRsn		=	mBuf[0]>>3 &0x0F;
	return 1;
}

int siUnpkSiPropDly      (SiPropDly *pPropDly,u8 *mBuf, u8 length)
{
	pPropDly->pres	=	1;
	pPropDly->delayVal	=	(mBuf[0]<<8) | mBuf[1];
	return 1;
}

int siUnpkCallRef     (SiCallRef *pCallRef,u8 *mBuf, u8 length)
{
	pCallRef->pres		=	1;
	pCallRef->callId[0]	=	mBuf[0];
	pCallRef->callId[1]	=	mBuf[1];
	pCallRef->callId[2]	=	mBuf[2];
	pCallRef->pntCde	=	mBuf[3]|((mBuf[4]&0x3F)<<8);
	return 1;
}

int siUnpkCdPtyNum    (SiCdPtyNum *pCdPtyNum,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pCdPtyNum->pres			=	1;
	pCdPtyNum->natAddrInd	=	mBuf[0] & 0x07F;
	pCdPtyNum->oddEven	=	(mBuf[0]>>7) & 0x01;
	pCdPtyNum->numPlan	=	(mBuf[1]>>4) & 0x07;
	pCdPtyNum->innInd	=	(mBuf[1]>>7) & 0x01;

	num_ptr	=	mBuf+2;
	for(i = 0, j = 0; i < length-2; i++)
	{
		pCdPtyNum->addrSig[j++] = num_ptr[i] & 0x0f;
		pCdPtyNum->addrSig[j++] = num_ptr[i] >> 4;
	}
	if((pCdPtyNum->oddEven) && (j > 0))
		j--;
	pCdPtyNum->numOfDigit = j;

	return 1;
}



int siUnpkCgPtyNum    (SiCgPtyNum *pCgPtyNum,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pCgPtyNum->pres			=	1;
	pCgPtyNum->natAddrInd	=	mBuf[0] & 0x7F;
	pCgPtyNum->oddEven		=	(mBuf[0]>>7) & 0x01;
	pCgPtyNum->scrnInd		=	mBuf[1] & 0x03;
	pCgPtyNum->presRest		=	(mBuf[1]>>2) & 0x03;
	pCgPtyNum->numPlan		=	(mBuf[1]>>4) & 0x07;
	pCgPtyNum->niInd		=	(mBuf[1]>>7) & 0x01;

	num_ptr	=	mBuf+2;
	for(i = 0, j = 0; i < length-2; i++)
	{
		pCgPtyNum->addrSig[j++] = num_ptr[i] & 0x0f;
		pCgPtyNum->addrSig[j++] = num_ptr[i] >> 4;
	}	
	if((pCgPtyNum->oddEven) && (j > 0))
		j--;
	pCgPtyNum->numOfDigit = j;

	return 1;
}

int siUnpkCgPtyCat    (SiCgPtyCat *pCgPtyCat,u8 *mBuf, u8 length)
{
	pCgPtyCat->pres			=		1;
	pCgPtyCat->cgPtyCat		=		mBuf[0];
	return 1;
}



int siUnpkCauseDgn    (SiCauseDgn *pCauseDgn,u8 *mBuf, u8 length)
{
	pCauseDgn->pres			=		1;
	pCauseDgn->location		=		mBuf[0]&0x0F;
	pCauseDgn->cdeStand		=		(mBuf[0]>>5) &0x03;
	
	if((mBuf[0]&0x80)==0x80)
	{	
		pCauseDgn->causeVal		=		mBuf[1]&0x7F;
		if(length>2)
		{
			pCauseDgn->length	=	(length-2);
			memcpy(pCauseDgn->dgnVal,mBuf+2,pCauseDgn->length);
		}		
	}
	else
	{
		pCauseDgn->causeVal		=		mBuf[2]&0x7F;
		if(length>3)
		{
			pCauseDgn->length	=	(length-3);
			memcpy(pCauseDgn->dgnVal,mBuf+3,pCauseDgn->length);
		}		
	}

	return 1;
}



int siUnpkCirGrpSupMTypInd (SiCirGrpSupMTypInd *pCgsmti,u8 *mBuf, u8 length)
{
	pCgsmti->pres			=		1;
	pCgsmti->typeInd		=		mBuf[0]&0x03;
	return 1;
}



int siUnpkCirStateInd (SiCirStateInd *pCirStateInd,u8 *mBuf, u8 length)
{
	pCirStateInd->pres		=	1;
	pCirStateInd->length	=	length;
	memcpy(pCirStateInd->cirSteInd,mBuf,pCirStateInd->length);
	return 1;
}



int siUnpkCugIntCode  (SiCugIntCode *pCugIntCode,u8 *mBuf, u8 length)
{
	pCugIntCode->pres		=	1;
	pCugIntCode->dig1		=	(mBuf[0]>>4)&0x0F;
	pCugIntCode->dig2		=	(mBuf[0])&0x0F;
	pCugIntCode->dig3		=	(mBuf[1]>>4)&0x0F;
	pCugIntCode->dig4		=	(mBuf[1])&0x0F;
	pCugIntCode->binCde		=	(mBuf[2]<<8)|mBuf[3];
	return 1;
}

int siUnpkConnectedNum (SiConnectedNum *pConnectedNum,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pConnectedNum->pres			=	1;
	pConnectedNum->natAddrInd	=	mBuf[0] & 0x7F;
	pConnectedNum->oddEven		=	(mBuf[0]>>7) & 0x01;
	pConnectedNum->scrnInd		=	mBuf[1] & 0x03;
	pConnectedNum->presRest		=	(mBuf[1]>>2) & 0x03;
	pConnectedNum->numPlan		=	(mBuf[1]>>4) & 0x07;

	num_ptr	=	mBuf+2;
	for(i = 0, j = 0; i < length-2; i++)
	{
		pConnectedNum->addrSig[j++] = num_ptr[i] & 0x0f;
		pConnectedNum->addrSig[j++] = num_ptr[i] >> 4;
	}	
	if((pConnectedNum->oddEven) && (j > 0))
		j--;
	pConnectedNum->numOfDigit = j;

	return 1;
}

int siUnpkConnReq     (SiConnReq *pConnReq,u8 *mBuf, u8 length)
{
	pConnReq->pres			=	1;
	pConnReq->locRef[0]		=	mBuf[0];
	pConnReq->locRef[1]		=	mBuf[1];
	pConnReq->locRef[2]		=	mBuf[2];		
	pConnReq->pntCde		=	mBuf[3]|((mBuf[4]&0x3F)<<8);
	pConnReq->protClass		=	mBuf[5];
	pConnReq->credit		=	mBuf[6];
	return 1;
}

int siUnpkContInd     (SiContInd *pContInd,u8 *mBuf, u8 length)
{
	pContInd->pres		=	1;
	pContInd->contInd	=	mBuf[0]&0x01;
	return 1;
}

int siUnpkSiEchoCtl    (SiEchoCtl *pEchoCtl,u8 *mBuf, u8 length)
{
	pEchoCtl->pres		=	1;
	pEchoCtl->outEchoRsp	=	mBuf[0]&0x03;
	pEchoCtl->incEchoRsp	=	(mBuf[0]>>2)&0x03;
	pEchoCtl->outEchoReq	=	(mBuf[0]>>4)&0x03;
	pEchoCtl->incEchoReq	=	(mBuf[0]>>6)&0x03;
	return 1;
}

int siUnpkEvntInfo    (SiEvntInfo *pEvntInfo,u8 *mBuf, u8 length)
{
	pEvntInfo->pres				=	1;
	pEvntInfo->evntInd			=	mBuf[0]&0x7F;
	pEvntInfo->evntPresResInd	=	mBuf[0]>>7&0x01;
	return 1;
}



int siUnpkFacInd      (SiFacInd *pFacInd,u8 *mBuf, u8 length)
{
	pFacInd->pres		=	1;
	pFacInd->facInd		=	mBuf[0];
	return 1;
}

int siUnpkFwdCallInd  (SiFwdCallInd *pFwdCallInd,u8 *mBuf, u8 length)
{
	pFwdCallInd->pres				=	1;
	pFwdCallInd->natIntCallInd		=	mBuf[0] & 0x01;
	pFwdCallInd->end2EndMethInd		=	mBuf[0]>>1 &0x03;
	pFwdCallInd->intInd				=	mBuf[0]>>3 &0x01;
	pFwdCallInd->end2EndInfoInd		=	mBuf[0]>>4 &0x01;
	pFwdCallInd->isdnUsrPrtInd		=	mBuf[0]>>5 &0x01;
	pFwdCallInd->isdnUsrPrtPrfInd	=	mBuf[0]>>6 &0x03;
	pFwdCallInd->isdnAccInd			=	mBuf[1] &0x01;
	pFwdCallInd->sccpMethInd		=	mBuf[1]>>1 &0x03;
	return 1;
}

int siUnpkFreePhParam  (SiFreePhInd *pFreePhInd,u8 *mBuf, u8 length){return 1;}//reserved

int siUnpkSiGenDigits   (SiGenDigits *pGenDigits,u8 *mBuf, u8 length)
{
	pGenDigits->pres	=	1;
	pGenDigits->typeOfDigits	=	(mBuf[0]) & 0x1F;
	pGenDigits->encodeScheme	=	(mBuf[0]>>5)&0x07;
	pGenDigits->length			=	length-1;
	memcpy(pGenDigits->digits, mBuf+1, pGenDigits->length);
	return 1;
}

int siUnpkNotifInd       (SiNotifInd *pNotifInd,u8 *mBuf, u8 length)
{
	pNotifInd->pres	=	1;
	pNotifInd->notifInd	=	mBuf[0];
	return 1;
}

int siUnpkSiGenNum      (SiGenNum *pGenNum,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pGenNum->pres			=	1;
	pGenNum->nmbQual		=	mBuf[0];
	pGenNum->natAddrInd		=	mBuf[1] & 0x07F;
	pGenNum->oddEven		=	(mBuf[1]>>7) & 0x01;
	pGenNum->scrnInd		=	mBuf[2] & 0x03;
	pGenNum->presRest		=	(mBuf[2]>>2) & 0x03;
	pGenNum->numPlan		=	(mBuf[2]>>4) & 0x07;
	pGenNum->niInd			=	(mBuf[2]>>7) & 0x01;

	num_ptr	=	mBuf+3;
	for(i = 0, j = 0; i < length-3; i++)
	{
		pGenNum->addrSig[j++] = num_ptr[i] & 0x0f;
		pGenNum->addrSig[j++] = num_ptr[i] >> 4;
	}	
	if((pGenNum->oddEven) && (j > 0))
		j--;
	pGenNum->numOfDigit = j;

	return 1;
}

int siUnpkHopCounter  (SiHopCounter *pHopCounter,u8 *mBuf, u8 length)
{
	pHopCounter->pres		=	1;
	pHopCounter->hopCounter	=	mBuf[0]&0x1F;
	return 1;
}

int siUnpkInfoInd     (SiInfoInd *pInfoInd,u8 *mBuf, u8 length)
{
	pInfoInd->pres				=	1;
	pInfoInd->cgPtyAddrRespInd	=	mBuf[0] & 0x03;
	pInfoInd->holdProvInd		=	mBuf[0]>>2 & 0x01;
	pInfoInd->cgPtyCatRespInd	=	mBuf[0]>>5 & 0x01;
	pInfoInd->chrgInfoRespInd	=	mBuf[0]>>6 & 0x01;
	pInfoInd->solInfoInd		=	mBuf[0]>>7 & 0x01;
	return 1;
}

int siUnpkInfoReqInd  (SiInfoReqInd *pInfoReqInd,u8 *mBuf, u8 length)
{
	pInfoReqInd->pres				=	1;
	pInfoReqInd->cgPtyAdReqInd	=	mBuf[0] & 0x01;
	pInfoReqInd->holdingInd		=	mBuf[0]>>1 & 0x01;
	pInfoReqInd->cgPtyCatReqInd	=	mBuf[0]>>3 & 0x01;
	pInfoReqInd->chrgInfoReqInd	=	mBuf[0]>>4 & 0x01;
	pInfoReqInd->malCaIdReqInd	=	mBuf[0]>>7 & 0x01;
	return 1;
}

int siUnpkSiMcidRspInd (SiMcidRspInd *pMcidRsp,u8 *mBuf, u8 length)
{
	pMcidRsp->pres		=	1;
	pMcidRsp->rspInd	=	mBuf[0]&0x01;
	pMcidRsp->hldInd	=	(mBuf[0]>>1)&0x01;
	return 1;
}

int siUnpkSiMcidReqInd (SiMcidReqInd *pMcidReq,u8 *mBuf, u8 length)
{
	pMcidReq->pres		=	1;
	pMcidReq->reqInd	=	mBuf[0]&0x01;
	pMcidReq->hldInd	=	(mBuf[0]>>1)&0x01;
	return 1;
}

int siUnpkSiMsgCompInfo  (SiMsgCompInfo *pMsgCom,u8 *mBuf, u8 length)
{
	pMsgCom->pres	=	1;
	pMsgCom->tranXInd		=	mBuf[0]&0x01;
	pMsgCom->relCllInd		=	(mBuf[0]>>1)&0x01;
	pMsgCom->sndNotInd		=	(mBuf[0]>>2)&0x01;
	pMsgCom->dcrdMsgInd		=	(mBuf[0]>>3)&0x01;
	pMsgCom->passNotPoss	=	(mBuf[0]>>4)&0x01;
	pMsgCom->bbNbIntwkI		=	(mBuf[0]>>5)&0x03;
	return 1;
}

int siUnpkSiMlppPrec     (SiMlppPrec *pMlppPrec,u8 *mBuf, u8 length)
{
	pMlppPrec->pres		=	1;
	pMlppPrec->precdLvl	=	mBuf[0] & 0x0F;
	pMlppPrec->lfb		=	(mBuf[0]>>5) & 0x03;
	pMlppPrec->frstDig	=	(mBuf[1]>>4) & 0x0F;
	pMlppPrec->scndDig	=	(mBuf[1]) & 0x0F;
	pMlppPrec->thrdDig	=	(mBuf[2]>>4) & 0x0F;
	pMlppPrec->frthDig	=	(mBuf[2]) & 0x0F;
	pMlppPrec->servDomain	=	(mBuf[3]<<16)|(mBuf[4]<<8)|mBuf[5];
	return 1;
}

int siUnpkNatConInd   (SiNatConInd *pNatConInd,u8 *mBuf, u8 length)
{
	pNatConInd->pres			=	1;
	pNatConInd->satInd			=	mBuf[0] & 0x03;
	pNatConInd->contChkInd		=	mBuf[0]>>2 & 0x03;
	pNatConInd->echoCntrlDevInd	=	mBuf[0]>>4 & 0x01;
	return 1;
}

int siUnpkSiNetSpecFacil (SiNetSpecFacil *pNetFac,u8 *mBuf, u8 length)
{
	pNetFac->pres		=	1;
	pNetFac->length		=	length;
	memcpy(pNetFac->netFac,mBuf,pNetFac->length);
	return 1;
}

int siUnpkOptBckCalInd (SiOptBckCalInd *pOptBckCalInd,u8 *mBuf, u8 length)
{
	pOptBckCalInd->pres				=	1;
	pOptBckCalInd->inbndInfoInd		=	mBuf[0]&0x01;
	pOptBckCalInd->caFwdMayOcc		=	mBuf[0]>>1&0x01;
	pOptBckCalInd->simpleSegmInd	=	mBuf[0]>>2&0x01;
	pOptBckCalInd->mlppUserInd		=	mBuf[0]>>3&0x01;
	return 1;
}

int siUnpkOpFwdCalInd (SiOpFwdCalInd *pOpFwdCalInd,u8 *mBuf, u8 length)
{
	pOpFwdCalInd->pres				=	1;
	pOpFwdCalInd->clsdUGrpCaInd		=	mBuf[0]&0x03;
	pOpFwdCalInd->simpleSegmInd		=	mBuf[0]>>2&0x01;
	pOpFwdCalInd->conLineIdReqInd	=	mBuf[0]>>7&0x01;
	return 1;
}

int siUnpkOrigCdNum    (SiOrigCdNum *pOrigCdNum,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pOrigCdNum->pres			=	1;
	pOrigCdNum->natAddrInd		=	mBuf[0] & 0x07F;
	pOrigCdNum->oddEven			=	(mBuf[0]>>7) & 0x01;	
	pOrigCdNum->presRest		=	(mBuf[1]>>2) & 0x03;
	pOrigCdNum->numPlan			=	(mBuf[1]>>4) & 0x07;

	num_ptr	=	mBuf+2;
	for(i = 0, j = 0; i < length-2; i++)
	{
		pOrigCdNum->addrSig[j++] = num_ptr[i] & 0x0f;
		pOrigCdNum->addrSig[j++] = num_ptr[i] >> 4;
	}	
	if((pOrigCdNum->oddEven) && (j > 0))
		j--;
	pOrigCdNum->numOfDigit = j;

	return 1;
}

int siUnpkSigPointCode (SiSigPointCode *pSigPointCode,u8 *mBuf, u8 length)
{
	pSigPointCode->pres		=	1;
	pSigPointCode->sigPointCode	=	((mBuf[1]&0x3F)<<8)|mBuf[0];
	return 1;
}

int siUnpkSiParmCompInfo (SiParmCompInfo *pParmCom,u8 *mBuf, u8 length)
{
	pParmCom->pres		=	1;
	pParmCom->length		=	length;
	memcpy(pParmCom->content,mBuf,pParmCom->length);
	return 1;
}

int siUnpkRangStat     (SiRangStat *pRangStat,u8 *mBuf, u8 length)
{
	int status_len;
	pRangStat->pres			=	1;
	pRangStat->range		=	mBuf[0];

	status_len = ((pRangStat->range&0x07) == 0)? (pRangStat->range>>3) : ((pRangStat->range>>3) + 1);
	memcpy(pRangStat->status, mBuf+1, status_len%(ISUP_STATUS_LEN+1));
	if(length > 5)
		pRangStat->range		=	32;	//error and Discard	
	return 1;
}

int siUnpkRangNoStat     (SiRangNoStat *pRangStat,u8 *mBuf, u8 length)
{
	pRangStat->pres			=	1;
	pRangStat->range		=	mBuf[0];
	return 1;
}

int siUnpkRedirInfo    (SiRedirInfo *pRedirInfo,u8 *mBuf, u8 length)
{
	pRedirInfo->pres				=	1;
	pRedirInfo->redirInd			=	mBuf[0]&0x07;
	pRedirInfo->origRedirReas		=	mBuf[0]>>4&0x0F;
	pRedirInfo->redirCnt			=	mBuf[1]&0x07;
	pRedirInfo->redirReas			=	mBuf[1]>>4&0x0F;
	return 1;
}

int siUnpkRedirgNum    (SiRedirNum *pRedirgNum,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pRedirgNum->pres			=	1;
	pRedirgNum->natAddrInd		=	mBuf[0] & 0x07F;
	pRedirgNum->oddEven			=	(mBuf[0]>>7) & 0x01;	
	pRedirgNum->presRest		=	(mBuf[1]>>2) & 0x03;
	pRedirgNum->numPlan			=	(mBuf[1]>>4) & 0x07;

	num_ptr	=	mBuf+2;
	for(i = 0, j = 0; i < length-2; i++)
	{
		pRedirgNum->addrSig[j++] = num_ptr[i] & 0x0f;
		pRedirgNum->addrSig[j++] = num_ptr[i] >> 4;
	}	
	if((pRedirgNum->oddEven) && (j > 0))
		j--;
	pRedirgNum->numOfDigit = j;

	return 1;
}

int siUnpkSiRedirRestr (SiRedirRestr *pRedirRstr,u8 *mBuf, u8 length)
{
	pRedirRstr->pres				=	1;
	pRedirRstr->presRest			=	mBuf[0]&0x03;
	return 1;
}

int siUnpkSiRemotOper  (SiRemotOper *pRemotOper,u8 *mBuf, u8 length)
{
	pRemotOper->pres		=	1;
	pRemotOper->length		=	length;
	memcpy(pRemotOper->content,mBuf,pRemotOper->length);
	return 1;
}

int siUnpkServiceAct    (SiServiceAct *pServiceAct,u8 *mBuf, u8 length)
{
	pServiceAct->pres		=	1;
	pServiceAct->length		=	length;
	memcpy(pServiceAct->serviceAct,mBuf,pServiceAct->length);
	return 1;
}

int siUnpkSubNum      (SiSubNum *pSubNum,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pSubNum->pres		=	1;
	pSubNum->oddEven	=	(mBuf[0]>>7) & 0x01;

	num_ptr	=	mBuf+1;
	for(i = 0, j = 0; i < length-1; i++)
	{
		pSubNum->addrSig[j++] = num_ptr[i] & 0x0f;
		pSubNum->addrSig[j++] = num_ptr[i] >> 4;
	}	
	if((pSubNum->oddEven) && (j > 0))
		j--;
	pSubNum->numOfDigit = j;

	return 1;
}

int siUnpkSusResInd    (SiSusResInd *pSusResInd,u8 *mBuf, u8 length)
{
	pSusResInd->pres			=	1;
	pSusResInd->susResInd		=	mBuf[0]&0x01;
	return 1;
}

int siUnpkTranNetSel   (SiTranNetSel *pTranNetSel,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pTranNetSel->pres		=	1;
	pTranNetSel->netIdPln	=	mBuf[0] & 0x0F;
	pTranNetSel->typNetId	=	(mBuf[0]>>4) & 0x07;
	pTranNetSel->oddEven	=	(mBuf[0]>>7) & 0x01;

	num_ptr	=	mBuf+1;
	for(i = 0, j = 0; i < length-1; i++)
	{
		pTranNetSel->netId[j++] = num_ptr[i] & 0x0f;
		pTranNetSel->netId[j++] = num_ptr[i] >> 4;
	}
	if((pTranNetSel->oddEven) && (j > 0))
		j--;
	pTranNetSel->numOfDigit = j;
	return 1;
}

int siUnpkTxMedReq     (SiTxMedReq *pTxMedReq,u8 *mBuf, u8 length)
{
	pTxMedReq->pres			=	1;
	pTxMedReq->trMedReq		=	mBuf[0];
	return 1;
}

int siUnpkSiUsrServInfo (SiUsrServInfo *pUsrServInfo,u8 *mBuf, u8 length)
{
	pUsrServInfo->pres		=	1;
	pUsrServInfo->length		=	length;
	memcpy(pUsrServInfo->content,mBuf,pUsrServInfo->length);
	return 1;
}

int siUnpkSiUsrTSrvInfo (SiUsrTSrvInfo *pUsrTSrvInfo,u8 *mBuf, u8 length)
{
	pUsrTSrvInfo->pres		=	1;
	pUsrTSrvInfo->length		=	length;
	memcpy(pUsrTSrvInfo->content,mBuf,pUsrTSrvInfo->length);
	return 1;
}

int siUnpkUsr2UsrInd   (SiUsr2UsrInd *pUsr2UsrInd,u8 *mBuf, u8 length)
{
	pUsr2UsrInd->pres		=	1;
	pUsr2UsrInd->type		=	mBuf[0]&0x01;
	pUsr2UsrInd->serv1		=	(mBuf[0]>>1)&0x03;
	pUsr2UsrInd->serv2		=	(mBuf[0]>>3)&0x03;
	pUsr2UsrInd->serv3		=	(mBuf[0]>>5)&0x03;
	pUsr2UsrInd->spare		=	(mBuf[0]>>7)&0x01;
	return 1;
}

int siUnpkUsr2UsrInfo  (SiUsr2UsrInfo *pUsr2UsrInfo,u8 *mBuf, u8 length)
{	
	pUsr2UsrInfo->pres		=	1;
	pUsr2UsrInfo->length	=	length;
	memcpy(pUsr2UsrInfo->info, mBuf, pUsr2UsrInfo->length);
	return 1;	
}

int siUnpkPassAlng     (SiPassAlng *pPassAlng,u8 *mBuf, u8 length)
{
	pPassAlng->pres		=	1;
	pPassAlng->length		=	length;
	memcpy(pPassAlng->passAlng,mBuf,pPassAlng->length);
	return 1;
}

/* unpacking functions for ITU97/ETSIV3 Information Element  */
int siUnpkSiConfTrtInd     (SiConfTrtInd *pConfTrtInd,u8 *mBuf, u8 	length)
{
	pConfTrtInd->pres		=	1;
	pConfTrtInd->confAcceptInd		=	mBuf[0]&0x03;
	if((mBuf[0]&0x80)!=0x80)
	{	
		pConfTrtInd->length = length-1;
		memcpy(pConfTrtInd->extInfo,mBuf+1,pConfTrtInd->length);
	}
	else
		pConfTrtInd->length = 0;
	return 1;
}

int siUnpkUidActionInd     (SiUidActionInd *pUidActionInd,u8 *mBuf, u8 length)
{
	pUidActionInd->pres		=	1;
	pUidActionInd->throughConnInstInd		=	mBuf[0]&0x01;
	pUidActionInd->t9InstInd		=	(mBuf[0]>>1)&0x01;
	if((mBuf[0]&0x80)!=0x80)
	{	
		pUidActionInd->length = length-1;
		memcpy(pUidActionInd->extInfo,mBuf+1,pUidActionInd->length);
	}
	else
		pUidActionInd->length = 0;
	return 1;
}

int siUnpkBackGVNS     (SiBackGVNS *pBackGVNS,u8 *mBuf, u8 length)
{
	pBackGVNS->pres		=	1;
	pBackGVNS->termAccessInd		=	mBuf[0]&0x03;
	if((mBuf[0]&0x80)!=0x80)
	{	
		pBackGVNS->length = length-1;
		memcpy(pBackGVNS->extInfo,mBuf+1,pBackGVNS->length);
	}
	else
		pBackGVNS->length = 0;

	return 1;
}

int siUnpkDisplayInfo     (SiDisplayInfo *pDisplayInfo,u8 *mBuf, u8 length)
{
	pDisplayInfo->pres		=	1;
	pDisplayInfo->length		=	length;
	memcpy(pDisplayInfo->displayInfo,mBuf,pDisplayInfo->length);
	return 1;
}

int siUnpkForwardGVNS     (SiForwardGVNS *pForwardGVNS,u8 *mBuf, u8 length)
{
	int i,j,point;
	u8	*num_ptr;

	pForwardGVNS->pres			=	1;
	point = 0;
	//Originating participating service provider 
	pForwardGVNS->lenInd1		=	mBuf[point] & 0x0F;
	if(pForwardGVNS->lenInd1 > 4)
		pForwardGVNS->lenInd1 = 4;
	pForwardGVNS->oddEven1		=	(mBuf[point]>>7) & 0x01;

	point++;
	num_ptr	=	mBuf+point;
	for(i = 0, j = 0; i < pForwardGVNS->lenInd1; i++)
	{
		pForwardGVNS->digits1[j++] = num_ptr[i] & 0x0f;
		pForwardGVNS->digits1[j++] = num_ptr[i] >> 4;
	}
	if((pForwardGVNS->oddEven1) && (j > 0))
		j--;
	pForwardGVNS->numOfDigit1 = j;
	if(pForwardGVNS->numOfDigit1 > 7)
		pForwardGVNS->numOfDigit1 = 7;
	point +=pForwardGVNS->lenInd1;

	//GVNS user group 
	pForwardGVNS->lenInd2		=	mBuf[point] & 0x0F;
	if(pForwardGVNS->lenInd2 > 8)
		pForwardGVNS->lenInd2 = 8;

	pForwardGVNS->oddEven2		=	(mBuf[point]>>7) & 0x01;	

	point++;
	num_ptr	=	mBuf+point;
	for(i = 0, j = 0; i < pForwardGVNS->lenInd2; i++)
	{
		pForwardGVNS->digits2[j++] = num_ptr[i] & 0x0f;
		pForwardGVNS->digits2[j++] = num_ptr[i] >> 4;
	}
	if((pForwardGVNS->oddEven2) && (j > 0))
		j--;
	pForwardGVNS->numOfDigit2 = j;
	point +=pForwardGVNS->lenInd2;

	//Terminating network routing number 
	pForwardGVNS->lenInd3		=	mBuf[point] & 0x0F;
	if(pForwardGVNS->lenInd3 > 9)
		pForwardGVNS->lenInd3 = 9;
	if(pForwardGVNS->lenInd3 == 0)
		pForwardGVNS->lenInd3 = 1;
	pForwardGVNS->numPlan		=	(mBuf[point]>>4) & 0x07;	
	pForwardGVNS->oddEven3		=	(mBuf[point]>>7) & 0x01;	
	pForwardGVNS->natOfAddr		=	mBuf[++point] & 0x7f;	

	point++;
	num_ptr	=	mBuf+point;
	for(i = 0, j = 0; i < pForwardGVNS->lenInd3-1; i++)
	{
		pForwardGVNS->digits3[j++] = num_ptr[i] & 0x0f;
		pForwardGVNS->digits3[j++] = num_ptr[i] >> 4;
	}
	if((pForwardGVNS->oddEven3) && (j > 0))
		j--;
	pForwardGVNS->numOfDigit3 = j;
	return 1;
}
int siUnpkCcss     (SiCcss *pCcss,u8 *mBuf, u8 length)
{
	pCcss->pres	=	1;
	pCcss->ccssCallInd	=	mBuf[0] & 0x01;
	return 1;
}
int siUnpkNetMgmtControls     (SiNetMgmtControls *pNetMgmtControls,u8 *mBuf, u8 length)
{
	pNetMgmtControls->pres	=	1;
	pNetMgmtControls->tmpAltRoutInd	=	mBuf[0] & 0x01;
	if((mBuf[0]&0x80)!=0x80)
	{	
		pNetMgmtControls->length = length-1;
		memcpy(pNetMgmtControls->extInfo,mBuf+1,pNetMgmtControls->length);
	}
	else
		pNetMgmtControls->length = 0;
	return 1;
}
int siUnpkCirAsgnMap     (SiCirAsgnMap *pCirAsgnMap,u8 *mBuf, u8 length)
{
	pCirAsgnMap->pres	=	1;
	pCirAsgnMap->mapType	=	mBuf[0] & 0x3f;
	memcpy(pCirAsgnMap->mapFormat,mBuf+1,4);
	return 1;

}
int siUnpkCorrelationId     (SiCorrelationId *pCorrelationId,u8 *mBuf, u8 length)
{
	pCorrelationId->pres	=	1;
	pCorrelationId->length	=	length;
	memcpy(pCorrelationId->correlationId,mBuf,pCorrelationId->length);
	return 1;
}
int siUnpkCallDivTrtInd     (SiCallDivTrtInd *pCallDivTrtInd,u8 *mBuf, u8 length)
{
	pCallDivTrtInd->pres	=	1;
	pCallDivTrtInd->callDivInd	=	mBuf[0] & 0x03;
	if((mBuf[0]&0x80)!=0x80)
	{	
		pCallDivTrtInd->length = length-1;
		memcpy(pCallDivTrtInd->extInfo,mBuf+1,pCallDivTrtInd->length);
	}
	else
		pCallDivTrtInd->length = 0;
	return 1;
}
int siUnpkCallInNmb     (SiCallInNmb *pCallInNmb,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pCallInNmb->pres			=	1;
	pCallInNmb->natAddrInd		=	mBuf[0] & 0x07F;
	pCallInNmb->oddEven			=	(mBuf[0]>>7) & 0x01;	
	pCallInNmb->presRest		=	(mBuf[1]>>2) & 0x03;
	pCallInNmb->numPlan			=	(mBuf[1]>>4) & 0x07;

	num_ptr	=	mBuf+2;
	for(i = 0, j = 0; i < length-2; i++)
	{
		pCallInNmb->addrSig[j++] = num_ptr[i] & 0x0f;
		pCallInNmb->addrSig[j++] = num_ptr[i] >> 4;
	}	
	if((pCallInNmb->oddEven) && (j > 0))
		j--;
	pCallInNmb->numOfDigit = j;
	return 1;
}
int siUnpkCallOfferTrtInd     (SiCallOfferTrtInd *pCallOfferTrtInd,u8 *mBuf, u8 length)
{
	pCallOfferTrtInd->pres	=	1;
	pCallOfferTrtInd->callOfferInd	=	mBuf[0] & 0x03;
	if((mBuf[0]&0x80)!=0x80)
	{	
		pCallOfferTrtInd->length = length-1;
		memcpy(pCallOfferTrtInd->extInfo,mBuf+1,pCallOfferTrtInd->length);
	}
	else
		pCallOfferTrtInd->length = 0;
	return 1;
}
int siUnpkScfId     (SiScfId *pScfId,u8 *mBuf, u8 length)
{
	pScfId->pres	=	1;
	pScfId->length	=	length;
	memcpy(pScfId->scfId,mBuf,pScfId->length);
	return 1;
}
int siUnpkUidCapInd     (SiUidCapInd *pUidCapInd,u8 *mBuf, u8 length)
{
	pUidCapInd->pres		=	1;
	pUidCapInd->throughConnInstInd		=	mBuf[0]&0x01;
	pUidCapInd->t9InstInd		=	(mBuf[0]>>1)&0x01;
	if((mBuf[0]&0x80)!=0x80)
	{	
		pUidCapInd->length = length-1;
		memcpy(pUidCapInd->extInfo,mBuf+1,pUidCapInd->length);
	}
	else
		pUidCapInd->length = 0;
	return 1;
}

int siUnpkCollCallReq     (SiCollCallReq *pCollCallReq,u8 *mBuf, u8 length)
{
	pCollCallReq->pres		=	1;
	pCollCallReq->collCallReqInd		=	mBuf[0]&0x01;
	return 1;
}
int siUnpkNaPaChgPID     (SiNaPaChgPID *pNaPaChgPID,u8 *mBuf, u8 length)
{
	pNaPaChgPID->pres		=	1;
	pNaPaChgPID->length		=	length;
	memcpy(pNaPaChgPID->naPaChgPtyId,mBuf,pNaPaChgPID->length);
	return 1;
}
int siUnpkCallTRef     (SiCallTRef *pCallTRef,u8 *mBuf, u8 length)
{
	pCallTRef->pres		=	1;
	pCallTRef->callTrnsfr		=	mBuf[0];
	return 1;

}
int siUnpkLoopPrvntInd     (SiLoopPrvntInd *pLoopPrvntInd,u8 *mBuf, u8 length)
{
	pLoopPrvntInd->pres		=	1;
	pLoopPrvntInd->loopPrvntType		=	mBuf[0]&0x01;
	pLoopPrvntInd->loopPrvntRspInd		=	(mBuf[0]>>1)&0x03;
	return 1;

}
int siUnpkAppTransParam     (SiAppTransParam *pAppTransParam,u8 *mBuf, u8 length)
{
	pAppTransParam->pres	=	1;
	pAppTransParam->appContextId	=	mBuf[0]&0x7f;
	pAppTransParam->atii	=	mBuf[1]&0x03;
	pAppTransParam->apmSegInd	=	mBuf[2]&0x3f;
	pAppTransParam->seqInd	=	(mBuf[2]>>6)&0x01;
	if((mBuf[2]&0x80)!=0x80)
	{
		pAppTransParam->slr	=	mBuf[3]&0x7f;
		pAppTransParam->length	=	length-4;
		memcpy(pAppTransParam->encapAppInfo,mBuf+4,pAppTransParam->length);
	}
	else
	{
		pAppTransParam->length	=	length-3;
		memcpy(pAppTransParam->encapAppInfo,mBuf+3,pAppTransParam->length);
	}
	return 1;
}


/* unpacking functions for UK specific Information Element  */
int siUnpkSiNatForCalInd     (SiNatForCalInd *pNatForCalInd,u8 *mBuf, u8 length)
{
	pNatForCalInd->pres		=	1;
	pNatForCalInd->cbi		=	mBuf[0]&0x01;
	pNatForCalInd->ntaInd		=	(mBuf[0]>>1)&0x01;
	return 1;
}

int siUnpkSiNatForCalIndLbL     (SiNatForCalIndLbL *pNatForCalIndLbL,u8 *mBuf, u8 length)
{
	pNatForCalIndLbL->pres		=	1;
	pNatForCalIndLbL->rci		=	mBuf[0]&0x0f;
	if((mBuf[0]&0x80)!=0x80)
		pNatForCalIndLbL->isi		=	mBuf[1]&0x0f;
	else
		pNatForCalIndLbL->isi	=	0;
	return 1;
}

int siUnpkSiPresNum     (SiPresNum *pPresNum,u8 *mBuf, u8 length)
{
	int i,j;
	u8	*num_ptr;

	pPresNum->pres			=	1;
	pPresNum->natAddrInd	=	mBuf[0] & 0x7F;
	pPresNum->oddEven		=	(mBuf[0]>>7) & 0x01;
	pPresNum->scrInd		=	mBuf[1] & 0x03;
	pPresNum->presRest		=	(mBuf[1]>>2) & 0x03;
	pPresNum->numPlan		=	(mBuf[1]>>4) & 0x07;
	pPresNum->pnp		=	(mBuf[1]>>7) & 0x01;

	num_ptr	=	mBuf+2;
	for(i = 0, j = 0; i < length-2; i++)
	{
		pPresNum->addrSig[j++] = num_ptr[i] & 0x0f;
		pPresNum->addrSig[j++] = num_ptr[i] >> 4;
	}	
	if((pPresNum->oddEven) && (j > 0))
		j--;
	pPresNum->numOfDigit = j;

	return 1;
}



int siUnpkSiPartCLI     (SiPartCLI *pPartCLI,u8 *mBuf, u8 length)
{
	pPartCLI->pres			=	1;
	pPartCLI->swichTypeD1	=	mBuf[0] & 0x0F;
	pPartCLI->swichTypeD2	=	mBuf[0] >> 4;
	pPartCLI->pnoIdD1	=	mBuf[1] & 0x0F;
	pPartCLI->pnoIdD2	=	mBuf[1] >> 4;
	pPartCLI->pnoIdD3	=	mBuf[2] & 0x0F;
	pPartCLI->switchNumD1	=	mBuf[2] >> 4;
	pPartCLI->switchNumD2	=	mBuf[3] & 0x0F;
	pPartCLI->switchNumD3	=	mBuf[3] >> 4;
	memcpy(pPartCLI->agreement,mBuf+4,5);
	return 1;
}

int siUnpkCaldSubBasSerMar   (SiCaldSubBasSerMar *pCaldSubBasSerMar,u8 *mBuf, u8 length)
{
	pCaldSubBasSerMar->pres			=	1;
	pCaldSubBasSerMar->cbInd			=	mBuf[0] & 0x01 ;
	pCaldSubBasSerMar->subIcbInd	=	(mBuf[0]>>1) & 0x01;
	pCaldSubBasSerMar->preIcbInd	=	(mBuf[0]>>2) & 0x01;
	pCaldSubBasSerMar->permIcbInd	=	(mBuf[0]>>3) & 0x01;
	pCaldSubBasSerMar->tosInd		=	(mBuf[0]>>4) & 0x01;
	pCaldSubBasSerMar->ICBExpInd	=	(mBuf[0]>>5) & 0x01;
	pCaldSubBasSerMar->caldSubFacInfInd	=	(mBuf[0]>>6) & 0x01;
	pCaldSubBasSerMar->calgSubFacInfInd	=	(mBuf[0]>>7) & 0x01;
	pCaldSubBasSerMar->permOcbInd		=	mBuf[1] & 0x01 ;
	pCaldSubBasSerMar->ogLocCalBarInd	=	(mBuf[1]>>1) & 0x01;
	pCaldSubBasSerMar->ogNatCalBarInd	=	(mBuf[1]>>2) & 0x01;
	pCaldSubBasSerMar->ogIntCalBarInd	=	(mBuf[1]>>3) & 0x01;
	pCaldSubBasSerMar->opCalBarInd		=	(mBuf[1]>>4) & 0x01;
	pCaldSubBasSerMar->supFacCalBarInd	=	(mBuf[1]>>5) & 0x01;
	pCaldSubBasSerMar->digMaskInd		=	(mBuf[1]>>6) & 0x01;
	pCaldSubBasSerMar->calPreBarInd		=	(mBuf[1]>>7) & 0x01;
	pCaldSubBasSerMar->caldSubTarGp		=	mBuf[2] & 0x7F;
	return 1;
}

int siUnpkCalgSubBasSerMar   (SiCalgSubBasSerMar *pCalgSubBasSerMar,u8 *mBuf, u8 length)
{
	pCalgSubBasSerMar->pres			=	1;
	pCalgSubBasSerMar->cbInd		=	mBuf[0] & 0x01 ;
	pCalgSubBasSerMar->subIcbInd	=	(mBuf[0]>>1) & 0x01;
	pCalgSubBasSerMar->preIcbInd	=	(mBuf[0]>>2) & 0x01;
	pCalgSubBasSerMar->permIcbInd	=	(mBuf[0]>>3) & 0x01;
	pCalgSubBasSerMar->tosInd		=	(mBuf[0]>>4) & 0x01;
	pCalgSubBasSerMar->ICBExpInd	=	(mBuf[0]>>5) & 0x01;
	pCalgSubBasSerMar->caldSubFacInfInd	=	(mBuf[0]>>6) & 0x01;
	pCalgSubBasSerMar->calgSubFacInfInd	=	(mBuf[0]>>7) & 0x01;
	pCalgSubBasSerMar->permOcbInd		=	mBuf[1] & 0x01 ;
	pCalgSubBasSerMar->ogLocCalBarInd	=	(mBuf[1]>>1) & 0x01;
	pCalgSubBasSerMar->ogNatCalBarInd	=	(mBuf[1]>>2) & 0x01;
	pCalgSubBasSerMar->ogIntCalBarInd	=	(mBuf[1]>>3) & 0x01;
	pCalgSubBasSerMar->opCalBarInd		=	(mBuf[1]>>4) & 0x01;
	pCalgSubBasSerMar->supFacCalBarInd	=	(mBuf[1]>>5) & 0x01;
	pCalgSubBasSerMar->digMaskInd		=	(mBuf[1]>>6) & 0x01;
	pCalgSubBasSerMar->calPreBarInd		=	(mBuf[1]>>7) & 0x01;
	pCalgSubBasSerMar->calgSubTarGp		=	mBuf[2] & 0x7F;
	pCalgSubBasSerMar->opInd			=	(mBuf[2]>>7) & 0x01;
	return 1;
}

int siUnpkCalgSubOrgFacMar   (SiCalgSubOrgFacMar *pCalgSubOrgFacMar,u8 *mBuf, u8 length)
{
	pCalgSubOrgFacMar->pres			=	1;
	pCalgSubOrgFacMar->disSubInd		=	mBuf[0] & 0x01 ;
	pCalgSubOrgFacMar->attCOI	=	(mBuf[0]>>1) & 0x01;
	pCalgSubOrgFacMar->adDurChgInd	=	(mBuf[0]>>2) & 0x01;
	pCalgSubOrgFacMar->PBXSubInd	=	(mBuf[0]>>3) & 0x01;
	return 1;
}

int siUnpkCaldSubTermFacMar   (SiCaldSubTermFacMar *pCaldSubTermFacMar,u8 *mBuf, u8 length)
{
	pCaldSubTermFacMar->pres			=	1;
	pCaldSubTermFacMar->sviInd		=	mBuf[0] & 0x01 ;
	pCaldSubTermFacMar->cniInd	=	(mBuf[0]>>1) & 0x01;
	pCaldSubTermFacMar->pbxNigIntInd	=	(mBuf[0]>>2) & 0x01;
	pCaldSubTermFacMar->calWaitInd	=	(mBuf[0]>>3) & 0x01;
	pCaldSubTermFacMar->fixedDestSerInd	=	(mBuf[0]>>4) & 0x01;
	return 1;
}

int siUnpkNatInfReqInd   (SiNatInfReqInd *pNatInfReqInd,u8 *mBuf, u8 length)
{
	pNatInfReqInd->pres			=	1;
	pNatInfReqInd->calgSubBasSerMarReqInd		=	mBuf[0] & 0x01 ;
	pNatInfReqInd->caldSubBasSerMarReqInd	=	(mBuf[0]>>1) & 0x01;
	pNatInfReqInd->calgSubOrgFacMarReqInd	=	(mBuf[0]>>2) & 0x01;
	pNatInfReqInd->caldSubTerFacMarReqInd	=	(mBuf[0]>>3) & 0x01;
	return 1;
}


int siUnpkNatInfInd   (SiNatInfInd *pNatInfInd,u8 *mBuf, u8 length)
{
	pNatInfInd->pres			=	1;
	pNatInfInd->calgSubBasSerMarRespInd		=	mBuf[0] & 0x01 ;
	pNatInfInd->caldSubBasSerMarRespInd	=	(mBuf[0]>>1) & 0x01;
	pNatInfInd->calgSubOrgFacMarRespInd	=	(mBuf[0]>>2) & 0x01;
	pNatInfInd->caldSubTerFacMarRespInd	=	(mBuf[0]>>3) & 0x01;
	return 1;
}

int siUnpkCirValRspInd   (SiCirValRspInd *pCirValRspInd,u8 *mBuf, u8 length)
{
	pCirValRspInd->pres			=	1;
	pCirValRspInd->cirValRspInd		=	mBuf[0] & 0x01 ;
	return 1;
}

int siUnpkCirGrpCharInd   (SiCirGrpCharInd *pCirGrpCharInd,u8 *mBuf, u8 length)
{
	pCirGrpCharInd->pres			=	1;
	pCirGrpCharInd->cirGrpCarInd		=	mBuf[0] & 0x03 ;
	pCirGrpCharInd->dblSzCtrlInd		=	(mBuf[0]>>2) & 0x03 ;
	pCirGrpCharInd->alarmCarInd			=	(mBuf[0]>>4) & 0x03 ;
	pCirGrpCharInd->contChkReqInd		=	(mBuf[0]>>6) & 0x03 ;	
	return 1;
}

int siUnpkCirIdName   (SiCirIdName *pCirIdName,u8 *mBuf, u8 length)
{
	int i;
	pCirIdName->pres			=	1;
	
	for(i=0;i<26;i++)
	{
		pCirIdName->trunkNumClli[i]		=	mBuf[i] & 0x7f ;		
	}
	return 1;
}

int siUnpkCLLI   (SiCLLI *pCLLI,u8 *mBuf, u8 length)
{
	int i;
	pCLLI->pres			=	1;
	
	for(i=0;i<11;i++)
	{
		pCLLI->clliCode[i]		=	mBuf[i] & 0x7f ;
	}
	return 1;
}

/* packing functions for ISUP information elements */
int siPkSiAccDelInfo (SiAccDelInfo *pAccDelInfo,u8 *mBuf)
{
	mBuf[0] = pAccDelInfo->delInd &0x01;
	return 1;
}


int siPkAccTrnspt   (SiAccTrnspt *pAccTrnspt,u8 *mBuf)
{
	memcpy(mBuf,pAccTrnspt->infoElmts,pAccTrnspt->infoLen);
	return pAccTrnspt->infoLen;
}

int siPkAutoCongLvl (SiAutoCongLvl *pAutoCongLvl,u8 *mBuf)
{
	mBuf[0]	=	pAutoCongLvl->auCongLvl;
	return 1;
}

int siPkBckCalInd   (SiBckCalInd *pBckCalInd,u8 *mBuf)
{
	mBuf[0] =	0;
	mBuf[0] |=	pBckCalInd->chrgInd & 0x03;
	mBuf[0] |=	(pBckCalInd->cadPtyStatInd & 0x03) << 2;
	mBuf[0] |=	(pBckCalInd->cadPtyCatInd & 0x03) << 4;
	mBuf[0] |=	(pBckCalInd->end2EndMethInd & 0x03) << 6;

	mBuf[1]  =	0;
	mBuf[1] |=	pBckCalInd->intInd & 0x01;
	mBuf[1] |=	(pBckCalInd->end2EndInfoInd & 0x01) << 1;
	mBuf[1] |=	(pBckCalInd->isdnUsrPrtInd & 0x01) << 2;
	mBuf[1] |=	(pBckCalInd->holdInd & 0x01) << 3;
	mBuf[1] |=	(pBckCalInd->isdnAccInd & 0x01) << 4;
	mBuf[1] |=	(pBckCalInd->echoCtrlDevInd & 0x01) << 5;
	mBuf[1] |=	(pBckCalInd->sccpMethInd & 0x03) << 6;

	return 2;
}



int siPkSiCllDiverInfo (SiCllDiverInfo *pCllDivr,u8 *mBuf)
{	
	mBuf[0]			=	pCllDivr->notSuscr&0x07;
	mBuf[0]			|=	(pCllDivr->redirRsn & 0x0F) << 3;
	return 1;
}

int siPkSiPropDly      (SiPropDly *pPropDly,u8 *mBuf)
{
	mBuf[0]	=	(pPropDly->delayVal>>8) & 0xFF;
	mBuf[1]	=	pPropDly->delayVal & 0xFF;
	return 2;
}

int siPkCallRef     (SiCallRef *pCallRef,u8 *mBuf)
{
	mBuf[0]	=	pCallRef->callId[0];
	mBuf[1]	=	pCallRef->callId[1];
	mBuf[2]	=	pCallRef->callId[2];
	mBuf[3]	=	pCallRef->pntCde & 0xFF;
	mBuf[4]	=	(pCallRef->pntCde>>8) & 0x3F;
	return 5;
}

int siPkCdPtyNum    (SiCdPtyNum *pCdPtyNum,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pCdPtyNum->numOfDigit/2 + (pCdPtyNum->numOfDigit & 0x01);
	num_ptr	= mBuf+2;

	pCdPtyNum->oddEven = pCdPtyNum->numOfDigit & 0x01;

	mBuf[0]		 = pCdPtyNum->natAddrInd & 0x7F;
	mBuf[0]		|= (pCdPtyNum->oddEven & 0x01) <<7;
	mBuf[1]		 = (pCdPtyNum->numPlan & 0x07) << 4;
	mBuf[1]		|= (pCdPtyNum->natAddrInd & 0x01) <<7;

	if(num_len==0) 
		num_len=1;
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pCdPtyNum->addrSig[j++] & 0x0f;
		num_ptr[i] += pCdPtyNum->addrSig[j++] << 4;
	}

	if(pCdPtyNum->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 2;
}

int siPkCgPtyNum    (SiCgPtyNum *pCgPtyNum,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pCgPtyNum->numOfDigit/2 + (pCgPtyNum->numOfDigit & 0x01);
	num_ptr	= mBuf+2;

	pCgPtyNum->oddEven = pCgPtyNum->numOfDigit & 0x01;
	
	mBuf[0]		= pCgPtyNum->natAddrInd & 0x7F;
	mBuf[0]		|= (pCgPtyNum->oddEven & 0x01) <<7;
	mBuf[1]		= pCgPtyNum->scrnInd & 0x03;
	mBuf[1]		|= (pCgPtyNum->presRest & 0x03) << 2;
	mBuf[1]		|= (pCgPtyNum->numPlan & 0x07) << 4;
	mBuf[1]		|= (pCgPtyNum->niInd & 0x01) <<7;
	if(num_len==0) 
		num_len=1;	
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pCgPtyNum->addrSig[j++] & 0x0f;
		num_ptr[i] += pCgPtyNum->addrSig[j++] << 4;
	}

	if(pCgPtyNum->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 2;
}

int siPkCgPtyCat    (SiCgPtyCat *pCgPtyCat,u8 *mBuf)
{
	mBuf[0]			 =	pCgPtyCat->cgPtyCat;
	return 1;
}

int siPkCauseDgn    (SiCauseDgn *pCauseDgn,u8 *mBuf)
{
	mBuf[0]			 =	0x80;
	mBuf[0]			|=	pCauseDgn->location&0x0F;
	mBuf[0]			|=	(pCauseDgn->cdeStand & 0x03)<<5;
	mBuf[1]			 =	0x80;
	mBuf[1]			|=	pCauseDgn->causeVal&0x7F;
	if(pCauseDgn->length != 0)
		memcpy(mBuf+2,pCauseDgn->dgnVal,pCauseDgn->length);
	return pCauseDgn->length+2;
}

int siPkCirGrpSupMTypInd (SiCirGrpSupMTypInd *pCgsmti,u8 *mBuf)
{
	mBuf[0]			=	pCgsmti->typeInd&0x03;
	return 1;
}

int siPkCirStateInd (SiCirStateInd *pCirStateInd,u8 *mBuf)
{		
	memcpy(mBuf,pCirStateInd->cirSteInd,pCirStateInd->length);
	return pCirStateInd->length;	
}

int siPkCugIntCode  (SiCugIntCode *pCugIntCode,u8 *mBuf)
{	
	mBuf[0]		=	(pCugIntCode->dig1<<4)|(pCugIntCode->dig2&0x0F);
	mBuf[1]		=	(pCugIntCode->dig3<<4)|(pCugIntCode->dig4&0x0F);
	mBuf[2]		=	pCugIntCode->binCde>>8;
	mBuf[3]		=	pCugIntCode->binCde & 0xFF;
	return 4;
}

int siPkConnectedNum (SiConnectedNum *pConnectedNum,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pConnectedNum->numOfDigit/2 + (pConnectedNum->numOfDigit & 0x01);
	num_ptr	= mBuf+2;
	
	pConnectedNum->oddEven = pConnectedNum->numOfDigit & 0x01;
	
	mBuf[0]		= pConnectedNum->natAddrInd & 0x7F;
	mBuf[0]		|= (pConnectedNum->oddEven & 0x01) <<7;
	mBuf[1]		= pConnectedNum->scrnInd & 0x03;
	mBuf[1]		|= (pConnectedNum->presRest & 0x03) << 2;
	mBuf[1]		|= (pConnectedNum->numPlan & 0x07) << 4;
	if(num_len==0) 
		num_len=1;	
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pConnectedNum->addrSig[j++] & 0x0f;
		num_ptr[i] += pConnectedNum->addrSig[j++] << 4;
	}

	if(pConnectedNum->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 2;
}

int siPkConnReq     (SiConnReq *pConnReq,u8 *mBuf)
{
	mBuf[0] = pConnReq->locRef[0];
	mBuf[1] = pConnReq->locRef[1];
	mBuf[2] = pConnReq->locRef[2];
	mBuf[3] = pConnReq->pntCde & 0xFF;
	mBuf[4] = (pConnReq->pntCde>>8) & 0x3F;
	mBuf[5] = pConnReq->protClass;
	mBuf[6] = pConnReq->credit;
	return 7;
}

int siPkContInd     (SiContInd *pContInd,u8 *mBuf)
{
	mBuf[0]	=	pContInd->contInd&0x01;
	return 1;
}

int siPkSiEchoCtl    (SiEchoCtl *pEchoCtl,u8 *mBuf)
{
	mBuf[0]	=	pEchoCtl->outEchoRsp & 0x03;
	mBuf[0]	|=	(pEchoCtl->incEchoRsp & 0x03) << 2;
	mBuf[0]	|=	(pEchoCtl->outEchoReq & 0x03) << 4;
	mBuf[0]	|=	(pEchoCtl->incEchoReq & 0x03) << 6;
	return 1;
}

int siPkEvntInfo    (SiEvntInfo *pEvntInfo,u8 *mBuf)
{
	mBuf[0]  =	0;
	mBuf[0] |=	pEvntInfo->evntInd & 0x7F;
	mBuf[0] |=	(pEvntInfo->evntPresResInd &0x01) << 7;
	return 1;
}


int siPkFacInd      (SiFacInd *pFacInd,u8 *mBuf)
{
	mBuf[0]		=		pFacInd->facInd;
	return 1;
}

int siPkFwdCallInd  (SiFwdCallInd *pFwdCallInd,u8 *mBuf)
{
	mBuf[0]  =	0;
	mBuf[0] |=	pFwdCallInd->natIntCallInd & 0x01;
	mBuf[0] |=	(pFwdCallInd->end2EndMethInd &0x03) << 1;
	mBuf[0] |=	(pFwdCallInd->intInd &0x01) << 3;
	mBuf[0] |=	(pFwdCallInd->end2EndInfoInd &0x01) << 4;
	mBuf[0] |=	(pFwdCallInd->isdnUsrPrtInd &0x01) << 5;
	mBuf[0] |=	(pFwdCallInd->isdnUsrPrtPrfInd &0x03) << 6;
	mBuf[1] |=	pFwdCallInd->isdnAccInd &0x01;
	mBuf[1] |=	(pFwdCallInd->sccpMethInd &0x03) << 1;
	return 2;
}

int siPkFreePhParam  (SiFreePhInd *pFreePhInd,u8 *mBuf){return 0;}//reserved

int siPkSiGenDigits   (SiGenDigits *pGenDigits,u8 *mBuf)
{
	mBuf[0] = pGenDigits->typeOfDigits & 0x1F; 
	mBuf[0] |= (pGenDigits->encodeScheme & 0x07)<<5;
	memcpy(mBuf+1, pGenDigits->digits, pGenDigits->length);
	return pGenDigits->length + 1;
}

int siPkNotifInd       (SiNotifInd *pNotifInd,u8 *mBuf)
{
	mBuf[0] = pNotifInd->notifInd;
	return 1;
}

int siPkSiGenNum      (SiGenNum *pGenNum,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pGenNum->numOfDigit/2 + (pGenNum->numOfDigit & 0x01);
	num_ptr	= mBuf+3;
	pGenNum->oddEven = pGenNum->numOfDigit & 0x01;

	mBuf[0]		 = pGenNum->nmbQual;
	mBuf[1]		 = pGenNum->natAddrInd & 0x7F;
	mBuf[1]		|= (pGenNum->oddEven & 0x01) <<7;
	mBuf[2]		 = pGenNum->scrnInd & 0x03;
	mBuf[2]		|= (pGenNum->presRest & 0x03) << 2;
	mBuf[2]		|= (pGenNum->numPlan & 0x07) << 4;
	mBuf[2]		|= (pGenNum->niInd & 0x01) <<7;
	if(num_len==0) 
		num_len=1;	
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pGenNum->addrSig[j++] & 0x0f;
		num_ptr[i] += pGenNum->addrSig[j++] << 4;
	}

	if(pGenNum->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 3;
}

int siPkHopCounter  (SiHopCounter *pHopCounter,u8 *mBuf)
{
	mBuf[0]	=	pHopCounter->hopCounter&0x1F;
	return 1;
}

int siPkInfoInd     (SiInfoInd *pInfoInd,u8 *mBuf)
{
	mBuf[0]		=		0;
	mBuf[0]		|=		pInfoInd->cgPtyAddrRespInd & 0x03;
	mBuf[0]		|=		(pInfoInd->holdProvInd& 0x01) <<2 ;
	mBuf[0]		|=		(pInfoInd->cgPtyCatRespInd& 0x01) <<5 ;
	mBuf[0]		|=		(pInfoInd->chrgInfoRespInd& 0x01) <<6 ;
	mBuf[0]		|=		(pInfoInd->solInfoInd& 0x01) <<7;
	mBuf[1]		=		0;
	return 2;
}

int siPkInfoReqInd  (SiInfoReqInd *pInfoReqInd,u8 *mBuf)
{
	mBuf[0] =	0;
	mBuf[0]	|=	pInfoReqInd->cgPtyAdReqInd & 0x01;
	mBuf[0]	|=	(pInfoReqInd->holdingInd  & 0x01) <<1;
	mBuf[0]	|=	(pInfoReqInd->cgPtyCatReqInd& 0x01) <<3 ;
	mBuf[0]	|=	(pInfoReqInd->chrgInfoReqInd& 0x01) <<4 ;
	mBuf[0]	|=	(pInfoReqInd->malCaIdReqInd& 0x01)<<7;
	mBuf[1]	=	0;
	return 2;
}

int siPkSiMcidRspInd (SiMcidRspInd *pMcidRsp,u8 *mBuf)
{
	mBuf[0]		=	pMcidRsp->rspInd &0x01;
	mBuf[0]		|=	(pMcidRsp->hldInd &0x01)<<1;
	return 1;
}

int siPkSiMcidReqInd (SiMcidReqInd *pMcidReq,u8 *mBuf)
{
	mBuf[0]		=	pMcidReq->reqInd &0x01;
	mBuf[0]		|=	(pMcidReq->hldInd &0x01)<<1;
	return 1;
}

int siPkSiMsgCompInfo  (SiMsgCompInfo *pMsgCom,u8 *mBuf)
{
	mBuf[0]		=	pMsgCom->tranXInd &0x01;
	mBuf[0]		|=	(pMsgCom->relCllInd &0x01)<<1;
	mBuf[0]		|=	(pMsgCom->sndNotInd &0x01)<<2;
	mBuf[0]		|=	(pMsgCom->dcrdMsgInd &0x01)<<3;
	mBuf[0]		|=	(pMsgCom->passNotPoss &0x01)<<4;
	mBuf[0]		|=	(pMsgCom->bbNbIntwkI &0x03)<<5;
	return 1;
}

int siPkSiMlppPrec     (SiMlppPrec *pMlppPrec,u8 *mBuf)
{
	mBuf[0]		=	pMlppPrec->precdLvl & 0x0F;
	mBuf[0]		|=	(pMlppPrec->lfb & 0x03)<<5;
	mBuf[1]		=	pMlppPrec->scndDig &0x0f;
	mBuf[1]		|=	(pMlppPrec->frstDig & 0x0f)<<4;
	mBuf[2]		=	pMlppPrec->frthDig &0x0f;
	mBuf[2]		|=	(pMlppPrec->thrdDig & 0x0f)<<4;
	mBuf[3]		=	(pMlppPrec->servDomain>>16) &0xFF;
	mBuf[4]		=	(pMlppPrec->servDomain>>8) &0xFF;
	mBuf[5]		=	pMlppPrec->servDomain &0xFF;
	return 6;
}

int siPkNatConInd   (SiNatConInd *pNatConInd,u8 *mBuf)
{
	mBuf[0]  =	0;
	mBuf[0] |=	pNatConInd->satInd & 0x03;
	mBuf[0] |=	(pNatConInd->contChkInd & 0x03) << 2;
	mBuf[0] |=	(pNatConInd->echoCntrlDevInd & 0x01) << 4;
	return 1;
}

int siPkSiNetSpecFacil (SiNetSpecFacil *pNetFac,u8 *mBuf)
{
	memcpy(mBuf,pNetFac->netFac,pNetFac->length);
	return pNetFac->length;
}

int siPkOptBckCalInd (SiOptBckCalInd *pOptBckCalInd,u8 *mBuf)
{
	mBuf[0]  =	pOptBckCalInd->inbndInfoInd & 0x01;
	mBuf[0] |=	(pOptBckCalInd->caFwdMayOcc & 0x01) << 1;
	mBuf[0] |=	(pOptBckCalInd->simpleSegmInd & 0x01) << 2;
	mBuf[0] |=	(pOptBckCalInd->mlppUserInd & 0x01) << 3;
	return 1;
}

int siPkOpFwdCalInd (SiOpFwdCalInd *pOpFwdCalInd,u8 *mBuf)
{

	mBuf[0]  =	pOpFwdCalInd->clsdUGrpCaInd & 0x03;
	mBuf[0] |=	(pOpFwdCalInd->simpleSegmInd & 0x01) << 2;
	mBuf[0] |=	(pOpFwdCalInd->conLineIdReqInd & 0x01) << 7;
	return 1;
}

int siPkOrigCdNum    (SiOrigCdNum *pOrigCdNum,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pOrigCdNum->numOfDigit/2 + (pOrigCdNum->numOfDigit & 0x01);
	num_ptr	= mBuf+2;
	pOrigCdNum->oddEven = pOrigCdNum->numOfDigit & 0x01;

	mBuf[0]		= pOrigCdNum->natAddrInd & 0x7F;
	mBuf[0]		|= (pOrigCdNum->oddEven & 0x01) << 7;	
	mBuf[1]		= (pOrigCdNum->presRest & 0x03) << 2;
	mBuf[1]		|= (pOrigCdNum->numPlan & 0x07) << 4;
	if(num_len==0) 
		num_len=1;
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pOrigCdNum->addrSig[j++] & 0x0f;
		num_ptr[i] += pOrigCdNum->addrSig[j++] << 4;
	}

	if(pOrigCdNum->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 2;	
}

int siPkSigPointCode (SiSigPointCode *pSigPointCode,u8 *mBuf)
{
	mBuf[0]	=	pSigPointCode->sigPointCode & 0xFF;
	mBuf[1]	=	(pSigPointCode->sigPointCode>>8) & 0x3F;
	return 2;
}

int siPkSiParmCompInfo (SiParmCompInfo *pParmCom,u8 *mBuf)
{
	memcpy(mBuf,pParmCom->content,pParmCom->length);
	return pParmCom->length;
}

int siPkRangStat     (SiRangStat *pRangStat,u8 *mBuf)
{
	int status_len;
	mBuf[0]	=	pRangStat->range;
	status_len = ((pRangStat->range&0x07) == 0)? (pRangStat->range>>3) : ((pRangStat->range>>3) + 1);
	memcpy(mBuf+1, pRangStat->status, status_len);
	return status_len+1;
}
int siPkRangNoStat     (SiRangNoStat *pRangStat,u8 *mBuf)
{
	mBuf[0]	=	pRangStat->range;
	return 1;
}

int siPkRedirInfo    (SiRedirInfo *pRedirInfo,u8 *mBuf)
{
	mBuf[0]  =	pRedirInfo->redirInd & 0x07;
	mBuf[0] |=	(pRedirInfo->origRedirReas & 0x0F) << 4;
	mBuf[1]  =	pRedirInfo->redirCnt & 0x07;
	mBuf[1] |=	(pRedirInfo->redirReas & 0x0F) << 4;
	return 2;
}

int siPkRedirgNum    (SiRedirNum *pRedirgNum,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pRedirgNum->numOfDigit/2 + (pRedirgNum->numOfDigit & 0x01);
	num_ptr	= mBuf+2;
	pRedirgNum->oddEven = pRedirgNum->numOfDigit & 0x01;

	mBuf[0]		= pRedirgNum->natAddrInd & 0x7F;
	mBuf[0]		|= (pRedirgNum->oddEven & 0x01) << 7;	
	mBuf[1]		= (pRedirgNum->presRest & 0x03) << 2;
	mBuf[1]		|= (pRedirgNum->numPlan & 0x07) << 4;
	if(num_len==0) 
		num_len=1;	
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pRedirgNum->addrSig[j++] & 0x0f;
		num_ptr[i] += pRedirgNum->addrSig[j++] << 4;
	}

	if(pRedirgNum->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 2;
}

int siPkSiRedirRestr (SiRedirRestr *pRedirRstr,u8 *mBuf)
{
	mBuf[0]  =	pRedirRstr->presRest & 0x03;
	return 1;
}

int siPkSiRemotOper  (SiRemotOper *pRemotOper,u8 *mBuf)
{
	memcpy(mBuf,pRemotOper->content,pRemotOper->length);
	return pRemotOper->length;
}

int siPkServiceAct    (SiServiceAct *pServiceAct,u8 *mBuf)
{
	memcpy(mBuf,pServiceAct->serviceAct,pServiceAct->length);
	return pServiceAct->length;
}

int siPkSubNum      (SiSubNum *pSubNum,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pSubNum->numOfDigit/2 + (pSubNum->numOfDigit & 0x01);
	num_ptr	= mBuf+1;
	pSubNum->oddEven = pSubNum->numOfDigit & 0x01;

	mBuf[0]		 = (pSubNum->oddEven &0x01) <<7;
	if(num_len==0) 
		num_len=1;
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pSubNum->addrSig[j++] & 0x0f;
		num_ptr[i] += pSubNum->addrSig[j++] << 4;
	}

	if(pSubNum->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 1;
}

int siPkSusResInd    (SiSusResInd *pSusResInd,u8 *mBuf)
{
	mBuf[0] = pSusResInd->susResInd &0x01;
	return 1;
}

int siPkTranNetSel   (SiTranNetSel *pTranNetSel,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pTranNetSel->numOfDigit/2 + (pTranNetSel->numOfDigit & 0x01);
	num_ptr	= mBuf+1;

	pTranNetSel->oddEven = pTranNetSel->numOfDigit & 0x01;

	mBuf[0]		 = pTranNetSel->netIdPln & 0x0F;
	mBuf[0]		|= (pTranNetSel->typNetId & 0x03) <<4;
	mBuf[0]		|= (pTranNetSel->oddEven & 0x01) <<7;

	if(num_len==0) 
		num_len=1;
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pTranNetSel->netId[j++] & 0x0f;
		num_ptr[i] += pTranNetSel->netId[j++] << 4;
	}

	if(pTranNetSel->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 1;
}

int siPkTxMedReq     (SiTxMedReq *pTxMedReq,u8 *mBuf)
{
	mBuf[0]	=	pTxMedReq->trMedReq;
	return 1;
}

int siPkSiUsrServInfo (SiUsrServInfo *pUsrServInfo,u8 *mBuf)
{
	memcpy(mBuf,pUsrServInfo->content,pUsrServInfo->length);
	return pUsrServInfo->length;
}

int siPkSiUsrTSrvInfo (SiUsrTSrvInfo *pUsrTSrvInfo,u8 *mBuf)
{
	memcpy(mBuf,pUsrTSrvInfo->content,pUsrTSrvInfo->length);
	return pUsrTSrvInfo->length;
}

int siPkUsr2UsrInd   (SiUsr2UsrInd *pUsr2UsrInd,u8 *mBuf)
{
	mBuf[0]		= pUsr2UsrInd->type & 0x01;
	mBuf[0]		|= (pUsr2UsrInd->serv1 & 0x03)<<1;
	mBuf[0]		|= (pUsr2UsrInd->serv2 & 0x03)<<3;
	mBuf[0]		|= (pUsr2UsrInd->serv3 & 0x03)<<5;
	mBuf[0]		|= (pUsr2UsrInd->spare & 0x01)<<7;
	return 1;
}

int siPkUsr2UsrInfo  (SiUsr2UsrInfo *pUsr2UsrInfo,u8 *mBuf)
{
	memcpy(mBuf, pUsr2UsrInfo->info, pUsr2UsrInfo->length);
	return pUsr2UsrInfo->length;
}

int siPkPassAlng     (SiPassAlng *pPassAlng,u8 *mBuf)
{
	memcpy(mBuf,pPassAlng->passAlng,pPassAlng->length);
	return pPassAlng->length;
}
/* packing functions for ITU97/ETSIV3 Information Element  */
int siPkSiConfTrtInd     (SiConfTrtInd *pConfTrtInd,u8 *mBuf)
{
	mBuf[0] = pConfTrtInd->confAcceptInd&0x03;
	if(pConfTrtInd->length)
		memcpy(mBuf+1, pConfTrtInd->extInfo, pConfTrtInd->length);
	else
		mBuf[0]	= mBuf[0] | 0x80;
	return pConfTrtInd->length+1;
}
int siPkUidActionInd     (SiUidActionInd *pUidActionInd,u8 *mBuf)
{
	mBuf[0] = pUidActionInd->throughConnInstInd&0x01;
	mBuf[0] |= (pUidActionInd->t9InstInd&0x01) << 1;
	if(pUidActionInd->length)
		memcpy(mBuf+1, pUidActionInd->extInfo, pUidActionInd->length);
	else
		mBuf[0]	= mBuf[0] | 0x80;
	return pUidActionInd->length+1;
}
int siPkBackGVNS     (SiBackGVNS *pBackGVNS,u8 *mBuf)
{
	mBuf[0] = pBackGVNS->termAccessInd&0x03;
	if(pBackGVNS->length)
	{
		memcpy(mBuf+1, pBackGVNS->extInfo, pBackGVNS->length);
	}
	else
		mBuf[0]	= mBuf[0] | 0x80;
	return pBackGVNS->length+1;
}

int siPkDisplayInfo     (SiDisplayInfo *pDisplayInfo,u8 *mBuf)
{
	memcpy(mBuf,pDisplayInfo->displayInfo,pDisplayInfo->length);
	return pDisplayInfo->length;
}
int siPkForwardGVNS     (SiForwardGVNS *pForwardGVNS,u8 *mBuf)
{
	int i,j,num_len,point;
	u8	*num_ptr;

	point = 0;
	//Originating participating service provider 
	num_len = pForwardGVNS->numOfDigit1/2 + (pForwardGVNS->numOfDigit1 & 0x01);
	if(num_len>4)
		num_len=4;
	if(num_len==0) 
		num_len=1;
	mBuf[point]		= num_len & 0x0F;
	mBuf[point]		|= (pForwardGVNS->numOfDigit1 & 0x01) << 7;	
	point++;
	num_ptr	= mBuf+point;
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pForwardGVNS->digits1[j++] & 0x0f;
		num_ptr[i] += pForwardGVNS->digits1[j++] << 4;
	}

	if(pForwardGVNS->numOfDigit1 & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	point +=num_len;

	//GVNS user group 
	num_len = pForwardGVNS->numOfDigit2/2 + (pForwardGVNS->numOfDigit2 & 0x01);
	if(num_len>8)
		num_len=8;
	if(num_len==0) 
		num_len=1;
	mBuf[point]		= num_len & 0x0F;
	mBuf[point]		|= (pForwardGVNS->numOfDigit2 & 0x01) << 7;	
	point++;
	num_ptr	= mBuf+point;
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pForwardGVNS->digits2[j++] & 0x0f;
		num_ptr[i] += pForwardGVNS->digits2[j++] << 4;
	}

	if(pForwardGVNS->numOfDigit2 & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	point +=num_len;

	//Terminating network routing number 
	num_len = pForwardGVNS->numOfDigit3/2 + (pForwardGVNS->numOfDigit3 & 0x01);
	if(num_len>8)
		num_len=8;
	if(num_len==0) 
		num_len=1;
	mBuf[point]		= (num_len+1) & 0x0F;
	mBuf[point]		|= (pForwardGVNS->numPlan & 0x03) << 4;	
	mBuf[point]		|= (pForwardGVNS->numOfDigit2 & 0x01) << 7;		
	point++;
	mBuf[point]		= pForwardGVNS->natOfAddr & 0x07F;	
	point++;
	num_ptr	= mBuf+point;
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pForwardGVNS->digits3[j++] & 0x0f;
		num_ptr[i] += pForwardGVNS->digits3[j++] << 4;
	}

	if(pForwardGVNS->numOfDigit3 & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	point +=num_len;

	return point;	
}
int siPkCcss     (SiCcss *pCcss,u8 *mBuf)
{
	mBuf[0] = pCcss->ccssCallInd&0x01;
	return 1;
}
int siPkNetMgmtControls     (SiNetMgmtControls *pNetMgmtControls,u8 *mBuf)
{
	mBuf[0] = pNetMgmtControls->tmpAltRoutInd&0x01;
	if(pNetMgmtControls->length)
		memcpy(mBuf+1, pNetMgmtControls->extInfo, pNetMgmtControls->length);
	else
		mBuf[0]	= mBuf[0] | 0x80;
	return pNetMgmtControls->length+1;
}
int siPkCirAsgnMap     (SiCirAsgnMap *pCirAsgnMap,u8 *mBuf)
{
	mBuf[0] = pCirAsgnMap->mapType&0x03F;
	memcpy(mBuf+1,pCirAsgnMap->mapFormat,4);
	return 5;
}
int siPkCorrelationId     (SiCorrelationId *pCorrelationId,u8 *mBuf)
{
	memcpy(mBuf,pCorrelationId->correlationId,pCorrelationId->length);
	return pCorrelationId->length;
}
int siPkCallDivTrtInd     (SiCallDivTrtInd *pCallDivTrtInd,u8 *mBuf)
{
	mBuf[0] = pCallDivTrtInd->callDivInd&0x03;
	if(pCallDivTrtInd->length)
		memcpy(mBuf+1, pCallDivTrtInd->extInfo, pCallDivTrtInd->length);
	else
		mBuf[0]	= mBuf[0] | 0x80;
	return pCallDivTrtInd->length+1;
}
int siPkCallInNmb     (SiCallInNmb *pCallInNmb,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pCallInNmb->numOfDigit/2 + (pCallInNmb->numOfDigit & 0x01);
	num_ptr	= mBuf+2;
	pCallInNmb->oddEven = pCallInNmb->numOfDigit & 0x01;

	mBuf[0]		= pCallInNmb->natAddrInd & 0x7F;
	mBuf[0]		|= (pCallInNmb->oddEven & 0x01) << 7;	
	mBuf[1]		= (pCallInNmb->presRest & 0x03) << 2;
	mBuf[1]		|= (pCallInNmb->numPlan & 0x07) << 4;
	if(num_len==0) 
		num_len=1;
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pCallInNmb->addrSig[j++] & 0x0f;
		num_ptr[i] += pCallInNmb->addrSig[j++] << 4;
	}

	if(pCallInNmb->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 2;	
}

int siPkCallOfferTrtInd     (SiCallOfferTrtInd *pCallOfferTrtInd,u8 *mBuf)
{
	mBuf[0] = pCallOfferTrtInd->callOfferInd&0x03;
	if(pCallOfferTrtInd->length)
		memcpy(mBuf+1, pCallOfferTrtInd->extInfo, pCallOfferTrtInd->length);
	else
		mBuf[0]	= mBuf[0] | 0x80;
	return pCallOfferTrtInd->length+1;
}
int siPkScfId     (SiScfId *pScfId,u8 *mBuf)
{
	memcpy(mBuf,pScfId->scfId,pScfId->length);
	return pScfId->length;
}
int siPkUidCapInd     (SiUidCapInd *pUidCapInd,u8 *mBuf)
{
	mBuf[0] = pUidCapInd->throughConnInstInd&0x01;
	mBuf[0] |= (pUidCapInd->t9InstInd&0x01) << 1;
	if(pUidCapInd->length)
	{
		memcpy(mBuf+1, pUidCapInd->extInfo, pUidCapInd->length);
	}
	else
		mBuf[0]	= mBuf[0] | 0x80;
	return pUidCapInd->length+1;
}
int siPkCollCallReq     (SiCollCallReq *pCollCallReq,u8 *mBuf)
{
	mBuf[0]	= pCollCallReq->collCallReqInd & 0x01;
	return 1;
}
int siPkNaPaChgPID     (SiNaPaChgPID *pNaPaChgPID,u8 *mBuf)
{
	memcpy(mBuf,pNaPaChgPID->naPaChgPtyId,pNaPaChgPID->length);
	return pNaPaChgPID->length;
}
int siPkCallTRef     (SiCallTRef *pCallTRef,u8 *mBuf)
{
	mBuf[0]	= pCallTRef->callTrnsfr;
	return 1;
}
int siPkLoopPrvntInd     (SiLoopPrvntInd *pLoopPrvntInd,u8 *mBuf)
{
	mBuf[0]	= pLoopPrvntInd->loopPrvntType & 0x01;
	mBuf[0]		|= (pLoopPrvntInd->loopPrvntRspInd & 0x03)<<1;
	return 1;
}
int siPkAppTransParam     (SiAppTransParam *pAppTransParam,u8 *mBuf)
{
	mBuf[0]	= pAppTransParam->appContextId & 0x7f;
	mBuf[0]	|= 0x80;
	mBuf[1]	= pAppTransParam->atii & 0x03;
	mBuf[1]	|= 0x80;
	mBuf[2]	= pAppTransParam->apmSegInd & 0x3f;
	mBuf[2]	|= (pAppTransParam->seqInd & 0x01)<<6;

	if(pAppTransParam->slr)
	{
		mBuf[3]	= pAppTransParam->slr & 0x7f;
		mBuf[3] = mBuf[3] |0x80;
		memcpy(mBuf+4,pAppTransParam->encapAppInfo,pAppTransParam->length);
		return pAppTransParam->length+4;
	}
	else
	{
		mBuf[2]	|= 0x80;
		memcpy(mBuf+3,pAppTransParam->encapAppInfo,pAppTransParam->length);
		return pAppTransParam->length+3;
	}
}

/* packing functions for UK specific Information Element  */
int siPkSiNatForCalInd     (SiNatForCalInd *pNatForCalInd,u8 *mBuf)
{
	mBuf[0]	= pNatForCalInd->cbi & 0x01;
	mBuf[0]		|= (pNatForCalInd->ntaInd & 0x01)<<1;
	mBuf[1]	=	0;
	return 2;
}

int siPkSiNatForCalIndLbL     (SiNatForCalIndLbL *pNatForCalIndLbL,u8 *mBuf)
{
	mBuf[0]	= pNatForCalIndLbL->rci & 0x0f;
	if(pNatForCalIndLbL->isi)
	{
		mBuf[1]	= pNatForCalIndLbL->isi & 0x0f;
		mBuf[1] = mBuf[1] |0x80;
		return 2;
	}
	else
	{
		mBuf[0] = mBuf[0] |0x80;
		return 1;
	}
}

int siPkSiPresNum    (SiPresNum *pPresNum,u8 *mBuf)
{
	int i,j,num_len;
	u8	*num_ptr;
	num_len = pPresNum->numOfDigit/2 + (pPresNum->numOfDigit & 0x01);
	num_ptr	= mBuf+2;

	pPresNum->oddEven = pPresNum->numOfDigit & 0x01;

	mBuf[0]		= pPresNum->natAddrInd & 0x7F;
	mBuf[0]		|= (pPresNum->oddEven & 0x01) <<7;
	mBuf[1]		= pPresNum->scrInd & 0x03;
	mBuf[1]		|= (pPresNum->presRest & 0x03) << 2;
	mBuf[1]		|= (pPresNum->numPlan & 0x07) << 4;
	mBuf[1]		|= (pPresNum->pnp & 0x01) <<7;
	if(num_len==0) 
		num_len=1;	
	for(i = 0, j = 0; i < num_len; i++)
	{
		num_ptr[i] = pPresNum->addrSig[j++] & 0x0f;
		num_ptr[i] += pPresNum->addrSig[j++] << 4;
	}

	if(pPresNum->numOfDigit & 0x01)
		num_ptr[num_len-1] &= 0x0f;
	return num_len + 2;
}



int siPkSiPartCLI     (SiPartCLI *pPartCLI,u8 *mBuf)
{	
	mBuf[0] =	pPartCLI->swichTypeD1& 0x0f;
	mBuf[0] +=	pPartCLI->swichTypeD2 << 4;

	mBuf[1] =	pPartCLI->pnoIdD1& 0x0f;
	mBuf[1] +=	pPartCLI->pnoIdD2 << 4;

	mBuf[2] =	pPartCLI->pnoIdD3& 0x0f;
	mBuf[2] +=	pPartCLI->switchNumD1 << 4;

	mBuf[3] =	pPartCLI->switchNumD2& 0x0f;
	mBuf[3] +=	pPartCLI->switchNumD3 << 4;

	memcpy(mBuf+4,pPartCLI->agreement,5);
	return 9;
}

int siPkCaldSubBasSerMar   (SiCaldSubBasSerMar *pCaldSubBasSerMar,u8 *mBuf)
{
	mBuf[0] = pCaldSubBasSerMar->cbInd & 0x01 ;
	mBuf[0] |=	(pCaldSubBasSerMar->subIcbInd & 0x01) <<1;
	mBuf[0] |=	(pCaldSubBasSerMar->preIcbInd & 0x01) <<2;
	mBuf[0] |=	(pCaldSubBasSerMar->permIcbInd & 0x01) <<3;
	mBuf[0] |=	(pCaldSubBasSerMar->tosInd & 0x01) <<4;
	mBuf[0] |=	(pCaldSubBasSerMar->ICBExpInd & 0x01) <<5;
	mBuf[0] |=	(pCaldSubBasSerMar->caldSubFacInfInd & 0x01) <<6;
	mBuf[0] |=	(pCaldSubBasSerMar->calgSubFacInfInd & 0x01) <<7;
	mBuf[1] =	pCaldSubBasSerMar->permOcbInd & 0x01;
	mBuf[1] |=	(pCaldSubBasSerMar->ogLocCalBarInd & 0x01) <<1;
	mBuf[1] |=	(pCaldSubBasSerMar->ogNatCalBarInd & 0x01) <<2;
	mBuf[1] |=	(pCaldSubBasSerMar->ogIntCalBarInd & 0x01) <<3;
	mBuf[1] |=	(pCaldSubBasSerMar->opCalBarInd & 0x01) <<4;
	mBuf[1] |=	(pCaldSubBasSerMar->supFacCalBarInd & 0x01)<<5;
	mBuf[1] |=	(pCaldSubBasSerMar->digMaskInd & 0x01) <<6;
	mBuf[1] |=	(pCaldSubBasSerMar->calPreBarInd & 0x01) <<7;
	mBuf[2]	 =	pCaldSubBasSerMar->caldSubTarGp & 0x7F;
	return 3;
}


int siPkCalgSubBasSerMar   (SiCalgSubBasSerMar *pCalgSubBasSerMar,u8 *mBuf)
{
	mBuf[0] = pCalgSubBasSerMar->cbInd & 0x01 ;
	mBuf[0] |=	(pCalgSubBasSerMar->subIcbInd & 0x01) <<1;
	mBuf[0] |=	(pCalgSubBasSerMar->preIcbInd & 0x01) <<2;
	mBuf[0] |=	(pCalgSubBasSerMar->permIcbInd & 0x01) <<3;
	mBuf[0] |=	(pCalgSubBasSerMar->tosInd & 0x01) <<4;
	mBuf[0] |=	(pCalgSubBasSerMar->ICBExpInd & 0x01) <<5;
	mBuf[0] |=	(pCalgSubBasSerMar->caldSubFacInfInd & 0x01) <<6;
	mBuf[0] |=	(pCalgSubBasSerMar->calgSubFacInfInd & 0x01) <<7;
	mBuf[1] =	pCalgSubBasSerMar->permOcbInd & 0x01;
	mBuf[1] |=	(pCalgSubBasSerMar->ogLocCalBarInd & 0x01) <<1;
	mBuf[1] |=	(pCalgSubBasSerMar->ogNatCalBarInd & 0x01) <<2;
	mBuf[1] |=	(pCalgSubBasSerMar->ogIntCalBarInd & 0x01) <<3;
	mBuf[1] |=	(pCalgSubBasSerMar->opCalBarInd & 0x01) <<4;
	mBuf[1] |=	(pCalgSubBasSerMar->supFacCalBarInd & 0x01)<<5;
	mBuf[1] |=	(pCalgSubBasSerMar->digMaskInd & 0x01) <<6;
	mBuf[1] |=	(pCalgSubBasSerMar->calPreBarInd & 0x01) <<7;
	mBuf[2]	 =	pCalgSubBasSerMar->calgSubTarGp & 0x7F;
	mBuf[2] |=	(pCalgSubBasSerMar->opInd & 0x01) <<7;
	return 3;
}


int siPkCalgSubOrgFacMar   (SiCalgSubOrgFacMar *pCalgSubOrgFacMar,u8 *mBuf)
{
	mBuf[0] = pCalgSubOrgFacMar->disSubInd & 0x01 ;
	mBuf[0] |=	(pCalgSubOrgFacMar->attCOI & 0x01) <<1;
	mBuf[0] |=	(pCalgSubOrgFacMar->adDurChgInd & 0x01) <<2;
	mBuf[0] |=	(pCalgSubOrgFacMar->PBXSubInd & 0x01) <<3;
	mBuf[1]	=	0;
	return 2;
}

int siPkCaldSubTermFacMar   (SiCaldSubTermFacMar *pCaldSubTermFacMar,u8 *mBuf)
{
	mBuf[0] = pCaldSubTermFacMar->sviInd & 0x01 ;
	mBuf[0] |=	(pCaldSubTermFacMar->cniInd & 0x01) <<1;
	mBuf[0] |=	(pCaldSubTermFacMar->pbxNigIntInd & 0x01) <<2;
	mBuf[0] |=	(pCaldSubTermFacMar->calWaitInd & 0x01) <<3;
	mBuf[0] |=	(pCaldSubTermFacMar->fixedDestSerInd & 0x01) <<4;
	mBuf[1]	=	0;
	return 2;
}

int siPkNatInfReqInd   (SiNatInfReqInd *pNatInfReqInd,u8 *mBuf)
{
	mBuf[0] = pNatInfReqInd->calgSubBasSerMarReqInd & 0x01 ;
	mBuf[0] |=	(pNatInfReqInd->caldSubBasSerMarReqInd & 0x01) <<1;
	mBuf[0] |=	(pNatInfReqInd->calgSubOrgFacMarReqInd & 0x01) <<2;
	mBuf[0] |=	(pNatInfReqInd->caldSubTerFacMarReqInd & 0x01) <<3;
	mBuf[1] = 0;
	return 2;
}

int siPkNatInfInd  (SiNatInfInd *pNatInfInd,u8 *mBuf)
{
	mBuf[0] = pNatInfInd->calgSubBasSerMarRespInd & 0x01 ;
	mBuf[0] |=	(pNatInfInd->caldSubBasSerMarRespInd & 0x01) <<1;
	mBuf[0] |=	(pNatInfInd->calgSubOrgFacMarRespInd & 0x01) <<2;
	mBuf[0] |=	(pNatInfInd->caldSubTerFacMarRespInd & 0x01) <<3;
	mBuf[1] = 0;
	return 2;
}
//for ansi-isup
int siPkCirValRspInd  (SiCirValRspInd *pCirValRspInd,u8 *mBuf)
{
	mBuf[0] = pCirValRspInd->cirValRspInd & 0x01 ;
	return 1;         
}                   
                    
int siPkCirGrpCharInd  (SiCirGrpCharInd *pCirGrpCharInd,u8 *mBuf)
{                   
	mBuf[0] = pCirGrpCharInd->cirGrpCarInd & 0x03 ;
	mBuf[0] |=	(pCirGrpCharInd->dblSzCtrlInd & 0x03) <<2;
	mBuf[0] |=	(pCirGrpCharInd->alarmCarInd & 0x03) <<4;
	mBuf[0] |=	(pCirGrpCharInd->contChkReqInd & 0x03) <<6;
	return 1;       
}                 
                  
int siPkCirIdName  (SiCirIdName *pCirIdName,u8 *mBuf)
{                 
	int i;
	for(i=0;i<26;i++)
	{
		mBuf[i] = pCirIdName->trunkNumClli[i]	& 0x7f ;		
	}	
	return 26;
}

int siPkCLLI  (SiCLLI *pCLLI,u8 *mBuf)
{                 
	int i;
	for(i=0;i<11;i++)
	{
		mBuf[i] = pCLLI->clliCode[i]	& 0x7f ;		
	}	
	return 11;
}


/* unpacking/packing functions for ISUP message */
int siUnpkACM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduACM *ptr 	=	&(pdus_ptr->m.addrComp);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=2 m_v=0
	if(length < 2)
		return -1;		
	
	//M-fixed
	siUnpkBckCalInd(&ptr->bckCalInd,flw_ptr,0);
	flw_ptr += 2;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;
			switch(*flw_ptr)
			{
				case ME_OPBACKCALLIND:
					siUnpkOptBckCalInd (&ptr->optBckCalInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_CALREF:
					siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_CAUSIND:
					siUnpkCauseDgn (&ptr->causeDgn,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_USR2USRIND:
					siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_USR2USRINFO:
					siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_ACCTPORT:
					siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_NOTIFINDC:
					siUnpkNotifInd(&ptr->notifInd1,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_TRANSMEDUSD:
					siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_ECHOCNTRL:
					siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_ACCDELINFO:
					siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_REDIRNUM:
					siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CLLDIVERS:
					siUnpkSiCllDiverInfo(&ptr->cllDivr,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_NETSPFAC:
					siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_REMOTOPER:
					siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_SERVACT:
					siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_REDIRRESTR:
					siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CONFTRTIND:					// (SS7_ITU97 || SS7_ETSIV3)
					siUnpkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_UIDACTIONIND:					// (SS7_ITU97 || SS7_ETSIV3)
					siUnpkUidActionInd(&ptr->uidActionInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALDSUBBASSERMAR:					//UK specific
					siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkACM(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduACM *ptr 	=	&(pdus_ptr->m.addrComp);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkBckCalInd(&ptr->bckCalInd,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*pointer_ptr = 0;
	opt_pointer=1;
		
	//Optional
	if(ptr->optBckCalInd.pres == 1)
	{
		flw_ptr[0] = ME_OPBACKCALLIND;
		flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->causeDgn.pres == 1)
	{
		flw_ptr[0] = ME_CAUSIND;
		flw_ptr[1] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usr2UsrInfo.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRINFO;
		flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->notifInd1.pres == 1)
	{
		flw_ptr[0] = ME_NOTIFINDC;
		flw_ptr[1] = siPkNotifInd(&ptr->notifInd1,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->txMedUsed.pres == 1)
	{
		flw_ptr[0] = ME_TRANSMEDUSD;
		flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->echoControl.pres == 1)
	{
		flw_ptr[0] = ME_ECHOCNTRL;
		flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accDelInfo.pres == 1)
	{
		flw_ptr[0] = ME_ACCDELINFO;
		flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirNum.pres == 1)
	{
		flw_ptr[0] = ME_REDIRNUM;
		flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->cllDivr.pres == 1)
	{
		flw_ptr[0] = ME_CLLDIVERS;
		flw_ptr[1] = siPkSiCllDiverInfo(&ptr->cllDivr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->remotOper.pres == 1)
	{
		flw_ptr[0] = ME_REMOTOPER;
		flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->serviceAct.pres == 1)
	{
		flw_ptr[0] = ME_SERVACT;
		flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirRstr.pres == 1)
	{
		flw_ptr[0] = ME_REDIRRESTR;
		flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->confTrtInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_CONFTRTIND;
		flw_ptr[1] = siPkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->uidActionInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_UIDACTIONIND;
		flw_ptr[1] = siPkUidActionInd(&ptr->uidActionInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(ptr->caldSubBasSerMar.pres == 1)//UK specific
	{
		flw_ptr[0] = ME_CALDSUBBASSERMAR;
		flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkANM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduANM *ptr 	=	&(pdus_ptr->m.answer);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;
	
	//M-fixed
	
	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_BACKCALLIND:
				siUnpkBckCalInd (&ptr->bckCalInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_OPBACKCALLIND:
				siUnpkOptBckCalInd (&ptr->optBckCalInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CALREF:
				siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USR2USRIND:
				siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USR2USRINFO:
				siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CONNUMB:
				siUnpkConnectedNum(&ptr->connNum,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_ACCTPORT:
				siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_ACCDELINFO:
				siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_NOTIFINDC:
				siUnpkNotifInd(&ptr->notifInd1,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_PARCOMPIN:
				siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CLLHISTORY:
				siUnpkSiPropDly(&ptr->cllHstry,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_GENNMB:
				siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;	
			case ME_TRANSMEDUSD:
				siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_NETSPFAC:
				siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_REMOTOPER:
				siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_REDIRGNUM:
				siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_SERVACT:
				siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_ECHOCNTRL:
				siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_REDIRRESTR:
				siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_BACKWARDGVNS:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkBackGVNS(&ptr->backGVNS,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_DISPLAYINFO:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkDisplayInfo(&ptr->displayInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CALDSUBBASSERMAR:					//UK specific
				siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkANM(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduANM *ptr 	=	&(pdus_ptr->m.answer);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*pointer_ptr = 0;
	opt_pointer=1;
		
	//Optional
	if(ptr->bckCalInd.pres == 1)
	{
		flw_ptr[0] = ME_BACKCALLIND;
		flw_ptr[1] = siPkBckCalInd(&ptr->bckCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->optBckCalInd.pres == 1)
	{
		flw_ptr[0] = ME_OPBACKCALLIND;
		flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usr2UsrInfo.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRINFO;
		flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->connNum.pres == 1)
	{
		flw_ptr[0] = ME_CONNUMB;
		flw_ptr[1] = siPkConnectedNum(&ptr->connNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accDelInfo.pres == 1)
	{
		flw_ptr[0] = ME_ACCDELINFO;
		flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->notifInd1.pres == 1)
	{
		flw_ptr[0] = ME_NOTIFINDC;
		flw_ptr[1] = siPkNotifInd(&ptr->notifInd1,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->cllHstry.pres == 1)
	{
		flw_ptr[0] = ME_CLLHISTORY;
		flw_ptr[1] = siPkSiPropDly(&ptr->cllHstry,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->genNmb.pres == 1)
	{
		flw_ptr[0] = ME_GENNMB;
		flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->txMedUsed.pres == 1)
	{
		flw_ptr[0] = ME_TRANSMEDUSD;
		flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->remotOper.pres == 1)
	{
		flw_ptr[0] = ME_REMOTOPER;
		flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirNum.pres == 1)
	{
		flw_ptr[0] = ME_REDIRGNUM;
		flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->serviceAct.pres == 1)
	{
		flw_ptr[0] = ME_SERVACT;
		flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->echoControl.pres == 1)
	{
		flw_ptr[0] = ME_ECHOCNTRL;
		flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirRstr.pres == 1)
	{
		flw_ptr[0] = ME_REDIRRESTR;
		flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(ptr->backGVNS.pres == 1)//(SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_BACKWARDGVNS;
		flw_ptr[1] = siPkBackGVNS(&ptr->backGVNS,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(ptr->displayInfo.pres == 1)//(SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_DISPLAYINFO;
		flw_ptr[1] = siPkDisplayInfo(&ptr->displayInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(ptr->caldSubBasSerMar.pres == 1)//UK specific
	{
		flw_ptr[0] = ME_CALDSUBBASSERMAR;
		flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}


int siUnpkCPG(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCPG *ptr 	=	&(pdus_ptr->m.caProg);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=1 m_v=0
	if(length < 1)
		return -1;
	
	//M-fixed
	siUnpkEvntInfo(&ptr->evntInfo,flw_ptr,0);
	flw_ptr += 1;
	
	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_EVNTINFO:
				siUnpkEvntInfo(&ptr->evntInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CAUSIND:
				siUnpkCauseDgn (&ptr->causeDgn,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CALREF:
				siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_BACKCALLIND:
				siUnpkBckCalInd (&ptr->bckCalInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_OPBACKCALLIND:
				siUnpkOptBckCalInd (&ptr->optBckCalInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_ACCTPORT:
				siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USR2USRIND:
				siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_NOTIFINDC:
				siUnpkNotifInd(&ptr->notifInd1,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_NETSPFAC:
				siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_REMOTOPER:
				siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_TRANSMEDUSD:
				siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_ACCDELINFO:
				siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_REDIRNUM:
				siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_PARCOMPIN:
				siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CLLDIVERS:
				siUnpkSiCllDiverInfo(&ptr->cllDivr,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_SERVACT:
				siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_REDIRRESTR:
				siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CALLTRNSFRNMB:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkCgPtyNum(&ptr->calTrnsNmb,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_ECHOCNTRL:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CONNUMB:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkConnectedNum(&ptr->connNum,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_BACKWARDGVNS:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkBackGVNS(&ptr->backGVNS,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_GENNMB:						// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;	
			case ME_CLLHISTORY:						// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkSiPropDly(&ptr->cllHstry,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CONFTRTIND:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_UIDACTIONIND:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkUidActionInd(&ptr->uidActionInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CALDSUBBASSERMAR:					//UK specific
				siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkCPG(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCPG *ptr 	=	&(pdus_ptr->m.caProg);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkEvntInfo(&ptr->evntInfo,flw_ptr);


	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*pointer_ptr = 0;
	opt_pointer=1;
		
	//Optional
	if(ptr->evntInfo.pres == 1)
	{
		flw_ptr[0] = ME_EVNTINFO;
		flw_ptr[1] = siPkEvntInfo(&ptr->evntInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->causeDgn.pres == 1)
	{
		flw_ptr[0] = ME_CAUSIND;
		flw_ptr[1] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->bckCalInd.pres == 1)
	{
		flw_ptr[0] = ME_BACKCALLIND;
		flw_ptr[1] = siPkBckCalInd(&ptr->bckCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->optBckCalInd.pres == 1)
	{
		flw_ptr[0] = ME_OPBACKCALLIND;
		flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->notifInd1.pres == 1)
	{
		flw_ptr[0] = ME_NOTIFINDC;
		flw_ptr[1] = siPkNotifInd(&ptr->notifInd1,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->remotOper.pres == 1)
	{
		flw_ptr[0] = ME_REMOTOPER;
		flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->txMedUsed.pres == 1)
	{
		flw_ptr[0] = ME_TRANSMEDUSD;
		flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accDelInfo.pres == 1)
	{
		flw_ptr[0] = ME_ACCDELINFO;
		flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirNum.pres == 1)
	{
		flw_ptr[0] = ME_REDIRNUM;
		flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->cllDivr.pres == 1)
	{
		flw_ptr[0] = ME_CLLDIVERS;
		flw_ptr[1] = siPkSiCllDiverInfo(&ptr->cllDivr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->serviceAct.pres == 1)
	{
		flw_ptr[0] = ME_SERVACT;
		flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirRstr.pres == 1)
	{
		flw_ptr[0] = ME_REDIRRESTR;
		flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}		
	if(ptr->calTrnsNmb.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_CALLTRNSFRNMB;
		flw_ptr[1] = siPkCgPtyNum(&ptr->calTrnsNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->echoControl.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_ECHOCNTRL;
		flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->connNum.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_CONNUMB;
		flw_ptr[1] = siPkConnectedNum(&ptr->connNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->backGVNS.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_BACKWARDGVNS;
		flw_ptr[1] = siPkBackGVNS(&ptr->backGVNS,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->genNmb.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_GENNMB;
		flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->cllHstry.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_CLLHISTORY;
		flw_ptr[1] = siPkSiPropDly(&ptr->cllHstry,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->confTrtInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_CONFTRTIND;
		flw_ptr[1] = siPkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->uidActionInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_UIDACTIONIND;
		flw_ptr[1] = siPkUidActionInd(&ptr->uidActionInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(ptr->caldSubBasSerMar.pres == 1)//UK specific
	{
		flw_ptr[0] = ME_CALDSUBBASSERMAR;
		flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}


int siUnpkCQR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCQR *ptr 	=	&(pdus_ptr->m.cirGrpQryRes);
	u8 *flw_ptr		= 	raw_ptr;
	u8			*pointer_ptr;

	
	//check mandatory length
	//m_f=0 m_v=2
	if(length < 2)
		return -1;
	
	//M-fixed
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkRangNoStat(&ptr->rangNoStat,pointer_ptr+1, pointer_ptr[0]);
	flw_ptr++;

//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkCirStateInd(&ptr->cirSteInd,pointer_ptr+1, pointer_ptr[0]);
	
	//Optional

	return 1;
}

int siPkCQR(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCQR *ptr 	=	&(pdus_ptr->m.cirGrpQryRes);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			len;//opt_pointer

	
	//M-fixed

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	2;
	
	len = flw_ptr-pointer_ptr;	
	*(pointer_ptr) = len;
	flw_ptr[0]	=	siPkRangNoStat(&ptr->rangNoStat,flw_ptr+1);
	flw_ptr +=	flw_ptr[0]+1;
	pointer_ptr++;

	len = flw_ptr-pointer_ptr;	
	*(pointer_ptr) = len;
	flw_ptr[0]	=	siPkCirStateInd(&ptr->cirSteInd,flw_ptr+1);
	flw_ptr +=	flw_ptr[0]+1;
	pointer_ptr++;

	//Optional
		
	return flw_ptr - raw_ptr;	
}

int siUnpkGRA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduGRA *ptr 	=	&(pdus_ptr->m.cirGrpResAck);
	u8 *flw_ptr		= 	raw_ptr;
	u8	*pointer_ptr;

	
	//check mandatory length
	//m_f=0 m_v=1 
	if(length < 1)
		return -1;
	
	//M-fixed
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]);

	
	//Optional

	return 1;
}

int siPkGRA(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduGRA *ptr 	=	&(pdus_ptr->m.cirGrpResAck);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed


	//M-variable
	opt_pointer =0;
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*(pointer_ptr++) = 1;

	flw_ptr[0]	=	siPkRangStat(&ptr->rangStat,flw_ptr+1);	
	flw_ptr +=	flw_ptr[0]+1;
		
	//Optional
	return flw_ptr - raw_ptr;	
}

int siUnpkCFN(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCFN *ptr 	=	&(pdus_ptr->m.confusion);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;
	
	//check mandatory length
	//m_f=0 m_v=1
	if(length < 1)
		return -1;
	
	//M-fixed
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkCauseDgn(&ptr->causeDgn,pointer_ptr+1, pointer_ptr[0]);
	flw_ptr++;
	
	//Optional

	return 1;
}

int siPkCFN(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCFN *ptr 	=	&(pdus_ptr->m.confusion);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	2;
	*(pointer_ptr++) = 2;
	*pointer_ptr = 0;
	flw_ptr[0]	=	siPkCauseDgn(&ptr->causeDgn,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 2;	
	flw_ptr +=	flw_ptr[0]+1;
		
	return flw_ptr - raw_ptr;
}

int siUnpkCON(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCON *ptr 	=	&(pdus_ptr->m.connect);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=2 m_v=0
	if(length < 2)
		return -1;		
	
	//M-fixed
	siUnpkBckCalInd(&ptr->bckCalInd,flw_ptr,0);
	flw_ptr += 2;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_OPBACKCALLIND:
				siUnpkOptBckCalInd (&ptr->optBckCalInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CONNUMB:
				siUnpkConnectedNum(&ptr->connNum,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CALREF:
				siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USR2USRIND:
				siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USR2USRINFO:
				siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_ACCTPORT:
				siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_NETSPFAC:
				siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_NOTIFINDC:
				siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_REMOTOPER:
				siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_TRANSMEDUSD:
				siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_ECHOCNTRL:
				siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_ACCDELINFO:
				siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CLLHISTORY:
				siUnpkSiPropDly(&ptr->cllHstry,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_PARCOMPIN:
				siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_REDIRGNUM:
				siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_SERVACT:
				siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_GENNMB:
				siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;	
			case ME_REDIRRESTR:
				siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_BACKWARDGVNS:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkBackGVNS(&ptr->backGVNS,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CONFTRTIND:					// (SS7_ITU97 || SS7_ETSIV3)
				siUnpkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;

			case ME_CALDSUBBASSERMAR:					//UK specific
				siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkCON(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCON *ptr 	=	&(pdus_ptr->m.connect);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkBckCalInd(&ptr->bckCalInd,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*pointer_ptr = 0;
	opt_pointer=1;
		
	//Optional
	if(ptr->optBckCalInd.pres == 1)
	{
		flw_ptr[0] = ME_OPBACKCALLIND;
		flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->connNum.pres == 1)
	{
		flw_ptr[0] = ME_CONNUMB;
		flw_ptr[1] = siPkConnectedNum(&ptr->connNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usr2UsrInfo.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRINFO;
		flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->notifInd.pres == 1)
	{
		flw_ptr[0] = ME_NOTIFINDC;
		flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->remotOper.pres == 1)
	{
		flw_ptr[0] = ME_REMOTOPER;
		flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->txMedUsed.pres == 1)
	{
		flw_ptr[0] = ME_TRANSMEDUSD;
		flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->echoControl.pres == 1)
	{
		flw_ptr[0] = ME_ECHOCNTRL;
		flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accDelInfo.pres == 1)
	{
		flw_ptr[0] = ME_ACCDELINFO;
		flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->cllHstry.pres == 1)
	{
		flw_ptr[0] = ME_CLLHISTORY;
		flw_ptr[1] = siPkSiPropDly(&ptr->cllHstry,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirNum.pres == 1)
	{
		flw_ptr[0] = ME_REDIRGNUM;
		flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->serviceAct.pres == 1)
	{
		flw_ptr[0] = ME_SERVACT;
		flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->genNmb.pres == 1)
	{
		flw_ptr[0] = ME_GENNMB;
		flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirRstr.pres == 1)
	{
		flw_ptr[0] = ME_REDIRRESTR;
		flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}


	if(ptr->backGVNS.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_BACKWARDGVNS;
		flw_ptr[1] = siPkBackGVNS(&ptr->backGVNS,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->confTrtInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_CONFTRTIND;
		flw_ptr[1] = siPkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(ptr->caldSubBasSerMar.pres == 1)//UK specific
	{
		flw_ptr[0] = ME_CALDSUBBASSERMAR;
		flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkCOT(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCOT *ptr 	=	&(pdus_ptr->m.continuity);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=1 m_v=0
	if(length < 1)
		return -1;
	
	//M-fixed
	siUnpkContInd(&ptr->contInd,flw_ptr,0);
	
	return 1;
}

int siPkCOT(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCOT *ptr 	=	&(pdus_ptr->m.continuity);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;
	
	opt_pointer = 0;
	pointer_ptr = 0;
	
	//M-fixed
	siPkContInd(&ptr->contInd,flw_ptr);
	flw_ptr += 1;
		
	return flw_ptr - raw_ptr;
}

int siUnpkFRJ(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduFRJ *ptr 	=	&(pdus_ptr->m.facReject);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;
	
	//check mandatory length
	//m_f=1 m_v=1
	if(length < 2)
		return -1;
	
	//M-fixed
	siUnpkFacInd(&ptr->facInd,flw_ptr,0);
	flw_ptr += 1;

	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkCauseDgn(&ptr->causeDgn,pointer_ptr+1, pointer_ptr[0]);
	flw_ptr++;	
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_USR2USRIND:
					siUnpkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkFRJ(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduFRJ *ptr 	=	&(pdus_ptr->m.facReject);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	siPkFacInd(&ptr->facInd,flw_ptr);
	flw_ptr += 1;	

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	2;
	*(pointer_ptr++) = 2;
	*pointer_ptr = 0;
	flw_ptr[0]	=	siPkCauseDgn(&ptr->causeDgn,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 2;	
	flw_ptr +=	flw_ptr[0]+1;
	//Optional
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;
}

int siUnpkINF(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduINF *ptr 	=	&(pdus_ptr->m.info);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=2 m_v=0
	if(length < 2)
		return -1;		
	
	//M-fixed
	siUnpkInfoInd(&ptr->infoInd,flw_ptr,0);
	flw_ptr += 2;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_CALGPARTCAT:
					siUnpkCgPtyCat(&ptr->cgPtyCat,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;				
				case ME_CALGPARTNUM:
					siUnpkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;				
				case ME_CALREF:
					siUnpkCallRef(&ptr->callRef,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;			
				case ME_CONREQ:
					siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;	
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_NETSPFAC:
					siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_NATINFIND:	//UK specific
					siUnpkNatInfInd(&ptr->natInfInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALDSUBBASSERMAR://UK specific
					siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALGSUBBASSERMAR://UK specific
					siUnpkCalgSubBasSerMar(&ptr->calgSubBasSerMar,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALGSUBORIFACMAR://UK specific
					siUnpkCalgSubOrgFacMar(&ptr->calgSubOrgFacMar,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALDSUBTERFACMAR://UK specific
					siUnpkCaldSubTermFacMar(&ptr->caldSubTermFacMar,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkINF(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduINF *ptr 	=	&(pdus_ptr->m.info);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkInfoInd(&ptr->infoInd,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*pointer_ptr = 0;
	opt_pointer=1;
		
	//Optional
	if(ptr->cgPtyCat.pres == 1)
	{
		flw_ptr[0] = ME_CALGPARTCAT;
		flw_ptr[1] = siPkCgPtyCat(&ptr->cgPtyCat,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->cgPtyNum.pres == 1)
	{
		flw_ptr[0] = ME_CALGPARTNUM;
		flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->connReq.pres == 1)
	{
		flw_ptr[0] = ME_CONREQ;
		flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	


	if(ptr->natInfInd.pres == 1)//UK specific
	{
		flw_ptr[0] = ME_NATINFIND;
		flw_ptr[1] = siPkNatInfInd(&ptr->natInfInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->caldSubBasSerMar.pres == 1)  //UK specific
	{
		flw_ptr[0] = ME_CALDSUBBASSERMAR;
		flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->calgSubBasSerMar.pres == 1)  //UK specific
	{
		flw_ptr[0] = ME_CALGSUBBASSERMAR;
		flw_ptr[1] = siPkCalgSubBasSerMar(&ptr->calgSubBasSerMar,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->calgSubOrgFacMar.pres == 1)  //UK specific
	{
		flw_ptr[0] = ME_CALGSUBORIFACMAR;
		flw_ptr[1] = siPkCalgSubOrgFacMar(&ptr->calgSubOrgFacMar,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->caldSubTermFacMar.pres == 1)  //UK specific
	{
		flw_ptr[0] = ME_CALDSUBTERFACMAR;
		flw_ptr[1] = siPkCaldSubTermFacMar(&ptr->caldSubTermFacMar,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	


	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;
}

int siUnpkINR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduINR *ptr 	=	&(pdus_ptr->m.infoReq);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=2 m_v=0
	if(length < 2)
		return -1;		
	
	//M-fixed
	siUnpkInfoReqInd(&ptr->infoReqInd,flw_ptr,0);
	flw_ptr += 2;
	
	//Optional
	if(*flw_ptr != 0)
	{                  
		flw_ptr += *flw_ptr;                  
		while(*flw_ptr != 0)                  
		{                  
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;
				
			switch(*flw_ptr)
			{
				case ME_CALREF:
					siUnpkCallRef(&ptr->callRef,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_NETSPFAC:
					siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_PARCOMPIN:                
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;                  
				case ME_NATINFREQIND: //UK specific
					siUnpkNatInfReqInd(&ptr->natInfReqInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;
			}
		}		
	}	
	return 1;
}

int siPkINR(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduINR *ptr 	=	&(pdus_ptr->m.infoReq);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkInfoReqInd(&ptr->infoReqInd,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*pointer_ptr = 0;
	opt_pointer=1;
		
	//Optional

	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	 
	if(ptr->natInfReqInd.pres == 1)//UK specific
	{
		flw_ptr[0] = ME_NATINFREQIND;
		flw_ptr[1] = siPkNatInfReqInd(&ptr->natInfReqInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;
}

int siUnpkIAM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduIAM *ptr 	=	&(pdus_ptr->m.initAddr);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;
	
	//check mandatory length
	//m_f=5 m_v=1
	if(length < 6)
		return -1;		
	
	//M-fixed
	siUnpkNatConInd(&ptr->natConInd,flw_ptr,0);
	flw_ptr += 1;
	siUnpkFwdCallInd(&ptr->fwdCallInd,flw_ptr,0);
	flw_ptr += 2;
	siUnpkCgPtyCat(&ptr->cgPtyCat,flw_ptr,0);
	flw_ptr += 1;
	siUnpkTxMedReq(&ptr->txMedReq,flw_ptr,0);
	flw_ptr += 1;
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkCdPtyNum(&ptr->cdPtyNum,pointer_ptr+1, pointer_ptr[0]);
	flw_ptr++;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_TRANNETSEL:
					siUnpkTranNetSel(&ptr->tranNetSel,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_CALREF:
					siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_CALGPARTNUM:
					siUnpkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_OPFWDCALLIND:
					siUnpkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;	
				case ME_REDIRGNUM:
					siUnpkRedirgNum(&ptr->redirgNum,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_REDIRINFO:
					siUnpkRedirInfo(&ptr->redirInfo,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CLSDUGRPINTCDE:
					siUnpkCugIntCode(&ptr->cugIntCode,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CONREQ:
					siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;	
				case ME_ORIGCALDNUM:
					siUnpkOrigCdNum(&ptr->origCdNum,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_USR2USRINFO:
					siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_ACCTPORT:
					siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_USRSERVINFO:
					siUnpkSiUsrServInfo(&ptr->usrServInfo,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_USR2USRIND:
					siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_GENNMB:
					siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_PROPDLYCTR:
					siUnpkSiPropDly(&ptr->propDly,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_USRSERVINFOPR:
					siUnpkSiUsrServInfo(&ptr->usrServInfo1,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_NETSPFAC:
					siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_GENDIGITS:
					siUnpkSiGenDigits(&ptr->genDigits,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_ORISCCDE:
					siUnpkSigPointCode(&ptr->orgPteCde,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_USRTSRVINFO:
					siUnpkSiUsrTSrvInfo(&ptr->usrTSrvInfo,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_REMOTOPER:
					siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_NOTIFINDC:
					siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_SERVACT:
					siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_MLPPPREC:
					siUnpkSiMlppPrec(&ptr->mlppPrec,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_TRANSMEDPRM:
					siUnpkTxMedReq(&ptr->txMedUsPr,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_LOCNMB:
					siUnpkCgPtyNum(&ptr->cgPtyNum1,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
// SS7_ITU97
				case ME_FORWARDGVNS:
					siUnpkForwardGVNS(&ptr->forwardGVNS,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CCSS:
					siUnpkCcss(&ptr->ccss,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_NETMGMTCONTROLS:
					siUnpkNetMgmtControls(&ptr->netMgmtControls,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CIRASGNMAP:
					siUnpkCirAsgnMap(&ptr->cirAsgnMap,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CORRELATIONID:
					siUnpkCorrelationId(&ptr->correlationId,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALLDIVTRTIND:
					siUnpkCallDivTrtInd(&ptr->callDivTrtInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALLINNMB:
					siUnpkCallInNmb(&ptr->callInNmb,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALLOFFERTRTIND:
					siUnpkCallOfferTrtInd(&ptr->callOfferTrtInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CONFTRTIND:
					siUnpkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_SCFID:
					siUnpkScfId(&ptr->scfId,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_UIDCAPIND:
					siUnpkUidCapInd(&ptr->uidCapInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_ECHOCNTRL:
					siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_HOPCOUNTER:
					siUnpkHopCounter(&ptr->hopCounter,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_COLLCALLREQ:
					siUnpkCollCallReq(&ptr->collCallReq,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
//UK specific
				case ME_NATFORCALIND:
					siUnpkSiNatForCalInd(&ptr->natForCalInd,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_PRESNUM:
					siUnpkSiPresNum(&ptr->presNum,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_LASDIVLINID:
					siUnpkCgPtyNum(&ptr->lasDivLinId,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_PARTCLI:
					siUnpkSiPartCLI(&ptr->partCLI,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_NATFORCALIND_LTL:
					siUnpkSiNatForCalIndLbL(&ptr->natForCalIndLbL,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siUnpkIAM_AN(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduIAM *ptr 	=	&(pdus_ptr->m.initAddr);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;
	
	//check mandatory length
	//m_f=4 m_v=2
	if(length < 6)
		return -1;		
	
	//M-fixed
	siUnpkNatConInd(&ptr->natConInd,flw_ptr,0);
	flw_ptr += 1;
	siUnpkFwdCallInd(&ptr->fwdCallInd,flw_ptr,0);
	flw_ptr += 2;
	siUnpkCgPtyCat(&ptr->cgPtyCat,flw_ptr,0);
	flw_ptr += 1;
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkSiUsrServInfo(&ptr->usrServInfo,pointer_ptr+1, pointer_ptr[0]);
	flw_ptr++;
	
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkCdPtyNum(&ptr->cdPtyNum,pointer_ptr+1, pointer_ptr[0]);
	flw_ptr++;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_TRANNETSEL:
				siUnpkTranNetSel(&ptr->tranNetSel,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CALREF:
				siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CALGPARTNUM:
				siUnpkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_OPFWDCALLIND:
				siUnpkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;	
			case ME_REDIRGNUM:
				siUnpkRedirgNum(&ptr->redirgNum,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_REDIRINFO:
				siUnpkRedirInfo(&ptr->redirInfo,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CLSDUGRPINTCDE:
				siUnpkCugIntCode(&ptr->cugIntCode,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_CONREQ:
				siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;	
			case ME_ORIGCALDNUM:
				siUnpkOrigCdNum(&ptr->origCdNum,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_USR2USRINFO:
				siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_ACCTPORT:
				siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USR2USRIND:
				siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_GENNMB:
				siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_PROPDLYCTR:
				siUnpkSiPropDly(&ptr->propDly,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USRSERVINFOPR:
				siUnpkSiUsrServInfo(&ptr->usrServInfo1,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_NETSPFAC:
				siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_GENDIGITS:
				siUnpkSiGenDigits(&ptr->genDigits,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_ORISCCDE:
				siUnpkSigPointCode(&ptr->orgPteCde,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USRTSRVINFO:
				siUnpkSiUsrTSrvInfo(&ptr->usrTSrvInfo,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_REMOTOPER:
				siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_PARCOMPIN:
				siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_NOTIFINDC:
				siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_SERVACT:
				siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_MLPPPREC:
				siUnpkSiMlppPrec(&ptr->mlppPrec,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_TRANSMEDPRM:
				siUnpkTxMedReq(&ptr->txMedUsPr,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			case ME_LOCNMB:
				siUnpkCgPtyNum(&ptr->cgPtyNum1,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;					
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkIAM(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduIAM	*ptr 		=	&(pdus_ptr->m.initAddr);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkNatConInd(&ptr->natConInd,flw_ptr);
	flw_ptr	+=	siPkFwdCallInd(&ptr->fwdCallInd,flw_ptr);
	flw_ptr	+=	siPkCgPtyCat(&ptr->cgPtyCat,flw_ptr);
	flw_ptr	+=	siPkTxMedReq(&ptr->txMedReq,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	2;
	*(pointer_ptr++) = 2;
	*pointer_ptr = 0;
	flw_ptr[0]	=	siPkCdPtyNum(&ptr->cdPtyNum,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 2;	
	flw_ptr +=	flw_ptr[0]+1;
		
	//Optional
	if(ptr->tranNetSel.pres == 1)
	{
		flw_ptr[0] = ME_TRANNETSEL;
		flw_ptr[1] = siPkTranNetSel(&ptr->tranNetSel,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->cgPtyNum.pres == 1)
	{
		flw_ptr[0] = ME_CALGPARTNUM;
		flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->natForCalInd.pres == 1)//UK specific
	{
		flw_ptr[0] = ME_NATFORCALIND;
		flw_ptr[1] = siPkSiNatForCalInd(&ptr->natForCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
		
	if(ptr->opFwdCalInd.pres == 1)
	{
		flw_ptr[0] = ME_OPFWDCALLIND;
		flw_ptr[1] = siPkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirgNum.pres == 1)
	{
		flw_ptr[0] = ME_REDIRGNUM;
		flw_ptr[1] = siPkRedirgNum(&ptr->redirgNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->redirInfo.pres == 1)
	{
		flw_ptr[0] = ME_REDIRINFO;
		flw_ptr[1] = siPkRedirInfo(&ptr->redirInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->cugIntCode.pres == 1)
	{
		flw_ptr[0] = ME_CLSDUGRPINTCDE;
		flw_ptr[1] = siPkCugIntCode(&ptr->cugIntCode,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->connReq.pres == 1)
	{
		flw_ptr[0] = ME_CONREQ;
		flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->origCdNum.pres == 1)
	{
		flw_ptr[0] = ME_ORIGCALDNUM;
		flw_ptr[1] = siPkOrigCdNum(&ptr->origCdNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->usr2UsrInfo.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRINFO;
		flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(ptr->usrServInfo.pres == 1)
	{
		flw_ptr[0] = ME_USRSERVINFO;
		flw_ptr[1] = siPkSiUsrServInfo(&ptr->usrServInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->genNmb.pres == 1)
	{
		flw_ptr[0] = ME_GENNMB;
		flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->propDly.pres == 1)
	{
		flw_ptr[0] = ME_PROPDLYCTR;
		flw_ptr[1] = siPkSiPropDly(&ptr->propDly,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usrServInfo1.pres == 1)
	{
		flw_ptr[0] = ME_USRSERVINFOPR;
		flw_ptr[1] = siPkSiUsrServInfo(&ptr->usrServInfo1,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->genDigits.pres == 1)
	{
		flw_ptr[0] = ME_GENDIGITS;
		flw_ptr[1] = siPkSiGenDigits(&ptr->genDigits,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->orgPteCde.pres == 1)
	{
		flw_ptr[0] = ME_ORISCCDE;
		flw_ptr[1] = siPkSigPointCode(&ptr->orgPteCde,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usrTSrvInfo.pres == 1)
	{
		flw_ptr[0] = ME_USRTSRVINFO;
		flw_ptr[1] = siPkSiUsrTSrvInfo(&ptr->usrTSrvInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->remotOper.pres == 1)
	{
		flw_ptr[0] = ME_REMOTOPER;
		flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->notifInd.pres == 1)
	{
		flw_ptr[0] = ME_NOTIFINDC;
		flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->serviceAct.pres == 1)
	{
		flw_ptr[0] = ME_SERVACT;
		flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->mlppPrec.pres == 1)
	{
		flw_ptr[0] = ME_MLPPPREC;
		flw_ptr[1] = siPkSiMlppPrec(&ptr->mlppPrec,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->txMedUsPr.pres == 1)
	{
		flw_ptr[0] = ME_TRANSMEDPRM;
		flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsPr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->cgPtyNum1.pres == 1)
	{
		flw_ptr[0] = ME_LOCNMB;
		flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum1,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
// SS7_ITU97
	if(ptr->forwardGVNS.pres == 1)
	{
		flw_ptr[0] = ME_FORWARDGVNS;
		flw_ptr[1] = siPkForwardGVNS(&ptr->forwardGVNS,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->ccss.pres == 1)
	{
		flw_ptr[0] = ME_CCSS;
		flw_ptr[1] = siPkCcss(&ptr->ccss,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->netMgmtControls.pres == 1)
	{
		flw_ptr[0] = ME_NETMGMTCONTROLS;
		flw_ptr[1] = siPkNetMgmtControls(&ptr->netMgmtControls,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->cirAsgnMap.pres == 1)
	{
		flw_ptr[0] = ME_CIRASGNMAP;
		flw_ptr[1] = siPkCirAsgnMap(&ptr->cirAsgnMap,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->correlationId.pres == 1)
	{
		flw_ptr[0] = ME_CORRELATIONID;
		flw_ptr[1] = siPkCorrelationId(&ptr->correlationId,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->callDivTrtInd.pres == 1)
	{
		flw_ptr[0] = ME_CALLDIVTRTIND;
		flw_ptr[1] = siPkCallDivTrtInd(&ptr->callDivTrtInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->callInNmb.pres == 1)
	{
		flw_ptr[0] = ME_CALLINNMB;
		flw_ptr[1] = siPkCallInNmb(&ptr->callInNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->callOfferTrtInd.pres == 1)
	{
		flw_ptr[0] = ME_CALLOFFERTRTIND;
		flw_ptr[1] = siPkCallOfferTrtInd(&ptr->callOfferTrtInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->confTrtInd.pres == 1)
	{
		flw_ptr[0] = ME_CONFTRTIND;
		flw_ptr[1] = siPkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->scfId.pres == 1)
	{
		flw_ptr[0] = ME_SCFID;
		flw_ptr[1] = siPkScfId(&ptr->scfId,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->uidCapInd.pres == 1)
	{
		flw_ptr[0] = ME_UIDCAPIND;
		flw_ptr[1] = siPkUidCapInd(&ptr->uidCapInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->echoControl.pres == 1)
	{
		flw_ptr[0] = ME_ECHOCNTRL;
		flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->hopCounter.pres == 1)
	{
		flw_ptr[0] = ME_HOPCOUNTER;
		flw_ptr[1] = siPkHopCounter(&ptr->hopCounter,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->collCallReq.pres == 1)
	{
		flw_ptr[0] = ME_COLLCALLREQ;
		flw_ptr[1] = siPkCollCallReq(&ptr->collCallReq,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

//UK specific
//	if(ptr->natForCalInd.pres == 1)
//	{
//		flw_ptr[0] = ME_NATFORCALIND;
//		flw_ptr[1] = siPkSiNatForCalInd(&ptr->natForCalInd,flw_ptr+2);
//		flw_ptr += flw_ptr[1] + 2;
//		*pointer_ptr = opt_pointer;		
//	}
	if(ptr->presNum.pres == 1)
	{
		flw_ptr[0] = ME_PRESNUM;
		flw_ptr[1] = siPkSiPresNum(&ptr->presNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->lasDivLinId.pres == 1)
	{
		flw_ptr[0] = ME_LASDIVLINID;
		flw_ptr[1] = siPkCgPtyNum(&ptr->lasDivLinId,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->partCLI.pres == 1)
	{
		flw_ptr[0] = ME_PARTCLI;
		flw_ptr[1] = siPkSiPartCLI(&ptr->partCLI,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->natForCalIndLbL.pres == 1)
	{
		flw_ptr[0] = ME_NATFORCALIND_LTL;
		flw_ptr[1] = siPkSiNatForCalIndLbL(&ptr->natForCalIndLbL,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siPkIAM_AN(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduIAM	*ptr 		=	&(pdus_ptr->m.initAddr);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkNatConInd(&ptr->natConInd,flw_ptr);
	flw_ptr	+=	siPkFwdCallInd(&ptr->fwdCallInd,flw_ptr);
	flw_ptr	+=	siPkCgPtyCat(&ptr->cgPtyCat,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	3;

	*(pointer_ptr++) = 3;
	
	flw_ptr[0]	=	siPkSiUsrServInfo(&ptr->usrServInfo,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 3;	
	flw_ptr +=	flw_ptr[0]+1;
	*(pointer_ptr++) = opt_pointer;
	
	flw_ptr[0]	=	siPkCdPtyNum(&ptr->cdPtyNum,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 1 + opt_pointer -1;	
	flw_ptr +=	flw_ptr[0]+1;
		
		
		
	//Optional
	if(ptr->tranNetSel.pres == 1)
	{
		flw_ptr[0] = ME_TRANNETSEL;
		flw_ptr[1] = siPkTranNetSel(&ptr->tranNetSel,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->cgPtyNum.pres == 1)
	{
		flw_ptr[0] = ME_CALGPARTNUM;
		flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->opFwdCalInd.pres == 1)
	{
		flw_ptr[0] = ME_OPFWDCALLIND;
		flw_ptr[1] = siPkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirgNum.pres == 1)
	{
		flw_ptr[0] = ME_REDIRGNUM;
		flw_ptr[1] = siPkRedirgNum(&ptr->redirgNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->redirInfo.pres == 1)
	{
		flw_ptr[0] = ME_REDIRINFO;
		flw_ptr[1] = siPkRedirInfo(&ptr->redirInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->cugIntCode.pres == 1)
	{
		flw_ptr[0] = ME_CLSDUGRPINTCDE;
		flw_ptr[1] = siPkCugIntCode(&ptr->cugIntCode,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->connReq.pres == 1)
	{
		flw_ptr[0] = ME_CONREQ;
		flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->origCdNum.pres == 1)
	{
		flw_ptr[0] = ME_ORIGCALDNUM;
		flw_ptr[1] = siPkOrigCdNum(&ptr->origCdNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->usr2UsrInfo.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRINFO;
		flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->genNmb.pres == 1)
	{
		flw_ptr[0] = ME_GENNMB;
		flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->propDly.pres == 1)
	{
		flw_ptr[0] = ME_PROPDLYCTR;
		flw_ptr[1] = siPkSiPropDly(&ptr->propDly,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usrServInfo1.pres == 1)
	{
		flw_ptr[0] = ME_USRSERVINFOPR;
		flw_ptr[1] = siPkSiUsrServInfo(&ptr->usrServInfo1,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->genDigits.pres == 1)
	{
		flw_ptr[0] = ME_GENDIGITS;
		flw_ptr[1] = siPkSiGenDigits(&ptr->genDigits,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->orgPteCde.pres == 1)
	{
		flw_ptr[0] = ME_ORISCCDE;
		flw_ptr[1] = siPkSigPointCode(&ptr->orgPteCde,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usrTSrvInfo.pres == 1)
	{
		flw_ptr[0] = ME_USRTSRVINFO;
		flw_ptr[1] = siPkSiUsrTSrvInfo(&ptr->usrTSrvInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->remotOper.pres == 1)
	{
		flw_ptr[0] = ME_REMOTOPER;
		flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->notifInd.pres == 1)
	{
		flw_ptr[0] = ME_NOTIFINDC;
		flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->serviceAct.pres == 1)
	{
		flw_ptr[0] = ME_SERVACT;
		flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->mlppPrec.pres == 1)
	{
		flw_ptr[0] = ME_MLPPPREC;
		flw_ptr[1] = siPkSiMlppPrec(&ptr->mlppPrec,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->txMedUsPr.pres == 1)
	{
		flw_ptr[0] = ME_TRANSMEDPRM;
		flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsPr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->cgPtyNum1.pres == 1)
	{
		flw_ptr[0] = ME_LOCNMB;
		flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum1,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkREL(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduREL *ptr 	=	&(pdus_ptr->m.release);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=0 m_v=1
	if(length < 1)
		return -1;
	
	//M-fixed
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkCauseDgn(&ptr->causeDgn,pointer_ptr+1, pointer_ptr[0]);
	flw_ptr++;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_REDIRINFO:
					siUnpkRedirInfo(&ptr->redirInfo,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_REDIRNUM:
					siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_ACCTPORT:
					siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_SIGPTCDE:
					siUnpkSigPointCode(&ptr->sigPointCode,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_USR2USRINFO:
					siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_AUTOCONGLVL:
					siUnpkAutoCongLvl (&ptr->auCongLvl,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_NETSPFAC:
					siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_ACCDELINFO:
					siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_REDIRRESTR:
					siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_USR2USRIND:
					siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_DISPLAYINFO:					// (SS7_ITU97 || SS7_ETSIV3)
					siUnpkDisplayInfo(&ptr->displayInfo,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_REMOTOPER:						// (SS7_ITU97 || SS7_ETSIV3)
					siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;

				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
		
	return 1;
}

int siPkREL(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduREL *ptr 	=	&(pdus_ptr->m.release);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	2;
	*(pointer_ptr++) = 2;
	*pointer_ptr = 0;
	flw_ptr[0]	=	siPkCauseDgn(&ptr->causeDgn,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 2;	
	flw_ptr +=	flw_ptr[0]+1;
	//Optional
	if(ptr->redirInfo.pres == 1)
	{
		flw_ptr[0] = ME_REDIRINFO;
		flw_ptr[1] = siPkRedirInfo(&ptr->redirInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->redirNum.pres == 1)
	{
		flw_ptr[0] = ME_REDIRNUM;
		flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->sigPointCode.pres == 1)
	{
		flw_ptr[0] = ME_SIGPTCDE;
		flw_ptr[1] = siPkSigPointCode(&ptr->sigPointCode,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->usr2UsrInfo.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRINFO;
		flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->auCongLvl.pres == 1)
	{
		flw_ptr[0] = ME_AUTOCONGLVL;
		flw_ptr[1] = siPkAutoCongLvl(&ptr->auCongLvl,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->netFac.pres == 1)
	{
		flw_ptr[0] = ME_NETSPFAC;
		flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accDelInfo.pres == 1)
	{
		flw_ptr[0] = ME_ACCDELINFO;
		flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->redirRstr.pres == 1)
	{
		flw_ptr[0] = ME_REDIRRESTR;
		flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}		
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->displayInfo.pres == 1)//(SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_DISPLAYINFO;
		flw_ptr[1] = siPkDisplayInfo(&ptr->displayInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->remotOper.pres == 1)
	{
		flw_ptr[0] = ME_REMOTOPER;
		flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;
}

int siUnpkRLC(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduRLC *ptr 	=	&(pdus_ptr->m.relComplete);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0 
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_CAUSIND:
					siUnpkCauseDgn(&ptr->causeDgn,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkRLC(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduRLC *ptr 	=	&(pdus_ptr->m.relComplete);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;	
	//Optional
	if(ptr->causeDgn.pres == 1)
	{
		flw_ptr[0] = ME_CAUSIND;
		flw_ptr[1] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;
}

int siUnpkSAM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduSAM *ptr 	=	&(pdus_ptr->m.subAddr);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=0 m_v=1 
	if(length < 1)
		return -1;
	
	//M-fixed
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkSubNum(&ptr->subNum,pointer_ptr+1, pointer_ptr[0]);
	
	//Optional

	return 1;
}

int siPkSAM(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduSAM *ptr 	=	&(pdus_ptr->m.subAddr);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	2;
	*(pointer_ptr++) = 2;
	*pointer_ptr = 0;
	flw_ptr[0]	=	siPkSubNum(&ptr->subNum,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 2;	
	flw_ptr +=	flw_ptr[0]+1;

	//Optional
		
	return flw_ptr - raw_ptr;	
}

int siUnpkUSR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduUSR *ptr 	=	&(pdus_ptr->m.usr2Usr);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=0 m_v=1
	if(length < 1)
		return -1;
	
	//M-fixed
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkUsr2UsrInfo(&ptr->usr2UsrInfo,pointer_ptr+1, pointer_ptr[0]);
	flw_ptr++;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_ACCTPORT:
					siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
		
	return 1;
}

int siPkUSR(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduUSR *ptr 	=	&(pdus_ptr->m.usr2Usr);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	2;
	*(pointer_ptr++) = 2;
	*pointer_ptr = 0;
	flw_ptr[0]	=	siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 2;	
	flw_ptr +=	flw_ptr[0]+1;
	//Optional
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;
}

int siUnpkFOT(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduFOT *ptr 	=	&(pdus_ptr->m.fwdTrans);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0 
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_CALREF:
					siUnpkCallRef(&ptr->callRef,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkFOT(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduFOT *ptr 	=	&(pdus_ptr->m.fwdTrans);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;	
	//Optional
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters

	return flw_ptr - raw_ptr;
}

int siUnpkRES(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduRES *ptr 	=	&(pdus_ptr->m.resume);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=1 m_v=0
	if(length < 1)
		return -1;		
	
	//M-fixed
	siUnpkSusResInd(&ptr->suspResInd,flw_ptr,0);
	flw_ptr += 1;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_CALREF:
					siUnpkCallRef(&ptr->callRef,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;				
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkRES(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduRES *ptr 	=	&(pdus_ptr->m.resume);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;
	
	//M-fixed
	flw_ptr	+=	siPkSusResInd(&ptr->suspResInd,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*pointer_ptr = 0;
	opt_pointer=1;
		
	//Optional

	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkSUS(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduSUS *ptr 	=	&(pdus_ptr->m.suspend);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=1 m_v=0
	if(length < 1)
		return -1;		
	
	//M-fixed
	siUnpkSusResInd(&ptr->suspResInd,flw_ptr,0);
	flw_ptr += 1;
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_CALREF:
					siUnpkCallRef(&ptr->callRef,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;				
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkSUS(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduSUS *ptr 	=	&(pdus_ptr->m.suspend);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkSusResInd(&ptr->suspResInd,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*pointer_ptr = 0;
	opt_pointer=1;
		
	//Optional

	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkCGB(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCGB *ptr 	=	&(pdus_ptr->m.cirGrpBlk);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=1 m_v=1
	if(length < 2)
		return -1;
	
	//M-fixed
	siUnpkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr,0);
	flw_ptr += 1;
		
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]);
	
	//Optional

	return 1;
}

int siPkCGB(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCGB *ptr 	=	&(pdus_ptr->m.cirGrpBlk);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;
	
	opt_pointer=0;

	
	//M-fixed
	flw_ptr	+=	siPkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 1;
	flw_ptr[0]	=	siPkRangStat(&ptr->rangStat,flw_ptr+1);
	flw_ptr +=	flw_ptr[0]+1;
		
	//Optional
		
	return flw_ptr - raw_ptr;	
}

int siUnpkCGBA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCGBA *ptr 	=	&(pdus_ptr->m.cirGrpBlkAck);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=1 m_v=1
	if(length < 2)
		return -1;
	
	//M-fixed
	siUnpkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr,0);
	flw_ptr += 1;
		
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]);
	
	//Optional

	return 1;
}

int siPkCGBA(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCGBA *ptr 	=	&(pdus_ptr->m.cirGrpBlkAck);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;
	
	opt_pointer=1;

	
	//M-fixed
	flw_ptr	+=	siPkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 1;
	flw_ptr[0]	=	siPkRangStat(&ptr->rangStat,flw_ptr+1);
	flw_ptr +=	flw_ptr[0]+1;
		
	//Optional
		
	return flw_ptr - raw_ptr;	
}

int siUnpkCGU(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCGU *ptr 	=	&(pdus_ptr->m.cirGrpUnblk);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=1 m_v=1
	if(length < 2)
		return -1;
	
	//M-fixed
	siUnpkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr,0);
	flw_ptr += 1;
		
	//M-variable
	//flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]);
	
	//Optional

	return 1;
}

int siPkCGU(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCGU *ptr 	=	&(pdus_ptr->m.cirGrpUnblk);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	opt_pointer=0;
	//M-fixed
	flw_ptr	+=	siPkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 1;
	flw_ptr[0]	=	siPkRangStat(&ptr->rangStat,flw_ptr+1);
	flw_ptr +=	flw_ptr[0]+1;
		
	//Optional
		
	return flw_ptr - raw_ptr;	
}

int siUnpkCGUA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCGUA *ptr 	=	&(pdus_ptr->m.cirGrpUblkAck);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=1 m_v=1
	if(length < 2)
		return -1;
	
	//M-fixed
	siUnpkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr,0);
	flw_ptr += 1;
		
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]);
	
	//Optional

	return 1;
}

int siPkCGUA(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCGUA *ptr 	=	&(pdus_ptr->m.cirGrpUblkAck);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;
	
	opt_pointer =0;

	
	//M-fixed
	flw_ptr	+=	siPkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr);

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 1;
	flw_ptr[0]	=	siPkRangStat(&ptr->rangStat,flw_ptr+1);
	flw_ptr +=	flw_ptr[0]+1;
		
	//Optional
		
	return flw_ptr - raw_ptr;	
}

int siUnpkGRS(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduGRS *ptr 	=	&(pdus_ptr->m.cirGrpRes);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=0 m_v=1
	if(length < 1)
		return -1;
	
	//M-fixed
	
	//M-variable
//	flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkRangNoStat(&ptr->rangNoStat,pointer_ptr+1, pointer_ptr[0]);
	
	//Optional

	return 1;
}

int siPkGRS(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduGRS *ptr 	=	&(pdus_ptr->m.cirGrpRes);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*(pointer_ptr++) = 1;

	flw_ptr[0]	=	siPkRangNoStat(&ptr->rangNoStat,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 2;	
	flw_ptr +=	flw_ptr[0]+1;

	//Optional
		
	return flw_ptr - raw_ptr;	
}

int siUnpkCQM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCQM *ptr 	=	&(pdus_ptr->m.cirGrpQry);
	u8 *flw_ptr		= 	raw_ptr;
	u8 *pointer_ptr;

	
	//check mandatory length
	//m_f=0 m_v=1
	if(length < 1)
		return -1;
	
	//M-fixed
	
	//M-variable
	//flw_ptr += *flw_ptr;
	pointer_ptr = flw_ptr + *flw_ptr;
	if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length)
		return -1;
	siUnpkRangNoStat(&ptr->rangNoStat,pointer_ptr+1, pointer_ptr[0]);
	
	//Optional

	return 1;
}

int siPkCQM(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCQM *ptr 	=	&(pdus_ptr->m.cirGrpQry);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	pointer_ptr = flw_ptr;
	flw_ptr +=	1;
	*(pointer_ptr++) = 1;
	flw_ptr[0]	=	siPkRangNoStat(&ptr->rangNoStat,flw_ptr+1);
	opt_pointer = flw_ptr[0] + 2;	
	flw_ptr +=	flw_ptr[0]+1;

	//Optional
		
	return flw_ptr - raw_ptr;	
}

int siUnpkFAA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduFAA *ptr 	=	&(pdus_ptr->m.facAccept);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=1 m_v=0
	if(length < 1)
		return -1;
	
	//M-fixed
	siUnpkFacInd(&ptr->facInd,flw_ptr,0);
	flw_ptr += 1;

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_USR2USRIND:
					siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_CALREF:
					siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_CONREQ:
					siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;	
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkFAA(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduFAA *ptr 	=	&(pdus_ptr->m.facAccept);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkFacInd(&ptr->facInd,flw_ptr);

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
		
	//Optional
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->connReq.pres == 1)
	{
		flw_ptr[0] = ME_CONREQ;
		flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkFAR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduFAR *ptr 	=	&(pdus_ptr->m.facRequest);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=1 m_v=0
	if(length < 1)
		return -1;
	
	//M-fixed
	siUnpkFacInd(&ptr->facInd,flw_ptr,0);
	flw_ptr += 1;

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_USR2USRIND:
				siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CALREF:
				siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CONREQ:
				siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;	
			case ME_PARCOMPIN:
				siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkFAR(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduFAR *ptr 	=	&(pdus_ptr->m.facRequest);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkFacInd(&ptr->facInd,flw_ptr);

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
		
	//Optional
	if(ptr->usr2UsrInd.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRIND;
		flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->callRef.pres == 1)
	{
		flw_ptr[0] = ME_CALREF;
		flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->connReq.pres == 1)
	{
		flw_ptr[0] = ME_CONREQ;
		flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkPAM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduPAM *ptr 	=	&(pdus_ptr->m.passAlng);
	u8 *flw_ptr		= 	raw_ptr;
	
	siUnpkPassAlng(&ptr->passAlng,flw_ptr,length);
	
	return 1;
}

int siPkPAM(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduPAM *ptr 	=	&(pdus_ptr->m.passAlng);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	pointer_ptr = 0;
	opt_pointer = 0;
		
	return siPkPassAlng(&ptr->passAlng,flw_ptr);
}

int siUnpkUPT(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduUPAT *ptr 	=	&(pdus_ptr->m.usrPrtAvTst);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkUPT(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduUPAT *ptr 	=	&(pdus_ptr->m.usrPrtAvTst);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
	//Optional
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkUPA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduUPAT *ptr 	=	&(pdus_ptr->m.usrPrtAvTst);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkUPA(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduUPAT *ptr 	=	&(pdus_ptr->m.usrPrtAvTst);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
	//Optional
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkFAC(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduFAC *ptr 	=	&(pdus_ptr->m.facility);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0 
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_MSGCOMP:
				siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_REMOTOPER:
					siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_SERVACT:
					siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_CALLTRNSFRNMB:					// (SS7_ITU97 || SS7_ETSIV3)
					siUnpkCgPtyNum(&ptr->calTrnsNmb,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_ACCTPORT:
					siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_NOTIFINDC:
					siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;

				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkFAC(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduFAC *ptr 	=	&(pdus_ptr->m.facility);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
	//Optional
	if(ptr->msgCom.pres == 1)
	{
		flw_ptr[0] = ME_MSGCOMP;
		flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->remotOper.pres == 1)
	{
		flw_ptr[0] = ME_REMOTOPER;
		flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->serviceAct.pres == 1)
	{
		flw_ptr[0] = ME_SERVACT;
		flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->calTrnsNmb.pres == 1)// (SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = ME_CALLTRNSFRNMB;
		flw_ptr[1] = siPkCgPtyNum(&ptr->calTrnsNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->notifInd.pres == 1)
	{
		flw_ptr[0] = ME_NOTIFINDC;
		flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkNRM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduNRM *ptr 	=	&(pdus_ptr->m.netResMgt);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_MSGCOMP:
					siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_ECHOCNTRL:
					siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				case ME_TRANSMEDUSD:
					siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;					
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkNRM(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduNRM *ptr 	=	&(pdus_ptr->m.netResMgt);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
	//Optional
	if(ptr->msgCom.pres == 1)
	{
		flw_ptr[0] = ME_MSGCOMP;
		flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->txMedUsed.pres == 1)
	{
		flw_ptr[0] = ME_TRANSMEDUSD;
		flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->echoControl.pres == 1)
	{
		flw_ptr[0] = ME_ECHOCNTRL;
		flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkIDR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduIDR *ptr 	=	&(pdus_ptr->m.identReq);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_MCIDREQ:
					siUnpkSiMcidReqInd(&ptr->mcidReq,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;					
				case ME_MSGCOMP:
					siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkIDR(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduIDR *ptr 	=	&(pdus_ptr->m.identReq);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
	//Optional
	if(ptr->mcidReq.pres == 1)
	{
		flw_ptr[0] = ME_MCIDREQ;
		flw_ptr[1] = siPkSiMcidReqInd(&ptr->mcidReq,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->msgCom.pres == 1)
	{
		flw_ptr[0] = ME_MSGCOMP;
		flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkIRS(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduIRS *ptr 	=	&(pdus_ptr->m.identRsp);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
				case ME_MCIDRSP:
					siUnpkSiMcidRspInd(&ptr->mcidRsp,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_MSGCOMP:
					siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_PARCOMPIN:
					siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_CALGPARTNUM:
					siUnpkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2, flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;				
				case ME_ACCTPORT:
					siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;
				case ME_GENNMB:
					siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;	
				case MEI_CHRGINFODELAY:	//( SS7_ITU97 || SS7_ETSIV3)
					siUnpkNaPaChgPID(&ptr->naPaChgPID,flw_ptr+2,flw_ptr[1]);
					flw_ptr += flw_ptr[1] + 2;
					break;	

				default:
					flw_ptr += flw_ptr[1] + 2;
					break;				
			}
		}		
	}	
	return 1;
}

int siPkIRS(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduIRS *ptr 	=	&(pdus_ptr->m.identRsp);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
	//Optional
	if(ptr->mcidRsp.pres == 1)
	{
		flw_ptr[0] = ME_MCIDRSP;
		flw_ptr[1] = siPkSiMcidRspInd(&ptr->mcidRsp,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->msgCom.pres == 1)
	{
		flw_ptr[0] = ME_MSGCOMP;
		flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->cgPtyNum.pres == 1)
	{
		flw_ptr[0] = ME_CALGPARTNUM;
		flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->genNmb.pres == 1)
	{
		flw_ptr[0] = ME_GENNMB;
		flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}		
	if(ptr->naPaChgPID.pres == 1)//( SS7_ITU97 || SS7_ETSIV3)
	{
		flw_ptr[0] = MEI_CHRGINFODELAY;
		flw_ptr[1] = siPkNaPaChgPID(&ptr->naPaChgPID,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}		
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}

int siUnpkSGM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduSGM *ptr 	=	&(pdus_ptr->m.segment);
	u8 *flw_ptr		= 	raw_ptr;

	
	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;
	
	//M-fixed

	//M-variable
	
	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_ACCTPORT:
				siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_USR2USRINFO:
				siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_MSGCOMP:
				siUnpkSiMsgCompInfo(&ptr->msgComp,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_GENDIGITS:
				siUnpkSiGenDigits(&ptr->genDigits,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_NOTIFINDC:
				siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_GENNMB:
				siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkSGM(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduSGM *ptr 	=	&(pdus_ptr->m.segment);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;	
	//Optional
	if(ptr->accTrans.pres == 1)
	{
		flw_ptr[0] = ME_ACCTPORT;
		flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->usr2UsrInfo.pres == 1)
	{
		flw_ptr[0] = ME_USR2USRINFO;
		flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->msgComp.pres == 1)
	{
		flw_ptr[0] = ME_MSGCOMP;
		flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgComp,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->genDigits.pres == 1)
	{
		flw_ptr[0] = ME_GENDIGITS;
		flw_ptr[1] = siPkSiGenDigits(&ptr->genDigits,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->notifInd.pres == 1)
	{
		flw_ptr[0] = ME_NOTIFINDC;
		flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	

	if(ptr->genNmb.pres == 1)
	{
		flw_ptr[0] = ME_GENNMB;
		flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}


int siUnpkPRI(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduPRI *ptr 	=	&(pdus_ptr->m.preRelease);
	u8 *flw_ptr		= 	raw_ptr;


	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;

	//M-fixed

	//M-variable

	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_MSGCOMP:
				siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_PARCOMPIN:
				siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_OPBACKCALLIND:
				siUnpkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_OPFWDCALLIND:
				siUnpkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_APPTRAN:
				siUnpkAppTransParam(&ptr->appTransParam,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkPRI(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduPRI *ptr 	=	&(pdus_ptr->m.preRelease);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;


	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;	
	//Optional
	if(ptr->msgCom.pres == 1)
	{
		flw_ptr[0] = ME_MSGCOMP;
		flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->optBckCalInd.pres == 1)
	{
		flw_ptr[0] = ME_OPBACKCALLIND;
		flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;
	}
	if(ptr->opFwdCalInd.pres == 1)
	{
		flw_ptr[0] = ME_OPFWDCALLIND;
		flw_ptr[1] = siPkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->appTransParam.pres == 1)
	{
		flw_ptr[0] = ME_APPTRAN;
		flw_ptr[1] = siPkAppTransParam(&ptr->appTransParam,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters

	return flw_ptr - raw_ptr;	
}

int siUnpkAPP(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduAPP *ptr 	=	&(pdus_ptr->m.appTransport);
	u8 *flw_ptr		= 	raw_ptr;


	//check mandatory length
	//m_f=0 m_v=0
//	if(length < 1)
//		return -1;

	//M-fixed

	//M-variable

	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_MSGCOMP:
				siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_PARCOMPIN:
				siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_APPTRAN:
				siUnpkAppTransParam(&ptr->appTransParam,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkAPP(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduAPP *ptr 	=	&(pdus_ptr->m.appTransport);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;


	//M-fixed

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;	
	//Optional
	if(ptr->msgCom.pres == 1)
	{
		flw_ptr[0] = ME_MSGCOMP;
		flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->parmCom.pres == 1)
	{
		flw_ptr[0] = ME_PARCOMPIN;
		flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	if(ptr->appTransParam.pres == 1)
	{
		flw_ptr[0] = ME_APPTRAN;
		flw_ptr[1] = siPkAppTransParam(&ptr->appTransParam,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}

	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters

	return flw_ptr - raw_ptr;	
}

int siUnpkCVR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length)
{
	SiPduCVR *ptr 	=	&(pdus_ptr->m.cirValRsp);
	u8 *flw_ptr		= 	raw_ptr;


	//check mandatory length
	//m_f=2 m_v=0
	if(length < 2)
		return -1;

	//M-fixed
	siUnpkCirValRspInd(&ptr->valRspInd,flw_ptr,0);
	flw_ptr += 1;
	siUnpkCirGrpCharInd(&ptr->grpCharInd,flw_ptr,0);
	flw_ptr += 1;	

	//M-variable

	//Optional
	if(*flw_ptr != 0)
	{
		flw_ptr += *flw_ptr;
		while(*flw_ptr != 0)
		{
			if(flw_ptr+flw_ptr[1]+2-raw_ptr > length)
				return -3;			
			switch(*flw_ptr)
			{
			case ME_CIRIDNAME:
				siUnpkCirIdName(&ptr->cirIdName,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			case ME_CLLI:
				siUnpkCLLI(&ptr->clli,flw_ptr+2,flw_ptr[1]);
				flw_ptr += flw_ptr[1] + 2;
				break;
			default:
				flw_ptr += flw_ptr[1] + 2;
				break;				
			}
		}		
	}	
	return 1;
}

int siPkCVR(SiAllPdus *pdus_ptr, u8 *raw_ptr)
{
	SiPduCVR *ptr 	=	&(pdus_ptr->m.cirValRsp);
	u8			*flw_ptr	= 	raw_ptr;
	u8			*pointer_ptr;
	u8			opt_pointer;

	
	//M-fixed
	flw_ptr	+=	siPkCirValRspInd(&ptr->valRspInd,flw_ptr);
	flw_ptr	+=	siPkCirGrpCharInd(&ptr->grpCharInd,flw_ptr);

	//M-variable
	opt_pointer = 1;
	pointer_ptr = flw_ptr;
	flw_ptr++;
	*pointer_ptr = 0;
		
	//Optional
	if(ptr->cirIdName.pres == 1)
	{
		flw_ptr[0] = ME_CIRIDNAME;
		flw_ptr[1] = siPkCirIdName(&ptr->cirIdName,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}
	if(ptr->clli.pres == 1)
	{
		flw_ptr[0] = ME_CLLI;
		flw_ptr[1] = siPkCLLI(&ptr->clli,flw_ptr+2);
		flw_ptr += flw_ptr[1] + 2;
		*pointer_ptr = opt_pointer;		
	}	
	
	if(*pointer_ptr != 0)
		*(flw_ptr++) = 0;	//End of optional parameters
		
	return flw_ptr - raw_ptr;	
}


static int siSelUnpkFun_ITU(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length)
{
	switch(type)
	{
	case M_ACM:
		return siUnpkACM(pdus_ptr, raw_ptr, length);
	case M_ANM:
		return siUnpkANM(pdus_ptr, raw_ptr, length);
	case M_CPG:
		return siUnpkCPG(pdus_ptr, raw_ptr, length);
	case M_CGB:
		return siUnpkCGB(pdus_ptr, raw_ptr, length);
	case M_CGBA:
		return siUnpkCGBA(pdus_ptr, raw_ptr, length);
	case M_CQM:
		return siUnpkCQM(pdus_ptr, raw_ptr, length);
	case M_CQR:
		return siUnpkCQR(pdus_ptr, raw_ptr, length);
	case M_GRS:
		return siUnpkGRS(pdus_ptr, raw_ptr, length);
	case M_GRA:
		return siUnpkGRA(pdus_ptr, raw_ptr, length);
	case M_CGU:
		return siUnpkCGU(pdus_ptr, raw_ptr, length);
	case M_CGUA:
		return siUnpkCGUA(pdus_ptr, raw_ptr, length);	
	case M_CFN:
		return siUnpkCFN(pdus_ptr, raw_ptr, length);
	case M_CON:
		return siUnpkCON(pdus_ptr, raw_ptr, length);
	case M_COT:
		return siUnpkCOT(pdus_ptr, raw_ptr, length);
	case M_FAC:
		return siUnpkFAC(pdus_ptr, raw_ptr, length);
	case M_FAA:
		return siUnpkFAA(pdus_ptr, raw_ptr, length);
	case M_FRJ:
		return siUnpkFRJ(pdus_ptr, raw_ptr, length);
	case M_FAR:
		return siUnpkFAR(pdus_ptr, raw_ptr, length);
	case M_FOT:
		return siUnpkFOT(pdus_ptr, raw_ptr, length);
	case M_IDR:
		return siUnpkIDR(pdus_ptr, raw_ptr, length);
	case M_IRS:
		return siUnpkIRS(pdus_ptr, raw_ptr, length);
	case M_INF:
		return siUnpkINF(pdus_ptr, raw_ptr, length);
	case M_INR:
		return siUnpkINR(pdus_ptr, raw_ptr, length);
	case M_IAM:
		return siUnpkIAM(pdus_ptr, raw_ptr, length);
	case M_NRM:
		return siUnpkNRM(pdus_ptr, raw_ptr, length);	
	case M_PAM:
		return siUnpkPAM(pdus_ptr, raw_ptr, length);
	case M_REL:
		return siUnpkREL(pdus_ptr, raw_ptr, length);
	case M_RLC:
		return siUnpkRLC(pdus_ptr, raw_ptr, length);			
	case M_RES:
		return siUnpkRES(pdus_ptr, raw_ptr, length);
	case M_SGM:
		return siUnpkSGM(pdus_ptr, raw_ptr, length);			
	case M_SAM:
		return siUnpkSAM(pdus_ptr, raw_ptr, length);
	case M_SUS:
		return siUnpkSUS(pdus_ptr, raw_ptr, length);
	case M_UPA:
		return siUnpkUPA(pdus_ptr, raw_ptr, length);
	case M_UPT:
		return siUnpkUPT(pdus_ptr, raw_ptr, length);
	case M_USR:
		return siUnpkUSR(pdus_ptr, raw_ptr, length);
	case M_PRI:
		return siUnpkPRI(pdus_ptr, raw_ptr, length);
	case M_APP:
		return siUnpkAPP(pdus_ptr, raw_ptr, length);	
	case M_UBL:			
	case M_UBA:			
	case M_UCIC:
	case M_BLO:
	case M_BLA:
	case M_RSC:
	case M_OLM:
	case M_LPA:
	case M_CRG:				
		return 1;
	default:
		break;	
	}
	return -2;//nonsupport
}

static int siSelPkFun_ITU(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type)
{
	switch(type)
	{
	case M_ACM:
		return siPkACM(pdus_ptr, raw_ptr);
	case M_ANM:
		return siPkANM(pdus_ptr, raw_ptr);
	case M_CPG:
		return siPkCPG(pdus_ptr, raw_ptr);
	case M_CGB:
		return siPkCGB(pdus_ptr, raw_ptr);			
	case M_CGBA:
		return siPkCGBA(pdus_ptr, raw_ptr);
	case M_CQM:
		return siPkCQM(pdus_ptr, raw_ptr);
	case M_CQR:
		return siPkCQR(pdus_ptr, raw_ptr);
	case M_GRS:
		return siPkGRS(pdus_ptr, raw_ptr);
	case M_GRA:
		return siPkGRA(pdus_ptr, raw_ptr);
	case M_CGU:
		return siPkCGU(pdus_ptr, raw_ptr);
	case M_CGUA:
		return siPkCGUA(pdus_ptr, raw_ptr);	
	case M_CFN:
		return siPkCFN(pdus_ptr, raw_ptr);
	case M_CON:
		return siPkCON(pdus_ptr, raw_ptr);
	case M_COT:
		return siPkCOT(pdus_ptr, raw_ptr);
	case M_FAC:
		return siPkFAC(pdus_ptr, raw_ptr);
	case M_FAA:
		return siPkFAA(pdus_ptr, raw_ptr);
	case M_FRJ:
		return siPkFRJ(pdus_ptr, raw_ptr);
	case M_FAR:
		return siPkFAR(pdus_ptr, raw_ptr);
	case M_FOT:
		return siPkFOT(pdus_ptr, raw_ptr);
	case M_IDR:
		return siPkIDR(pdus_ptr, raw_ptr);
	case M_IRS:
		return siPkIRS(pdus_ptr, raw_ptr);
	case M_INF:
		return siPkINF(pdus_ptr, raw_ptr);
	case M_INR:
		return siPkINR(pdus_ptr, raw_ptr);
	case M_IAM:
		return siPkIAM(pdus_ptr, raw_ptr);								
	case M_NRM:
		return siPkNRM(pdus_ptr, raw_ptr);	
	case M_PAM:			
		return siPkPAM(pdus_ptr, raw_ptr);
	case M_REL:
		return siPkREL(pdus_ptr, raw_ptr);
	case M_RLC:
		return siPkRLC(pdus_ptr, raw_ptr);			
	case M_RES:
		return siPkRES(pdus_ptr, raw_ptr);
	case M_SGM:
		return siPkSGM(pdus_ptr, raw_ptr);			
	case M_SAM:
		return siPkSAM(pdus_ptr, raw_ptr);
	case M_SUS:
		return siPkSUS(pdus_ptr, raw_ptr);
	case M_UPA:
		return siPkUPA(pdus_ptr, raw_ptr);
	case M_UPT:
		return siPkUPT(pdus_ptr, raw_ptr);
	case M_USR:
		return siPkUSR(pdus_ptr, raw_ptr);
	case M_PRI:
		return siPkPRI(pdus_ptr, raw_ptr);		
	case M_APP:
		return siPkAPP(pdus_ptr, raw_ptr);			
	case M_UBL:			
	case M_UBA:			
	case M_UCIC:
	case M_BLO:
	case M_BLA:
	case M_RSC:
	case M_OLM:
	case M_LPA:
	case M_CRG:				
		return 0;						
	default:
		break;	
	}
	return -2;
}

static int siSelUnpkFun_ANSI(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length)
{
	switch(type)
	{
	case M_ACM:
		return siUnpkACM(pdus_ptr, raw_ptr, length);
	case M_ANM:
		return siUnpkANM(pdus_ptr, raw_ptr, length);
	case M_CPG:
		return siUnpkCPG(pdus_ptr, raw_ptr, length);
	case M_CGB:
		return siUnpkCGB(pdus_ptr, raw_ptr, length);
	case M_CGBA:
		return siUnpkCGBA(pdus_ptr, raw_ptr, length);
	case M_CQM:
		return siUnpkCQM(pdus_ptr, raw_ptr, length);
	case M_CQR:
		return siUnpkCQR(pdus_ptr, raw_ptr, length);
	case M_GRS:
		return siUnpkGRS(pdus_ptr, raw_ptr, length);
	case M_GRA:
		return siUnpkGRA(pdus_ptr, raw_ptr, length);
	case M_CGU:
		return siUnpkCGU(pdus_ptr, raw_ptr, length);
	case M_CGUA:
		return siUnpkCGUA(pdus_ptr, raw_ptr, length);	
	case M_CFN:
		return siUnpkCFN(pdus_ptr, raw_ptr, length);
	case M_CON:
		return siUnpkCON(pdus_ptr, raw_ptr, length);
	case M_COT:
		return siUnpkCOT(pdus_ptr, raw_ptr, length);
	case M_FAC:
		return siUnpkFAC(pdus_ptr, raw_ptr, length);
	case M_FAA:
		return siUnpkFAA(pdus_ptr, raw_ptr, length);
	case M_FRJ:
		return siUnpkFRJ(pdus_ptr, raw_ptr, length);
	case M_FAR:
		return siUnpkFAR(pdus_ptr, raw_ptr, length);
	case M_FOT:
		return siUnpkFOT(pdus_ptr, raw_ptr, length);
	case M_IDR:
		return siUnpkIDR(pdus_ptr, raw_ptr, length);
	case M_IRS:
		return siUnpkIRS(pdus_ptr, raw_ptr, length);
	case M_INF:
		return siUnpkINF(pdus_ptr, raw_ptr, length);
	case M_INR:
		return siUnpkINR(pdus_ptr, raw_ptr, length);
	case M_IAM:
		return siUnpkIAM_AN(pdus_ptr, raw_ptr, length);			
	case M_NRM:
		return siUnpkNRM(pdus_ptr, raw_ptr, length);	
	case M_PAM:
		return siUnpkPAM(pdus_ptr, raw_ptr, length);
	case M_REL:
		return siUnpkREL(pdus_ptr, raw_ptr, length);
	case M_RLC:
		return siUnpkRLC(pdus_ptr, raw_ptr, length);			
	case M_RES:
		return siUnpkRES(pdus_ptr, raw_ptr, length);
	case M_SGM:
		return siUnpkSGM(pdus_ptr, raw_ptr, length);			
	case M_SAM:
		return siUnpkSAM(pdus_ptr, raw_ptr, length);
	case M_SUS:
		return siUnpkSUS(pdus_ptr, raw_ptr, length);
	case M_UPA:
		return siUnpkUPA(pdus_ptr, raw_ptr, length);
	case M_UPT:
		return siUnpkUPT(pdus_ptr, raw_ptr, length);
	case M_USR:
		return siUnpkUSR(pdus_ptr, raw_ptr, length);
	case M_PRI:
		return siUnpkPRI(pdus_ptr, raw_ptr, length);		
	case M_CVR://for ansi only
		return siUnpkCVR(pdus_ptr, raw_ptr, length);
	case M_UBL:
	case M_UBA:
	case M_UCIC:
	case M_BLO:
	case M_BLA:
	case M_RSC:
	case M_OLM:
	case M_LPA:
	case M_CRG:
	case M_CVT://only for ansi 
		return 1;		
	default:
		break;	
	}
	return -2;
}

static int siSelPkFun_ANSI(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type)
{
	switch(type)
	{
	case M_ACM:
		return siPkACM(pdus_ptr, raw_ptr);
	case M_ANM:
		return siPkANM(pdus_ptr, raw_ptr);
	case M_CPG:
		return siPkCPG(pdus_ptr, raw_ptr);
	case M_CGB:
		return siPkCGB(pdus_ptr, raw_ptr);			
	case M_CGBA:
		return siPkCGBA(pdus_ptr, raw_ptr);
	case M_CQM:
		return siPkCQM(pdus_ptr, raw_ptr);
	case M_CQR:
		return siPkCQR(pdus_ptr, raw_ptr);
	case M_GRS:
		return siPkGRS(pdus_ptr, raw_ptr);
	case M_GRA:
		return siPkGRA(pdus_ptr, raw_ptr);
	case M_CGU:
		return siPkCGU(pdus_ptr, raw_ptr);
	case M_CGUA:
		return siPkCGUA(pdus_ptr, raw_ptr);	
	case M_CFN:
		return siPkCFN(pdus_ptr, raw_ptr);
	case M_CON:
		return siPkCON(pdus_ptr, raw_ptr);
	case M_COT:
		return siPkCOT(pdus_ptr, raw_ptr);
	case M_FAC:
		return siPkFAC(pdus_ptr, raw_ptr);
	case M_FAA:
		return siPkFAA(pdus_ptr, raw_ptr);
	case M_FRJ:
		return siPkFRJ(pdus_ptr, raw_ptr);
	case M_FAR:
		return siPkFAR(pdus_ptr, raw_ptr);
	case M_FOT:
		return siPkFOT(pdus_ptr, raw_ptr);
	case M_IDR:
		return siPkIDR(pdus_ptr, raw_ptr);
	case M_IRS:
		return siPkIRS(pdus_ptr, raw_ptr);
	case M_INF:
		return siPkINF(pdus_ptr, raw_ptr);
	case M_INR:
		return siPkINR(pdus_ptr, raw_ptr);
	case M_IAM:
		return siPkIAM_AN(pdus_ptr, raw_ptr);			
	case M_NRM:
		return siPkNRM(pdus_ptr, raw_ptr);	
	case M_PAM:			
		return siPkPAM(pdus_ptr, raw_ptr);
	case M_REL:
		return siPkREL(pdus_ptr, raw_ptr);
	case M_RLC:
		return siPkRLC(pdus_ptr, raw_ptr);			
	case M_RES:
		return siPkRES(pdus_ptr, raw_ptr);
	case M_SGM:
		return siPkSGM(pdus_ptr, raw_ptr);			
	case M_SAM:
		return siPkSAM(pdus_ptr, raw_ptr);
	case M_SUS:
		return siPkSUS(pdus_ptr, raw_ptr);
	case M_UPA:
		return siPkUPA(pdus_ptr, raw_ptr);
	case M_UPT:
		return siPkUPT(pdus_ptr, raw_ptr);
	case M_USR:
		return siPkUSR(pdus_ptr, raw_ptr);
	case M_PRI:
		return siPkPRI(pdus_ptr, raw_ptr);
	case M_CVR:
		return siPkCVR(pdus_ptr, raw_ptr);
	case M_UBL:			
	case M_UBA:			
	case M_UCIC:
	case M_BLO:
	case M_BLA:
	case M_RSC:
	case M_OLM:
	case M_LPA:
	case M_CRG:		
	case M_CVT://only for ansi
		return 0;						
	default:
		break;	
	}
	return -2;
}







int siSelUnpkFun(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length, u8 variant)
{
	switch(variant)
	{
	case VARIANT_ITU:	
	case VARIANT_ETSI:	
	case VARIANT_UK:	
		return siSelUnpkFun_ITU(pdus_ptr, raw_ptr, type, length);
	case VARIANT_ANSI:
		return siSelUnpkFun_ANSI(pdus_ptr, raw_ptr, type, length);		
	default:
		break;	
	}
	return -2;
}

int siSelPkFun(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type,u8 variant)
{
	switch(variant)
	{
		case VARIANT_ETSI:
		case VARIANT_UK:
		case VARIANT_ITU:	
			return siSelPkFun_ITU(pdus_ptr, raw_ptr, type);
		case VARIANT_ANSI:
			return siSelPkFun_ANSI(pdus_ptr, raw_ptr, type);
		default:
			break;	
	}
	return -2;
}







//
//static int siSelUnpkFun_ETSI(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length)
//{
//	return -1;
//}
//
//static int siSelPkFun_ETSI(SiAllPdus *pdus_ptr, u8 *raw_ptr, int type)
//{
//	return -1;
//}
//
//static int siSelUnpkFun_UK(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length)
//{
//	return -1;
//}
//
//static int siSelPkFun_UK(SiAllPdus *pdus_ptr, u8 *raw_ptr, int type)
//{
//	return -1;
//}

void isup_send_cvr(u32 pid)
{
	SiPduCVR *ptr 	=	&(isup_sd_pdus.m.cirValRsp);
	
	memset(ptr,0,sizeof(SiPduCVR));
	ptr->valRspInd.cirValRspInd	=	0; //0=successful,1=failure
	ptr->grpCharInd.cirGrpCarInd	=	2;
	ptr->grpCharInd.dblSzCtrlInd	=	3;
	ptr->grpCharInd.alarmCarInd		=	1;
	ptr->grpCharInd.contChkReqInd	=	1;		
	isup_send_msg(pid,M_CVR);
}

