/* Title:	logCollector.h
 * Description:
 * Author:	
 * Date:	
 */

#ifndef logCollector__H
#define logCollector__H

#include "../../../../plat/public/src/include/asn1.h"
#include "../../../../plat/snmp/src/include/snmp.h"
#include "../../../omcLib/c_program/omcLib/omcLib.h"

#ifndef MYSQL_H
#include "mysql.h"
#endif

#ifndef logCollector_DEBUG
#define logColl_DEBUG 0
#endif

#define MaxLogSrcNum		16	//max number of command can be execute as same time
#define MaxAttrDefnNum		256
#define MaxOidLen			20	//max number of object ID
#define MaxSubOidLen		10	//max number of sub object ID
#define MaxVarNum			50	//max number of var in one pdu
#define DefPort				4960	//define receive port
#define HOSTNAME			"localhost"
#define PUB_DB				"OMC_PUB"	//OMC's public database
#define SysConfTable		"OMC_PUB.sysConf"	//system config table
#define logConfTable		"OMC_PUB.sysLogSrcConf"	//system config table
#define IpTable				"OMC_PUB.sysInfo"	//system's IP table

//msgState flag define
#define nIdle			0
#define nWaitResponse	1

//logState flag define
#define nGetInfo		0
#define nGetLog			1
#define nWaitLog		2

//snmp pdu type define [define in snmp.h]
#define nGet			0
#define nGetNext		1
#define nResp			2
#define nSet			3

#define nBgnOid			1
#define nEndOid			2
#define nDataOid		3

//snmp var type code
#define  nInteger			0x02
#define  nOctetString		0x04
#define  nNull				0x05
#define  nObjectId			0x06
#define  nNoSuchObject		0x80
#define  nNoSuchInstance	0x81
#define  nEndOfMibView		0x82

typedef struct unitAttrDefn {
	int sysTypeNo;
	int dataTypeNo;
	char fieldObjIdStr[16];
	char fieldName[64];
	int valueType;
	int valueLen;
} unitAttrDefn;

typedef struct unitLogSrc {
	int isEnable;
	int sysTypeNo;
	int sysNo;
	int subSysNo;

	int requestId;
	char dstIP[16];
	WORD dstPort;
	DWORD preObjId[20];			//the oid before x
	int preObjIdLen;
	int maxMsgLen;
	char snmpCommunity[16];

	int dataTypeNo;
	int maxSizeOfRec;
	int maxRecNumOfBuf;
	int maxRecNumOfDay;
	char dataStoreTable[64];	//database.table
	int attrDefnArrOffset;
	int attrDefnNum;

	unsigned long bgnNo;
	unsigned long endNo;
	unsigned long logNo;

	BYTE logState;				//-1:nFailed,0:nWaitProc,1:nNoFinish,2:nFinished 
	BYTE msgState;				//command process state:0=idle,1=waitResponse 
	BYTE waitTimeCount;			//the times number of timeout
	BYTE timeoutCount;			//the timeCount

	int sleepTime;				//the time count of sleep to wait log
	int sleepCount;				//tht count 

	int totalVarNum;
	int finishVarNum;

	char desc[200];

	//var_list info
	BYTE varNum;
} unitLogSrc;

//Interface Functions Declare,define in logCollector.c
int logCollectorInit();
int logCollectorTimer();

#endif
