⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cc1ind.c

📁 phs 源代码 小灵通协议源代码 phs source code
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************************************/
/** 		Copyright (c) 1998, UTStarcom, Inc. 			*/
/**			 All Rights Reserved. 				*/
/** 									*/
/** Subsystem: 		CC 						*/
/** File: 		cc1ind.c 					*/
/** Created By: 	tara zhang					*/
/** Created On: 	08/02/2003					*/
/** 									*/
/** Purpose:								*/
/** 	This file handle received message from L2 .			*/
/**									*/
/** Necessary Compilation Flags: FLAG_1, , FLAG_N 			*/
/**********************************************************************	*/
/** Modify by: 								*/
/** Modify purpose:							*/
/************************************************************************/
#ifndef PM_ONPC

#define __CC1IND_C_

#ifdef __cplusplus
extern "C"{
#endif

#include "cc.h"



/************************************************************************/
/*Function Name : cc_setup_ind						*/
/*Function	: handle the call setup message received from CS.	*/
/* Process	: 							*/
/* Comment 	: parse setup message,if message content is correct 	*/
/*			then send setup indiction to MN			*/
/* Author 	: tara zhang 						*/
/* Time 	: 2003/08/02 						*/
/* Return Value : none 							*/
/* Parameter 	: none							*/
/************************************************************************/
/** Modify by: MMM, MM/dd/yy						*/
/** Modify purpose:							*/
/************************************************************************/
void cc_setup_ind()
{
	U1 *input_ptr = (U1*)&IN_MSGDAT->dat[4];  /* input message data,not contain message header */
	U1 *output_ptr = NULL;     		/* output message buffer */
	U1 length = IN_MSGDAT->len - 4;      /* the length not contain header */
	U1 info_len = 0;
	U1 msg_flag = 0;
	U1 ret = NG_FF;
	int i;
	U1 reason = 0;

	OUT_PRIEVT->buf_adr = m_hntbuf( );    		/* malloc memory */
	if(OUT_PRIEVT->buf_adr == NULL)
	{
		return;
	}

	OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S;  /* output pointer address */
	output_ptr = OUT_PRIEVT->inf_adr;		/* output pointer address */
	OUT_PRIEVT->inf_len = 0;			/* output data length */

	i = 0;
	while(input_ptr < &IN_MSGDAT->dat[4] + length)
		{
			info_len = input_ptr[1] +2;   /* every information element content length */
			if ( info_len < 2 )
				info_len = 0xFF;

			for( ; i < SETUP_ELEMENT_CNT; i++ )
			{
				if(*input_ptr == cc_setup_info[i].element_id)
				{
					ret = cc_info_element_chk(input_ptr);  /* check information element whether or not correct */

					if(*input_ptr & BIT8)  /* if single information element */
					{
					        PACKED_INT(input_ptr) ++;
						if(ret == NG && lock_shift_flag== 1) /* mandatory if codeset is shifted */
							msg_flag |= BIT4;   // mandatory information element content error.
							continue;
					}
					else
					{
						if(ret == 0x58)   /* incompatible destination(if bear capability occur error) */
							msg_flag = 0x58;
						if(ret == NG && (cc_setup_info[i].man_flag == MANDA))
							msg_flag |= BIT4;	/* mandatory information element content error */
						else if(ret == NG)
							msg_flag |= BIT3;   /* option information element content error */
					}
					move_up_b( output_ptr, input_ptr, info_len );
					PACKED_INT(output_ptr) += info_len;
					PACKED_INT(input_ptr) += info_len;
					OUT_PRIEVT->inf_len += info_len;
					i++;
					break;
				}
				else if(*input_ptr != cc_setup_info[i].element_id)
				{
					if(cc_setup_info[i].option_id == MANDA)
					{
						msg_flag |= BIT2;    // mandatory information element is missing
						i++;
						break;
					}
					continue;
				}
			}
			if (i == SETUP_ELEMENT_CNT)
			{
				msg_flag |= BIT1;   /* information element not exist / not implemented */
			}
		}
	if ( ((msg_flag & 0xfa ) == 0 )	&& ( cc_speed_flg == OK ) )
	{   /* send message to MN */
		SYS_WORK->tsk_id = TASKMNG;   /* set task id*/
		OUT_PRIEVT->evt_cod = ECC;    /* set event code*/
		OUT_PRIEVT->pri_cod = PSCALSET;  /* set message type */
		OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S;  /* information element pointer */

		m_excreq( (U2*)&SYS_WORK->tsk_id );

		if(p_state_table->state != 0xff)   /* in state machine,find state */
		{
			//SYS_WORK->call_state = p_state_table->state;
			Cc_sts = (U1)p_state_table->state;
		}

		if ( msg_flag & 0x05 )
		{
			reason = 0x62;
			cc_cause_state(reason,msg_flag );  /* send status message	*/
		}
	}
	else
	{
		if ( msg_flag & BIT2 )   /* mandatory infomation element is missing */
			reason = 0x60;
		else if ( msg_flag & BIT4 )  /* mandatory information element content error */
			reason = 0x64;
		else if ( cc_speed_flg == NG  || (msg_flag == 0x58 ))  /* incompatible destination(if bear capability occur error) */
			reason = 0x58;

		OUT_DLDEVT->msg_adr = (CC_MSGDAT *)OUT_PRIEVT->buf_adr;  /* get memory */
		cc_cause_rel_comp(reason);  /* send release complete message	*/

		disconnect_complete_flag = 1;
	}
}


/************************************************************************/
/*Function Name : cc_alert_ind						*/
/*Function	: handle the call alert message received from CS.	*/
/* Process	: 							*/
/* Comment 	: parse alert message,if message content is correct 	*/
/*			then send alert indiction to MN			*/
/* Author 	: tara zhang 						*/
/* Time 	: 2003/08/02 						*/
/* Return Value : none 							*/
/* Parameter 	: none							*/
/************************************************************************/
/** Modify by: MMM, MM/dd/yy						*/
/** Modify purpose:							*/
/************************************************************************/
void cc_alert_ind( )
{
	U1 *input_ptr = (U1*)&IN_MSGDAT->dat[4];    /* input message data,not contain message header */
	U1 *output_ptr = NULL;                /* output message buffer */
	U1 length = IN_MSGDAT->len - 4;        /* the length not contain header */
	U1 info_len = 0;
	U1 msg_flag = 0;
	U1 ret = NG_FF;
	int i;
	U1 reason =0;

	OUT_PRIEVT->buf_adr = m_hntbuf( );			/* malloc memory */
	if(OUT_PRIEVT->buf_adr == NULL)
	{
		return;
	}

	OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S;          /* output pointer address */
	output_ptr = OUT_PRIEVT->inf_adr;                       /* output pointer address */
	OUT_PRIEVT->inf_len = 0;                                /* output data length */

	if(length == 0)   /* not contain any information element */
	{
		m_frebuf(OUT_PRIEVT->buf_adr);
		OUT_PRIEVT->inf_len = 0;
		OUT_PRIEVT->buf_adr = 0;
		OUT_PRIEVT->inf_adr = 0;

	}
	else if(length >0)
	{
		i = 0;
		while(input_ptr < &IN_MSGDAT->dat[4] + length)
		{
			info_len = input_ptr[1] +2;   /* every information element content length */
			if ( info_len < 2 )
				info_len = 0xFF;

			for(; i < ALERT_ELEMENT_CNT; i++ )
			{
				if(*input_ptr == cc_alert_info[i].element_id)
				{
					ret = cc_info_element_chk(input_ptr);   /* check information element content */
					if(ret == NG && (cc_alert_info[i].man_flag == MANDA))
						msg_flag |= BIT4;	/* mandatory information element content error */
					else if(ret == NG)
						msg_flag |= BIT3;   /* option information element content error */

					move_up_b( output_ptr, input_ptr, info_len );
					PACKED_INT(output_ptr) += info_len;
					PACKED_INT(input_ptr) += info_len;
					OUT_PRIEVT->inf_len += info_len;
					i++;
					break;
				}
				else if(*input_ptr != cc_alert_info[i].element_id)
				{
					if(cc_alert_info[i].option_id == MANDA)
					{
						msg_flag |= BIT2;    // mandatory information element is missing
						i++;
						break;
					}
					continue;

				}
			}
			if (i == ALERT_ELEMENT_CNT)
			{
				msg_flag |= BIT1;  /* information element not exist / not implemented */
			}
		}
	}
	else
		msg_flag |= BIT2;  // mandatory information element is missing

	//if((OUT_PRIEVT->inf_len == 0)&&((msg_flag & 0xfa) == 0))
		//m_frebuf(OUT_PRIEVT->buf_adr);

	cc_stop_time( TC303ON );   /* stop timer tc303p */

	if((msg_flag & 0xfa) == 0)   /* send alert indiction message to MN */
	{
		SYS_WORK->tsk_id = TASKMNG;				/* set task id */
		OUT_PRIEVT->evt_cod = ECC;              		/* set event code */
		OUT_PRIEVT->pri_cod = PSCALCON;         	/* set message type */
		m_excreq( (U2*)&SYS_WORK->tsk_id );          	/* send out */

		if(p_state_table->state != 0xff)
		{
//			SYS_WORK->call_state = p_state_table->state;
			Cc_sts = (U1)p_state_table->state;  /* cc state change to P4 state */
		}
	}
	if(msg_flag)   /* messag have some error */
	{
	     reason = 0x62;
	     cc_cause_state(reason,msg_flag);
	}

}


/************************************************************************/
/*Function Name : cc_progress_ind						*/
/*Function	: handle the call progress message received from CS.	*/
/* Process	: 							*/
/* Comment 	: parse progress message,if message content is correct 	*/
/*			then send progress indiction to MN			*/
/* Author 	: tara zhang 						*/
/* Time 	: 2003/08/02 						*/
/* Return Value : none 							*/
/* Parameter 	: none							*/
/************************************************************************/
/** Modify by: MMM, MM/dd/yy						*/
/** Modify purpose:							*/
/************************************************************************/
void cc_progress_ind( )
{
	U1 *input_ptr = (U1*)&IN_MSGDAT->dat[4];          /* input message data,not contain message header */
	U1 *output_ptr = NULL;                      /* output message buffer */
	U1 length = IN_MSGDAT->len - 4;              /* the length not contain header */
	U1 info_len = 0;
	U1 msg_flag = 0;
	U1 ret = NG_FF;
	int i;
	U1 reason =0;

	OUT_PRIEVT->buf_adr = m_hntbuf( );			/* malloc memory */
	if(OUT_PRIEVT->buf_adr == NULL)
	{
		return;
	}

	OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S;          /* output pointer address */
	output_ptr = OUT_PRIEVT->inf_adr;                       /* output pointer address */
	OUT_PRIEVT->inf_len = 0;                                /* output data length */

	if(length > 0)
	{
		i =0;
		while(input_ptr < &IN_MSGDAT->dat[4] + length)
		{
			info_len = input_ptr[1] +2;    /* every information element content length */
			if ( info_len < 2 )
				info_len = 0xFF;

			for( ; i < PROGRESS_ELEMENT_CNT; i++ )
			{
				if(*input_ptr == cc_progress_info[i].element_id)
				{
					ret = cc_info_element_chk(input_ptr);   /* check information element content */
					if(ret == NG && (cc_progress_info[i].man_flag == MANDA))
						msg_flag |= BIT4;	/* mandatory information element content error */
					else if(ret == NG)
						msg_flag |= BIT3;   /* option info element content error */

					move_up_b( output_ptr, input_ptr, info_len );
					PACKED_INT(output_ptr) += info_len;
					PACKED_INT(input_ptr) += info_len;

					OUT_PRIEVT->inf_len += info_len;
					i++;
					break;
				}
				else if(*input_ptr != cc_progress_info[i].element_id)
				{
					if(cc_progress_info[i].option_id == MANDA)
					{
						msg_flag |= BIT2;    // mandatory information element is missing
						i++;
						break;
					}
					continue;

				}
			}
			if (i == PROGRESS_ELEMENT_CNT)
			{
				msg_flag |= BIT1;   /* information element not exist / not implemented */
			}
		}
	}
	else
		msg_flag |= BIT2; // mandatory information element is missing

	if((msg_flag & 0xfa) == 0)   /* send progress indication to MN */
	{
		SYS_WORK->tsk_id = TASKMNG;  /* set task id */
		OUT_PRIEVT->evt_cod = ECC;  /* set event code */
		OUT_PRIEVT->pri_cod = PSPRGRES;  /* set message type */
		OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S;

		m_excreq( (U2*)&SYS_WORK->tsk_id );
	}
	if(msg_flag)   /* messag have some error */
	{
	     reason = 0x62;
	     cc_cause_state(reason,msg_flag);  /* send status message */
	}
}

/************************************************************************/
/*Function Name : cc_proceed_ind						*/
/*Function	: handle the call proceed message received from CS.	*/
/* Process	: 							*/
/* Comment 	: parse proceed message,if message content is correct 	*/
/*			then send proceed indiction to MN			*/
/* Author 	: tara zhang 						*/
/* Time 	: 2003/08/02 						*/
/* Return Value : none 							*/
/* Parameter 	: none							*/
/************************************************************************/
/** Modify by: MMM, MM/dd/yy						*/
/** Modify purpose:							*/
/************************************************************************/
void cc_proceed_ind( )
{
	U1 *input_ptr = (U1*)&IN_MSGDAT->dat[4];    /* input message data,not contain message header */
	U1 *output_ptr = NULL;                /* output message buffer */
	U1 length = IN_MSGDAT->len - 4;        /* the length not contain header */
	U1 info_len = 0;
	U1 msg_flag = 0;
	U1 ret = NG_FF;
	int i;
	U1 reason =0;

#ifdef EXT_IO
        HisOut(0,0xda,0x0b,0,0);
#endif
	OUT_PRIEVT->buf_adr = m_hntbuf( );			/* malloc memory */
	if(OUT_PRIEVT->buf_adr == NULL)
	{
		return;
	}

	OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S;          /* output pointer address */
	output_ptr = OUT_PRIEVT->inf_adr;                       /* output pointer address */
	OUT_PRIEVT->inf_len = 0;                                /* output data length */

	if(length == 0)  /* not contain any information element */
	{
		m_frebuf(OUT_PRIEVT->buf_adr);
		OUT_PRIEVT->inf_len = 0;
		OUT_PRIEVT->buf_adr = 0;
		OUT_PRIEVT->inf_adr = 0;
	}
	else if(length > 0)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -