📄 cc0main.c
字号:
break;
default: /* others*/
return(NG);
}
return(ret);
}
/****************************************************************************/
/* */
/* NUMBER */
/* CALL U1 cc_single_info_chk( U1 *msg_ptr) */
/* PARAM unsigned char *msg_ptr : single informatio element buffer*/
/* FUNC check single octet information element */
/* RETURN whether or not used reserved item
OK:normal
NG:reserved (RCR STD-28 standard) */
/* */
/****************************************************************************************/
U1 cc_single_info_chk( U1 *msg_ptr )
{
U1 mask;
if((msg_ptr[0] & 0xf0) == LOCK_SHIFT) /* locking shift information element */
{
lock_shift_flag = 1;
mask = msg_ptr[0] & 0x07; /* bit 1-3,is codeset identifier */
codeset_id= mask; /* reserved */
if( (mask > 0x00) && (mask < 0x05) )
{ /* wrong */
return(NG);
} /* normal */
return(OK);
}
else if((msg_ptr[0] & 0xf0) == REPEAT_IND) /* repeat indicator information element */
{
mask = msg_ptr[0] & 0x0f; /* bit 1-4 is repeat indiction */
if(mask != 0x02) /* 0x02 indictor prioritized list for selecting one possibility,
other is reserved */
{
return(NG); /* reserved */
}
return(OK); /* return normal */
}
else if(msg_ptr[0] == SNED_COMPLETE) /* sending complete information element */
{
return(OK); /* return normal */
}
return(NG);
}
/****************************************************************************/
/* */
/* NUMBER 13 */
/* CALL void cc_code0_bear_capability */
/* PARAM msg_ptr is bearer capability element info point. */
/* DISCRIPTION: msg_ptr[0]: emement_id---BEARER_CAPABILITY */
/* msg_ptr[1]: bearer capability content length. */
/* msg_ptr[2]: include coding standard(bit 6,7) */
/* and information transfer capability */
/* (bit 1,2,3,4,5) */
/* msg_ptr[3]: include transfer mode(bit 6,7) */
/* and information transfer rate */
/* (bit 1,2,3,4,5) */
/* msg_ptr[4]: include Layer 1(bit 7,6 is 01) */
/* and user information layer 1 protocol */
/* (bit 1,2,3,4,5) */
/* others ingnored */
/* RETURN: the cause element info whether or not effect. */
/****************************************************************************/
U1 cc_code0_bear_capability( U1 *msg_ptr )
{
U1 mask;
if(msg_ptr[2] & 0x80) /* extension bit should be 1 */
{
mask = msg_ptr[2] & 0x60; /*only support RCR stardard or local network*/
if( (mask != 0x00) && (mask != 0x60) ) /* bit 7,6 is 00: RCR standard
is 11: local network */
{
return(0x58); /* incompatible destination */
}
mask = msg_ptr[2] & 0x1f; /* information transfer capability */
if( (mask != 0x00) && (mask != 0x08) && (mask != 0x10) ) /*speech,digital,3.1khz audio */
{
return(0x58);
}
}
else /*when extention bit =0 ,error */
{
return(0x58);
}
if(msg_ptr[1] < 2) /*bearer capability length is wrong */
{
return(0x58);
}
if(msg_ptr[3] & 0x80)
{
mask = msg_ptr[3] & 0x60; /* transfer mode */
if(mask != 0x00) /* only support circuit mode */
{
return(0x58);
}
mask = msg_ptr[3] & 0x1f; /* information transfer rate */
if ( version == V2 )
{
if( (mask == 0x07) || (mask == 0x0a) || (mask == 0x10) ) /* only support 32 kbit/s */
{
return(0x58);
}
else if(mask != 0x0c)
{
return(0x58);
}
}
else
{
if( (mask == 0x07) || (mask == 0x0a) ) /* support 32 kbit/s or 64 kbit/s */
{
return(0x58);
}
else if(mask == 0x0c) /* circuit mode 32kbit/s */
{
cc_speed_flg = OK;
}
else if(mask == 0x10) /*circuit mode 64kbit/s */
{
if( (msg_ptr[2] & 0x1f) != 0x08 ) /*if tranfer capability is not unrestricted */
{
return(0x58); /* there is wrong */
}
cc_speed_flg = OK;
}
else
{
return(0x58);
}
}
}
else /* extention bit=0 */
{
return(0x58);
}
if(msg_ptr[1] < 3)
{
return(OK);
}
mask = msg_ptr[4] & 0x60; /* Layer 1 */
if(mask != 0x20) /* layer 1 should be 01(bit 7,6) */
{
return(0x58);
}
mask = msg_ptr[4] & 0x1f; /* user information layer 1 protocol */
if( (mask == 0x01) || (mask == 0x07) ) /* only support 32kbit/s ADPCM */
{
return(0x58);
}
else if(mask != 0x04) /* need 32kbit/s ADPCM */
{
return(0x58);
}
if(!(msg_ptr[4] & 0x80)) /*if extention bit=0*/
{
if(msg_ptr[1] < 4) /*but length <4*/
{
return(0x58);
}
}
return(OK); /* ignore the following oct 5a,5b.....6,7 oct,etc */
}
/****************************************************************************/
/* */
/* NUMBER 13 */
/* CALL void cc_code0_cause_chk */
/* PARAM msg_ptr is cause element info point. */
/* DISCRIPTION: msg_ptr[0]: emement_id---CAUSE */
/* msg_ptr[1]: cause content length. */
/* msg_ptr[2]: include coding standard(bit 6,7) */
/* and location (bit 1,2,3,4) */
/* msg_ptr[3]: if msg_ptr[2] externsion bit is 1, */
/* then this byte is specifation type. */
/* if msg_ptr[2] externsion bit is 0, */
/* then this byte is cause value. */
/* msg_ptr[4]: cause value. */
/* RETURN: the cause element info whether or not effect. */
/****************************************************************************/
U1 cc_code0_cause_chk( U1 *msg_ptr )
{
U1 flag3;
U1 mask;
flag3 = 0;
mask = msg_ptr[2] & 0x60; /*only support RCR stardard or local network*/
if( (mask != 0x00) && (mask != 0x60) ) /* bit 7,6 is 00: RCR standard
is 11: local network */
{
return(NG);
}
if(msg_ptr[2] & 0x10) /* bit 5 is reserved */
{
return(NG);
}
mask = msg_ptr[2] & 0x0f; /*the generation location of the cause*/
if( (mask == 0x06) || (mask == 0x08) || (mask == 0x09) || (mask > 0x0a) ) /* reserved */
{
return(NG);
}
if(msg_ptr[2] & 0x80) /*extention bit=1,cause info not include specification type */
{
if(msg_ptr[1] == 3)
{
return(NG);
}
}
else /* extention bit=0,cause info should include specification type*/
{
if(msg_ptr[1] == 2)
{
return(NG);
}
flag3++; /*it indicates the oct of 3a exists */
}
if(flag3 == 1) /*oct 3a */
{
if(msg_ptr[3] & 0x80) /* extension bit should be 1 */
{
mask = msg_ptr[3] & 0x7f;
if( (mask != 0x05) && (mask != 0x08) ) /*specification type :only phs 0x05 or option 0x08 */
{
return(NG);
}
}
else
{
return(NG);
}
}
flag3 += 3; /*use the flag to point the cause value location */
if(msg_ptr[flag3] & 0x80) /* extension bit should be 1 */
{
mask = msg_ptr[flag3] & 0x7f; /* cause value */
Cc_cause_back = mask;
if( (mask == 0x00) || (mask == 0x04) || (mask == 0x05) ||
((mask >= 0x08) && (mask <= 0x0f)) ||
((mask >= 0x17) && (mask <= 0x19)) ||
(mask == 0x20) || (mask == 0x21) ||
((mask >= 0x23) && (mask <= 0x25)) || (mask == 0x27) ||
(mask == 0x28) || (mask == 0x2d) || (mask == 0x2e) ||
(mask == 0x30) || ((mask >= 0x33) && (mask <= 0x38)) ||
((mask >= 0x3b) && (mask <= 0x3e)) || (mask == 0x40) ||
(mask == 0x43) || (mask == 0x44) ||
((mask >= 0x47) && (mask <= 0x4e)) || (mask == 0x50) ||
(mask == 0x57) || (mask == 0x59) || (mask == 0x5a) ||
((mask >= 0x5c) && (mask <= 0x5e)) ||
((mask >= 0x67) && (mask <= 0x6e)) ||
((mask >= 0x70) && (mask <= 0x7e)) )
{
return(NG);
}
}
else
{
return(NG);
}
return(OK);
}
/****************************************************************************/
/* */
/* NUMBER 13 */
/* CALL void cc_code0_call_state_chk */
/* PARAM msg_ptr is call state element info point. */
/* DISCRIPTION: */
/* Call State is used to describe the call state of the current call. */
/* msg_ptr[0]: emement_id---CALL_STATE */
/* msg_ptr[1]: CALL_STATE content length. */
/* msg_ptr[2]: include coding standard(bit 8,7) */
/* and call state value (bit 1,2,3,4,5,6) */
/* RETURN: the cause element info whether or not effect. */
/****************************************************************************/
U1 cc_code0_call_state_chk( U1 *msg_ptr )
{
U1 mask;
mask = msg_ptr[2] & 0xc0; /* coding standars*/
if( (mask != 0x00) && (mask != 0xc0) ) /* only support RCR standard or local network */
{
return(NG);
}
mask = msg_ptr[2] & 0x3f; /* call state value */
p_call_state = mask;
if( (mask == 0x05) || ((mask > 0x0c) && (mask < 0x13)) || (mask > 0x13) ) /* this is reserved */
{
return(NG);
}
return(OK);
}
/****************************************************************************/
/* */
/* NUMBER 13 */
/* CALL void cc_code0_facility_chk */
/* PARAM msg_ptr is call state element info point. */
/* DISCRIPTION: */
/* msg_ptr[0]: emement_id---FACILITY */
/* msg_ptr[1]: FACILITY content length. */
/* msg_ptr[2]: include spare(bit 6,7) */
/* and protocol profile (bit 1,2,3,4,5) */
/* other is protocol data units(PDUs) part. */
/* RETURN: the cause element info whether or not effect. */
/****************************************************************************/
U1 cc_code0_facility_chk( U1 *msg_ptr )
{
U1 mask;
if(msg_ptr[2] & 0x80) /* extension bit should be 1 */
{
if((msg_ptr[2] & 0x60) != 0x00) /* the spare should be 00(bit 7,6) */
{
return(NG);
}
mask = msg_ptr[2] & 0x1f; /* protocol profile */
if(mask != 0x11) /* only support Remote Operation Protocol(0x11) */
{
return(NG);
}
}
else /* if extension bit is 0,it's error */
{
return(NG);
}
if(msg_ptr[1] < 2)
{
return(OK);
}
if(msg_ptr[1] > 5) /* the information element include protocol data units(PDUs) */
{
if(msg_ptr[5] != 0x02) /* invoke identifier tag should be 0x02 */
{
return(NG);
}
if(msg_ptr[6] != 1) /*invoke identifier length should be 1 */
{
return(NG);
}
}
if(msg_ptr[3] == 0xa1) /* invoke type:recalling type channel switch for public system,
recalling type channel switch for private system,
DTMF singal*/
{
return(OK);
}
else if(msg_ptr[3] == 0xa2) /* it is the return result */
{
if(msg_ptr[1] != 6) /* the total length should be 6 (1+5),reference to RCR STD28 */
{
return(NG);
}
if(msg_ptr[4] != 3) /* PDUs length should be 3 ,reference to RCR STD28*/
{
return(NG);
}
}
else if(msg_ptr[3] == 0xa3) /* return error,reference to RCR STD28 */
{
if( (msg_ptr[1] != 9) && (msg_ptr[1] != 17) ) /* when the error is specified by Q.950,the length is 9 */
/*and when the error is specified by RCR,the length is 17 */
{
return(NG);
}
if(msg_ptr[4] == 6) /*Q.950 error*/
{
if(msg_ptr[8] != 0x02) /* error value tag should be 0x02 */
{
return(NG);
}
if((msg_ptr[9] & 0x7f) != 1) /* error value length should be 0x01 */
{
return(NG);
}
}
else if(msg_ptr[4] == 14) /* error specified by RCR */
{
if(msg_ptr[8] != 0x06) /* error value tag should be 0x06 */
{
return(NG);
}
if((msg_ptr[9] & 0x7f) != 9) /* error value length */
{
return(NG);
}
}
else
{
return(NG);
}
}
else if(msg_ptr[3] == 0xa4) /*reject */
{
if(msg_ptr[1] != 9) /* the total length should be 0x09,refer to RCR STD28 */
{
return(NG);
}
if(msg_ptr[4] != 6) /* component length should be 0x06 */
{
return(NG);
}
if(msg_ptr[9] != 1) /* problem length should be 0x01 */
{
return(NG);
}
if(msg_ptr[8] == 0x80) /* general problem */
{
if(msg_ptr[10] > 0x02) /*general problem value:0,1,2*/
{
return(NG);
}
}
else if(msg_ptr[8] == 0x81) /* invoke problem */
{
if(msg_ptr[10] > 0x07) /*invoke problem value:0 ~ 7*/
{
return(NG);
}
}
else if(msg_ptr[8] == 0x82) /* return result problem */
{
if(msg_ptr[10] > 0x02) /*return result problem value:0,1,2*/
{
return(NG);
}
}
else if(msg_ptr[8] == 0x83) /* return error problem */
{
if(msg_ptr[10] > 0x04) /*return error problem value:0,1,2,3,4*/
{
return(NG);
}
}
}
else
{
return(NG);
}
return(OK);
}
/****************************************************************************/
/* */
/* NUMBER 13 */
/* CALL void cc_code0_progress_chk */
/* PARAM msg_ptr is call state element info point. */
/* DISCRIPTION: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -