/*	------------------------------------*/
/*	IS41 codec for WIN					*/
/*	created by Xinyu Yan 2006-04-14		*/
/*	------------------------------------*/
#include "map_includes.h"

extern void is41_debug(DWORD mask, const char *fmt, ...);
extern int encode_param_termlist(struct IS41_PAR_TERMLIST *ptr,u32 flag,ASN_BUF *asn_buf,int *buf_len);
extern int decode_param_termlist(IS41_PAR_TERMLIST *ptr,ASN_BUF *asn_buf);

#define BIT30_TRUE		0x40000000

void is41enc_print_absent(char *param_str)
{
	is41_debug(IS41DB_ERR, "[IS41-Encode]: %s absent!", param_str);
}

void is41dec_print_absent(char *param_str)
{
	is41_debug(IS41DB_ERR, "[IS41-Decode]: %s absent!", param_str);
}

int	decode_Is41Param(char *tag, int maxlen, u8 *len, u8 *value, ASN_BUF *asn_buf)
{
	int		decodeLen;

	decodeLen = GetTLV(tag, maxlen, value, 0x80, asn_buf);
	if(decodeLen > 0)
	{
		if(len != NULL)
			*len = decodeLen;
		return decodeLen;
	}
	return 0;
}

u32 is41enc_MSID(u8 seq, IS41_PAR_MSID *ptr, ASN_BUF *asn_buf)
{
	if(ptr->choice_flag == 0)
		return AddTLV(is41_sequenceTag(IS41PAR_MIN, seq), MIN_LEN, ptr->min, 0x80, asn_buf);
	else if(ptr->choice_flag == 1)
		return AddTLV(is41_sequenceTag(IS41PAR_IMSI, seq), IMSI_LEN, ptr->imsi, 0x80, asn_buf);
	else
		return 0;
}

u32 is41dec_MSID(IS41_PAR_MSID *ptr, ASN_BUF *asn_buf)
{
	if(decode_Is41Param(IS41PAR_MIN, MIN_LEN, NULL, ptr->min, asn_buf))
		ptr->choice_flag = 0;
	else if(decode_Is41Param(IS41PAR_IMSI, IMSI_LEN, NULL, ptr->imsi, asn_buf))
		ptr->choice_flag = 1;
	else
		return 0;
	return 1;
}

u32 is41enc_WINCAP(u8 seq, IS41_PAR_WIN_CAP *ptr, ASN_BUF *asn_buf)
{
	u32 buf_len = 0;
	char tag[32];
	
	if(!(ptr->param_flag & 0x03))
	{
		is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:wincap no content!!");
		return 0;
	}
	if(ptr->param_flag & BIT0_TRUE)
	{
		sprintf(tag, "%s-%d.%s", IS41PAR_WINCAP, seq, IS41PAR_TRIGCAP);
		buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->triggercapLen & MAX_IS41_VARPAR_LEN_1,ptr->triggercap,0x80,asn_buf);
	}
	if(ptr->param_flag & BIT1_TRUE)
	{
		sprintf(tag, "%s-%d.%s", IS41PAR_WINCAP, seq, IS41PAR_WINOPRCAP);
		buf_len = AddTLV(is41_sequenceTag(tag,2),ptr->winoprcapLen & MAX_IS41_VARPAR_LEN_1,ptr->winoprcap,0x80,asn_buf);
	}
	return buf_len;
}

u32 is41dec_WINCAP(IS41_PAR_WIN_CAP *ptr, ASN_BUF *asn_buf)
{
	char tag[32];
	
	ptr->param_flag = 0;
	sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_TRIGCAP);
	if(decode_Is41Param(tag, 32, &ptr->triggercapLen, ptr->triggercap, asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_WINOPRCAP);
	if(decode_Is41Param(tag, 32, &ptr->winoprcapLen, ptr->winoprcap, asn_buf));
		ptr->param_flag |= BIT1_TRUE;
		
	if(ptr->param_flag != 0)
		return 1;
	else
		return 0;
}

u32 is41enc_triggerlist(u8 seq, u8 triggerlistnum, IS41_PAR_TRIGGER_LIST *ptr, ASN_BUF *asn_buf)
{
	u32			buf_len = 0;
	int			i;
	char		tag[64];
	u32			flag1;
	IS41_PAR_TRIGGER_LIST	*ptr1;
	
	if(!triggerlistnum)
	{
		is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:TriggerAddressList no content!!");
		return 0;
	}
	for(i = 0; i < triggerlistnum; i++)
	{
		ptr1 = ptr + i;
		flag1 = ptr1->param_flag;
		if((flag1 & 0x03) != 0x03)
		{
			is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!");
			return 0;
		}
		if(flag1 & BIT0_TRUE)
		{
			sprintf(tag, "%s-%d.%s-%d.%s", IS41PAR_TRIGADRLIST, seq, IS41PAR_TRIGLIST, i+1, IS41PAR_GLOBALTITLE);
			buf_len = AddTLV(is41_sequenceTag(tag,1), ptr1->destaddrLen, ptr1->destaddr, 0x80, asn_buf);
		}
		if(flag1 & BIT1_TRUE)
		{
			sprintf(tag, "%s-%d.%s-%d.%s", IS41PAR_TRIGADRLIST, seq, IS41PAR_TRIGLIST, i+1, IS41PAR_WINTRIGLIST);
			buf_len = AddTLV(is41_sequenceTag(tag,2), ptr1->wintriglistLen, ptr1->wintriglist, 0x80, asn_buf);
		}
	}
	return buf_len;
}

u32 is41dec_triggerlist(u8 *triggerlistnum, IS41_PAR_TRIGGER_LIST *ptr, ASN_BUF *asn_buf)
{
	int			i;
	char		tag[64];
	IS41_PAR_TRIGGER_LIST	*ptr1;
	
	*triggerlistnum = 0;
	for(i = 0; i < MAX_IS41_TRIG_LIST_NUM; i++)
	{
		ptr1 = ptr + i;
		ptr1->param_flag = 0;
		sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_GLOBALTITLE);
		if(decode_Is41Param(tag, 32, &ptr1->destaddrLen, ptr1->destaddr, asn_buf))
			ptr1->param_flag |= BIT0_TRUE;
		sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_WINTRIGLIST);
		if(decode_Is41Param(tag, 32, &ptr1->wintriglistLen, ptr->wintriglist, asn_buf))
			ptr1->param_flag |= BIT1_TRUE;
		if(ptr1->param_flag == 0x03)
			(*triggerlistnum)++;
		else if(ptr1->param_flag == 0)
			break;
		else
		{
			is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:triggerlist lacks mandatory info!!");
			break;
		}
	}
	if(*triggerlistnum != 0)
		return 1;
	else
		return 0;
}

u32 is41enc_exescr(u8 seq, IS41_PAR_EXESCR *ptr, ASN_BUF *asn_buf)
{
	u32		buf_len = 0;
	char	tag[32];
	
	if(ptr->param_flag & BIT0_TRUE)
	{
		sprintf(tag, "%s-%d.%s", IS41PAR_EXESCR, seq, IS41PAR_SCRNAME);
		buf_len = AddTLV(is41_sequenceTag(tag,1), ptr->scrnameLen, ptr->scrname, 0x80, asn_buf);
	}
	else
		is41_debug(IS41DB_ERR,"[IS41-Encode] Warning,reason:exescr lacks mandatory info!!");
	if(ptr->param_flag & BIT1_TRUE)
	{
		sprintf(tag, "%s-%d.%s", IS41PAR_EXESCR, seq, IS41PAR_SCRARG);
		buf_len = AddTLV(is41_sequenceTag(tag,2), ptr->scrargLen, ptr->scrarg, 0x80, asn_buf);
	}
	return buf_len;
}

u32 is41dec_exescr(IS41_PAR_EXESCR *ptr, ASN_BUF *asn_buf)
{
	char tag[32];
	
	ptr->param_flag = 0;
	sprintf(tag, "%s.%s", IS41PAR_EXESCR, IS41PAR_SCRNAME);
	if(decode_Is41Param(tag, 32, &ptr->scrnameLen, ptr->scrname, asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	sprintf(tag, "%s.%s", IS41PAR_EXESCR, IS41PAR_SCRARG);
	if(decode_Is41Param(tag, 96, &ptr->scrargLen, ptr->scrarg, asn_buf));
		ptr->param_flag |= BIT1_TRUE;
		
	if(ptr->param_flag&BIT0_TRUE)
		return 1;
	else
		return 0;
}

/****************************************************************************************/
int assign_is41OriginationRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_ORREQ_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.orreq_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf);
	else
		is41enc_print_absent("BillingID");
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,2), ptr->digitsLen, ptr->digits, 0x80, &asn_buf);
	else
		is41enc_print_absent("Digits");
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,3), 4, ptr->esn, 0x80, &asn_buf);
	else
		is41enc_print_absent("ESN");
	if(flag & BIT3_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,4), 3, ptr->mscid, 0x80, &asn_buf);
	else
		is41enc_print_absent("MSCID");
	if(flag & BIT4_TRUE)
		buf_len = is41enc_MSID(5, &ptr->msid, &asn_buf);
	else
		is41enc_print_absent("MSID");
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ORIGTRIG,6), ptr->origtrigLen, ptr->origtrig, 0x80, &asn_buf);
	else
		is41enc_print_absent("OriginationTriggers");
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,7), ptr->transcapLen, ptr->transcap, 0x80, &asn_buf);
	else
		is41enc_print_absent("TransactionCapability");
	//optional
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNAME,8), ptr->cpnameLen, ptr->cpname, 0x80, &asn_buf);
	if(flag & BIT8_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS1,9), ptr->cpndgts1Len, ptr->cpndgts1, 0x80, &asn_buf);
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS2,10), ptr->cpndgts2Len, ptr->cpndgts2, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,11), ptr->cpsubLen, ptr->cpsub, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,12), 2, ptr->locid, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,13), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT13_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATIND,14), ptr->featindLen, ptr->featind, 0x80, &asn_buf);
	if(flag & BIT14_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,15), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf);
	if(flag & BIT15_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,16), ptr->otfiLen, ptr->otfi, 0x80, &asn_buf);
	if(flag & BIT16_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,17), 5, ptr->pc_ssn, 0x80, &asn_buf);
	if(flag & BIT17_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,18), 1, &ptr->plind, 0x80, &asn_buf);
	if(flag & BIT18_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,19), ptr->senderinLen, ptr->senderin, 0x80, &asn_buf);
	if(flag & BIT19_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,20), 2, ptr->scellid, 0x80, &asn_buf);
	if(flag & BIT20_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,21), 1, &ptr->triggertype, 0x80, &asn_buf);
	if(flag & BIT21_TRUE)
		buf_len = is41enc_WINCAP(22, &ptr->wincap, &asn_buf);
	return buf_len;
}

int assign_is41OriginationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_ORREQ_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.orreq_rsp;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACCDEN,1), 1, &ptr->accden, 0x80, &asn_buf);
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACTCODE,2), ptr->actcodeLen, ptr->actcode, 0x80, &asn_buf);
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,3), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf);
	if(flag & BIT3_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG1,4), ptr->cpnstrg1Len, ptr->cpnstrg1, 0x80, &asn_buf);
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG2,5), ptr->cpnstrg2Len, ptr->cpnstrg2, 0x80, &asn_buf);
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,6), ptr->cpsubLen, ptr->cpsub, 0x80, &asn_buf);
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,7), ptr->cardgtsLen, ptr->cardgts, 0x80, &asn_buf);
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,8), ptr->digitsLen, ptr->digits, 0x80, &asn_buf);
	if(flag & BIT8_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DISPTEXT,9), ptr->disptextLen, ptr->disptext, 0x80, &asn_buf);
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,10), ptr->acdgtsLen, ptr->acdgts, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,11), ptr->abdgtsLen, ptr->abdgts, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,12), ptr->billdgtsLen, ptr->billdgts, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,13), ptr->redindLen, ptr->redind, 0x80, &asn_buf);
	if(flag & BIT13_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,14), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf);
	if(flag & BIT14_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_GRPINFO,15), ptr->grpinfoLen, ptr->grpinfo, 0x80, &asn_buf);
	if(flag & BIT15_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,16), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT16_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_NATIME,17), ptr->natimeLen, ptr->natime, 0x80, &asn_buf);
	if(flag & BIT17_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,18), ptr->otfiLen, ptr->otfi, 0x80, &asn_buf);
	if(flag & BIT18_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_PILOT,19), ptr->pilotLen, ptr->pilot, 0x80, &asn_buf);
	if(flag & BIT19_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,20), ptr->rndgtsLen, ptr->rndgts, 0x80, &asn_buf);
	if(flag & BIT20_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNSTRING,21), ptr->rnstringLen, ptr->rnstring, 0x80, &asn_buf);
	if(flag & BIT21_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,22), ptr->rsubLen, ptr->rsub, 0x80, &asn_buf);
	if(flag & BIT22_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RESUMEPIC,23), 1, &ptr->resumepic, 0x80, &asn_buf);
	if(flag & BIT23_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,24), ptr->routdgtsLen, ptr->routdgts, 0x80, &asn_buf);
	if(flag & BIT24_TRUE)
		encode_param_termlist(&ptr->termlist, ptr->termlist.param_flag, &asn_buf, &buf_len);
	if(flag & BIT25_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,26), ptr->termtrigLen, ptr->termtrig, 0x80, &asn_buf);
	if(flag & BIT26_TRUE)
		buf_len = is41enc_triggerlist(27, ptr->triggerlistnum, ptr->triggerlist, &asn_buf);
	return buf_len;
}

int extract_is41OriginationRequest_arg(struct MapOprSrv_struct *opr_ptr, u32 buf_len, u8 *buf)
{
	ASN_BUF					asn_buf;
	struct IS41_ORREQ_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.orreq_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("BillingID");
	if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	else
		is41dec_print_absent("Digits");
	if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	else
		is41dec_print_absent("ESN");
	if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	else
		is41dec_print_absent("MSCID");
	if(is41dec_MSID(&ptr->msid, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	else
		is41dec_print_absent("MSID");
	if(decode_Is41Param(IS41PAR_ORIGTRIG, 32, &ptr->origtrigLen, ptr->origtrig, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	else
		is41dec_print_absent("OriginationTriggers");
	if(decode_Is41Param(IS41PAR_TRANSCAP, 32, &ptr->transcapLen, ptr->transcap, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	else
		is41dec_print_absent("TransactionCapability");
	//optional
	if(decode_Is41Param(IS41PAR_CPNAME, 32, &ptr->cpnameLen, ptr->cpname, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	if(decode_Is41Param(IS41PAR_CPNDGTS1, 32, &ptr->cpndgts1Len, ptr->cpndgts1, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	if(decode_Is41Param(IS41PAR_CPNDGTS2, 32, &ptr->cpndgts2Len, ptr->cpndgts2, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_CPSUB, 32, &ptr->cpsubLen, ptr->cpsub, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	if(decode_Is41Param(IS41PAR_FEATIND, 32, &ptr->featindLen, ptr->featind, &asn_buf))
		ptr->param_flag |= BIT13_TRUE;
	if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf))
		ptr->param_flag |= BIT14_TRUE;
	if(decode_Is41Param(IS41PAR_OTFI, 32, &ptr->otfiLen, ptr->otfi, &asn_buf))
		ptr->param_flag |= BIT15_TRUE;
	if(decode_Is41Param(IS41PAR_PCSSN, 5, NULL, ptr->pc_ssn, &asn_buf))
		ptr->param_flag |= BIT16_TRUE;
	if(decode_Is41Param(IS41PAR_PLIND, 1, NULL, &ptr->plind, &asn_buf))
		ptr->param_flag |= BIT17_TRUE;
	if(decode_Is41Param(IS41PAR_SENDERIN, 32, &ptr->senderinLen, ptr->senderin, &asn_buf))
		ptr->param_flag |= BIT18_TRUE;
	if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf))
		ptr->param_flag |= BIT19_TRUE;
	if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf))
		ptr->param_flag |= BIT20_TRUE;
	if(is41dec_WINCAP(&ptr->wincap, &asn_buf))
		ptr->param_flag |= BIT21_TRUE;
	return 1;
}

int extract_is41OriginationRequest_rsp(struct MapOprSrv_struct *opr_ptr, u32 buf_len, u8 *buf)
{
	ASN_BUF					asn_buf;
	struct IS41_ORREQ_RSP	*ptr;
	
	ptr = &opr_ptr->msg_list.orreq_rsp;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;	
	//optional
	if(decode_Is41Param(IS41PAR_ACCDEN, 1, NULL, &ptr->accden, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	if(decode_Is41Param(IS41PAR_ACTCODE, 32, &ptr->actcodeLen, ptr->actcode, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	if(decode_Is41Param(IS41PAR_CPNSTRG1, 32, &ptr->cpnstrg1Len, ptr->cpnstrg1, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	if(decode_Is41Param(IS41PAR_CPNSTRG2, 32, &ptr->cpnstrg2Len, ptr->cpnstrg2, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	if(decode_Is41Param(IS41PAR_CPSUB, 32, &ptr->cpsubLen, ptr->cpsub, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	if(decode_Is41Param(IS41PAR_CARDGTS, 32, &ptr->cardgtsLen, ptr->cardgts, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	if(decode_Is41Param(IS41PAR_DISPTEXT, 32, &ptr->disptextLen, ptr->disptext, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	if(decode_Is41Param(IS41PAR_ACDGTS, 32, &ptr->acdgtsLen, ptr->acdgts, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_ABDGTS, 32, &ptr->abdgtsLen, ptr->abdgts, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_BILLDGTS, 32, &ptr->billdgtsLen, ptr->billdgts, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_REDIND, 32, &ptr->redindLen, ptr->redind, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf))
		ptr->param_flag |= BIT13_TRUE;
	if(decode_Is41Param(IS41PAR_GRPINFO, 32, &ptr->grpinfoLen, ptr->grpinfo, &asn_buf))
		ptr->param_flag |= BIT14_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT15_TRUE;
	if(decode_Is41Param(IS41PAR_NATIME, 32, &ptr->natimeLen, ptr->natime, &asn_buf))
		ptr->param_flag |= BIT16_TRUE;
	if(decode_Is41Param(IS41PAR_OTFI, 32, &ptr->otfiLen, ptr->otfi, &asn_buf))
		ptr->param_flag |= BIT17_TRUE;
	if(decode_Is41Param(IS41PAR_PILOT, 32, &ptr->pilotLen, ptr->pilot, &asn_buf))
		ptr->param_flag |= BIT18_TRUE;
	if(decode_Is41Param(IS41PAR_RNDGTS, 32, &ptr->rndgtsLen, ptr->rndgts, &asn_buf))
		ptr->param_flag |= BIT19_TRUE;
	if(decode_Is41Param(IS41PAR_RNSTRING, 32, &ptr->rnstringLen, ptr->rnstring, &asn_buf))
		ptr->param_flag |= BIT20_TRUE;
	if(decode_Is41Param(IS41PAR_RSUB, 32, &ptr->rsubLen, ptr->rsub, &asn_buf))
		ptr->param_flag |= BIT21_TRUE;
	if(decode_Is41Param(IS41PAR_RESUMEPIC, 1, NULL, &ptr->resumepic, &asn_buf))
		ptr->param_flag |= BIT22_TRUE;
	if(decode_Is41Param(IS41PAR_ROUTDGTS, 32, NULL, ptr->routdgts, &asn_buf))
		ptr->param_flag |= BIT23_TRUE;
	if(decode_param_termlist(&ptr->termlist, &asn_buf))
		ptr->param_flag |= BIT24_TRUE;
	if(decode_Is41Param(IS41PAR_TERMTRIG, 32, &ptr->termtrigLen, ptr->termtrig, &asn_buf))
		ptr->param_flag |= BIT25_TRUE;
	if(is41dec_triggerlist(&ptr->triggerlistnum, ptr->triggerlist, &asn_buf))
		ptr->param_flag |= BIT26_TRUE;
	return 1;
}

int assign_is41AnalyzedInformation_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_ANLYZD_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.anlyzd_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf);
	else
		is41enc_print_absent("BillingID");
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,2), ptr->digitsLen, ptr->digits, 0x80, &asn_buf);
	else
		is41enc_print_absent("Digits");
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf);
	else
		is41enc_print_absent("MSCID");
	if(flag & BIT3_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,4), ptr->transcapLen, ptr->transcap, 0x80, &asn_buf);
	else
		is41enc_print_absent("TransactionCapability");
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,5), 1, &ptr->triggertype, 0x80, &asn_buf);
	else
		is41enc_print_absent("TriggerType");
	if(flag & BIT5_TRUE)
		buf_len = is41enc_WINCAP(6, &ptr->wincap, &asn_buf);
	else
		is41enc_print_absent("WINCapability");
	//optional
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNAME,7), ptr->cpnameLen, ptr->cpname, 0x80, &asn_buf);
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS1,8), ptr->cpndgts1Len, ptr->cpndgts1, 0x80, &asn_buf);
	if(flag & BIT8_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS2,9), ptr->cpndgts2Len, ptr->cpndgts2, 0x80, &asn_buf);
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,10), ptr->cpsubLen, ptr->cpsub, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,11), ptr->cardgtsLen, ptr->cardgts, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCI,12), ptr->cciLen, ptr->cci, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DESTDGTS,13), ptr->destdgtsLen, ptr->destdgts, 0x80, &asn_buf);
	if(flag & BIT13_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,14), ptr->redindLen, ptr->redind, 0x80, &asn_buf);
	if(flag & BIT14_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,15), 4, ptr->esn, 0x80, &asn_buf);
	if(flag & BIT15_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATIND,16), ptr->featindLen, ptr->featind, 0x80, &asn_buf);
	if(flag & BIT16_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,17), 2, ptr->locid, 0x80, &asn_buf);
	if(flag & BIT17_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,18), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT18_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,19), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf);
	if(flag & BIT19_TRUE)
		buf_len = is41enc_MSID(20, &ptr->msid, &asn_buf);
	if(flag & BIT20_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,21), ptr->otfiLen, ptr->otfi, 0x80, &asn_buf);
	if(flag & BIT21_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,22), 1, &ptr->plind, 0x80, &asn_buf);
	if(flag & BIT22_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,23), ptr->rndgtsLen, ptr->rndgts, 0x80, &asn_buf);
	if(flag & BIT23_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RDNAME,24), ptr->rdnameLen, ptr->rdname, 0x80, &asn_buf);
	if(flag & BIT24_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,25), ptr->rsubLen, ptr->rsub, 0x80, &asn_buf);
	if(flag & BIT25_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,26), ptr->routdgtsLen, ptr->routdgts, 0x80, &asn_buf);
	if(flag & BIT26_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,27), 2, ptr->scellid, 0x80, &asn_buf);
	if(flag & BIT27_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,28), 1, &ptr->mytyp, 0x80, &asn_buf);
	if(flag & BIT28_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TAT,29), 1, &ptr->tat, 0x80, &asn_buf);
	if(flag & BIT29_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,30), 2, ptr->tdo, 0x80, &asn_buf);
	if(flag & BIT30_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,31), 3, ptr->tod, 0x80, &asn_buf);
	return buf_len;
}

int assign_is41AnalyzedInformation_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_ANLYZD_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.anlyzd_rsp;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	//optional
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACCDEN,1), 1, &ptr->accden, 0x80, &asn_buf);
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACTCODE,2), ptr->actcodeLen, ptr->actcode, 0x80, &asn_buf);
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,3), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf);
	if(flag & BIT3_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,4), ptr->cardgtsLen, ptr->cardgts, 0x80, &asn_buf);
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCI,5), ptr->cciLen, ptr->cci, 0x80, &asn_buf);
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,6), ptr->digitsLen, ptr->digits, 0x80, &asn_buf);
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DISPTEXT,7), ptr->disptextLen, ptr->disptext, 0x80, &asn_buf);
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,8), ptr->acdgtsLen, ptr->acdgts, 0x80, &asn_buf);
	if(flag & BIT8_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,9), ptr->abdgtsLen, ptr->abdgts, 0x80, &asn_buf);
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,10), ptr->billdgtsLen, ptr->billdgts, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,11), ptr->redindLen, ptr->redind, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,12), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_NATIME,13), ptr->natimeLen, ptr->natime, 0x80, &asn_buf);
	if(flag & BIT13_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,14), ptr->otfiLen, ptr->otfi, 0x80, &asn_buf);
	if(flag & BIT14_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,15), ptr->rndgtsLen, ptr->rndgts, 0x80, &asn_buf);
	if(flag & BIT15_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RESUMEPIC,16), 1, &ptr->resumepic, 0x80, &asn_buf);
	if(flag & BIT16_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,17), ptr->routdgtsLen, ptr->routdgts, 0x80, &asn_buf);
	if(flag & BIT17_TRUE)
		encode_param_termlist(&ptr->termlist, ptr->termlist.param_flag, &asn_buf, &buf_len);
	if(flag & BIT18_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,19), ptr->termtrigLen, ptr->termtrig, 0x80, &asn_buf);
	if(flag & BIT19_TRUE)
		buf_len = is41enc_triggerlist(20, ptr->triggerlistnum, ptr->triggerlist, &asn_buf);
	return buf_len;
}

int extract_is41AnalyzedInformation_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF					asn_buf;
	struct IS41_ANLYZD_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.anlyzd_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("BillingID");
	if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	else
		is41dec_print_absent("Digits");
	if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	else
		is41dec_print_absent("MSCID");
	if(decode_Is41Param(IS41PAR_TRANSCAP, 32, &ptr->transcapLen, ptr->transcap, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	else
		is41dec_print_absent("TransactionCapability");
	if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	else
		is41dec_print_absent("TriggerType");
	if(is41dec_WINCAP(&ptr->wincap, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	else
		is41dec_print_absent("WINCapability");
	//optional
	if(decode_Is41Param(IS41PAR_CPNAME, 32, &ptr->cpnameLen, ptr->cpname, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	if(decode_Is41Param(IS41PAR_CPNDGTS1, 32, &ptr->cpndgts1Len, ptr->cpndgts1, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	if(decode_Is41Param(IS41PAR_CPNDGTS2, 32, &ptr->cpndgts2Len, ptr->cpndgts2, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	if(decode_Is41Param(IS41PAR_CPSUB, 32, &ptr->cpsubLen, ptr->cpsub, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_CARDGTS, 32, &ptr->cardgtsLen, ptr->cardgts, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_CCI, 32, &ptr->cciLen, ptr->cci, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_DESTDGTS, 32, &ptr->destdgtsLen, ptr->destdgts, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	if(decode_Is41Param(IS41PAR_REDIND, 32, &ptr->redindLen, ptr->redind, &asn_buf))
		ptr->param_flag |= BIT13_TRUE;
	if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf))
		ptr->param_flag |= BIT14_TRUE;
	if(decode_Is41Param(IS41PAR_FEATIND, 32, &ptr->featindLen, ptr->featind, &asn_buf))
		ptr->param_flag |= BIT15_TRUE;
	if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf))
		ptr->param_flag |= BIT16_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT17_TRUE;
	if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf))
		ptr->param_flag |= BIT18_TRUE;
	if(is41dec_MSID(&ptr->msid, &asn_buf))
		ptr->param_flag |= BIT19_TRUE;
	if(decode_Is41Param(IS41PAR_OTFI, 32, &ptr->otfiLen, ptr->otfi, &asn_buf))
		ptr->param_flag |= BIT20_TRUE;
	if(decode_Is41Param(IS41PAR_PLIND, 1, NULL, &ptr->plind, &asn_buf))
		ptr->param_flag |= BIT21_TRUE;
	if(decode_Is41Param(IS41PAR_RNDGTS, 32, &ptr->rndgtsLen, ptr->rndgts, &asn_buf))
		ptr->param_flag |= BIT22_TRUE;
	if(decode_Is41Param(IS41PAR_RDNAME, 32, &ptr->rdnameLen, ptr->rdname, &asn_buf))
		ptr->param_flag |= BIT23_TRUE;
	if(decode_Is41Param(IS41PAR_RSUB, 32, &ptr->rsubLen, ptr->rsub, &asn_buf))
		ptr->param_flag |= BIT24_TRUE;
	if(decode_Is41Param(IS41PAR_ROUTDGTS, 32, &ptr->routdgtsLen, ptr->routdgts, &asn_buf))
		ptr->param_flag |= BIT25_TRUE;
	if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf))
		ptr->param_flag |= BIT26_TRUE;
	if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf))
		ptr->param_flag |= BIT27_TRUE;
	if(decode_Is41Param(IS41PAR_TAT, 1, NULL, &ptr->tat, &asn_buf))
		ptr->param_flag |= BIT28_TRUE;		
	if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf))
		ptr->param_flag |= BIT29_TRUE;
	if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf))
		ptr->param_flag |= BIT30_TRUE;
	return 1;
}

int extract_is41AnalyzedInformation_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF					asn_buf;
	struct IS41_ANLYZD_RSP	*ptr;
	
	ptr = &opr_ptr->msg_list.anlyzd_rsp;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	//optional
	if(decode_Is41Param(IS41PAR_ACCDEN, 1, NULL, &ptr->accden, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	if(decode_Is41Param(IS41PAR_ACTCODE, 32, &ptr->actcodeLen, ptr->actcode, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	if(decode_Is41Param(IS41PAR_CARDGTS, 32, &ptr->cardgtsLen, ptr->cardgts, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	if(decode_Is41Param(IS41PAR_CCI, 32, &ptr->cciLen, ptr->cci, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	if(decode_Is41Param(IS41PAR_DISPTEXT, 32, &ptr->disptextLen, ptr->disptext, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	if(decode_Is41Param(IS41PAR_ACDGTS, 32, &ptr->acdgtsLen, ptr->acdgts, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	if(decode_Is41Param(IS41PAR_ABDGTS, 32, &ptr->abdgtsLen, ptr->abdgts, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	if(decode_Is41Param(IS41PAR_BILLDGTS, 32, &ptr->billdgtsLen, ptr->billdgts, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_REDIND, 32, &ptr->redindLen, ptr->redind, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_NATIME, 32, &ptr->natimeLen, ptr->natime, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	if(decode_Is41Param(IS41PAR_OTFI, 32, &ptr->otfiLen, ptr->otfi, &asn_buf))
		ptr->param_flag |= BIT13_TRUE;
	if(decode_Is41Param(IS41PAR_RNDGTS, 32, &ptr->rndgtsLen, ptr->rndgts, &asn_buf))
		ptr->param_flag |= BIT14_TRUE;
	if(decode_Is41Param(IS41PAR_RESUMEPIC, 1, NULL, &ptr->resumepic, &asn_buf))
		ptr->param_flag |= BIT15_TRUE;
	if(decode_Is41Param(IS41PAR_ROUTDGTS, 32, &ptr->routdgtsLen, ptr->routdgts, &asn_buf))
		ptr->param_flag |= BIT16_TRUE;
	if(decode_param_termlist(&ptr->termlist, &asn_buf))
		ptr->param_flag |= BIT17_TRUE;
	if(decode_Is41Param(IS41PAR_TERMTRIG, 32, &ptr->termtrigLen, ptr->termtrig, &asn_buf))
		ptr->param_flag |= BIT18_TRUE;
	if(is41dec_triggerlist(&ptr->triggerlistnum, ptr->triggerlist, &asn_buf))
		ptr->param_flag |= BIT19_TRUE;
	return 1;
}

int assign_is41OAnswer_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_OANSWER_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.oanswer_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf);
	else
		is41enc_print_absent("BillingID");
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2), 4, ptr->esn, 0x80, &asn_buf);
	else
		is41enc_print_absent("ESN");
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf);
	else
		is41enc_print_absent("MSCID");
	if(flag & BIT3_TRUE)
		buf_len = is41enc_MSID(4, &ptr->msid, &asn_buf);
	else
		is41enc_print_absent("MSID");
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,5), 2, ptr->tdo, 0x80, &asn_buf);
	else
		is41enc_print_absent("TimeDateOffset");
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,6), 3, ptr->tod, 0x80, &asn_buf);
	else
		is41enc_print_absent("TimeOfDay");
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,7), 1, &ptr->triggertype, 0x80, &asn_buf);
	else
		is41enc_print_absent("TriggerType");
	//optional
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,8), 2, ptr->locid, 0x80, &asn_buf);
	if(flag & BIT8_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,9), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATIND,10), ptr->featindLen, ptr->featind, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,11), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,12), 2, ptr->scellid, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,13), 1, &ptr->mytyp, 0x80, &asn_buf);
	return buf_len;
}

int extract_is41OAnswer_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF					asn_buf;
	struct IS41_OANSWER_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.oanswer_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("BillingID");
	if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	else
		is41dec_print_absent("ESN");
	if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	else
		is41dec_print_absent("MSCID");
	if(is41dec_MSID(&ptr->msid, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	else
		is41dec_print_absent("MSID");
	if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	else
		is41dec_print_absent("TimeDateOffset");
	if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	else
		is41dec_print_absent("TimeOfDay");
	if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	else
		is41dec_print_absent("TriggerType");
	//optional
	if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	if(decode_Is41Param(IS41PAR_FEATIND, 32, &ptr->featindLen, ptr->featind, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	return 1;
}

int assign_is41ODisconnect_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF					asn_buf;
	int						buf_len = 0;
	u32						flag;
	IS41_ODISCONNECT_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.odisconnect_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf);
	else
		is41enc_print_absent("BillingID");
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2), 4, ptr->esn, 0x80, &asn_buf);
	else
		is41enc_print_absent("ESN");
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf);
	else
		is41enc_print_absent("MSCID");
	if(flag & BIT3_TRUE)
		buf_len = is41enc_MSID(4, &ptr->msid, &asn_buf);
	else
		is41enc_print_absent("MSID");
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RELCAUSE,5), 1, &ptr->relcause, 0x80, &asn_buf);
	else
		is41enc_print_absent("ReleaseCause");
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,6), 2, ptr->tdo, 0x80, &asn_buf);
	else
		is41enc_print_absent("TimeDateOffset");
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,7), 3, ptr->tod, 0x80, &asn_buf);
	else
		is41enc_print_absent("TimeOfDay");
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,8), ptr->transcapLen, ptr->transcap, 0x80, &asn_buf);
	else
		is41enc_print_absent("TransactionCapability");
	if(flag & BIT8_TRUE)
		buf_len = is41enc_WINCAP(9, &ptr->wincap, &asn_buf);
	else
		is41enc_print_absent("WINCapability");
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,10), 1, &ptr->triggertype, 0x80, &asn_buf);
	else
		is41enc_print_absent("TriggerType");
	//optional
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,11), 2, ptr->locid, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,12), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,13), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf);
	if(flag & BIT13_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,14), 2, ptr->scellid, 0x80, &asn_buf);
	if(flag & BIT14_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,15), 1, &ptr->mytyp, 0x80, &asn_buf);
	return buf_len;
}

int assign_is41ODisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF					asn_buf;
	int						buf_len = 0;
	u32						flag;
	IS41_ODISCONNECT_RSP	*ptr;
	
	ptr = &opr_ptr->msg_list.odisconnect_rsp;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	//optional
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,1), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf);
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,2), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf);
	return buf_len;
}

int extract_is41ODisconnect_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF							asn_buf;
	struct IS41_ODISCONNECT_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.odisconnect_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("BillingID");
	if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	else
		is41dec_print_absent("ESN");
	if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	else
		is41dec_print_absent("MSCID");
	if(is41dec_MSID(&ptr->msid, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	else
		is41dec_print_absent("MSID");
	if(decode_Is41Param(IS41PAR_RELCAUSE, 1, NULL, &ptr->relcause, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	else
		is41dec_print_absent("ReleaseCause");
	if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	else
		is41dec_print_absent("TimeDateOffset");
	if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	else
		is41dec_print_absent("TimeOfDay");
	if(decode_Is41Param(IS41PAR_TRANSCAP, 32, &ptr->transcapLen, ptr->transcap, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	else
		is41dec_print_absent("TransactionCapability");
	if(is41dec_WINCAP(&ptr->wincap, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	else
		is41dec_print_absent("WINCapability");
	if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	else
		is41dec_print_absent("TriggerType");
	//optional
	if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf))
		ptr->param_flag |= BIT13_TRUE;
	if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf))
		ptr->param_flag |= BIT14_TRUE;
	return 1;
}

int extract_is41ODisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF							asn_buf;
	struct IS41_ODISCONNECT_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.odisconnect_rsp;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	//optional
	if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	return 1;
}

int assign_is41TAnswer_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_TANSWER_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.tanswer_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf);
	else
		is41enc_print_absent("BillingID");
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2), 4, ptr->esn, 0x80, &asn_buf);
	else
		is41enc_print_absent("ESN");
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf);
	else
		is41enc_print_absent("MSCID");
	if(flag & BIT3_TRUE)
		buf_len = is41enc_MSID(4, &ptr->msid, &asn_buf);
	else
		is41enc_print_absent("MSID");
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,5), 2, ptr->tdo, 0x80, &asn_buf);
	else
		is41enc_print_absent("TimeDateOffset");
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,6), 3, ptr->tod, 0x80, &asn_buf);
	else
		is41enc_print_absent("TimeOfDay");
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,7), ptr->transcapLen, ptr->transcap, 0x80, &asn_buf);
	else
		is41enc_print_absent("TransactionCapability");
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,8), 1, &ptr->triggertype, 0x80, &asn_buf);
	else
		is41enc_print_absent("TriggerType");
	if(flag & BIT8_TRUE)
		buf_len = is41enc_WINCAP(9, &ptr->wincap, &asn_buf);
	else
		is41enc_print_absent("WINCapability");
	//optional
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,10), 2, ptr->locid, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,11), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATIND,12), ptr->featindLen, ptr->featind, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,13), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf);
	if(flag & BIT13_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,14), 2, ptr->scellid, 0x80, &asn_buf);
	if(flag & BIT14_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,15), 1, &ptr->mytyp, 0x80, &asn_buf);
	if(flag & BIT15_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TAT,16), 1, &ptr->tat, 0x80, &asn_buf);
	return buf_len;
}

int extract_is41TAnswer_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_TANSWER_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.tanswer_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("BillingID");
	if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	else
		is41dec_print_absent("ESN");
	if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	else
		is41dec_print_absent("MSCID");
	if(is41dec_MSID(&ptr->msid, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	else
		is41dec_print_absent("MSID");
	if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	else
		is41dec_print_absent("TimeDateOffset");
	if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	else
		is41dec_print_absent("TimeOfDay");
	if(decode_Is41Param(IS41PAR_TRANSCAP, 32, &ptr->transcapLen, ptr->transcap, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	else
		is41dec_print_absent("TransactionCapability");
	if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	else
		is41dec_print_absent("TriggerType");
	if(is41dec_WINCAP(&ptr->wincap, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	else
		is41dec_print_absent("WINCapability");
	//optional
	if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_FEATIND, 32, &ptr->featindLen, ptr->featind, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf))
		ptr->param_flag |= BIT13_TRUE;
	if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf))
		ptr->param_flag |= BIT14_TRUE;
	if(decode_Is41Param(IS41PAR_TAT, 1, NULL, &ptr->tat, &asn_buf))
		ptr->param_flag |= BIT15_TRUE;
	return 1;
}

int assign_is41TDisconnect_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF					asn_buf;
	int						buf_len = 0;
	u32						flag;
	IS41_TDISCONNECT_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.tdisconnect_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf);
	else
		is41enc_print_absent("BillingID");
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2), 4, ptr->esn, 0x80, &asn_buf);
	else
		is41enc_print_absent("ESN");
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf);
	else
		is41enc_print_absent("MSCID");
	if(flag & BIT3_TRUE)
		buf_len = is41enc_MSID(4, &ptr->msid, &asn_buf);
	else
		is41enc_print_absent("MSID");
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,5), 2, ptr->tdo, 0x80, &asn_buf);
	else
		is41enc_print_absent("TimeDateOffset");
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,6), 3, ptr->tod, 0x80, &asn_buf);
	else
		is41enc_print_absent("TimeOfDay");
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,7), 1, &ptr->triggertype, 0x80, &asn_buf);
	else
		is41enc_print_absent("TriggerType");
	//optional
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,8), 2, ptr->locid, 0x80, &asn_buf);
	if(flag & BIT8_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,9), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,10), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_RELCAUSE,11), 1, &ptr->relcause, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,12), 2, ptr->scellid, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,13), 1, &ptr->mytyp, 0x80, &asn_buf);
	return buf_len;
}

int assign_is41TDisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF					asn_buf;
	int						buf_len = 0;
	u32						flag;
	IS41_TDISCONNECT_RSP	*ptr;
	
	ptr = &opr_ptr->msg_list.tdisconnect_rsp;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	//optional
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,1), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf);
	return buf_len;
}

int extract_is41TDisconnect_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF							asn_buf;
	struct IS41_TDISCONNECT_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.tdisconnect_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("BillingID");
	if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	else
		is41dec_print_absent("ESN");
	if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	else
		is41dec_print_absent("MSCID");
	if(is41dec_MSID(&ptr->msid, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	else
		is41dec_print_absent("MSID");
	if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	else
		is41dec_print_absent("TimeDateOffset");
	if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	else
		is41dec_print_absent("TimeOfDay");
	if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	else
		is41dec_print_absent("TriggerType");
	//optional
	if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_RELCAUSE, 1, NULL, &ptr->relcause, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	return 1;
}

int extract_is41TDisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF							asn_buf;
	struct IS41_TDISCONNECT_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.tdisconnect_rsp;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	//optional
	if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	return 1;
}

int assign_is41CallControlDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_CCDIR_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.ccdir_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf);
	else
		is41enc_print_absent("BillingID");
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,2), 3, ptr->mscid, 0x80, &asn_buf);
	else
		is41enc_print_absent("MSCID");
	if(flag & BIT2_TRUE)
		buf_len = is41enc_MSID(3, &ptr->msid, &asn_buf);
	else
		is41enc_print_absent("MSID");
	//optional
	if(flag & BIT3_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACTCODE,4), ptr->actcodeLen, ptr->actcode, 0x80, &asn_buf);
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,5), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf);
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DISPTEXT,6), ptr->disptextLen, ptr->disptext, 0x80, &asn_buf);
	if(flag & BIT6_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,7), ptr->acdgtsLen, ptr->acdgts, 0x80, &asn_buf);
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,8), ptr->abdgtsLen, ptr->abdgts, 0x80, &asn_buf);
	if(flag & BIT8_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,9), ptr->billdgtsLen, ptr->billdgts, 0x80, &asn_buf);
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,10), ptr->redindLen, ptr->redind, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,11), 4, ptr->esn, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,12), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,13), 1, &ptr->plind, 0x80, &asn_buf);
	if(flag & BIT13_TRUE)
		encode_param_termlist(&ptr->termlist, ptr->termlist.param_flag, &asn_buf, &buf_len);
	if(flag & BIT14_TRUE)
		buf_len = is41enc_triggerlist(15, ptr->triggerlistnum, ptr->triggerlist, &asn_buf);
	return buf_len;
}

int assign_is41CallControlDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_CCDIR_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.ccdir_rsp;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	//optional
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CALLSTATUS,1), ptr->callstatusLen, ptr->callstatus, 0x80, &asn_buf);
	return buf_len;
}

int extract_is41CallControlDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_CCDIR_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.ccdir_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("BillingID");
	if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	else
		is41dec_print_absent("MSCID");
	if(is41dec_MSID(&ptr->msid, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	else
		is41dec_print_absent("MSID");
	//optional
	if(decode_Is41Param(IS41PAR_ACTCODE, 32, &ptr->actcodeLen, ptr->actcode, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	if(decode_Is41Param(IS41PAR_DISPTEXT, 32, &ptr->disptextLen, ptr->disptext, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	if(decode_Is41Param(IS41PAR_ACDGTS, 32, &ptr->acdgtsLen, ptr->acdgts, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	if(decode_Is41Param(IS41PAR_ABDGTS, 32, &ptr->abdgtsLen, ptr->abdgts, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	if(decode_Is41Param(IS41PAR_BILLDGTS, 32, &ptr->billdgtsLen, ptr->billdgts, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	if(decode_Is41Param(IS41PAR_REDIND, 32, &ptr->redindLen, ptr->redind, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_PLIND, 1, NULL, &ptr->plind, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	if(decode_param_termlist(&ptr->termlist, &asn_buf))
		ptr->param_flag |= BIT13_TRUE;
	if(is41dec_triggerlist(&ptr->triggerlistnum, ptr->triggerlist, &asn_buf))
		ptr->param_flag |= BIT14_TRUE;
	return 1;
}

int extract_is41CallControlDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_CCDIR_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.ccdir_rsp;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	//optional
	if(decode_Is41Param(IS41PAR_CALLSTATUS, 32, &ptr->callstatusLen, ptr->callstatus, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	return 1;
}

int assign_is41SeizeResource_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_SEIZERES_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.seizeres_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	//optional
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,1), 1, &ptr->plind, 0x80, &asn_buf);
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_PSR,2), ptr->psrLen, ptr->psr, 0x80, &asn_buf);
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SR,3), ptr->srLen, ptr->sr, 0x80, &asn_buf);
	return buf_len;
}

int assign_is41SeizeResource_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_SEIZERES_RSP	*ptr;
	
	ptr = &opr_ptr->msg_list.seizeres_rsp;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DESTDGTS,1), ptr->destdgtsLen, ptr->destdgts, 0x80, &asn_buf);
	else
		is41enc_print_absent("DestinationDigits");
	return buf_len;
}

int extract_is41SeizeResource_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_SEIZERES_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.seizeres_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	//optional
	if(decode_Is41Param(IS41PAR_PLIND, 1, NULL, &ptr->plind, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	if(decode_Is41Param(IS41PAR_PSR, 32, &ptr->psrLen, ptr->psr, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	if(decode_Is41Param(IS41PAR_SR, 32, &ptr->srLen, ptr->sr, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	return 1;
}

int extract_is41SeizeResource_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_SEIZERES_RSP	*ptr;
	
	ptr = &opr_ptr->msg_list.seizeres_rsp;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_DESTDGTS, 32, &ptr->destdgtsLen, ptr->destdgts, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("DestinationDigits");
	return 1;
}

int assign_is41ConnectResource_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_CONNRES_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.connres_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DESTDGTS,1), ptr->destdgtsLen, ptr->destdgts, 0x80, &asn_buf);
	else
		is41enc_print_absent("DestinationDigits");
	//optional
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,2), ptr->cardgtsLen, ptr->cardgts, 0x80, &asn_buf);
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,3), ptr->routdgtsLen, ptr->routdgts, 0x80, &asn_buf);
	return buf_len;
}

int extract_is41ConnectResource_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_CONNRES_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.connres_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_DESTDGTS, 32, &ptr->destdgtsLen, ptr->destdgts, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("DestinationDigits");
	//optional
	if(decode_Is41Param(IS41PAR_CARDGTS, 32, &ptr->cardgtsLen, ptr->cardgts, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	if(decode_Is41Param(IS41PAR_ROUTDGTS, 32, &ptr->routdgtsLen, ptr->routdgts, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	return 1;
}

int assign_is41SRFDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_SRFDIR_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.srfdir_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	//optional
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,1), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf);
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITCC,2), ptr->dgtccLen, ptr->dgtcc, 0x80, &asn_buf);
	if(flag & BIT2_TRUE)
		buf_len = is41enc_exescr(3, &ptr->exescr, &asn_buf);
	if(flag & BIT3_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,4), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	return buf_len;
}

int assign_is41SRFDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF				asn_buf;
	int					buf_len = 0;
	u32					flag;
	IS41_SRFDIR_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.srfdir_rsp;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	//optional
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,1), ptr->digitsLen, ptr->digits, 0x80, &asn_buf);
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCRRESULT,2), ptr->scrresultLen, ptr->scrresult, 0x80, &asn_buf);
	return buf_len;
}

int extract_is41SRFDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_SRFDIR_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.srfdir_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	//optional
	if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	if(decode_Is41Param(IS41PAR_DIGITCC, 32, &ptr->dgtccLen, ptr->dgtcc, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	if(is41dec_exescr(&ptr->exescr, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	return 1;
}

int extract_is41SRFDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_SRFDIR_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.srfdir_rsp;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	//optional
	if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	if(decode_Is41Param(IS41PAR_SCRRESULT, 32, &ptr->scrresultLen, ptr->scrresult, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	return 1;
}

int assign_is41ShortMessageAnalyzed_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF					asn_buf;
	int						buf_len = 0;
	u32						flag;
	IS41_SM_ANLYZD_ARG		*ptr;
	
	ptr = &opr_ptr->msg_list.smanlyzd_arg;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBRLEN,1), 2, ptr->sms_brlen, 0x80, &asn_buf);
	else
		is41enc_print_absent("SMS_BearerLength");
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBILLID,2), ptr->sms_billidLen, ptr->sms_billid, 0x80, &asn_buf);
	else
		is41enc_print_absent("SMS_BillingID");
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSEVENT,3), 1, &ptr->sms_event, 0x80, &asn_buf);
	else
		is41enc_print_absent("SMS_Event");
	if(flag & BIT3_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSTID,4), ptr->smstidLen, ptr->smstid, 0x80, &asn_buf);
	else
		is41enc_print_absent("SMS_TeleserviceIdentifier");
	//optional
	if(flag & BIT4_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,5), 4, ptr->esn, 0x80, &asn_buf);
	if(flag & BIT5_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,6), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf);
	if(flag & BIT6_TRUE)
		buf_len = is41enc_MSID(7, &ptr->msid, &asn_buf);
	if(flag & BIT7_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCID,8), ptr->smscidLen, ptr->smscid, 0x80, &asn_buf);
	if(flag & BIT8_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSDA,9), ptr->smsdaLen, ptr->smsda, 0x80, &asn_buf);
	if(flag & BIT9_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSPMCNT,10), 4, ptr->sms_pmcnt, 0x80, &asn_buf);
	if(flag & BIT10_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODA,11), ptr->smsodaLen, ptr->smsoda, 0x80, &asn_buf);
	if(flag & BIT11_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODS,12), ptr->smsodsLen, ptr->smsods, 0x80, &asn_buf);
	if(flag & BIT12_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOA,13), ptr->smsooaLen, ptr->smsooa, 0x80, &asn_buf);
	if(flag & BIT13_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOS,14), ptr->smsoosLen, ptr->smsoos, 0x80, &asn_buf);
	if(flag & BIT14_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOA,15), ptr->smsoaLen, ptr->smsoa, 0x80, &asn_buf);
	if(flag & BIT15_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,16), 2, ptr->tdo, 0x80, &asn_buf);
	if(flag & BIT16_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,17), 3, ptr->tod, 0x80, &asn_buf);
	return buf_len;
}

int assign_is41ShortMessageAnalyzed_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf)
{
	ASN_BUF					asn_buf;
	int						buf_len = 0;
	u32						flag;
	IS41_SM_ANLYZD_RSP		*ptr;
	
	ptr = &opr_ptr->msg_list.smanlyzd_rsp;
	flag = ptr->param_flag;
	AsnEncode(buf, 256, &asn_buf);
	//optional
	if(flag & BIT0_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,1), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf);
	if(flag & BIT1_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBD,2), ptr->smsbdLen, ptr->smsbd, 0x80, &asn_buf);
	if(flag & BIT2_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCC,3), ptr->smscauseLen, ptr->smscause, 0x80, &asn_buf);
	if(flag & BIT3_TRUE)
		buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSEVENTNOT,4), ptr->sms_eventnotLen, ptr->sms_eventnot, 0x80, &asn_buf);
	return buf_len;
}

int extract_is41ShortMessageAnalyzed_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_SM_ANLYZD_ARG	*ptr;
	
	ptr = &opr_ptr->msg_list.smanlyzd_arg;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	if(decode_Is41Param(IS41PAR_SMSBRLEN, 2, NULL, ptr->sms_brlen, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	else
		is41dec_print_absent("SMS_BearerLength");
	if(decode_Is41Param(IS41PAR_SMSBILLID, 32, &ptr->sms_billidLen, ptr->sms_billid, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	else
		is41dec_print_absent("SMS_BillingID");
	if(decode_Is41Param(IS41PAR_SMSEVENT, 1, NULL, &ptr->sms_event, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	else
		is41dec_print_absent("SMS_Event");
	if(decode_Is41Param(IS41PAR_SMSTID, MAX_IS41_VARPAR_LEN, &ptr->smstidLen, ptr->smstid, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	else
		is41dec_print_absent("SMS_TeleserviceIdentifier");
	//optional
	if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf))
		ptr->param_flag |= BIT4_TRUE;
	if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf))
		ptr->param_flag |= BIT5_TRUE;
	if(is41dec_MSID(&ptr->msid, &asn_buf))
		ptr->param_flag |= BIT6_TRUE;
	if(decode_Is41Param(IS41PAR_SMSCID, MAX_IS41_VARPAR_LEN , &ptr->smscidLen, ptr->smscid, &asn_buf))
		ptr->param_flag |= BIT7_TRUE;
	if(decode_Is41Param(IS41PAR_SMSDA, MAX_IS41_VARPAR_LEN, &ptr->smsdaLen, ptr->smsda, &asn_buf))
		ptr->param_flag |= BIT8_TRUE;
	if(decode_Is41Param(IS41PAR_SMSPMCNT, 4, NULL, ptr->sms_pmcnt, &asn_buf))
		ptr->param_flag |= BIT9_TRUE;
	if(decode_Is41Param(IS41PAR_SMSODA, MAX_IS41_VARPAR_LEN, &ptr->smsodaLen, ptr->smsoda, &asn_buf))
		ptr->param_flag |= BIT10_TRUE;
	if(decode_Is41Param(IS41PAR_SMSODS, MAX_IS41_VARPAR_LEN, &ptr->smsodsLen, ptr->smsods, &asn_buf))
		ptr->param_flag |= BIT11_TRUE;
	if(decode_Is41Param(IS41PAR_SMSOOA, MAX_IS41_VARPAR_LEN, &ptr->smsooaLen, ptr->smsooa, &asn_buf))
		ptr->param_flag |= BIT12_TRUE;
	if(decode_Is41Param(IS41PAR_SMSOOS, MAX_IS41_VARPAR_LEN, &ptr->smsoosLen, ptr->smsoos, &asn_buf))
		ptr->param_flag |= BIT13_TRUE;
	if(decode_Is41Param(IS41PAR_SMSOA, MAX_IS41_VARPAR_LEN, &ptr->smsoaLen, ptr->smsoa, &asn_buf))
		ptr->param_flag |= BIT14_TRUE;
	if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf))
		ptr->param_flag |= BIT15_TRUE;
	if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf))
		ptr->param_flag |= BIT16_TRUE;
	return 1;
}

int extract_is41ShortMessageAnalyzed_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf)
{
	ASN_BUF						asn_buf;
	struct IS41_SM_ANLYZD_RSP	*ptr;
	
	ptr = &opr_ptr->msg_list.smanlyzd_rsp;
	ptr->param_flag = 0;
	if(buf_len == 0)
	{
		is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!");
		return 0;
	}
	if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1)
		return 0;
	//optional
	if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf))
		ptr->param_flag |= BIT0_TRUE;
	if(decode_Is41Param(IS41PAR_SMSBD, 256, &ptr->smsbdLen, ptr->smsbd, &asn_buf))
		ptr->param_flag |= BIT1_TRUE;
	if(decode_Is41Param(IS41PAR_SMSCC, 32, &ptr->smscauseLen, ptr->smscause, &asn_buf))
		ptr->param_flag |= BIT2_TRUE;
	if(decode_Is41Param(IS41PAR_SMSEVENTNOT, 32, &ptr->sms_eventnotLen, ptr->sms_eventnot, &asn_buf))
		ptr->param_flag |= BIT3_TRUE;
	return 1;
}

