📄 cc0main.c
字号:
/************************************************************************/
/** Copyright (c) 1998, UTStarcom, Inc. */
/** All Rights Reserved. */
/** */
/** Subsystem: CC */
/** File: cc0main.c */
/** Created By: tara zhang */
/** Created On: 08/02/2003 */
/** */
/** Purpose: */
/** This file contains CC part entry and parse information element .*/
/** */
/** Necessary Compilation Flags: FLAG_1, , FLAG_N */
/********************************************************************** */
/** Modify by: */
/** Modify purpose: */
/************************************************************************/
#ifndef PM_ONPC
#ifdef __cplusplus
extern "C"{
#endif
#define __CC0MAIN_C_
#include "cc.h"
/*************************************************************************************
FUNCTION: cc_main
DESCRIPTION:
CC entry point
ARGUMENTS PASSED:
None.
RETURN VALUE:
None
Revision History:
Modification Tracking
Author Date Number Description of Changes
------------------------- ------------ ---------- ------------------------------
tara zhang 08/06/2003 Initial version.
**************************************************************************************/
#ifdef _ON_SANYO_
U1 cc_main(void)
#else
U1 cc_main(void *mbox)
#endif
{
#ifndef _ON_SANYO_
memcpy ((void *) cc_syswork.in_evt, (const void *)(((EV_BUF_ST *)mbox)->event), sizeof (cc_syswork.in_evt));
#endif
p_state_table = cc_state_table[Cc_sts]; // SYS_WORK->state_table
set_up_b((U1 *)SYS_WORK->out_evt, 0, sizeof(SYS_WORK->out_evt));
version = Sys_ccsinf[19];
if ( cc_msg_source( ) == CALL_L2 ) /* judge the event source */
{
p_msg_header = (cc_msg_header*)((BYTE*)IN_DLDEVT->msg_adr + 6);
#ifdef EXT_IO
HisOut(0x00,0xcc,Cc_sts,p_msg_header->msg_type,0x00);
#endif
if(cc_check_msg_header(p_msg_header) == OK) /* check message header from L2 */
{
for(;!(p_msg_header->msg_type == p_state_table->evt_code || p_state_table->evt_code == 0xff);p_state_table++);
/* find event code in state mahcine table*/
if(!(p_state_table->fnc_adr))
{ /* event not in state machine table */
if(Cc_sts == ST_NULL)
cc_p0_err();
else
cc_err();
if (IN_MSGDAT->next_po)
{
m_frebuf(IN_MSGDAT->next_po); /* free memory */
}
}
else /* founded in state machine table */
{
p_state_table->fnc_adr(); /* handle received message */
}
if (( IN_DLDEVT->evt_cod == EDLDTDSP ) || ( IN_DLDEVT->evt_cod == EDLUDTDSP ))
{
if (IN_MSGDAT->next_po)
{
m_frebuf(IN_MSGDAT->next_po); /* free memory */
}
if ( IN_DLDEVT->msg_adr )
{
m_frebuf((U1 *)IN_DLDEVT->msg_adr); /* free memory */
}
}
}
else /* message header have some error */
{
if ( IN_DLDEVT->msg_adr ) /* free memory */
{
if (IN_MSGDAT->next_po)
{
m_frebuf(IN_MSGDAT->next_po);
}
m_frebuf( (U1 *)IN_DLDEVT->msg_adr );
}
}
}
else
{
if (SYS_WORK->in_evt[0] == EDLDTRS ) IN_PRIEVT->pri_cod = EDLDTRS;
for(;!(IN_PRIEVT->pri_cod == p_state_table->evt_code || p_state_table->evt_code == 0xff);p_state_table++);
/* find event code in state mahcine table*/
if(!(p_state_table->fnc_adr))
{/* event not in state machine table */
if (SYS_WORK->in_evt[0] == EINITL3)
{
cc_init();
return( 0 );
}
}
else /* founded in state machine table */
{
p_state_table->fnc_adr(); /* handle received event from high layer */
}
if (( SYS_WORK->in_evt[0] != EDLDTRS ) && ( SYS_WORK->in_evt[0] != EINITL3 ))
{
if ( IN_PRIEVT->buf_adr )
{
m_frebuf( (U1 *)IN_PRIEVT->buf_adr ); /* free memory */
}
}
}
return ( (U1)disconnect_complete_flag );
}
/****************************************************************************
NUMBER 2
CALL U1 cc_msg_source(void)
PARAM void
FUNC judge event source
RETURN CALL_L2: event from L2 layer
CALL_MNG:event from high layer
Revision History:
Modification Tracking
Author Date Number Description of Changes
------------------------- ------------ ---------- ------------------------------
tara zhang 08/06/2003 Initial version.
****************************************************************************/
U1 cc_msg_source( void )
{
U1 ret;
switch( SYS_WORK->in_evt[0] ) /* event code */
{
case EDLDTDSP:
case EDLUDTDSP:
ret = CALL_L2; /* event from data link layer */
break;
case EDLDTRS:
case EINITL3:
case ECC:
ret = CALL_MNG; /* event from high layer */
break;
}
return( ret );
}
/****************************************************************************
NUMBER 2
CALL U1 cc_cause_state(void)
PARAM reason: cause type
msg_flag:message content state
FUNC send call state event to cs
RETURN void
Revision History:
Modification Tracking
Author Date Number Description of Changes
------------------------- ------------ ---------- ------------------------------
tara zhang 08/06/2003 Initial version.
****************************************************************************/
void cc_cause_state(U1 reason,U1 msg_flag)
{
if (((msg_flag & 0xfa ) == 0) && ( msg_flag & 0x05 )) /* msg_flag = bit1 or bit3 (option info element error) */
{
OUT_DLDEVT->msg_adr = (CC_MSGDAT *)m_hntbuf( );
}
else /* msg_flag = bit2 or bit4(mandaroty info element error) */
{
OUT_DLDEVT->msg_adr = (CC_MSGDAT *)OUT_PRIEVT->buf_adr;
}
OUT_MSGDAT->len = 12;
SYS_WORK->out_ptr = (U1*)&OUT_MSGDAT->dat[4];
if ( msg_flag & BIT2 ) /* mandatory element infomation is missing. */
reason = 0x60;
else if ( msg_flag & BIT3 ) /* invalid information element content */
reason = 0x64;
else if ( msg_flag & BIT1 ) /* information element/parameter not exist,or not implemented */
reason = 0x63;
else if ( msg_flag & BIT4 ) /* invalid information element content */
reason = 0x64;
else if ( cc_speed_flg == NG || (msg_flag == 0x58 ))
reason = 0x58; /* incompatible destination */
cc_cause_write( reason );
PACKED_INT(SYS_WORK->out_ptr)++;
cc_call_state_write();
cc_msg_write( CCL2_STATE );
m_excreq( (U2*)&SYS_WORK->tsk_id );
}
/****************************************************************************/
/* */
/* NUMBER 13 */
/* CALL void cc_cause_write */
/* PARAM reason is cause value */
/* DISCRIPTION:fill cause element infomation */
/* out_ptr[0]: emement_id---CAUSE */
/* out_ptr[1]: cause content length. */
/* out_ptr[2]: include coding standard(bit 6,7) */
/* and location (bit 1,2,3,4) */
/* out_ptr[3]: specifation type. */
/* out_ptr[4]: cause value. */
/* RETURN: void */
/****************************************************************************/
void cc_cause_write( U1 reason )
{
SYS_WORK->out_ptr[0] = CAUSE;
PACKED_INT(SYS_WORK->out_ptr)++;
*(SYS_WORK->out_ptr) = 0x03; /* cause content length */
if ( Sys_ccsinf[19] == 0x01 )
{
PACKED_INT(SYS_WORK->out_ptr)++;
*(SYS_WORK->out_ptr) = 0x40; /* this inculde coding standars(6,7 bit) and location(1,2,3,4 bit) */
}
else
{
PACKED_INT(SYS_WORK->out_ptr)++;
*(SYS_WORK->out_ptr) = 0x00; /* RCR standard and location is 0x00 for user*/
}
PACKED_INT(SYS_WORK->out_ptr)++;
*(SYS_WORK->out_ptr) = 0x85; /* specification type */
PACKED_INT(SYS_WORK->out_ptr)++;
*(SYS_WORK->out_ptr) = BIT8 | reason; /* cause value */
}
/****************************************************************************/
/* */
/* NUMBER 13 */
/* CALL void cc_call_state_write */
/* PARAM reason is cause value */
/* DISCRIPTION:fill cause element infomation */
/* out_ptr[0]: emement_id---CALL_STATE */
/* out_ptr[1]: cause content length. */
/* out_ptr[2]: include coding standard(bit 7,8) */
/* and location (bit 1-6) */
/* RETURN: void */
/****************************************************************************/
void cc_call_state_write()
{
*(SYS_WORK->out_ptr) = CALL_STATE;
PACKED_INT(SYS_WORK->out_ptr)++;
*(SYS_WORK->out_ptr) = 1;
if ( Sys_ccsinf[19] == 0x01 )
{
PACKED_INT(SYS_WORK->out_ptr)++;
// *(SYS_WORK->out_ptr) = BIT8 | SYS_WORK->call_state;
*(SYS_WORK->out_ptr) = BIT8 | Cc_sts;
}
else /*set coding standard is RCR standard,bit 8.7 is 00*/
{
PACKED_INT(SYS_WORK->out_ptr)++;
// *(SYS_WORK->out_ptr) = SYS_WORK->call_state;
*(SYS_WORK->out_ptr) = Cc_sts;
}
}
/****************************************************************************/
/* */
/* NUMBER 42 */
/* CALL void cc_msg_write( msg ) */
/* PARAM U1 :message type */
/* FUNC fill message */
/* RETURN void */
/* GLOBAL */
/* L3_dl :dl state */
/* */
/****************************************************************************/
/*填写发发送到L2任务的消息*/
void cc_msg_write( U1 msg_id )
{
OUT_MSGDAT->dat[0] = CC_ID; /* protocol discriminator id */
OUT_MSGDAT->dat[1] = CALL_NO_L; /* call reference length */
//OUT_MSGDAT->dat[2] = SYS_WORK->call_reference_value;
OUT_MSGDAT->dat[2] = Cc_txnum; /* call reference = call reference flag + call reference value */
OUT_MSGDAT->dat[3] = msg_id; /* message type */
SYS_WORK->tsk_id = TASKL2;
OUT_DLDEVT->evt_cod = EDLDTRQ;
/*设置通道ID */
if ( L3_dl[FACCH_ST] == ST_SET ) /* FACCH */
OUT_DLDEVT->dl_typ = FACCH; /* set FACCH channel*/
else
OUT_DLDEVT->dl_typ = SACCH; /* set SACCH channel */
OUT_DLDEVT->dl_id = SLOT1; /* time slot */
OUT_DLDEVT->dl_sou = 0; /* L3 not need transfers confirm flag*/
if ( msg_id != L2CC_SETUP ) /* if setup message */
{
OUT_MSGDAT->next_po = 0;
}
}
/****************************************************************************/
/* */
/* NUMBER 6 */
/* CALL void cc_reference_clear( ) */
/* PARAM -- */
/* FUNC initial cc varible */
/* RETURN -- */
/* GLOBAL Cc_txnum :call reference (sending) */
/* Cc_rxnum :call reference (receiving) */
/* Cc_cause_back: cuase */
/* Cc_recall_flg :recall strate */
/* */
/****************************************************************************/
void cc_reference_clear( void )
{
Cc_txnum = 0; /* call reference (sending) */
Cc_rxnum = 0; /* call reference (receiving) */
Cc_cause_back = 0; /* cuase */
Cc_recall_flg = 0; /* recall strate */
Cc_sts = ST_NULL; /* cc state */
}
/****************************************************************************/
/* */
/* NUMBER 43 */
/* CALL void cc_init ( void ) */
/* PARAM -- */
/* FUNC initial */
/* RETURN void */
/* GLOBAL */
/* */
/****************************************************************************/
void cc_init( void )
{
cc_stop_time(0xff);
cc_reference_clear();
}
/***************************************************************************************/
/* */
/* NUMBER */
/* CALL U1 cc_info_element_chk( U1 *msg_ptr) */
/* PARAM unsigned char *msg_ptr : information element buffer */
/* FUNC check multi octet information element */
/* RETURN OK:normal
NG:unrecognised information element;
information element content not correct */
/* 0x58 : incompatible destination */
/* */
/****************************************************************************************/
U1 cc_info_element_chk( U1 *msg_ptr )
{
U1 ret; /* return value*/
if(*msg_ptr & 0x80) /* single information element */
{
ret = cc_single_info_chk(msg_ptr); /* check single information element */
return(ret); /* return value*/
}
if(msg_ptr[1] == 0) /* information element content length is null*/
{
return(OK);
}
switch( *msg_ptr )/* multi octet information element */
{
case BEARER_CAPABILITY : /* bear capability information element */
ret = cc_code0_bear_capability(msg_ptr);
break;
case CAUSE: /* cause information element */
ret = cc_code0_cause_chk(msg_ptr);
break;
case CALL_STATE : /* call state information element */
ret = cc_code0_call_state_chk(msg_ptr);
break;
case FACILITY: /* facility information element */
ret = cc_code0_facility_chk(msg_ptr);
break;
case PROGRESS_IND: /* progress infroramtion element */
ret = cc_code0_progress_chk(msg_ptr);
break;
case NOTIFICATION_IND: /* notification information element */
ret = cc_code0_notify_chk(msg_ptr);
break;
case KEYPAD_FACILITY: /* keypad facility information element */
ret = cc_code0_keypad_facility_chk(msg_ptr);
break;
case SINGAL: /* single information element */
ret = cc_code0_singal_chk(msg_ptr);
break;
case CALLING_PARTY_NUMBER: /* calling party number information element */
ret = cc_code0_calling_number_chk(msg_ptr);
break;
case CALLING_PARTY_SUBADDRESS: /* calling party subaddress information element */
ret = cc_code0_calling_subaddress_chk(msg_ptr);
break;
case CALLED_PARTY_NUMBER: /* called party number information element */
ret = cc_code0_called_number_chk(msg_ptr);
break;
case CALLED_PARTY_SUBADDRESS: /* called party subaddress information element */
ret = cc_code0_called_subaddress_chk(msg_ptr);
break;
case REDIRECTING_NUMBER:
ret = OK;
break;
case LOW_LAYER_CAPIBILITY: /* low layer compatibility information element*/
ret = cc_code0_low_capability_chk(msg_ptr);
break;
case HIGH_LAYER_CAPBILITY: /* high layer compatibility information element*/
ret = cc_code0_high_capability_chk(msg_ptr);
break;
case USER_USER: /* user-user information element*/
ret = cc_code0_user_user_chk(msg_ptr);
break;
case CHARGE_ADVICE: /* charge advice information element */
ret = cc_code0_charge_advice_chk(msg_ptr);
break;
case PS_IDENTITY: /* PS identity information element */
if((lock_shift_flag == 1) && (codeset_id == 0x05))
ret = cc_code5_ps_num_chk(msg_ptr);
break;
case MAN_CALL_ORIGINATION_IND: /* manual call origination information element */
if((lock_shift_flag == 1) && (codeset_id== 0x05))
ret = cc_code5_man_call_origin_chk(msg_ptr);
break;
case COMMUNICATION_TYPE : /* communication type information element */
if((lock_shift_flag == 1) && (codeset_id== 0x05))
ret = cc_code5_comm_type_chk(msg_ptr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -