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

📄 cc0main.c

📁 phs 源代码 小灵通协议源代码 phs source code
💻 C
📖 第 1 页 / 共 4 页
字号:
/* 			The progress indiction is used to report events generated 		*/
/*		while a call exist. 												*/
/*						msg_ptr[0]: emement_id---PROGRESS_IND				*/
/*						msg_ptr[1]: PROGRESS_IND content length.			*/
/*						msg_ptr[2]: include coding standard(bit 6,7) 		*/
/*									and location (bit 1,2,3,4,5)			*/
/*						msg_ptr[3]: progress description					*/
/*		RETURN:		the cause element info whether or not effect.			*/
/****************************************************************************/
U1	cc_code0_progress_chk( U1 *msg_ptr )
{
	U1	mask;

	if(msg_ptr[2] & 0x80)		/*extention bit should be 1*/
	{
		mask = msg_ptr[2] & 0x60;	 /*coding standard is RCR or local network*/
		if(	(mask != 0x00) && (mask != 0x60) )
		{
			return(NG);
		}
		if(msg_ptr[2] & 0x10)	/* bit5 is resered */
		{
			return(NG);
		}
		mask = msg_ptr[2] & 0x0f;	/*the location where this message is generated */
		if(	(mask != 0x00) && (mask != 0x01) && (mask != 0x02) &&
			(mask != 0x04) && (mask != 0x05) && (mask != 0x0a) )
		{
			return(NG);
		}
	}
	else	/*extention bit=0*/
	{
		return(NG);
	}

	if(msg_ptr[1] < 2)
	{
		return(OK);
	}

	if(msg_ptr[3] & 0x80)	/*extention bit should be 1*/
	{
		mask = msg_ptr[3] & 0x7f;		/* progress discription value */
		if ( version == V2 )
		{
			if(	(mask != 0x01) && (mask != 0x02) && (mask != 0x03) &&
				(mask != 0x04) && (mask != 0x08) )
			{
				return(NG);
			}
		}
		else
		{
			if(	(mask != 0x01) && (mask != 0x02) && (mask != 0x03) &&
				(mask != 0x04) && (mask != 0x05) && (mask != 0x08) )
			{
				return(NG);
			}
		}
	}
	else
	{
		return(NG);
	}

	return(OK);
}

/****************************************************************************/
/*                                                                          */
/*		NUMBER		13                                                      */
/*		CALL		void cc_code0_notify_chk				                */
/*		PARAM		msg_ptr is call state element info point.				*/
/*		DISCRIPTION:														*/
/* 			The notification indictor element is used to notify the  		*/
/*		information related to a call. 										*/
/*						msg_ptr[0]: emement_id---NOTIFICATION_IND			*/
/*						msg_ptr[1]: NOTIFICATION_IND content length.		*/
/*						msg_ptr[2]: notification discription				*/
/*		RETURN:		the cause element info whether or not effect.			*/
/****************************************************************************/
U1	cc_code0_notify_chk( U1 *msg_ptr )
{
	U1	mask;
	if(msg_ptr[2] & 0x80)	/* extension bit should be 1 */
	{
		mask = msg_ptr[2] & 0x7f;	/* notification discription */
		if( (mask != 0x00) && (mask != 0x01) )	/* only support user suspend or user resumed */
		{
			return(NG);
		}
	}
	else
	{
		return(NG);		/* extension bit is 0 */
	}
	return(OK);
}

/*******************************************************************************/
/*                                                                          	*/
/*		NUMBER		13                                                      	*/
/*		CALL		void cc_code0_keypad_facility_chk				        	*/
/*		PARAM		msg_ptr is call state element info point.					*/
/*		DISCRIPTION:															*/
/* 			The keypad facility is used to carry IA5 charactersset by   		*/
/*		terminal keypad.in addition,the keypad facility is used to carry the	*/
/*		hooking singal information and pause singal information from PS to CS.	*/
/*						msg_ptr[0]: emement_id---KEYPAD_FACILITY				*/
/*						msg_ptr[1]: KEYPAD_FACILITY content length.				*/
/*						msg_ptr[2]: keypad facility information(IA5 characters)	*/
/*		RETURN:		the cause element info whether or not effect.				*/
/********************************************************************************/
U1	cc_code0_keypad_facility_chk( U1 *msg_ptr )
{
	U1	i;

	for(i = 2; i < msg_ptr[1]+2; i++)
	{
		if(msg_ptr[i] & 0x80)	 /* keypad discription 8 bit is 0	*/
		{
			return(NG);
		}
	}
	return(OK);
}


U1	cc_code0_singal_chk( U1 *msg_ptr )
{
	if( ((msg_ptr[2] > 0x08) && (msg_ptr[2] < 0x3f)) ||
		((msg_ptr[2] > 0x47) && (msg_ptr[2] < 0x4f)) ||
		(msg_ptr[2] > 0x4f) )
	{
		return(NG);
	}
	return(OK);
}

/********************************************************************************/
/*                                                                          	*/
/*		NUMBER		13                                                     	 	*/
/*		CALL		void cc_code0_calling_number_chk			            	*/
/*		PARAM		msg_ptr is cause element info point.						*/
/*		DISCRIPTION:															*/
/*			The calling party number is used to identity the call transmision	*/
/*		origin,the maxinum length of this information element depends on the 	*/
/*		CS or network.															*/
/*					msg_ptr[0]: emement_id---CALLING_PARTY_NUMBER				*/
/*					msg_ptr[1]: CALLING_PARTY_NUMBER content length.			*/
/*					msg_ptr[2]: include type of number(bit 6,7,5) 				*/
/*								and numbering plan identifier(bit 1,2,3,4)		*/
/*					msg_ptr[3]: if msg_ptr[2] externsion bit is 1,				*/
/*								then folling msg_ptr[2] is number digit.		*/
/*								if msg_ptr[2] externsion bit is 0,				*/
/*								then this byte include presentation and network	*/
/*								screening indicator.							*/
/*					msg_ptr[4]: number digit.									*/
/*		RETURN:		the cause element info whether or not effect.				*/
/********************************************************************************/
U1	cc_code0_calling_number_chk( U1 *msg_ptr )
{
	U1	flag3;
	U1	mask;
	U1	i;

	flag3 = 0;

	mask = msg_ptr[2] & 0x70;	/* type of number */
	if(	(mask != 0x00) && (mask != 0x10) &&	(mask != 0x20) && (mask != 0x30) )
	{/* support undetermined,international number,domestic number,specific to the local network number */
		return(NG);
	}
	mask = msg_ptr[2] & 0x0f;	/* numbering plan identifier */
	if( (mask != 0x00) && (mask != 0x01) && (mask != 0x08) && (mask != 0x09) )
	{/* support undetermined,ISDN/telephone number plan,domestic number plan,private network number plan */
		return(NG);
	}
	if(!(msg_ptr[2] & 0x80))	/* extention bit=0,calling party number info should include
								presentation indiction and network screening indiction*/
	{
		if(msg_ptr[1] < 2)
		{
			return(NG);
		}
		flag3++;  /*it indicates the oct of 3a exists */
	}

	if(msg_ptr[1] < 2)
	{
		return(OK);
	}

	if(flag3 == 1)
	{
		if(msg_ptr[3] & 0x80)		/* extension bit should be 1 */
		{
			mask = msg_ptr[3] & 0x60;	/* presentation indiction */
			if(mask == 0x60)	 /* bit 7,6: 11,is reserved */
			{
				return(NG);
			}
			if(msg_ptr[3] & 0x1c)	/*reserved bits=0*/
			{
				return(NG);
			}
		}
		else	/* extension bit 0 */
		{
			return(NG);
		}
	}

	for(i = flag3+3; i < msg_ptr[1]+2; i++)
	{
		if(msg_ptr[i] & 0x80)	/* extension bit should be 0 */
		{
			return(NG);
		}
	}
	return(OK);
}

/********************************************************************************/
/*                                                                          	*/
/*		NUMBER		13                                                     	 	*/
/*		CALL		void cc_code0_calling_subaddress_chk			           	*/
/*		PARAM		msg_ptr is cause element info point.						*/
/*		DISCRIPTION:															*/
/*			The calling party subaddress information element is used to identity*/
/*		the subaddressof the origination-side									*/
/*					msg_ptr[0]: emement_id---CALLING_PARTY_SUBADDRESS			*/
/*					msg_ptr[1]: CALLING_PARTY_SUBADDRESS content length.		*/
/*					msg_ptr[2]: include subaddress type(bit 6,7,5) 				*/
/*								and odd/even indicator(bit4)					*/
/*					msg_ptr[3]: subaddress information							*/
/*		RETURN:		the cause element info whether or not effect.				*/
/********************************************************************************/
U1	cc_code0_calling_subaddress_chk( U1 *msg_ptr )
{
	U1	mask;

	if(msg_ptr[2] & 0x80)		/* bit8 = 1 */
	{
		mask = msg_ptr[2] & 0x70;
		if( (mask != 0x00) && (mask != 0x20) )	/* only support NSAP or User-specific subaddress */
		{
			return(NG);
		}
		if(msg_ptr[2] & 0x07)	/*  reserved bit should be 0*/
		{
			return(NG);
		}
	}
	else
	{
		return(NG);
	}
	return(OK);
}

/********************************************************************************/
/*                                                                          	*/
/*		NUMBER		13                                                     	 	*/
/*		CALL		void cc_code0_called_number_chk			            		*/
/*		PARAM		msg_ptr is cause element info point.						*/
/*		DISCRIPTION:															*/
/*			The called party number is used to indiction the communication		*/
/*		destination of the call,the maxinum length of this information element 	*/
/*		depends on the CS or network.											*/
/*					msg_ptr[0]: emement_id---CALLED_PARTY_NUMBER				*/
/*					msg_ptr[1]: CALLED_PARTY_NUMBER content length.				*/
/*					msg_ptr[2]: include type of number(bit 6,7,5) 				*/
/*								and numbering plan identifier(bit 1,2,3,4)		*/
/*					msg_ptr[3]: number digit.									*/
/*		RETURN:		the cause element info whether or not effect.				*/
/********************************************************************************/
U1	cc_code0_called_number_chk( U1 *msg_ptr )
{
	U1	mask;
	U1	i;

	if(msg_ptr[2] & 0x80)		/*bit8=1*/
	{
		mask = msg_ptr[2] & 0x70;		/* type of number */
		if(	(mask != 0x00) && (mask != 0x10) &&
			(mask != 0x20) && (mask != 0x30) )
		{ /* support undetermined,international number,domestic number,specific to the local network number */
			return(NG);
		}
		mask = msg_ptr[2] & 0x0f;		/* numbering plan identifier */
		if( (mask != 0x00) && (mask != 0x01) &&
			(mask != 0x08) && (mask != 0x09) )
		{/* support undetermined,ISDN/telephone number plan,domestic number plan,private network number plan */
			return(NG);
		}
	}
	else
	{
		return(NG);
	}

	for(i = 3; i < msg_ptr[1]+2; i++)	/* number digit */
	{
		if(msg_ptr[i] & 0x80)	/*bit8=0*/
		{
			return(NG);
		}
	}
	return(OK);
}

/********************************************************************************/
/*                                                                          	*/
/*		NUMBER		13                                                     	 	*/
/*		CALL		void cc_code0_called_subaddress_chk			           		*/
/*		PARAM		msg_ptr is cause element info point.						*/
/*		DISCRIPTION:															*/
/*			The called party subaddress information element is used to identity*/
/*		the subaddressof the origination-side									*/
/*					msg_ptr[0]: emement_id---CALLED_PARTY_SUBADDRESS			*/
/*					msg_ptr[1]: CALLED_PARTY_SUBADDRESS content length.			*/
/*					msg_ptr[2]: include subaddress type(bit 6,7,5) 				*/
/*								and odd/even indicator(bit4)					*/
/*					msg_ptr[3]: subaddress information							*/
/*		RETURN:		the cause element info whether or not effect.				*/
/********************************************************************************/
U1	cc_code0_called_subaddress_chk( U1 *msg_ptr )
{
	U1	mask;

	if(msg_ptr[2] & 0x80)	/*bit8=1*/
	{
		mask = msg_ptr[2] & 0x70;	/* subaddress type */
		if( (mask != 0x00) && (mask != 0x20) )
		{/* only support NSAP or User-specific subaddress */
			return(NG);
		}
		if(msg_ptr[2] & 0x07)	/*  reserved bit should be 0*/
		{
			return(NG);
		}
	}
	else
	{
		return(NG);
	}

	return(OK);
}

/****************************************************************************/
/*                                                                          */
/*		NUMBER		13                                                      */
/*		CALL		void cc_code0_low_capability_chk			                */
/*		PARAM		msg_ptr is bearer capability element info point.		*/
/*		DISCRIPTION:	msg_ptr[0]: emement_id---LOW_LAYER_CAPIBILITY			*/
/*						msg_ptr[1]: LOW_LAYER_CAPIBILITY 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_low_capability_chk( U1 *msg_ptr )
{
	U1	flag3;
	U1	mask;

	flag3 = 0;

	mask = msg_ptr[2] & 0x1f;	/*information transfer capability */
	if ( version == V2 )
	{/* support speech,unrestriccted digital information,3.1khz audio */
		if( (mask != 0x00) && (mask != 0x08) && (mask != 0x10) )
		{
			return(NG);
		}
	}
	else
	{/* support speech,unrestriccted digital information,3.1khz audio,vidio,digital with tone /announcement */
		if( (mask != 0x00) && (mask != 0x08) && (mask != 0x10) &&
			(mask != 0x11) && (mask != 0x18) )
		{
			return(NG);
		}
	}
	if(!(msg_ptr[2] & 0x80))	/* extension bit is 0,the element info should include oct 3a */
	{
		if(msg_ptr[1] < 2)
		{
			return(NG);
		}
		flag3++;	/*it indicates the oct of 3a exists */
	}

	if(msg_ptr[1] < 2)
	{
		return(OK);
	}

	if(flag3 == 1)
	{
		if(msg_ptr[3] & 0x80)	/* bit8 = 1	*/
		{
			if(msg_ptr[3] & 0x3f)	/* spare should be 0x0 */
			{
				return(NG);
			}
		}
		else	/* if bit8 = 0,then error	*/
		{
			return(NG);
		}
	}

	if(msg_ptr[1] < 2 + flag3)
	{
		return(OK);
	}

	if(msg_ptr[3 + flag3] & 0x80)
	{
		mask = msg_ptr[3 + flag3] & 0x60;	/* transfer mode */
		if(mask != 0x00)	/* only support circuit mode */
		{
			return(NG);
		}
		mask = msg_ptr[3 + flag3] & 0x1f;	/* information transfer rate */
		if ( version == V2 )
		{
			if( (mask == 0x00) || (mask == 0x07) || (mask == 0x0a) ||
				(mask == 0x10) || (mask == 0x11) || (mask == 0x13) ||
				(mask == 0x15) || (mask == 0x17) || (mask == 0x18) )
			{		/* only support 32 kbit/s */
				return(NG);
			}
			else if(mask != 0x0c) /* 32 kbit/s */
			{
				return(NG);
			}
		}
		else
		{
			if( (mask == 0x00) || (mask == 0x07) || (mask == 0x0a) ||
				(mask == 0x11) || (mask == 0x13) || (mask == 0x15) ||
				(mask == 0x17) || (mask == 0x18) )
			{	/* support 32 kbit/s or 64 kbit/s */
				return(NG);
			}
			else if( (mask != 0x0c) && (mask != 0x10) )  /* 32kbit/s / 64kbit/s */
			{
				return(NG);
			}
		}
	}
	else
	{
		return(NG);
	}

	if(msg_ptr[1] < 3 + flag3)
	{

⌨️ 快捷键说明

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