#include "mtpconst.h"

typedef	struct ls_info{
	BYTE		links_available;
	BYTE		links_available_t;
	BYTE		adjacentsp_acessible;
	BYTE		adjacentsp_restarting;
	WORD		adjacent_sp_place;
	BYTE		linksNum_configured;


	BYTE		influ_dstnum_asNLS;
	BYTE		influ_dstnum_asALS;

	BYTE		influ_dstplace_intable_asNLS[MAX_LS_DPC];
	BYTE		influ_dstplace_intable_asALS[MAX_LS_DPC];
}ls_info;

typedef	struct mtp3_flow{
	DWORD		UtoM[5];
	DWORD		MtoI[5];
	DWORD		ItoM[5];
	DWORD		MtoU[5];
	DWORD		stp[5];
	DWORD		UtoM_throwed[5];
	DWORD		MtoI_throwed[5];
	DWORD		ItoM_throwed[5];
	DWORD		MtoU_throwed[5];
	DWORD		stp_throwed[5];
    DWORD       stp_loop[5];
	DWORD		isup_detail[32];
}mtp3_flow;

typedef	struct network{
	BYTE		routine[256]; /* bit0-1: normal route available
							bit2-3: alternative route available
							bit4-5: acessible 
			  				bit6-7: current route */
	BYTE		rtpc_state[256];
	BYTE		rtpc_input[256];
	BYTE		rtac_state[256];
	BYTE		rtac_input[256];
	BYTE		rsrt_state[256];
	BYTE		rsrt_input[256];
	BYTE		rsrt_t10[256];
	BYTE		m3ua_rc_status[256];
	mtp3_flow	flow;
}network;

typedef struct nw_para{
	DWORD	dpc[256];
	BYTE	normal_ls[256];
	BYTE	alternative_ls[256];
	DWORD	opc24;
	DWORD 	opc14;
	BYTE	mtp3_t8[256];
	BYTE	mtp3_t15[256];
	BYTE	mtp3_t16[256];
	BYTE	acn[256][MAX_ACN_NUM];
	BYTE	ansi_local14b;
	BYTE	ansi_local24b;
	BYTE	ansi_remote[256];
	DWORD rc[256];
}nw_para;

typedef struct lk_pro
{
	BYTE  e1_to_linkset	__attribute__((packed));
	BYTE  e1_to_slc		__attribute__((packed));
	DWORD e1_to_mtp3	__attribute__((packed));
	BYTE  e1_lk_type	__attribute__((packed));//Bit0:0=ss7,1=m2ua
												//Bit1:1=enable,0=disable
												//Bit2:0=MTP3,1=MTP3LITE
												//BIT3:0=server,1=client
	BYTE  e1_to_sg		__attribute__((packed));
	BYTE  e1_to_iid		__attribute__((packed));
	DWORD remote_ip		__attribute__((packed));
	BYTE  inactive		__attribute__((packed));// Inactivity timer
	BYTE  inactive_tm	__attribute__((packed));// Allowed inactivity timeouts
	DWORD e1_to_alterMTP3		__attribute__((packed));//alternative MTP3
}lk_pro;

typedef struct lk_timer
{
	BYTE	t1;/* 500ms-1200ms */
	BYTE	t2;/* 700ms-2000ms */
	BYTE	t3;/* 500ms-1200ms */
	BYTE	t4;/* 500ms-1200ms */
	BYTE	t5;/* 500ms-1200ms */
	BYTE	t7;/* 1s-2s */
	BYTE	t8;/* 800ms-1200ms */
	BYTE	t12;/* 800ms-1500ms */
	BYTE	t13;/* 800ms-1500ms */
	BYTE	t14;/* 2s-3s */
	BYTE	t22;
	BYTE	t23;
}lk_timer;

typedef struct sg_para
{
	BYTE	enable							__attribute__((packed));
	BYTE	server							__attribute__((packed));
	BYTE	data_ack						__attribute__((packed));
	DWORD	ip								__attribute__((packed));
}sg_para;

typedef struct MTP3Parameter
{
	lk_pro	 lk[256];
	lk_timer lt[256];
	sg_para	 sg[256];
	BYTE	nw_pro;
	DWORD	ls_op_pc[128];/* for 128 linkset */
	BYTE	ls_pro[128];
	char	ls_reserved[128][16];//each linkset reserved 16 bytes for omc
	BYTE	mtp3_t10;
	BYTE	mtp3_t18;
	BYTE	mtp3_t19;
	BYTE	mtp3_t20;
	WORD	mtp3_t21;
	WORD	mtp3lite_port;
	nw_para	nw[4];
	BYTE	localAcn[MAX_ACN_NUM];
	ull		MTP3SerialNum;
}MTP3Parameter;

typedef	struct mtp{
	ls_info		ls[128];
	network		nw[4];
}mtp;

typedef	struct measure_of_mtp3{
	long	time_stamp;
	DWORD	lk_measure1[256][9];/* link measure oid=*.1 */
	DWORD	ls_measure[128][8];/* linkset measure oid=*.3 */
/*** traffic */
//	DWORD	tf_measure1[6][20];/* traffic octets */
	DWORD	tf_measure2[6][20];/* traffic MSUs */
	DWORD	tf_measure5[3];
}measure_of_mtp3;

typedef	struct mtp3_csta{
	measure_of_mtp3		measure[96];
}mtp3_csta;

typedef struct heartbeat_compoent_of_mtp3
{
	BYTE	version[3];
	BYTE	state;
	BYTE	link_state[64];
	BYTE	linkset_state[32];
	BYTE	masterMTP3[32];
	BYTE	SubState[2];
}heartbeat_compoent_of_mtp3;

typedef struct mtp2_heartbeat
{
	BYTE	systemid;
	BYTE	moduleid;
	BYTE	timestamp[4];
	BYTE	led_ctl_code[8];
	BYTE	alarm_component;
	BYTE	alarm_code;
	BYTE	reserved;
	BYTE	l1_state;
	BYTE	l2_state[8];
	BYTE	e1_dstip[8];
	BYTE	retrieved_bsnt[8];
}mtp2_heartbeat;

typedef struct mtp3DPCIndex
{
	DWORD	sortedNum;	
	DWORD	dpc[256];	
	DWORD	index[256];
}mtp3DPCIndex;

typedef struct mtp3_dpc_index
{
	mtp3DPCIndex	nw[4];
}mtp3_dpc_index;

/* by simon at 23/9/26 */
//extern mtp3_dpc_index	mtp3SortRoutine;

typedef struct _mtp3_state
{
	BYTE link_l1_state[256];
	BYTE link_l2_state[256];
	BYTE link_l3_state[256];
	BYTE lk_configured[256];
	BYTE lk_command[256];
	BYTE link_type[256];
	DWORD lk_mtp3[256];
	BYTE lk_NMTP3_ok[256];//normal mtp3 ok
	BYTE lk_AMTP3_ok[256];//alternative mtp3 ok
	
	BYTE lk_SpecANSI_flag[256];
	//special ANSI, use the Signalling network testing and maintenance special message

	BYTE lsac_state[256];
	BYTE tlac_state[256];
	BYTE tcoc_state[256];
	BYTE tcbc_state[256];
	BYTE tsrc_state[256];
	BYTE sltc_state[256];
	BYTE tprc_state;

	BYTE MTP3WatchDog[256];
}_mtp3_state;
/* by simon at 23/9/26 */
//extern _mtp3_state mtp3ObjState;

typedef struct _mtp3_input
{
	BYTE lsac_input_from_l2[256];
	BYTE lsac_input_from_sltc[256];
	BYTE lsac_input_from_stm[256];
	BYTE lsac_input_from_tcoc[256];
	BYTE lsac_input_from_mgmt[256];
	BYTE tlac_input_from_slm[256];
	BYTE tlac_input_from_mgmt[256];
	BYTE tlac_input_from_stm[256];
	BYTE tlac_input_from_hmdt[256];
	BYTE tlac_input_from_Tctl[256];/* input from timer control center*/
	BYTE tsrc_input_from_tcoc[256];
	BYTE tsrc_input_from_tcbc[256];
	BYTE tsrc_input_from_stm[256];
	BYTE tsrc_input_from_tlac[256];
	BYTE tcoc_input_from_tsrc[256];
	BYTE tcoc_input_from_stm[256];
	BYTE tcoc_input_from_hmdt[256];
	BYTE tcbc_input[256];
	BYTE tcbc_input_from_tsrc[256];
	BYTE sltc_input[256];
	BYTE tprc_input;
	BYTE taprc_input[128];
}_mtp3_input;
/* by simon at 23/9/26 */
//extern _mtp3_input mtp3ObjInput;

typedef struct _mtp3_IPMng
{
	BYTE	mtp3_flag_new[MAX_MTP3_NUM];
	BYTE	mtp3_flag_old[MAX_MTP3_NUM];
	DWORD	mtp3_flag_ip[MAX_MTP3_NUM];

	BYTE	LinkIPNum;
	DWORD	LinkIP[MAX_MTP3_NUM];
	BYTE	LinkIPSubSta[MAX_MTP3_NUM][2];
}_mtp3_IPMng;

typedef struct _mtp3_dynamic_opc
{
	BYTE 	opc_num[4];
	DWORD	opc[4][MTP3_MAX_DYNAMIC_OPC_PER_NW];
}mtp3_dynamic_opc;
/* by simon at 23/9/26 */
//extern _mtp3_IPMng MTP3IPMng;
