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

📄 ptlbase.hpp

📁 ABis无线接口全套资料
💻 HPP
字号:
/* ======================================================================== *\ | | |  JOYIT Communication Technology |  Copyright (C)  2003 -2005,  All Right Reserved. | |  System: JOYIT Platform |  Sub-system: |  Filename: ptlbase.cpp |  Environment: Red Hat Linux 7.2 & GNU C/C++ Compiler 2.96 |  Function description: Protocol base class |\* ======================================================================== */#ifndef _PTLBASE_HPP#define _PTLBASE_HPP#ifndef _PUBDEF_HPP#include "pubdef.hpp"#endif#ifndef _DATATYPE_HPP#include "datatype.hpp"#endifextern "C"{#ifndef _STDIO_H#include <stdio.h>#endif#ifndef _STRING_H#include <string.h>#endif};#define MAX_PTL				16		// Maximum protocol type allowed.#define MAX_IE				255		// Maximum IEs allowed. The permited rang is 0~254.#define MAX_MSG				255		// Maximum messages per protcol allowed.#define MAX_MSGLEN			512		// Maximum message length in octecs allowed.#define MAX_HEADER_LENGTH	64		// Maximum octets that PDU's header allowed.#define IE_NOT_EXIST		255		////// Declare supported protocol type.//// Joyit API, modify 2005-10-30, by Wujianjin.#define MOD_JOYIT			0x00	// Form of PDU in JOYIT inner style.#define MOD_MTPAPI			PTL_MTPAPI#define MOD_TUPAPI			PTL_TUPAPI#define MOD_ISUPAPI			PTL_ISUPAPI#define MOD_SCCPAPI			PTL_SCCPAPI#define MOD_MAPAPI			PTL_MAPAPI#define MOD_INAPAPI			PTL_INAPAPI#define MOD_Q931API			PTL_Q931API#define MOD_M2PAPI			0x30 // 0x91#define MOD_M2UAPI			0x31 // 0x92#define MOD_M3UAPI			0x32 // 0x93#define MOD_SUAPI			0x33 // 0x94#define MOD_TUAPI			0x34 // 0x95#define MOD_IUAPI			0x35 // 0x96// Signaling/Protocol, modify 2005-10-30, by Wujianjin.#define MOD_MTP				MOD_MTPAPI+0x80#define MOD_TUP				MOD_TUPAPI+0x80#define MOD_ISUP			MOD_ISUPAPI+0x80#define MOD_SCCP			MOD_SCCPAPI+0x80#define MOD_MAP				MOD_MAPAPI+0x80#define MOD_INAP			MOD_INAPAPI+0x80#define MOD_Q931			MOD_Q931API+0x80#define MOD_M2PA			MOD_M2PAPI+0x80#define MOD_M2UA			MOD_M2UAPI+0x80#define MOD_M3UA			MOD_M3UAPI+0x80#define MOD_SUA				MOD_SUAPI+0x80#define MOD_TUA				MOD_TUAPI+0x80#define MOD_IUA				MOD_IUAPI+0x80#define INDICATION_PRIMITIVE	0 // Add 2005-11-19, by Wu jianjin.#define REQUEST_PRIMITIVE		1 // Add 2005-11-19, by Wu jianjin.//// Declare variant//#define SIZE_OF_POINTER		sizeof(UINT32) // sizeof(char *)#pragma pack(1)struct SJoyitApiHead{ // Add 2005-05-01, by Wujianjin.	UINT8		PtlId;		// Protocol ID = PTL_SS7	UINT8		PtlVer; 	// Protocol Version	UINT16		PktLength;	// Packet Length	ModuleID	dmid;		// Global destination module id.	ModuleID	smid;		// Global original module id.	UINT8		Reserved;	// Reserved byte.	UINT8		Priority;	// Priority of packet.	// UINT16		msgType;	// Message type.	UINT16		primType;	// Primitive type. 2005-10-27, by Wujianjin.	UINT8		noie;		// Number of IEs.	// @@@ End head.};struct SInterApiHead{ // Add 2005-10-26, by Wujianjin.	// For inter-API message head, such as SICP --> LAYER3 or LAYER3 --> SICP.	// In this case, the other head's fields carry by head of WEvent.	// UINT16		msgType;	// Message type.	UINT16		primType; // Primitive type. 2005-10-27, by Wujianjin.	UINT8		noie;		// Number of IEs.	// @@@ End head.};struct SIEStatus{	unsigned char repeated	: 5;	// Repeated times of this IE, beside myself. Default vaule is zero.	unsigned char firstone	: 1;	// 0: The first one of repeated IE; 1: Not the first one.	unsigned char spare		: 2;	// Spare, for further used. Set to zero.};// IE structclass CIeBase{public:	UINT8	id;			// Primary key	UINT16	len;		// Length of IE(data) not include id and len	SIEStatus ieStatus;	// Status of this IE.	union	{		char	* ptr;	// Pointer point to IE's content when length of IE data longer than 4 bytes.		UINT32	data;	// Store IE's value when length of IE data shorter than 4 bytes.	};public:	CIeBase( );	~CIeBase( );	void Init( );	void Release( );public:	char  * GetIeData(UINT16& l); // Return IE data.	UINT32  GetIeData( ); // Return IE value, useful when IE data length short than sizoe(char *).public:	void operator = (CIeBase& s);	void Copy(CIeBase& s);};#pragma pack( )class CPduBase{public:	CPduBase( );	CPduBase(CPduBase& s); // Add 2005-11-04, by Wujianjin. Copy construction function.	CPduBase(UINT8 pt, UINT8 pv, UINT8 pcf, UINT16 mt);	virtual ~CPduBase( );public:	virtual void Init( ); // Initialize the PDU.	UINT8 NoIe( )	// Get number of IEs this message include.	{		return IeCounter;	}	void SetProtocolType(UINT8 pt)	{		pType = pt;	}	void SetVariant(UINT8 var)	{		pVariant = var;	}	void SetSS7Pcf(UINT8 pcf)	{		ss7Pcf = pcf;	}	void SetPrimitiveType(UINT16 pt) // 2005-10-27, by Wujianjin.	{		primType = pt;	}	void SetMessageType(UINT16 mt)	{		mType = mt;	}	UINT8 GetProtocolType( )	{		return pType;	}	UINT8 GetVariant( )	{		return pVariant;	}	UINT8 GetSS7Pcf( )	{		return ss7Pcf;	}	UINT16 GetPrimitiveType( ) // 2005-10-27, by Wujianjin.	{		return primType;	}	UINT16 GetMessageType( )	{		return mType;	}public:	int			PutIE(UINT8 id, UINT8 len, char * ptr);// Put IE into PDU.	int			PutIE(CIeBase& ie);					// Put IE into PDU.	int			GetIE(CIeBase& ie, UINT8 seq=0);		// Get IE content from PDU.	// CIeBase&	GetIE(UINT8 id, UINT8 seq=0);			// Get IE content from PDU.	CIeBase	  * GetIE(UINT8 id, UINT8 seq=0);			// Get IE	void		DeleteIEbyIndex(UINT8 idx);			// Delete the IE by index.	int			DelIE(UINT8 id, UINT8 seq=0);			// Delete IE from PDU. SEQ indicate sequence of repeated IE to be deleted.														// Sequence value begin from 0.	UINT8		RepeatedTimes(UINT8 id);			// Calculate the repeated time of this IE.	/*	void		GetFirstRepeatedIE(CIeBase& ie);// Get the first IE of which can repeated.	CIeBase&	GetFirstRepeatedIE(CIeBase& ie);// Get the first IE of which can repeated.	void		GetNextRepeatedIE(CIeBase& ie);	// Get the next repeated IE.	CIeBase&	GetNextRepeatedIE(CIeBase& ie);	// Get the next repeated IE.	void		GetLastRepeatedIE(CIeBase& ie);	// Get the last IE of which can repeated.	CIeBase&	GetLastRepeatedIE(CIeBase& ie);	// Get the last IE of which can repeated.	*/public:	// virtual int	Unpacked(char  * ptr, UINT16 len, UINT8 mod = MOD_JOYIT);	// Unpacked the PDU octets string.	// virtual char	* Output(UINT16& len, UINT8 mod = MOD_JOYIT);				// Packed the PDU in dedicat model.	virtual int	Unpacked(char  * ptr, UINT16 len);	// Unpacked the PDU octets string.	virtual char	* Output(UINT16& len);			// Packed the PDU in dedicat model.public:	virtual int DecomposeJoyitApi(char  * ptr, UINT16 len);	virtual char	* ComposeJoyitApi(UINT16& len);	// virtual int DecomposeInterApi(char  * ptr, UINT16 len); // Add 2005-10-26, by Wujianjin.	// virtual char	* ComposeInterApi(UINT16& len); // Add 2005-10-26, by Wujianjin.private:	UINT8	pType;		// Protocol type, ISUP/TUP/SCCP/M3UA/SIP.	UINT8	pVariant;	// Protocol variant, such as CHINA/ETSI/ANSI/ITU, etc.	UINT8	ss7Pcf;		// SS7 point code format. 24-bit/14-bit	UINT16	primType;	// Joyit API primitive type. Only available in Joyit API message. 2005-10-27, by Wujianjin.	UINT16	mType;		// Joyit API (ISUP/TUP/DSS1) message type. 2005-10-27, by Wujianjin.private:	UINT8	IeCounter;			// Number of IE be included.	// UINT8	Index2Ieid[MAX_IE];	// Store the sequence of all IEs.								// 1. The index indicate the sequence of this IE;								// 2. The array element value indicate the IE's ID.								// 3. Valid value range is 0~254, 255 means not exist.	UINT8	Ieid2Index[MAX_IE];	// Store the IE's ID index.								// 1. The index indicate the IE's ID.								// 2. The array element value indicate the IE sequence.								// 3. Valid value range is 0~254, 255 means not exist.public:	CIeBase	IE[MAX_IE];			// Store all IE information.	char	Header[MAX_HEADER_LENGTH];	UINT8	LengthOfHeader;public: // Add 2005-11-04, by Wujianjin.	UINT8 GetIEindex(UINT8 id, UINT8 seq); // Add 2005-11-04, by Wujianjin. Internal use only.	void ReconstructIndex( ); // Reconstruct the index in Ieid2Index array.};#endif// ------------------------------------------------------------------------////  Revision list.//  ==============////  1.0,        2005-08-02,     Wu jianjin//      Initial version.//	1.1,		2005-10-26,		Wu jianjin.//		Add Inter API message compose and decompose function.//// ------------------------------------------------------------------------

⌨️ 快捷键说明

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