#ifndef RAID_AGENT__H
#define RAID_AGENT__H

#include "../../../../plat/public/src/include/pub_include.h"
#include "../../../omcLib/c_program/omcLib/omcLib.h"
#include "../../../../plat/snmp/src/include/snmp.h"
#include <sys/types.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdio.h>

#ifndef MYSQL_H
	#include "mysql.h"
#endif
	
#ifndef RAIDAGENT_DEBUG
	#define RAIDAGENT_DEBUG 0
#endif

#define CONF_FILE "./conf/raid.conf"

int raid_agent_init(int omcSysNo);
void raid_agent_timer();

int raid_agent_task_init();
int raid_agent_task_timer();

void logRaid(const char *fmt,...);

#define RAID_SYSTYPENO 234
#define MAX_RAID_SERVER 8
#define MAX_RAID_SYSTEM 16
#define GET_STATUS_INTERVAL 10	//second
#define RESPONSE_TIMEOUT 10
#define RAID_LOCAL_PORT 4962
#define MAX_DISK_COUNT 8

#define FIELD_CARDNAME "CardName"
#define FIELD_DISKNUM "DiskNum"
#define FIELD_DISKSLOT "DiskSlot"
#define FIELD_DISKSTATE "DiskState"
#define FIELD_OPTPROG "OptProg"
#define FIELD_VENDORID "VendorID"
#define FIELD_PRODUCTID "ProductID"
#define FIELD_DISKSIZE "DiskSize"
#define FIELD_DISKERRCOUNT "DiskERRC"

#define PDU_SUMMARG 0
#define PDU_DETAIL 1
#define SERVER_TYPE_INTEL 0
#define SERVER_TYPE_DELL 1
#define ALARM_CLEAR 0
#define ALARM_ADD 1

#define ALARM_NONE 0
#define ALARM_RESPONSE_TIMEOUT 1
#define ALARM_DISK_OFFLINE 2
#define ALARM_DISK_FAILED 3
#define ALARM_DISK_REBUILD 4
#define ALARM_UNKNOWN 5

#define INTEL_STATE_OFFLINE_VALUE 16
#define INTEL_STATE_FAILED_VALUE 17
#define INTEL_STATE_REBUILD_VALUE 20
#define INTEL_STATE_ONLINE_VALUE 24

#define DELL_STATE_OFFLINE_VALUE 4
#define DELL_STATE_FAILED_VALUE 2
#define DELL_STATE_REBUILD_VALUE 24
#define DELL_STATE_ONLINE_VALUE 3

#define STATE_IDLE 0
#define STATE_GET_SUMMARY 1
#define STATE_RESPONSE_SUMMARY 2
#define STATE_GET_DETAIL 3
#define STATE_RESPONSE_DETAIL 4
#define STATE_FINISH 5

typedef struct raid_system
{
	int state;
	int sys_id;
	unsigned long remote_ip;
	unsigned long request_id;
	
	int cur_disk_num;
	int total_disk_num;
	
	int last_alarm_value[MAX_DISK_COUNT];
	unsigned long last_update_time;
	unsigned long timeout;
}raid_system;

typedef struct raid_server
{
	char server_name[16];
	int server_type;	//0-Intel,1-Dell
	int enable_flag;
	int related_system_type;
	int system_count;
	raid_system system[MAX_RAID_SYSTEM];
}raid_server;

typedef struct raid_param
{
	int enable_flag;
	int server_snmp_port;
	int system_type;	//0-MCSS,1-MCMS
	int server_count;
	raid_server server[MAX_RAID_SERVER];
}raid_param;


#endif

