/*******************************************************************************
 * (c) Copyright 2015 Microsemi Corporation.  All rights reserved.
 *
 *
 *
 * SVN $Revision: $
 * SVN $Date: $
 */

#ifndef __MR_API_TYPES_H__
	#define __MR_API_TYPES_H__

#include <api_oam_sdk/common/constants/inc/mr_constants.h>
#include <time.h>
#include "egl_types.h"

typedef int16_t	maNum_t;
typedef int16_t	mdNum_t;

typedef enum
{
	zeroPattern	= 1,
	onesPattern	= 2
} dataPattern_t;

typedef enum
{
	tp_null			= 1,
	tp_nullCrc32	= 2,
	tp_prbs			= 3,
	tp_prbsCrc32	= 4
}	testTlvPattern_t;

typedef enum
{
	endTlvType					= 0,
	senderIdTlvType				= 1,
	portStatusTlvType			= 2,
	dataTlvType					= 3,
	interfaceStatusTlvType		= 4,
	replyIngressTlvType			=  5,
	replyEgressTlvType			=  6,
	ltmEgressIdentifierTlvType	=  7,
	ltrEgressIdentifierTlvType	=  8,
	//PBB-TE MIP TLV 				9
	//Data Part 1 TLV (29.3.3.2)	10
	//Data Part 2 TLV (29.3.3.2)	11
	//Truncated Data TLV (29.3.3.2) 12
	//Reserved for IEEE 802.1 13	30
	organizationSpecificTlvType	=  31
} tlvType_t;

typedef enum
{
	VLAN_NONE = 1,
	CTAG_TYPE,
	STAG_TYPE
} tagType_t;

typedef enum
{
	wanPort 	= 0,
	lanPort 	= 1,
	mgntPort	= 2
} iFace_t;

typedef enum mrPortEnum {
	mrPort0 = 0,
	mrPort1 = 1,
	mrMgntPort = 2
} mrPort_t;

typedef enum
{
	prio0 = 0,
	prio1 = 1,
	prio2 = 2,
	prio3 = 3,
	prio4 = 4,
	prio5 = 5,
	prio6 = 6,
	prio7 = 7
} prio_t;

typedef enum
{
	cid_non					= 0, 			// This entry is not in the standard - Added by ND
	cid_chassisComponent	= 1,
	cid_interfaceAlias		= 2,
	cid_portComponent		= 3,
	cid_macAddress			= 4,
	cid_networkAddress		= 5,
	cid_interfaceName		= 6,
	cid_local				= 7
} chassisIdSub_t;		// taken from http://www.ieee802.org/1/files/public/MIBs/LLDP-MIB-200505060000Z.txt

typedef char	chassisId_t[48];		// This value is extracted from a TLV in the CCM so the max size is limited to 48 + 1
typedef char	manAddrDomain_t[48];
typedef char	manAddr_t[48];

//=======================================================================
//===================== Define Data Enumerations =========================
//=======================================================================
enum mdNameEnum {
	MD_NONE 			=1,
	DNSLIKENAME 		=2,
	MACADDRESSANDUINT	=3,
	CHARACTERSTRING		=4
	//RESERVED_MD_T
};
typedef enum mdNameEnum		mdNameTypeOld_t;

//=======================================================================

enum maNameTypeEnum {
	PRIMARYVID 		=1,
	CHARSTRING 		=2,
	UNSIGNEDINT16 	=3,
	RFC2685VPNID 	=4,
	ITUY1731_32		=32,
	RESERVED_MA_T
};
typedef enum maNameTypeEnum		maNameTypeOld_t;

//=======================================================================

enum rMepSMStatesEnum {
	SM_IDLE			= 0,
	SM_INIT_WAIT 	= 3,
	SM_START 		= 2,
	SM_OK 			= 4,
	SM_FAIL 		= 6
};
typedef enum rMepSMStatesEnum	rMepSMStates_t;

//=======================================================================

enum sMStatesEnum{
	IDLE		= 0,
	NO_DEFECT 	= 1,
	UNUSED		= 2,
	DEFECT 		= 3
};
typedef enum sMStatesEnum		smStates_t;

//=======================================================================

enum lbModeEnum{
	LB_BURST 	= 1,
	LB_CONST	= 0
};
typedef enum lbModeEnum			lbModeOld_t;

//=======================================================================

enum rdiValueEnum{
	SET		 	= 1,
	CLR			= 0
};
typedef enum rdiValueEnum		rdiVal_t;
typedef enum rdiValueEnum		flag_t;

//=======================================================================
enum directionEnum {
	down 	=0,
	up 		=1
};
typedef enum directionEnum		mepDir_t;

//=======================================================================
enum ccmIntervalEnum {
	intervalInvalid = 0,
	interval300Hz 	= 1,
	interval10ms 	= 2,
	interval100ms 	= 3,
	interval1s 		= 4,
	interval10s 	= 5,
	interval1min 	= 6,
	interval10min 	= 7
};
typedef enum ccmIntervalEnum	ccmIntervalOld_t;
typedef enum ccmIntervalEnum	interval_t;

//=======================================================================
enum TruthValueEnum {
	True	=1,
	False	=0
};
typedef enum TruthValueEnum		boolean_t;

//=======================================================================
enum enDisEnum {
	enable	= 1,
	disable	= 0
};
typedef enum enDisEnum			enDis_t;

//=======================================================================
enum svcDirEnum {
	tx_only	= 1,
	rx_only	= 2,
	both_tx_rx = 3,
	en_xconn = 4,
	en_rMepErr = 8
};
typedef enum svcDirEnum			svcDir_t;

//=======================================================================
enum svcEnEnum {
	enabled	= 1,
	disabled = 0
};
typedef enum svcEnEnum			svcEn_t;

//=======================================================================
enum ituDelayTypeEnum {
	dmm	= 2,
	idm = 1
};
typedef enum ituDelayTypeEnum	ituDelayType_t;
//=======================================================================
enum ituLossTypeEnum {
	lmm	= 2,
	ccm = 1
};
typedef enum ituLossTypeEnum	ituLossType_t;
//=======================================================================
enum mepTypeEnum {
	mep	= 0,
	mip = 1
};
typedef enum mepTypeEnum		mepType_t;
//=======================================================================
enum connTypeEnum {
	lost	= 1,
	restored = 0
};
typedef enum connTypeEnum		connType_t;
//=======================================================================
enum intEventTypeEnum {
	errDetected	= 1,
	errCleared = 0
};
typedef enum intEventTypeEnum		xConnType_t;
typedef enum intEventTypeEnum		rMepErrType_t;
//=======================================================================
enum multicastEnEnum {
	MC_ENABLED	= 1,
	MC_DISABLED = 0
};
typedef enum multicastEnEnum	multicastEn_t;

//=======================================================================
enum lbChnlEnum {
	Chnl0	= 0
};
typedef enum lbChnlEnum			lbChnl_t;				// Only 1 loopback channel supported

//=======================================================================
enum isValueEnum {
	isNoInterfaceStatusTLV	= 0,
	isUp 					= 1,
	isDown 					= 2,
	isTesting 				= 3,
	isUnknown 				= 4,
	isDormant 				= 5,
	isNotPresent 			= 6,
	isLowerLayerDown 		= 7
};

typedef enum isValueEnum		isValue_t;

//=======================================================================
enum psValueEnum {
	psNoPortStatusTLV	= 0,
	psBlocked			= 1,
	psUp				= 2
};

typedef enum psValueEnum		psValue_t;

//=======================================================================
enum pmSvcModeEnum {
	INVALID_SVC_MODE = 0,
	ORIGINATOR = 1,
	RESPONDER = 2
};
typedef enum pmSvcModeEnum		pmSvcMode_t;

//=======================================================================
enum svcTypeEnum {
	INVALID_SVC_TYPE = 0,
	LMM = 1,
	SLM = 2,
	DMM = 3,
	IDM = 4,
};
typedef enum svcTypeEnum		pmSvcType_t;

//=======================================================================
enum validEnum {
	invalid = 0,
	valid = 1
};
typedef enum validEnum		valid_t;
//=======================================================================
enum defectReason1Enum {
	INVALID_DR1 = 0,
	UNEXPECTED_LEVEL = 1,
	UNMATCHED_MAID = 2,
	AIS_DETECTED = 4
};
typedef enum defectReason1Enum		defectReason1_t;
//=======================================================================
enum defectReason2Enum {
	INVALID_DR2 = 0,
	UNEXPECTED_MEPID = 1,
	UNEXPECTED_INTERVAL = 2,
	LCK_DETECTED = 4
};
typedef enum defectReason2Enum		defectReason2_t;
//=======================================================================
enum templTypeEnum {
	CCM_TEMPL 	= 0,
	DELAY_TEMPL = 1,
	LOSS_TEMPL	= 2,
	LB_TEMPL	= 3,
	TST_TEMPL	= 4,
	LB_TEST_TLV_TEMPL	= 5
};
typedef enum templTypeEnum		templateType_t;
//=======================================================================
enum rdMaidTypeEnum {
	MR_MD_ONLY		= 1,
	MR_MA_ONLY		= 2,
	MR_MD_AND_MA	= 3
};
typedef enum rdMaidTypeEnum		rdMaidMask_t;

//=======================================================================
typedef uint32_t		svcID_t;

//=======================================================================
//===================== Define Data structures ===========================
//=======================================================================

//=======================================================================
typedef struct mdName_s mdNameFormatLen_t;
struct mdName_s {
	mdNameTypeOld_t		type;
	uint8_t				nameLength;
	char				name[43+1];
};
//=======================================================================
typedef struct maName_s maNameFormatLen_t;
struct maName_s {
	maNameTypeOld_t		type;
	uint8_t				nameLength;
	char				name[45+1];
};
//=======================================================================
typedef uint8_t macAddress_t[6];

//=======================================================================
typedef uint8_t orgValue_t[48];										// this TLV is simply a byte array...more advanced structuring to be added later

//=======================================================================
typedef uint8_t sidValue_t[48];										// this TLV is simply a byte array...more advanced structuring to be added later

//=======================================================================
typedef struct vidEntry_s {
	uint16_t			vlan;										// The 12-bit VLan to use for the TAG
	uint8_t				prio;										// The Priority to use for the TAG
	uint8_t				de;											// The Drop Eligibility bit for the TAG
} vidEntry_t;
typedef vidEntry_t 	pVidEntry_t;

//=======================================================================
typedef struct macEntry_s macEntry_t;
struct macEntry_s {
	uint8_t	byte[6];
};
//=======================================================================
 typedef struct tagStruct_s {
	boolean_t			present;									// Indicate if the TAG should be used (True) or not (False)
	#ifdef WIN_DLL_PADDING
	uint8_t				pad1b;										// required to word align variables for use in windows DLL
	#endif
	vidEntry_t			vidEntry;									// The vlan, prio and de to use for the Tag
} tag_t;

typedef struct{
	bool				present;									// Indicate if the TAG should be used (True) or not (False)
	uint16_t			tagId;
	uint16_t			tagVal;										// The vlan, prio and de to use for the Tag
} tagEntry_t;

//=======================================================================
typedef uint16_t		mepId_t;
//=======================================================================
typedef int16_t		pmNum_t;
//=======================================================================

typedef struct lcPmNumAlloc_s 	lcPmNumAlloc_t;
struct lcPmNumAlloc_s {
	uint16_t	cfg;
	uint16_t	rMepNum;
};
//=======================================================================
// MD Structures
typedef struct mdEntryOld_s 	mdEntryOld_t;
struct mdEntryOld_s {
	mdNameFormatLen_t	mdName;										// The MD Name
	uint8_t				mdLevel;									// The MD Level
};

//=======================================================================
// MA Structures
typedef struct maEntryOld_s 	maEntryOld_t;
struct maEntryOld_s {
	maNameFormatLen_t	maName;										// The MA Name
	ccmIntervalOld_t		ccmInterval;								// The enumerated value for the CCM Interval
};

//=======================================================================
//txTemplateStruct:
typedef struct txTemplateEntry_s txTemplateEntry_t;
struct txTemplateEntry_s {
	uint8_t		DA[6];												// DA[0] is the first byte on the wire, then DA[1],DA[2],etc.
	uint8_t		SA[6];												// SA[0] is the first byte on the wire, then SA[1],SA[2],etc.
	uint8_t		sTagTPID[2];										// Stag Type field - typically sTagTPID[0]=0x88,sTagTPID[1]=0xA8
	uint8_t		sTagVID[2];											// Stag VID -  sTagVID[0]=vlan[7:0],sTagVID[1]={prio,de,vlan[11:8]}
	uint8_t		cTagTPID[2];										// Ctag Type field - typically cTagTPID[0]=0x81,cTagTPID[1]=0x00
	uint8_t		cTagVID[2];											// Ctag VID -  cTagVID[0]=vlan[7:0],cTagVID[1]={prio,de,vlan[11:8]}
	uint8_t		eType[2];											// ether Type field - typically eType[0]=0x89,eType[1]=0x02
	uint8_t		proHdr[16];
	uint8_t		comCfmHdr[4];
	uint32_t		seqNum;
	uint16_t		cfmTLVLen;
	uint16_t		mepID;
	uint16_t		pktLen;
	uint8_t		proHdrLen;											// proHeader Length in Dwords
	uint8_t		pad1b;												// required to word align variables for use in windows DLL
	boolean_t	sTagPresent;										// 0 if no Stag is present, 1 if Stag is present
	boolean_t	cTagPresent;										// 0 if no Ctag is present, 1 if Ctag is present
	uint8_t		hdrLen;												// reserved for internal use, automatically generated by API.
	uint8_t		eTLV;
};
//=======================================================================
// Local MEP Structure
typedef struct lMepEntry_s lMepEntry_t;
struct lMepEntry_s {
	mepId_t				mepID;										// The MEP ID of this MEP
	enDis_t				enableCCMAlarms;							// if enabled then CCM Alarms are enabled
	uint8_t				port;										// Identifies the port on which the MEP/MIP resides
	tag_t				sTag;										// Stag values if present
	tag_t				cTag;										// Ctag values if present
};

//=======================================================================
// Remote MEP structure
typedef struct rMepEntryOld_s rMepEntryOld_t;
struct rMepEntryOld_s {
	mepId_t				mepID;										// The MEP ID of the (remote) MEP associated with this DB entry
	macAddress_t		macAddress;									// The MAC address of the remote MEP
};
//=======================================================================
typedef struct isTlv_s isTlv_t;
struct isTlv_s {
	boolean_t		present;										// Indicated if this TLV is present or not
	isValue_t		value;											// The enumerate value
};
//=======================================================================
typedef struct psTlv_s psTlv_t;
struct psTlv_s {
	boolean_t		present;										// Indicated if this TLV is present or not
	psValue_t		value;											// The enumerate value
};
//=======================================================================
typedef struct orgTlv_s orgTlv_t;
struct orgTlv_s {
	boolean_t		present;										// Indicated if this TLV is present or not
	uint8_t			length;											// The lenght in bytes of the TLV (including type & lenght fields)
	orgValue_t		value;											// The TLV value
};
//=======================================================================
typedef struct sidTlv_s sidTlv_t;
struct sidTlv_s {
	boolean_t		present;										// Indicated if this TLV is present or not
	uint8_t			length;											// The lenght in bytes of the TLV (including type & lenght fields)
	sidValue_t		value;											// The TLV value
};
//=======================================================================
typedef struct ccmTlv_s ccmTlv_t;
struct ccmTlv_s {
	isTlv_t			isTlv;											// The interface status TLV info
	psTlv_t			psTlv;											// The port status TLV info
	orgTlv_t		orgTlv;											// The organisation TLV info
	sidTlv_t		sidTlv;											// The sender ID TLV info
};
//=======================================================================
typedef uint8_t ccmTlvByteArray_t[56];

//=======================================================================
typedef struct lbTlv_s lbTlv_t;
struct lbTlv_s {
	uint16_t			length;
	uint8_t			bytes[1600];										// The Loopback TLV
};
//=======================================================================
typedef struct lbStats_s lbStats_t;
struct lbStats_s {
	uint32_t	numTxPkts;
	uint32_t	numTxAtRx;
	uint32_t	numRxPkts;
	uint32_t	minLatency;
	uint32_t	maxLatency;
	uint32_t	aveLatency;
	uint32_t	minJitter;
	uint32_t	maxJitter;
	uint32_t	aveJitter;
	uint8_t		sequenceErr;
	uint8_t		timeoutErr;
	uint8_t		multicast;
};
//=======================================================================
typedef struct lossStatsEntry_s lossStatsEntry_t;
struct lossStatsEntry_s {
	uint32_t	neTxCntr;
	uint32_t	neRxCntr;
	uint32_t	feTxCntr;
	uint32_t	feRxCntr;
};
//=======================================================================
typedef struct delayStatsEntry_s delayStatsEntry_t;
struct delayStatsEntry_s {
	uint32_t	fDPktCntr;
	uint32_t	fDErrCntr;
	uint32_t	fDVErrCntr;
	uint32_t	lastDelay;
	uint32_t	lastVar;
	uint32_t	minFD;
    uint32_t	maxFD;
    uint32_t	sumFDUpp;
    uint32_t	sumFDLow;
    uint32_t	minFDV;
    uint32_t	maxFDV;
    uint32_t	sumFDVUpp;
    uint32_t	sumFDVLow;
    uint32_t	fDBukt0;
    uint32_t	fDBukt1;
    uint32_t	fDBukt2;
    uint32_t	fDBukt3;
    uint32_t	fDVBukt0;
    uint32_t	fDVBukt1;
    uint32_t	fDVBukt2;
    uint32_t	fDVBukt3;
};
//=======================================================================
typedef struct pmErrCntEntry_s pmErrCntEntry_t;
struct pmErrCntEntry_s {
	uint32_t	eSCntr;
	uint32_t	sESCntr;
};
//=======================================================================
typedef struct lMepStatisticEntry_s lMepStatisticEntry_t;
struct lMepStatisticEntry_s {
	uint32_t	txCcmCnt;
	uint32_t	seqErrCnt;
	uint8_t	anyRdiSet;
	uint8_t	anyConnErr;
	uint8_t	rMepErrSt;
	uint8_t	xConnErrSt;
};
//=======================================================================
typedef struct rMepStatisticEntry_s rMepStatisticEntry_t;
struct rMepStatisticEntry_s {
	uint32_t			txCcmCnt;
	uint32_t			rxCcmCnt;
	uint8_t			rdi;
	uint8_t			ccmEnabled;
	uint8_t			connState;
	#ifdef WIN_DLL_PADDING
	uint8_t			pad1b;											// required to word align variables for use in windows DLL
	#endif
	macAddress_t	lastSA;
	#ifdef WIN_DLL_PADDING
	uint16_t			pad2b;											// required to word align variables for use in windows DLL
	#endif
	ccmTlv_t		ccmTlv;
};
//=======================================================================
#include <api_oam_sdk/common/types/inc/mr_api_private_types.h>										// Include the private data types before defining the remaining type.
//=======================================================================

//=======================================================================
enum efm_tEnum {
	EFM_ACTIVE 				=0,
	EFM_PASSIVE 			=1
};
typedef enum efm_tEnum		efmMode_t;

//========================================================================
typedef struct efmCfg_s efmCfg_t;
struct efmCfg_s {
	uint8_t	vars;
	uint8_t	events;
	uint8_t	lb;
	uint8_t	unidir;
	uint8_t	mode;
};
//========================================================================
typedef struct efmMatch_s efmMatch_t;
struct efmMatch_s {
	uint8_t	vars;
	uint8_t	events;
	uint8_t	lb;
	uint8_t	unidir;
};
//========================================================================
typedef struct pktHdr_s pktHdr_t;
struct pktHdr_s {
	macAddress_t	da;
	macAddress_t	sa;
	uint16_t			type;
	uint8_t			subType;
	uint16_t			flags;
	uint8_t			code;
};
//========================================================================
typedef struct efmFlags_s efmFlags_t;
struct efmFlags_s {
	uint8_t	flagByte;
	flag_t	linkFault;
	flag_t	dyingGasp;
	flag_t	criticalEvent;
	flag_t	localEval;
	flag_t	localStable;
	flag_t	remoteEval;
	flag_t	remoteStable;
};

//========================================================================

typedef struct efmLRInfoTlv_s efmLRInfoTlv_t;
struct efmLRInfoTlv_s {
	uint8_t		type;
	uint8_t		length;
	uint8_t		version;
	uint8_t		parser;
	efmCfg_t	efmCfg;
	uint8_t		mux;
	uint16_t		revision;
	uint16_t		maxPDUSize;
	uint32_t		oui;
	uint16_t		deviceId;
	uint16_t		versionId;
};

//========================================================================
typedef struct efmOrgInfoTlv_s efmOrgInfoTlv_t;
struct efmOrgInfoTlv_s {
	uint8_t		type;
	uint32_t		oui;
	uint8_t		tlv[255];
	uint8_t		tlvLength;
};

//========================================================================
typedef struct efmEventTlv_s efmEventTlv_t;
struct efmEventTlv_s {
	uint8_t		tlv[255];
	uint8_t		tlvLength;
};


//========================================================================
typedef struct efmInfoTempl_s efmInfoTempl_t;
struct efmInfoTempl_s {
	efmFlags_t		efmFlags;
	efmLRInfoTlv_t	localTlv;
	efmLRInfoTlv_t	remoteTlv;
	efmOrgInfoTlv_t	orgTlv;
	boolean_t		localPresent;
	boolean_t		remotePresent;
	boolean_t		orgPresent;
};

//========================================================================
typedef struct efmInfoTemplEntry_s efmInfoTemplEntry_t;
struct efmInfoTemplEntry_s {
	uint8_t			da[6];
	uint8_t			sa[6];
	uint16_t			type;
	uint8_t			subType;
	uint8_t			opCode;
	efmFlags_t		flags;
	efmLRInfoTlv_t	localTlv;
	efmLRInfoTlv_t	remoteTlv;
	efmOrgInfoTlv_t	orgTlv;
	uint8_t			localPresent;
	uint8_t			remotePresent;
	uint8_t			orgPresent;
};


//========================================================================
typedef struct efmLbTemplEntry_s efmLbTemplEntry_t;
struct efmLbTemplEntry_s {
	uint8_t			da[6];
	uint8_t			sa[6];
	uint16_t			type;
	uint16_t			flags;
	uint8_t			subType;
	uint8_t			opCode;
	uint16_t			dataLength;
	uint32_t			seqNum;
};

//========================================================================
typedef struct efmDiscIntInfo_s efmDiscIntInfo_t;
struct efmDiscIntInfo_s {
	efmFlags_t		remoteFlags;
	efmFlags_t		localFlags;
	boolean_t		remotePresent;
	uint8_t			localMuxSt;
	uint8_t			localParserSt;
	uint8_t			discSmSt;
	uint16_t			localRev;
	efmLRInfoTlv_t 	remoteTlv;
	uint8_t			timeOut;
	uint8_t			pad1b;
	char 			intMsg[256];
};

//========================================================================
typedef struct efmEventIntInfo_s efmEventIntInfo_t;
struct efmEventIntInfo_s {
	uint16_t			eventTypes;										// each bit represets an event type.
																	// 0 - ERRORED_SYMBOL_PER
																	// 1 - ERRORED_FRAME_EVENT
																	// 2 - ERRORED_FRAME_PER_EVENT
																	// 3 - ERRORED_FRAME_SECONDS_EVENT
	uint16_t			timeStamp[4];
	uint32_t			windowU[2];
	uint32_t			window[4];
	uint32_t			errorsU[2];
	uint32_t			errors[4];
	uint32_t			totalErrsU[4];
	uint32_t			totalErrsL[4];
	char 			intMsg[256];
};

//========================================================================
typedef struct efmIntInfo_s efmIntInfo_t;
struct efmIntInfo_s {
	boolean_t			discOccurred;								// Set to TRUE if an Discovery Interrupt occurred, otherwise false
	boolean_t			eventOccurred;								// Set to TRUE if an Event Interrupt occurred, otherwise false
	efmDiscIntInfo_t	discIntInfo;
	efmEventIntInfo_t	eventIntInfo;
};

//=======================================================================
typedef uint8_t packetBuffer_t[220];									// The packet buffer only captures the first 220 bytes of any packet
																	// byte [0] is the first byte on the wire, [1] is the second and so on.
//=======================================================================
typedef struct pktProbeIntInfo_s pktProbeIntInfo_t;
struct pktProbeIntInfo_s {
	boolean_t		eventOccurred;									// Set to TRUE if an event occurred, set to false if no event occurred
	uint32_t			probeMask;
	lMepHandle_t	lMepHandle;
	rMepHandle_t	rMepHandle;
	packetBuffer_t	captPkt;										// If a packet Prove event occurred the captured packet is available here
};
//=======================================================================
typedef struct connIntInfo_s connIntInfo_t;
struct connIntInfo_s {
	boolean_t		eventOccurred;									// Set to TRUE if an event occurred, set to false if no event occurred
	connType_t		value;											// either 'lost' or 'restored'
	rMepHandle_t	rMepHandle;										// The handle of remote MEP that reported the connectivity event.
};
//=======================================================================
typedef struct xConnIntInfo_s xConnIntInfo_t;
struct xConnIntInfo_s {
	boolean_t		eventOccurred;									// Set to TRUE if an event occurred, set to false if no event occurred
	xConnType_t		value;											// either 'errDetected' or 'errCleared'
	defectReason1_t	defectReason;									// Bits are set to identify the reason for the defect
	#ifdef WIN_DLL_PADDING
	uint8_t			pad1b;											// required to word align variables for use in windows DLL
	#endif
	lMepHandle_t	lMepHandle;										// The handle of local MEP on which the cross connect occurred.
	packetBuffer_t	captPkt;										// If a Cross Connect event occurred the captured packet is available here

};
//=======================================================================
typedef struct rMepErrIntInfo_s rMepErrIntInfo_t;
struct rMepErrIntInfo_s {
	boolean_t		eventOccurred;									// Set to TRUE if an event occurred, set to false if no event occurred
	rMepErrType_t	value;											// either 'errDetected' or 'errCleared'
	defectReason2_t	defectReason;									// Bits are set to identify the reason for the defect
	#ifdef WIN_DLL_PADDING
	uint8_t			pad1b;											// required to word align variables for use in windows DLL
	#endif
	lMepHandle_t	lMepHandle;										// The handle of local MEP on which the remote MEP Error occurred.
	packetBuffer_t	captPkt;										// If a remote MEP Error event occurred the captured packet is available here
};
//=======================================================================
typedef struct saChngIntInfo_s saChngIntInfo_t;
struct saChngIntInfo_s {
	boolean_t		eventOccurred;									// Set to TRUE if an event occurred, set to false if no event occurred
	macAddress_t	value;											// The new Source MAC Address
	rMepHandle_t	rMepHandle;										// The handle of remote MEP on which the SA change Error occurred.
};
//=======================================================================
typedef struct rdiChngIntInfo_s rdiChngIntInfo_t;
struct rdiChngIntInfo_s {
	boolean_t		eventOccurred;									// Set to TRUE if an event occurred, set to false if no event occurred
	rdiVal_t		value;											// The new value of the RDI bit
	rMepHandle_t	rMepHandle;										// The handle of the remote MEP on which RDI bit changed.
};
//=======================================================================
typedef struct tlvChngIntInfo_s tlvChngIntInfo_t;
struct tlvChngIntInfo_s {
	boolean_t			eventOccurred;								// Set to TRUE if an event occurred, set to false if no event occurred
	uint8_t				changeMask;									// bits indicate which TLVs changed, [0]-PS [1]-IS [2]-Org [3]-Sid
	rMepHandle_t		rMepHandle;									// The handle of the remote MEP on which the TLVs changed.
	ccmTlv_t			newTlv;										// The new value of the TLVs in hierarchial structure
	ccmTlvByteArray_t	newTlvBytes;								// The new value of the TLVs in byte array format
};
//=======================================================================
typedef struct isrRpt_s isrRpt_t;
struct isrRpt_s {
	uint32_t				intMask;									// bits indicate which interupts were detected,
																	//[0]-probe [1]-Conn [2]-xConn [3]-rMepErr
																	//[4]-saChng [5]-rdiChng [6]-tlvChng
	time_t				intTime;									// store the time the interrupt(s) was serviced.
//	efmIntInfo_t		efmIntInfo;									// Information related to the EFM discovery interrupt if it occurs.
	pktProbeIntInfo_t	pktProbeIntInfo;							// Information related to the packet probe interrupt if it occurs.
	connIntInfo_t		connIntInfo;								// Information related to the connectivity interrupt if it occurs.
	xConnIntInfo_t		xConnIntInfo;								// Information related to the cross connect interrupt if it occurs.
	rMepErrIntInfo_t	rMepErrIntInfo;								// Information related to the remote MEP Error interrupt if it occurs.
	saChngIntInfo_t		saChngIntInfo;								// Information related to the SA change interrupt if it occurs.
	rdiChngIntInfo_t	rdiChngIntInfo;								// Information related to the RDI change interrupt if it occurs.
	tlvChngIntInfo_t	tlvChngIntInfo;								// Information related to the TLVs change interrupt if it occurs.
//	char				captPktMsg[256];
};
//=======================================================================
// CCM service type - used for saving and restoring the CCM service configuration
typedef struct ccmSvc_s ccmSvc_t;

struct ccmSvc_s {
	boolean_t			svcPresent;						// indicates if the service is present or not
	svcEn_t				ccmTx;							// The Tx portion of the service is enabled
	svcEn_t				ccmRx;							// The Rx portion of the service is enabled
	#ifdef WIN_DLL_PADDING
	uint8_t				pad1b;							// required to word align variables for use in windows DLL
	#endif
	boolean_t			xConnSmEn;						// indicates if the Cross Connect Error SM is enabled/disabled
	boolean_t			rMepErrSmEn;					// indicates if the remote MEP Error SM is enabled/disabled
	#ifdef WIN_DLL_PADDING
	uint16_t				pad2b;							// required to word align variables for use in windows DLL
	#endif
	ccmTlv_t			ccmTlv;							// Details of the CCM TLV if any.
	txTemplateEntry_t	txTemplate;						// The txTemplate
};
//========================================================================
// PM service config type - used for specifying parameters when configuring
// the service
typedef struct svcCfg_s svcCfgInfo_t;

struct svcCfg_s {
	interval_t	interval;
	uint8_t		prio;
	pmSvcType_t svcType;
	pmSvcMode_t svcMode;
	uint32_t		lossOrDlyThres;
	uint32_t		dlyVarThres;
	uint16_t		pktSize;
};

//========================================================================
// PM service type - used for saving and restoring the PM service configuration
typedef struct ldSvc_s ldSvcInfo_t;

struct ldSvc_s {
	boolean_t	configured;
	enDis_t		enabled;
	uint8_t		prio;
	interval_t	interval;
	svcID_t		svcID;
	uint32_t		lossOrDlyThres;
	uint32_t		dlyVarThres;
	pmNum_t		pmNum;
	uint16_t		pktSize;
};
//========================================================================
// PM service type - used for saving and restoring the PM service configuration
typedef struct slmSvcInfo_s slmSvcInfo_t;

struct slmSvcInfo_s {
	boolean_t	configured;
	enDis_t		enabled;
	interval_t	interval;
	#ifdef WIN_DLL_PADDING
	uint8_t		pad1b;			// required to word align variables for use in windows DLL
	#endif
	svcID_t		svcID;
	uint32_t		lossThres;
	pmNum_t		pmNum;
	uint16_t		pktSize;
};
//========================================================================
// PM service type - used for saving and restoring the PM service configuration
typedef struct perfMeasSvc_s perfMeasSvc_t;

struct perfMeasSvc_s {
	ldSvcInfo_t		lmmOrig;
	ldSvcInfo_t		lmmResp;
	ldSvcInfo_t		dmmOrig[MR_MAX_DMM_PER_RMEP];
	ldSvcInfo_t		idmOrig;
	ldSvcInfo_t		idmResp;
	slmSvcInfo_t	slmOrig[8];			// one for each Priority
	slmSvcInfo_t	slmResp[8];			// one for each Priority
};
//========================================================================
// PM service type - used for saving and restoring the PM service configuration
typedef struct svcInfo_s svcInfo_t;

struct svcInfo_s {
	rMepHandle_t 	rMepHandle;
	pmNum_t 		pmNum;
	lcNum_t 		lcNum;
	uint8_t 			prio;
	pmSvcType_t 	svcType;
	pmSvcMode_t 	svcMode;
	interval_t		interval;

};
//========================================================================
/*
	interval_t			lossInterval;					// The loss interval, if 0 there is no Loss Service
	interval_t			delayInterval;					// The loss interval, if 0 there is no Loss Service
	ituLossType_t		lossType;						// Identifies the loss type (lmm or ccm)
	ituDelayType_t		delayType;						// Identifies the delay type (dmm or idm)
	svcEn_t				lmActive;						// Identifies if the loss service is enabled (if present)
	svcEn_t				dmActive;						// Identifies if the delay service is enabled (if present)
	pmNum_t				pmNum;							// The PM number for this service. 0xFF is a NULL pmNum
	boolean_t			assocRMep;						// Indicates if the PM service is directed at a remote MEP
	mepId_t				assocRMepID;					// If assocRMep=True then this is the mepID of the remote MEP
	uint32_t				lossThres;						// The Loss Threshold
	uint32_t				delayThres;						// The Delay Threshold
	uint32_t				delayVarThres;					// The Delay Variation Threshold
	macAddress_t		peerMacAddr;					// The MAC Address of the peer MEP that the svc is directed at (i.e. DA)
	boolean_t			detailed;						// Identifies if this service is the detailed service
	#ifdef WIN_DLL_PADDING
	uint8_t				pad1b;							// required to word align variables for use in windows DLL
	#endif
	txTemplateEntry_t	txTemplate;						// The txTemplate
};
*/

typedef struct y1564OneSecEntry_s {
	uint32_t	fifoRxCntVal;	// The raw RX count value from the per second FIFO
	uint32_t	fifoTxSeqNum;	// The last received sequence value (+1) from the per second FIFO
								// The +1 is because HW has added 1 to the last received Seq. No. before saving it.
	uint32_t	irTx;			// The Transmit Information Rate (IR) for this sampled 1sec interval.
	uint32_t	irTxMean;		// The Mean Transmit IR over the user specified test duration
	uint32_t	irMin;			// The Minimum Rx IR measured over the user specified test duration
	uint32_t	irMax;			// The Maximum Rx IR measured over the user specified test duration
	uint32_t	irMean;			// The Average Rx IR measured over the user specified test duration
	uint32_t	irCurr;			// The Rx IR measured for this sampled 1sec interval.
	int64_t		flCount;		// The accumulated sum of all lost frames over the user specified test duration
	double		flr;			// The Frame Loss Ratio * 1000000 measured for this sampled 1sec interval.
	uint32_t	availSecCnt;	// The accumulated count of all available seconds over the user specified test duration
} y1564OneSecEntry_t;

typedef struct y1564SampEntry_s {
	uint32_t	ftdMin;		// The minimum Frame Delay (in multiples of 256ns) recorded from the start of the test to time the HW register is read
	uint32_t	ftdMax;		// The maximum Frame Delay (in multiples of 256ns)recorded from the start of the test to time the HW register is read
	uint32_t	ftdMean;	// The Average Frame Delay (in multiples of 2.56ns) recorded from the start of the test to time the HW register is read
	uint32_t	ftdCurr;	// The Frame Delay (in multiples of 256ns) measured using the last packet received
	uint32_t	fdvMin;		// The minimum Frame Delay Variation (in multiples of 256ns) recorded from the start of the test to time the HW register is read
	uint32_t	fdvMax;		// The maximum Frame Delay Variation (in multiples of 256ns)recorded from the start of the test to time the HW register is read
	uint32_t	fdvMean;	// The Average Frame Delay Variation (in multiples of 2.56ns) recorded from the start of the test to time the HW register is read
	uint32_t	fdvCurr;	// The Frame Delay Variation (in multiples of 256ns) measured using the last packet received
	uint64_t	txCnt;		// A 64bit counter for the number of Tx packets. This is Not synchronised to RX.
	uint64_t	rxCnt;		// A 64bit counter for the number of Rx packets. This is Not synchronised to TX.
} y1564SampEntry_t;

typedef struct y1564DataEntry_s {
	y1564SampEntry_t	delayData;						// 'snapshot' of current FTD,FDV, Tx and Rx data.
	y1564OneSecEntry_t	irFlData[MR_LB_1SEC_FIFO_SIZE];	// Buffer of 1 sec HW sampled values for IR,FLR, FLcount and Availability
	uint32_t			totalSamples;					// indicated the current total number of 1 sec samples retrieved so far. Sticks at user set duration.
	uint8_t				validCnt;						// indicates the number of valid entries in the irFlData buffer (max = MR_LB_1SEC_FIFO_SIZE => 8)
	uint8_t				testDone;						// Indicates when the test is completed. If 0 then test is running, if 1 then test is completed
	// NOTE:
	// delayData.txCnt and delayData.rxCnt are not synchronised and should not be used for Final FLR and FL count
	// calculations until testDone = 1.
	// If validCnt = 1 then only irFlData[0] has valid data. All other buffer values are invalid
	// totalSamples will increment up to the user set duration (in sec) and stick at that value.
	// The testDone will toggle from 0 to 1 a short time after totalSamples = duration. The users must
	// continue to call the getY1564Data function periodically until testDone = 1.
} y1564DataEntry_t;

typedef int (*mrCaptPktCallBack_t)(uint8_t*,uint16_t,uint16_t);

//=======================================================================


typedef uint32_t networkAddress_t;


typedef enum {
	pushCtag = 0,
	pushStag = 1
} pushTag_t;

typedef enum {
	ta_noAction		= 0,
	ta_tagPop		= 1,
	ta_tagOverwrite	= 2,
	ta_tagPush		= 3
} tagAction_t;

typedef enum {
	cm_useVlanPcpTrafType	= 0,
	cm_useDefTrafType		= 1,
	cm_useDscpTrafType		= 2,
	cm_useVlanPcpTrafType_3	= 3
} cosMode_t;

#endif
