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

📄 ecmbuffer.h

📁 fax engine 传真引擎 relay fax 的开源项目 商业软件使用 高质量 高可靠
💻 H
字号:
/*****************************************************************************
* RelayFax Open Source Project
* Copyright 1996-2004 Alt-N Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the RelayFax Open 
* Source License.  A copy of this license is available in file LICENSE 
* in the top-level directory of the distribution.
*
* RelayFax is a registered trademark of Alt-N Technologies, Ltd.
*
* Individual files and/or contributed packages may be copyright by
* other parties and subject to additional restrictions.
*****************************************************************************/

#ifndef ECMBUFFER_H
#define ECMBUFFER_H


#define MAX_ECM_DATA	256		/* FIF */
#define ECM_DATA_HDR	4		/* Address + Control + FCF + Seq */
#define MAX_ECM_FRAME	(ECM_DATA_HDR + MAX_ECM_DATA + 2 ) /* HDR + DATA + FCS */
#define SEQ_MAP_SIZE	32
#define PPPINITFCS16    0xffff  /* Initial FCS value */
#define PPPGOODFCS16    0xf0b8  /* Good final FCS value */

class CECMBuffer
{

public:
	CECMBuffer() { InitFrame(); InitBlock(); };

	bool AddByte( unsigned char nOctet );
	void CalcFCS( unsigned char nOctet );
	bool CheckFCS(void);
	unsigned short GetFCS(void) { return (m_FCS ^ 0xffff); };
	unsigned char GetControl(void) { return m_Buffer[1]; };
	unsigned char GetFCF(void) { return m_Buffer[2]; };
	int GetSeq(void) { return (int)(m_Buffer[3]); };
	int GetLastSeq(void) { return m_LastSeq; };
	int GetHighestSeq(void) { return m_HighestSeq; };
	unsigned char* GetData(void) { return &m_Buffer[ECM_DATA_HDR]; };
	unsigned int GetSize(void) { return m_nBytes; };
	bool IsECMBlockGood( int nFrameCount );
	unsigned char* GetSeqMap(void) { return m_SeqMap; };

	void InitFrame(void) { m_nBytes = 0; m_FCS = PPPINITFCS16; };
	void UpdateLastSeq(void) { m_LastSeq = GetSeq(); if( m_LastSeq > m_HighestSeq) m_HighestSeq = m_LastSeq; };
	void IncrementLastSeq(void) { if( m_LastSeq > m_HighestSeq) m_HighestSeq = m_LastSeq; m_LastSeq++; };
	void InitBlock(void) { m_LastSeq = m_HighestSeq = -1; memset( m_SeqMap, 0xff, SEQ_MAP_SIZE ); };
	void SetLastSeq( int nSeq ) { m_LastSeq = nSeq; };
	void SetHighestSeq( int nSeq ) { m_HighestSeq = nSeq; };

protected:
	static unsigned short fcstab[256];	
	unsigned short fcs16( register unsigned short fcs, register unsigned char* cp, register int len);

	unsigned int m_nBytes;
	int m_LastSeq;
	int m_HighestSeq;
	unsigned short m_FCS;
	unsigned char m_SeqMap[ SEQ_MAP_SIZE ];
	unsigned char m_Buffer[ MAX_ECM_FRAME ];
};

#endif // ECMBUFFER_H

⌨️ 快捷键说明

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