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

📄 ptlbase.cpp

📁 GB接口数据解译程序
💻 CPP
字号:
/* ======================================================================== *\
 |
 |
 |  JOYIT Communication Technology
 |  Copyright (C)  2002-2003,  All Right Reserved.
 |
 |  System: Programmable Signaling Gateway
 |  Sub-system: OAM Server
 |  Filename: ptlbase.cpp
 |  Environment: Red Hat Linux 7.2 & GNU C/C++ Compiler 2.96
 |  Function description: Protocol base class
 |
\* ======================================================================== */

#include "ptlbase.hpp"

CIeBase::CIeBase( )
{
	Init( );
}

CIeBase::~CIeBase( )
{
	if ((len > SIZE_OF_POINTER)&&(ptr != NULL))
		delete ptr;
}

// ===========================================================================
//
// Description: Initialize all method data of CIeBase object.
// Input:  Null
// Output: Null
// Return: void
//
// ===========================================================================
void CIeBase::Init( )
{
	id = 0;		// Primary key
	len = 0;	// Length of IE(data) not include id and len
	ptr = NULL;	// Pointer point to IE's content when length of IE data longer than 4 bytes.
}

// ===========================================================================
//
// Description: Release memory that the IE seizured.
// Input:  Null
// Output: Null
// Return: void
//
void CPduBase::Init( ) // Initialize the PDU.
{
	// Set to zero.

}

// ===========================================================================
//
// Description: Put one IE into the PDU object.
// Input:
//		id		IE ID
//		len		Length of IE data
//		ptr		Pointer point to IE data
// Output: Null
// Return: int
//		>= 0	Success.
//		-1		IE's data invalid.
//		-2		Out of memory.
//
// ===========================================================================
int CPduBase::PutIE(UINT8 id, UINT16 len, UINT8* ptr)	// Put IE into PDU.
{
	int r = 0;
	if ((ptr != NULL)  &&(len > 0))
	{
		if (len > SIZE_OF_POINTER)
		{
			if(IE[id].ptr&&IE[id].len>SIZE_OF_POINTER)
				delete IE[id].ptr;
			IE[id].ptr = new char[len];
			if (IE[id].ptr != NULL)
			{
				memcpy(IE[id].ptr, ptr, len);
				IE[id].len=len;
				IE[id].id=id;
			}
			else
			{
				r = -2; // Out of memory.
			}
		}
		else
		{
			memcpy(&IE[id].data, ptr, len);
			IE[id].len=len;
			IE[id].id=id;
		}
	}
	return r;
}

CIeBase  * CPduBase::GetIE(UINT8 id, UINT8 seq)	// Get IE content from PDU.
{
	return &IE[id];
}
CPduBase::CPduBase()
{
}

⌨️ 快捷键说明

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