📄 cc1ind.c
字号:
// SYS_WORK->call_state = p_state_table->state;
Cc_sts = (U1)p_state_table->state;
}
}
if(msg_flag)
{
reason = 0x62;
cc_cause_state(reason,msg_flag);
}
}
/************************************************************************/
/*Function Name : cc_disconnect_ind */
/*Function : handle the disconnect message received from CS. */
/* Process : */
/* Comment : parse disconnect message,if message content is correct */
/* then send disconnect 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_disconnect_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;
U1 cause_flag = NG_FF;
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 < DISCONNECT_ELEMENT_CNT; i++ )
{
if(*input_ptr == cc_disconnect_info[i].element_id)
{
ret = cc_info_element_chk(input_ptr); /* check information element content */
if(ret == NG && (*input_ptr == CAUSE))
{
cause_flag = NG;
}
else if(*input_ptr == CAUSE)
cause_flag = OK;
if(*input_ptr & BIT8) /* single information element */
{
PACKED_INT(input_ptr) ++;
if(ret == NG && lock_shift_flag== 1)
msg_flag |= BIT4; /* mandatory information element content error */
}
else
{
if(ret == NG && (cc_disconnect_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_disconnect_info[i].element_id)
{
if(cc_disconnect_info[i].option_id == MANDA)
{
msg_flag |= BIT2; // mandatory information element is missing
i++;
break;
}
continue;
}
}
if (i == DISCONNECT_ELEMENT_CNT)
{
msg_flag |= BIT1; /* information element not exist / not implemented */
}
}
if (msg_flag & 0x0b )
{
if( msg_flag & BIT2 )
{
Cc_cause_back = 0x60; /* mandatory element infomation is missing. */
}
else if( msg_flag & BIT4 )
{
Cc_cause_back = 0x64; /* invalid information element content */
}
else if( msg_flag & BIT1 )
{
Cc_cause_back = 0x63; /* information element/parameter not exist,or not implemented */
}
if(cause_flag != OK) /* in disconnect message,cause element is mandatory */
{ /* if disconnect message not contain cause element */
output_ptr = OUT_PRIEVT->inf_adr;
if ( OUT_PRIEVT->inf_len != 0 )
{
for ( i = OUT_PRIEVT->inf_len; i > 0; i-- )
{
#ifndef SIMU_ON_PC
*(__packed U1*)(PACKED_INT(output_ptr) + i + 4) = *(__packed U1*)(PACKED_INT(output_ptr) + i - 1);
#else
*(output_ptr +i +4) = *(output_ptr +i-1);
#endif
}
}
SYS_WORK->out_ptr = output_ptr;
cc_cause_write( 0x1f ); /* cause: unspecified */
OUT_PRIEVT->inf_len += 5;
}
}
else
Cc_cause_back = 0;
SYS_WORK->tsk_id = TASKMNG; /*set task id */
OUT_PRIEVT->evt_cod = ECC; /* set event code */
OUT_PRIEVT->pri_cod = PSCALDIS; /* set message type */
//OUT_PRIEVT->add_dat = 0x00; //zch for protocol simulator
m_excreq( (U2*)&SYS_WORK->tsk_id ); /* send out */
if(p_state_table->state != 0xff) //zch0710
{
Cc_sts = (U1)p_state_table->state;/* cc state change to P12 state */
}
if ( msg_flag & BIT3 ) //mandatory information element content error */
{
OUT_DLDEVT->msg_adr = (CC_MSGDAT *)m_hntbuf( ); /* get memory */
if(OUT_DLDEVT->msg_adr == NULL)
{
return;
}
OUT_MSGDAT->len = 12; /* message data length */
SYS_WORK->out_ptr = (U1*)(OUT_DLDEVT->msg_adr + 6 + 4); /* output message pointer*/
cc_cause_write( 0x64 ); /* write cause info */
// SYS_WORK->call_state = Cc_sts;
PACKED_INT(SYS_WORK->out_ptr)++;
cc_call_state_write(); /* write calls state */
cc_msg_write( CCL2_STATE ); /*write status message */
m_excreq( (U2*)&SYS_WORK->tsk_id ); /*send out */
}
}
/************************************************************************/
/*Function Name : cc_release_ind */
/*Function : handle the release message received from CS. */
/* Process : */
/* Comment : parse release message,if message content is correct */
/* then send release 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_release_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;
U1 cause_flag = NG_FF;
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 < RELEASE_ELEMENT_CNT; i++ )
{
if(*input_ptr == cc_release_info[i].element_id)
{
ret = cc_info_element_chk(input_ptr);
if(ret == NG && (*input_ptr == CAUSE))
{
cause_flag = NG;
}
else if(*input_ptr == CAUSE)
cause_flag = OK;
if(*input_ptr & BIT8) /* single information element */
{
PACKED_INT(input_ptr) ++;
if(ret == NG && lock_shift_flag== 1)
msg_flag |= BIT4;
}
else
{
if(ret == NG && (cc_release_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_release_info[i].element_id)
{
if(cc_release_info[i].option_id == MANDA)
{
msg_flag |= BIT2; // mandatory information element is missing
i++;
break;
}
continue;
}
}
if (i == RELEASE_ELEMENT_CNT)
{
msg_flag |= BIT1; /* information element not exist / not implemented */
}
}
switch ( Cc_sts )
{
case ST_OVRSND: /* state that PS received "setup ack" message */
case ST_OUTCAL: /* state that PS received "call proceed" message from cs */
case ST_CALDLV: /* state that PS received "call alert "message from CS */
case ST_CALPRS: /* state that PS received "setup"message from cs,but not yet send any response */
case ST_CALRCV: /* atate that PS transmitted "call alert" message to cs,but thers is no response yet */
case ST_CONREQ: /* state that PS transmitted "call connect" to cs,and is waiting for "call connect ack" */
case ST_INCCAL: /* state that PS send "call proceed" to cs that all information neccessary for setup was received */
case ST_ACTV : /* state that PS received "call connect ack" from cs,and enters communication state*/
if(cause_flag == NG_FF) /* cause info element not received */
{
msg_flag |= BIT2; /* manda infomation element absent */
}
else if(cause_flag == NG) /* cause info element content error*/
{
msg_flag |= BIT4; /* manda information element content error */
}
break;
}
if ( OUT_PRIEVT->inf_len == 0 )
{
m_frebuf( OUT_PRIEVT->buf_adr );
OUT_PRIEVT->buf_adr = 0;
OUT_PRIEVT->inf_adr = 0;
}
SYS_WORK->tsk_id = TASKMNG;
OUT_PRIEVT->evt_cod = ECC;
OUT_PRIEVT->pri_cod = PSCALFRE;
m_excreq( (U2*)&SYS_WORK->tsk_id );
set_up_b((U1 *)SYS_WORK->out_evt, 0, sizeof(SYS_WORK->out_evt));
// OUT_DLDEVT->msg_adr = (CC_MSGDAT *)m_hntbuf( ); /* get memory */
//
// OUT_MSGDAT->len = CC_FMT_SZ; /* out message data length */
// reason = 0;
//
// if( msg_flag & BIT2 ) /* manda information element absnet */
// reason = 0x60; /* cause value#96 (mandatory informatin element is missing)*/
// else if( msg_flag & BIT3 ) /* manda information element content error*/
// reason = 0x64; /* cause value#100 */
// else if( msg_flag & BIT1 ) /* unknown infroamtion element */
// reason = 0x63; /* cause value#99 */
// else if ( msg_flag & BIT4 ) /* option informatin element */
// reason = 0x64; /* cause value#100 */
//
// if ( reason )
// {
// //W_out_msg_p = OUT_msg_jadr;
// SYS_WORK->out_ptr = &OUT_MSGDAT->dat[4]; /* output message data pointer */
// cc_cause_write( reason ); /* write cause value*/
// OUT_MSGDAT->len += 5; /* out message datalength */
// }
// cc_msg_write( CCL2_RELEASE_COMPLETE ); /* write release complete message */
OUT_DLDEVT->msg_adr = (CC_MSGDAT *)m_hntbuf( );
reason = 0;
cc_cause_release(reason,msg_flag,CCL2_RELEASE_COMPLETE);
if ( !(msg_flag & BIT4) )
{
OUT_DLDEVT->dl_sou = 1;
}
m_excreq( (U2*)&SYS_WORK->tsk_id );
if(msg_flag & BIT3) /* option information element content error*/
{
OUT_DLDEVT->msg_adr = (CC_MSGDAT *)m_hntbuf( ); /* get memory */
if(OUT_DLDEVT->msg_adr == NULL)
{
return;
}
OUT_MSGDAT->len = 12; /* out message data length */
SYS_WORK->out_ptr = (U1*)&OUT_MSGDAT->dat[4]; /* output message data pointer */
cc_cause_write( 0x64 ); /* write cause value */
// SYS_WORK->call_state = ST_NULL;
PACKED_INT(SYS_WORK->out_ptr)++;
cc_call_state_write();
cc_msg_write( CCL2_STATE );
OUT_DLDEVT->dl_sou = 1;
m_excreq( (U2*)&SYS_WORK->tsk_id );
}
cc_stop_time( 0xff ); /* stop timer */
cc_reference_clear(); /* cc initial */
disconnect_complete_flag = 1;
}
/************************************************************************/
/*Function Name : cc_release_ind */
/*Function : handle the release complete message received from CS. */
/* Process : */
/* Comment : parse release complete message,if message content is correct */
/* then send release complete 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_release_complete_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;
// if (( Cc_sts ) && (SYS_WORK->call_state == ST_NULL))
// {
// return;
// }
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) /* message no contains infomation element */
{
m_frebuf(OUT_PRIEVT->buf_adr);
OUT_PRIEVT->inf_len = 0;
OUT_PRIEVT->buf_adr = 0;
OUT_PRIEVT->inf_adr = 0;
if(( Cc_sts == ST_RELREQ ) && ( Cc_cause_back ))
{
OUT_PRIEVT->buf_adr = m_hntbuf( ); /* get memory */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -