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

📄 cc1ind.c

📁 phs 源代码 小灵通协议源代码 phs source code
💻 C
📖 第 1 页 / 共 5 页
字号:
	{
		reason = 0x62;
	        cc_cause_state(reason,msg_flag);
	}
}

/************************************************************************/
/*Function Name : cc_notify_ind						*/
/*Function	: handle the notify message received from CS.	*/
/* Process	: 							*/
/* Comment 	: parse notify message,if message content is correct 	*/
/*			then send notify 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_notify_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;
			if ( info_len < 2 )
				info_len = 0xFF;

			for(; i < NOTIFY_ELEMENT_CNT; i++ )
			{
				if(*input_ptr == cc_notify_info[i].element_id)
				{
					ret = cc_info_element_chk(input_ptr);    /* check information element content */

					if(ret == NG && (cc_notify_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_notify_info[i].element_id)
				{
					if(cc_notify_info[i].option_id == MANDA)
					{
						msg_flag |= BIT2;    // mandatory information element is missing
						i++;
						break;
					}
					continue;
				}
			}
			if (i == NOTIFY_ELEMENT_CNT)
			{
				msg_flag |= BIT1;
			}
		}
		if (( OUT_PRIEVT->inf_len == 0 ) && ((msg_flag & 0xfa ) == 0 ))
		{
			m_frebuf( OUT_PRIEVT->buf_adr );
			OUT_PRIEVT->buf_adr = 0;
			OUT_PRIEVT->inf_adr = 0;
		}

	}
	else
		msg_flag |= BIT2;  // mandatory information element is missing

	if((msg_flag & 0xfa) == 0)
	{
		SYS_WORK->tsk_id = TASKMNG;
		OUT_PRIEVT->evt_cod = ECC;
		OUT_PRIEVT->pri_cod = PSTHRU;
		m_excreq( (U2*)&SYS_WORK->tsk_id );
	}
	else
	{
		reason = 0x62;
	        cc_cause_state(reason,msg_flag);
	}
}

/************************************************************************/
/*Function Name : cc_state_ind						*/
/*Function	: handle the call status message received from CS.	*/
/* Process	: 							*/
/* Comment 	: parse call status message,				*/
/* Author 	: tara zhang 						*/
/* Time 	: 2003/08/02 						*/
/* Return Value : none 							*/
/* Parameter 	: none							*/
/************************************************************************/
/** Modify by: MMM, MM/dd/yy						*/
/** Modify purpose:							*/
/************************************************************************/
void cc_state_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 */

//	p_call_state  = SYS_WORK->call_state;
	p_call_state = Cc_sts;

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

		for( ; i < STATE_ELEMENT_CNT; i++ )
		{
			if(*input_ptr == cc_state_info[i].element_id)
			{
				ret = cc_info_element_chk(input_ptr); /* check information element content */

				if(ret == NG && (cc_state_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_state_info[i].element_id)
			{
				if(cc_state_info[i].option_id == MANDA)
				{
					msg_flag |= BIT2;    // mandatory information element is missing
					i++;
					break;
				}
				continue;
			}
		}
		if (i == STATE_ELEMENT_CNT)
		{
			msg_flag |= BIT1;   /* information element not exist / not implemented */
		}
	}

	if(p_call_state == 0)
	{
		if((msg_flag & 0xfa) == 0 )  /* if mandatory information element is correct */
		{
			if ( OUT_PRIEVT->inf_len == 0 )
			{
				m_frebuf( OUT_PRIEVT->buf_adr );  /* free memory */
				OUT_PRIEVT->buf_adr = 0;
				OUT_PRIEVT->inf_adr = 0;
			}

			SYS_WORK->tsk_id = TASKMNG;      	/* set task id */
			OUT_PRIEVT->evt_cod = ECC;       	/* set event code */
			OUT_PRIEVT->pri_cod = PSCALFAL;  /* set message type */
			m_excreq((U2*) &SYS_WORK->tsk_id );   /* send out */

			cc_init();   /* cc initial */
			//SYS_WORK->call_state = ST_NULL;
		}
		else  /* manda info element have some error */
		{
			reason = 0x62;
		        cc_cause_state(reason,msg_flag);  /* send status message*/
		}
	}
	//else if(( p_call_state != SYS_WORK->call_state ) && ( SYS_WORK->call_state != ST_RELREQ ))
	else if(( p_call_state != Cc_sts) && ( Cc_sts != ST_RELREQ ))
	{
		OUT_DLDEVT->msg_adr = (CC_MSGDAT *)OUT_PRIEVT->buf_adr;
		reason = 0x65;
		cc_cause_release(reason,msg_flag,CCL2_RELEASE);

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

		cc_stop_time( Cc_tim );
		cc_set_time( TC308ON );
		Cc_timcm &= ~TC308ON;

		if(p_state_table->state != 0xff)    //zch0710
		{
			Cc_sts = (U1)p_state_table->state;
		}
	}
	else
	{
		if (( msg_flag & 0xfa ) == 0 )
		{
			m_frebuf( OUT_PRIEVT->buf_adr );
		}
		if (msg_flag)
		{
			reason = 0x62;
		        cc_cause_state(reason,msg_flag);
		}
	}
}


/************************************************************************/
/*Function Name : cc_state_p0_ind						*/
/*Function	: handle status message at P0 state	*/
/* Process	: 							*/
/* Comment 	: parse call status message		*/
/* Author 	: tara zhang 						*/
/* Time 	: 2003/08/02 						*/
/* Return Value : none 							*/
/* Parameter 	: none							*/
/************************************************************************/
/** Modify by: MMM, MM/dd/yy						*/
/** Modify purpose:							*/
/************************************************************************/
void cc_state_p0_ind( void )
{
	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_DLDEVT->msg_adr = (CC_MSGDAT *)m_hntbuf( );   			/* malloc memory */
	if(OUT_DLDEVT->msg_adr == NULL)
	{
		return;
	}

	//OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S;          /* output pointer address */
	output_ptr = (U1*)&OUT_MSGDAT->dat[4];
	//output_ptr = OUT_PRIEVT->inf_adr;                       /* output pointer address */
	OUT_MSGDAT->len = 0;                                /* output data length */

//	if ( Cc_sts )
//		SYS_WORK->call_reference_value = Cc_txnum;

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

		for( ; i < STATE_ELEMENT_CNT; i++ )
		{
			if(*input_ptr == cc_state_info[i].element_id)
			{
				ret = cc_info_element_chk(input_ptr);  /* check information element content */

				if(ret == NG && (cc_state_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_MSGDAT->len += info_len;
				i++;
				break;
			}
			else if(*input_ptr != cc_state_info[i].element_id)
			{
				if(cc_state_info[i].option_id == MANDA)
				{
					msg_flag |= BIT2;    // mandatory information element is missing
					i++;
					break;
				}
				continue;
			}
		}
		if (i == STATE_ELEMENT_CNT)
		{
			msg_flag |= BIT1;  /* information element not exist / not implemented */
		}
	}

	if ( p_call_state == 0 )  /* if callstate value is P0	*/
	{
		if (( msg_flag & 0xfa ) == 0 )
			m_frebuf( (U1 *)OUT_DLDEVT->msg_adr );  /* free memory */
		if (msg_flag )  /* info element have some error */
		{
			OUT_PRIEVT->buf_adr = (U1 *)OUT_DLDEVT->msg_adr;
			reason = 0x62;
			cc_cause_state(reason,msg_flag );  /* send status message	*/
		}
	}
	else
	{
		reason = 0x65;

		if( msg_flag & BIT2 ) /* manda info element absent */
			reason = 0x60;
		else if (msg_flag & BIT3 )  /* option info element content error */
			reason = 0x64;
		else if( msg_flag & BIT1 ) /* unknown info element  */
			reason = 0x63;

		cc_cause_rel_comp(reason);  /*  write release complete message	*/
		disconnect_complete_flag = 1;
	}
}

/****************************************************************************/
/*                                                                          */
/*		NUMBER		40                                          */
/*		CALL		void cc_err		  		*/
/*		PARAM		void                                     */
/*		FUNC		handle error message			*/
/*		RETURN		void                                    */
/*		GLOBAL							*/
/*																			*/
/****************************************************************************/
void cc_err( )
{
	if ( L2_OPTMIN <= p_msg_header->msg_type && p_msg_header->msg_type <= L2_OPTMAX )
 	{/* in option range */
		OUT_PRIEVT->buf_adr = m_hntbuf( );   /* get memory */
		if(OUT_PRIEVT->buf_adr == NULL)
		{
			return;
		}
		OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S;
		OUT_PRIEVT->inf_len = (U2)(IN_MSGDAT->len-CC_FMT_SZ+1);
		move_up_b( OUT_PRIEVT->inf_adr, (U1*)&IN_MSGDAT->dat[4], OUT_PRIEVT->inf_len ); /* copy info content */

		SYS_WORK->tsk_id = TASKMNG;          	/* set task id*/
		OUT_PRIEVT->evt_cod = ECC;           	/*  set event code */
		OUT_PRIEVT->pri_cod = PSCALOPT;      /* set message type */
		m_excreq( (U2*)&SYS_WORK->tsk_id );       /*  send out */
	}
	else
	{
		OUT_DLDEVT->msg_adr = (CC_MSGDAT *)m_hntbuf( );  /* get memory */
		if(OUT_DLDEVT->msg_adr == NULL)
		{
			return;
		}
		OUT_MSGDAT->len = 12;   /* output message length */
		SYS_WORK->out_ptr = (U1*)&IN_MSGDAT->dat[4];  /*  output message data pointer */
		cc_cause_write( 0x62 );   /* message not compatible with call state / message type not exist
						/not implemented. */
		PACKED_INT(SYS_WORK->out_ptr)++;
		cc_call_state_write();     /* write call state info*/
		cc_msg_write( CCL2_STATE );  /*  write status message */
		m_excreq( (U2*)&SYS_WORK->tsk_id );
	}
}


/****************************************************************************/
/*                                                                          */
/*		NUMBER		48                                                      */
/*		CALL		void cc_dlcnf    				                        */
/*		PARAM		void                                                   */
/*		FUNC		handel dl confirm message received from L2 						*/
/*		RETURN		void                                         */
/*		GLOBAL									*/
/*                                                                          */
/****************************************************************************/
void cc_dlcnf( )
{
	SYS_WORK->

⌨️ 快捷键说明

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