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

📄 rt4schi.c

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

#define __RTSCHI_C_

#ifdef __cplusplus
extern "C"{
#endif

#include "rt.h"

extern  MN_STATE Mn_state;



U1 rt_define_info_res(void)
{
	U1 *input_ptr = (U1*)&IN_MSGDAT->dat[2];
	U1 *output_ptr = 0;

	if (!( Rt_tim & TR3022ON ))
	{
		m_frebuf((U1 *)IN_DLDEVT->msg_adr);
		return (0);
	}

	if(IN_MSGDAT->dat[0] != RT_ID)
	{
		m_frebuf((U1 *)IN_DLDEVT->msg_adr);
		return(0);
	}

	OUT_PRIEVT->buf_adr = m_hntbuf( );
	OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S +2;
	output_ptr = OUT_PRIEVT->inf_adr;
	OUT_PRIEVT->inf_len = 0;
	if(input_ptr[0] == rt_definfo_res_info[0].element_id)
	{
		if(rt_definfo_res_info[0].type == TYP2)
		{
			move_up_b(output_ptr,input_ptr,rt_definfo_res_info[0].len);
			OUT_PRIEVT->inf_len = rt_definfo_res_info[0].len;
		}
		else if(rt_definfo_res_info[0].type == TYP1)
		{
			move_up_b(output_ptr,input_ptr,(U2)(input_ptr[1]+2));
			OUT_PRIEVT->inf_len = input_ptr[1] +2;
		}
	}
//	if(*input_ptr != AREA_INFO)
//	{
//		m_frebuf((U1 *)IN_DLDEVT->msg_adr);
//		return (0);
//	}
//	else
//	{
//		move_up_b(output_ptr,input_ptr,8);
//		OUT_PRIEVT->inf_len = 8;
//	}

	m_frebuf((U1 *)IN_DLDEVT->msg_adr);

	if ( Rt_defrq == 1 )
	{
		if ((OUT_PRIEVT->inf_len == 0|| OUT_PRIEVT->inf_adr[0] != AREA_INFO)
		 ||((OUT_PRIEVT->inf_adr[1] < 0x2c) || ( OUT_PRIEVT->inf_adr[1] > 0x72))
		 ||((OUT_PRIEVT->inf_adr[2] < 0x2c) || ( OUT_PRIEVT->inf_adr[2] > 0x72))
		 ||((OUT_PRIEVT->inf_adr[3] < 0x2c) || ( OUT_PRIEVT->inf_adr[3] > 0x72))
		 ||((OUT_PRIEVT->inf_adr[4] < 0x2c) || ( OUT_PRIEVT->inf_adr[4] > 0x72))
		 ||((OUT_PRIEVT->inf_adr[5] < 0x2c) || ( OUT_PRIEVT->inf_adr[5] > 0x72))
		 ||(OUT_PRIEVT->inf_adr[6] > 0xF0))
		{
			m_frebuf(OUT_PRIEVT->buf_adr);
			rt_tm_stop( TR3022ON );
			SYS_WORK->tsk_id = TASKMNG;
			OUT_PRIEVT->evt_cod = ERT;
			OUT_PRIEVT->pri_cod = PSDEFING;
			m_excreq( (WORD*)&SYS_WORK->tsk_id );
			return (0);
		}
	}
	rt_tm_stop( TR3022ON );
	SYS_WORK->tsk_id = TASKMNG;
	OUT_PRIEVT->evt_cod = ERT;
	OUT_PRIEVT->pri_cod = PSDEFINF;
	m_excreq( (WORD*)&SYS_WORK->tsk_id );
	return (0);
}


U1 rt_function_res(void)
{
	U1 *input_ptr = (U1*)&IN_MSGDAT->dat[2];
	U1 *output_ptr = 0;
	U1 length = IN_MSGDAT->len - 2;
	U1 chk = 0,info_len = 0;
	int i;

	if (!( Rt_tim & TR3021ON ))
	{
		m_frebuf((U1 *)IN_DLDEVT->msg_adr);
		return (0);
	}

	if(IN_MSGDAT->dat[0] != RT_ID)
	{
		m_frebuf((U1 *)IN_DLDEVT->msg_adr);
		return(0);
	}

	OUT_PRIEVT->buf_adr = m_hntbuf( );
	OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S +2;
	output_ptr = OUT_PRIEVT->inf_adr;
	OUT_PRIEVT->inf_len = 0;

	while(input_ptr < &IN_MSGDAT->dat[2] + length)
	{
		for(i=0;i<FUNC_ELEMENT_CNT;i++)
//		for(i=0;i<length;i++)
		{
			if(*input_ptr == rt_func_res_info[i].element_id)
			{
				if(input_ptr[0] &0x80)
				{
					*output_ptr = input_ptr[0] &0xf0;
					//OUT_PRIEVT->inf_len += 1;
					info_len =1;

				}
				else
				{
					if(rt_func_res_info[i].type == TYP2)
					{
						info_len =rt_func_res_info[i].len ;
					}
					else if(rt_func_res_info[i].type == TYP1)
					{
						info_len = input_ptr[1] +2;
					}
					move_up_b(output_ptr, input_ptr, info_len);
				}

				switch(*input_ptr)
				{
					case CONDITION_REPORT_FUNC:
//						info_len = 2;
//						move_up_b(output_ptr, input_ptr, info_len);
						chk |= BIT1;
						break;
					case ENCRYPTION:
//						info_len = 3;
//						move_up_b(output_ptr, input_ptr, info_len);
						chk |= BIT2;
						if( input_ptr[1] & 0xEE	|| input_ptr[2] & 0xF0 )   /* encryption ciphering type is no ciphering */
						{/* no encryption control during communication */
							m_frebuf((U1 *)IN_DLDEVT->msg_adr);
							m_frebuf(OUT_PRIEVT->buf_adr);
							return (0);
						}
						break;
					case VOX_FUNC_INFO:
//						info_len = 2;
//						move_up_b(output_ptr, input_ptr, info_len);
						chk |= BIT6;
						if( input_ptr[1] & 0xFE )    /* may be need to  update */
						{
							m_frebuf((U1 *)IN_DLDEVT->msg_adr);
							m_frebuf(OUT_PRIEVT->buf_adr);
							return (0);
						}
						break;
					case TCH_SWITCH:
//						info_len = 2;
//						move_up_b(output_ptr, input_ptr, info_len);
						chk |= BIT4;
						break;
					default:
						input_ptr[0] &= 0xf0;
						switch(*input_ptr)
						{
							case PSID_NOTIFY_CONTROL_INFO:
//								*output_ptr = *input_ptr;
//								info_len = 1;
								chk |= BIT3;

							case TRANS_POWER_CONTROL:
//								*output_ptr = *input_ptr;
//								info_len = 1;
								chk |= BIT5;
								break;
							case ZONE_INFO_IND_FUNC:
//								*output_ptr = *input_ptr;
//								info_len = 1;
								chk |= BIT7;
								break;
						}
				}
				PACKED_INT(output_ptr) += info_len;
				PACKED_INT(input_ptr) += info_len;
				OUT_PRIEVT->inf_len += info_len;
			}

		}

	}

	m_frebuf((U1 *)IN_DLDEVT->msg_adr);

	//if ( Rt_fncrq != chk )
	//{
		rt_tm_stop( TR3021ON );
		SYS_WORK->tsk_id = TASKMNG;
		OUT_PRIEVT->evt_cod = ERT;
		OUT_PRIEVT->pri_cod = PSRTFUNC;
		m_excreq( (WORD*)&SYS_WORK->tsk_id );
		//return (0);
	//}

	return (0);
}


U1 rt_channel_disconnect(void)
{

	U1 *input_ptr = (U1*)&IN_MSGDAT->dat[2];
	U1 *output_ptr = 0;
	U1 length = IN_MSGDAT->len - 2;
	U1 chk = 0,info_len = 0;
	int i;

	Rtlchsts = 0;
#if SIMU_ON_PC
      HisOut(0,0xda,0x0c,0,0);
#endif
	OUT_PRIEVT->buf_adr = m_hntbuf( );
	OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S +2;
	output_ptr = OUT_PRIEVT->inf_adr;
	OUT_PRIEVT->inf_len = 0;
	while(input_ptr < &IN_MSGDAT->dat[2] + length)
	{
		for(i=0;i<RADIO_DIS_ELEMENT_CNT;i++)
		{
			if(*input_ptr == rt_radio_dis_info[i].element_id)
			{
				if(rt_radio_dis_info[i].type == TYP2)
				{
					info_len =rt_radio_dis_info[i].len ;
				}
				else if(rt_radio_dis_info[i].type == TYP1)
				{
					info_len = input_ptr[1] +2;
				}
				move_up_b(output_ptr, input_ptr, info_len);
				Rtlchsts = 0x0F;
				switch(*input_ptr)
					{
						case CAUSE:
							Rtlchsts = IN_MSGDAT->dat[3] & ~BIT8;   /* PS side */
							break;
						case CS_ID:
							if(cmp_up_b(input_ptr +1, &Sys_ccsinf[5], 5)
								|| ((input_ptr[6] & 0x03) != Sys_ccsinf[10]))
							{
								m_frebuf((U1 *)IN_DLDEVT->msg_adr);
								m_frebuf(OUT_PRIEVT->buf_adr);
								return (0);
							}
							break;
						case PS_ID:
							if ( cmp_up_b(&input_ptr[1], Sys_psid, 3)
								|| ((input_ptr[4] & 0x0F) != Sys_psid[3] ))
							{
								m_frebuf((U1 *)IN_DLDEVT->msg_adr);
								m_frebuf(OUT_PRIEVT->buf_adr);
								return (0);
							}
							break;
					}

				PACKED_INT(output_ptr) += info_len;
				PACKED_INT(input_ptr) += info_len;
				OUT_PRIEVT->inf_len += info_len;
			}
			else
			{
				if(rt_radio_dis_info[i].option == MANDA)
				{
					m_frebuf((U1 *)IN_DLDEVT->msg_adr);
					m_frebuf(OUT_PRIEVT->buf_adr);
					return (0);
				}
			}
		}
	}

	m_frebuf((U1 *)IN_DLDEVT->msg_adr);
	m_frebuf(OUT_PRIEVT->buf_adr);

	rt_trstp();
	SYS_WORK->tsk_id = TASKL2;
	OUT_DLDEVT->evt_cod = EDLUDTRQ;
	OUT_DLDEVT->dl_typ = FACCH;
	OUT_DLDEVT->dl_id = IN_DLDEVT->dl_id;
	OUT_DLDEVT->dl_sou = 1;
	OUT_DLDEVT->msg_adr = (RT_MSGDAT *)m_hntbuf();
	OUT_MSGDAT->len = 14;
	OUT_MSGDAT->dat[0] = RT_ID;
	OUT_MSGDAT->dat[1] = RTL2_RADIO_CHANNEL_DISC_COMP;
	OUT_MSGDAT->dat[2] = CS_ID;
	move_up_b((U1*) &OUT_MSGDAT->dat[3], SYS_CSID_P, 6 );
	OUT_MSGDAT->dat[9] = PS_ID;
	move_up_b( (U1*)&OUT_MSGDAT->dat[10], Sys_psid, 4 );
	m_excreq( (WORD*)&SYS_WORK->tsk_id );

	//Rt_sts = ST_RAD_DIS;
	Rt_sts = (U1)rt_state_table->state;
	return (2);
}

/********************************************************************************************************/
/*                                                                          				*/
/*		NUMBER		13                                                      		*/
/*		CALL		void rt_tch_switch_ind		                			*/
/*		PARAM		tx_cac is lch request message content					*/
/*		DISCRIPTION:	parse switch indiction message and get switch type.			*/
/*				message contains carrier number,csid,slotnumber				*/
/*													*/
/*		RETURN:											*/
/********************************************************************************************************/

U1 rt_tch_switch_ind(void)
{

	U1 tch_re;
	U1	abs_slot;
	U1 *input_ptr = (U1*)&IN_MSGDAT->dat[2];
	U1 *output_ptr = 0;
	U1 length = IN_MSGDAT->len - 2;
	U1 chk = 0,info_len = 0;
	int i;

	if ((Cc_sts != 10) && (IN_DLDEVT->dl_id == TCH1))
	{/* not communication state */
		if((ReCall == ON) && (Mn_state.public_mod == 6)
			&& (OUT_PRIEVT->inf_len == 0))

		{
			seam_outo_jump();
		}
		else
		{  /* if nou communication state,then discard the message */
			m_frebuf((U1 *)IN_DLDEVT->msg_adr);
			return (0);
		}
	}

	OUT_PRIEVT->buf_adr = m_hntbuf( );
	OUT_PRIEVT->inf_adr = OUT_PRIEVT->buf_adr+MSB_S +2;
	output_ptr = OUT_PRIEVT->inf_adr;
	OUT_PRIEVT->inf_len = 0;

	move_up_b( (U1 *)&Rt_radbak, (U1 *)&Rt_radinf, sizeof(Rt_radinf) );   /* backup radio information */
	Rt_radinf.car_num = 0x00;   /* initial the current radio info */
	Rt_radinf.slt_num = 0xFF;
	set_up_b(Rt_rcsid, 0, 7);
	while(input_ptr < &IN_MSGDAT->dat[2] + length)   /* parse switch indiction message */
	{
		for(i=0;i<SWITCH_IND_ELEMENT_CNT;i++)
//		for(i=0;i<length;i++)
		{
			if(*input_ptr == rt_switch_ind_info[i].element_id)
			{
				if(rt_switch_ind_info[i].type == TYP2)
				{
					info_len =rt_switch_ind_info[i].len ;
				}
				else if(rt_switch_ind_info[i].type == TYP1)
				{
					info_len = input_ptr[1] +2;
				}
				move_up_b(output_ptr, input_ptr, info_len);

				switch(*input_ptr)  /* information element */
				{
					case CARRIER_NUMBER:
						if(rt_carr_chk(input_ptr[1]) != OK )
						{
							m_frebuf((U1 *)IN_DLDEVT->msg_adr);
							m_frebuf(OUT_PRIEVT->buf_adr);
							move_up_b((U1 *)&Rt_radinf,(U1 *)&Rt_radbak,sizeof(Rt_radinf));
							return (0);
						}
						Rt_radinf.car_num = input_ptr[1];

//						info_len = 2;
//						move_up_b(output_ptr, input_ptr, info_len);
						break;

					case CS_ID:
						if ((Sys_ccsinf[5] != input_ptr[1])   /* compare operator id of CS */
							|| ((Sys_ccsinf[6] & BIT8)!= (input_ptr[2] & BIT8)))
						{/* if operator id is not same */
							m_frebuf((U1 *)IN_DLDEVT->msg_adr);
							m_frebuf(OUT_PRIEVT->buf_adr);
							move_up_b((U1 *)&Rt_radinf,(U1 *)&Rt_radbak,sizeof(Rt_radinf));
							return (0);
						}
						Rt_rcsid[6] = 1;
						move_up_b( Rt_rcsid, &input_ptr[1], 5 );
						Rt_rcsid[5] = input_ptr[6] & 0x03;

//						info_len = 7;
//						move_up_b(output_ptr, input_ptr, info_len);
						break;

					case SCH_TYPE:
//						info_len = 3;
//						move_up_b(output_ptr, input_ptr, info_len);
						break;
					case SLOT_NUMBER:
						if(input_ptr[1] & BIT8)	 /* bit8 reserved */
						{
							m_frebuf((U1 *)IN_DLDEVT->msg_adr);
							m_frebuf(OUT_PRIEVT->buf_adr);
							move_up_b((U1 *)&Rt_radinf,(U1 *)&Rt_radbak,sizeof(Rt_radinf));
							return (0);
						}
						abs_slot = (input_ptr[1] & 0x60) >> 5;  /* absolute slot number */

⌨️ 快捷键说明

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