/****************************************************************
 ****************************************************************
 **                                                            **
 **    (C)Copyright 2005-2006, American Megatrends Inc.        **
 **                                                            **
 **            All Rights Reserved.                            **
 **                                                            **
 **        6145-F, Northbelt Parkway, Norcross,                **
 **                                                            **
 **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
 **                                                            **
 ****************************************************************
 ****************************************************************
 ****************************************************************
 ****************************************************************
 *
 * ipmi_lanconfig.h
 * Lan configuration command handler
 *
 * Author: Bakka Ravinder Reddy <bakkar@ami.com>
 *
 *****************************************************************/
#ifndef IPMI_LANCONFIG_H
#define IPMI_LANCONFIG_H

#include <stdint.h>
//#include <nwcfg.h>

/*** External Definitions ***/
#define IP_ADDR_LEN             4
#define MAC_ADDR_LEN            6
#define MAX_COMM_STRING_SIZE    18
#define MAX_NUM_CIPHER_SUITE_PRIV_LEVELS    10

#define MAX_IPV6_ADDR_STRLEN  41
#define MAX_NUM_LAN_ALERT_DESTINATIONS		15			//1h to Fh

#define MAX_LAN_CONF_PARAM				0x1A
#define MIN_LAN_OEM_CONF_PARAM			192
#define MAX_LAN_OEM_CONF_PARAM			255

#define LAN_PARAM_SET_IN_PROGRESS               0
#define LAN_PARAM_AUTH_TYPE_SUPPORT             1
#define LAN_PARAM_AUTH_TYPE_ENABLES             2
#define LAN_PARAM_IP_ADDRESS                    3
#define LAN_PARAM_IP_ADDRESS_SOURCE             4
#define LAN_PARAM_MAC_ADDRESS                   5
#define LAN_PARAM_SUBNET_MASK                   6
#define LAN_PARAM_IPv4_HEADER                   7
#define LAN_PARAM_PRI_RMCP_PORT                 8
#define LAN_PARAM_SEC_RMCP_PORT                 9
#define LAN_PARAM_BMC_GENERATED_ARP_CONTROL     10
#define LAN_PARAM_GRATITIOUS_ARP_INTERVAL       11
#define LAN_PARAM_DEFAULT_GATEWAY_IP            12
#define LAN_PARAM_DEFAULT_GATEWAY_MAC           13
#define LAN_PARAM_BACKUP_GATEWAY_IP             14
#define LAN_PARAM_BACKUP_GATEWAY_MAC            15
#define LAN_PARAM_COMMUNITY_STRING              16
#define LAN_PARAM_DEST_NUM                      17
#define LAN_PARAM_SELECT_DEST_TYPE              18
#define LAN_PARAM_SELECT_DEST_ADDR              19
#define LAN_PARAM_VLAN_ID                       20
#define LAN_PARAM_VLAN_PRIORITY                 21
#define LAN_PARAM_CIPHER_SUITE_ENTRY_SUP        22
#define LAN_PARAM_CIPHER_SUITE_ENTRIES          23
#define LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS      24
#define LAN_PARAM_VLAN_TAGS                     25
#define LAN_PARAMS_BAD_PASSWORD_THRESHOLD       26

#define LAN_PARAMS_AMI_OEM_VLANIFC_ENABLE               192
#define LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR             193
#define LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC               194

#define LAN_PARAMS_AMI_OEM_IPV6_ENABLE                  195
#define LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE          196
#define LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR                 197
#define LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR               207
#define LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR_PREFIX        208
#define LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH           198
#define LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP              199
#define LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64           211

/* Parameter No. 200 to 202 are specified as SSI OEM LAN Parameters */
#define LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR         200
#define LAN_PARAMS_SSI_OEM_LINK_CTRL                    201
#define LAN_PARAMS_SSI_OEM_CMM_IP_ADDR                  202

#define LAN_PARAMS_AMI_OEM_IPV6_DNS_SETTINGS            203
#define LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM              204
#define LAN_PARAMS_AMI_OEM_NCSI_SETTINGS                205
#define LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE             210
#define LAN_PARAMS_AMI_OEM_NCSI_EXTENSION               212

#define LAN_PARAMS_AMI_OEM_PHY_SETTINGS                 206
#define LAN_PARAMS_AMI_OEM_MTU_SETTINGS                 209

#define UNSPECIFIED_IP_SOURCE   0x00
#define STATIC_IP_SOURCE                0x01
#define DHCP_IP_SOURCE                  0x02
#define BIOS_IP_SOURCE                  0x03
#define BMC_OTHER_SOURCE                0x04

#define VLAN_MASK_BIT  0x8000       /* VLAN enable bit */

/**
 * @struct AuthTypeEnables_T
 * @brief Authentication Type Enables
**/
#pragma pack(1)
typedef struct
{
    uint8_t   AuthTypeCallBack;
    uint8_t   AuthTypeUser;
    uint8_t   AuthTypeOperator;
    uint8_t   AuthTypeAdmin;
    uint8_t   AuthTypeOem;

}   AuthTypeEnables_T;

/**
 * @struct LANDestType_T
 * @brief LAN Destination Type
**/
typedef struct
{
    uint8_t   SetSelect;
    uint8_t   DestType;
    uint8_t   AlertAckTimeout;
    uint8_t   Retries;

}   LANDestType_T;


/**
 * @struct LANDestAddr_T
 * @brief LAN Destination Address
**/
typedef struct
{
    uint8_t   SetSelect;
    uint8_t   AddrFormat;
    uint8_t   GateWayUse;
    uint8_t   IPAddr  [IP_ADDR_LEN];
    uint8_t   MACAddr [MAC_ADDR_LEN];

}   LANDestAddr_T;

typedef struct
{
    uint8_t   SetSelect;
    uint8_t   AddrFormat;
    uint8_t   GateWayUse;
    uint8_t   IPAddr  [IP6_ADDR_LEN];
    uint8_t   MACAddr [MAC_ADDR_LEN];
}   LANDestv6Addr_T;

/**
 * @struct IPv4HdrParams_T
 * @brief IPv4 Header Parameters
**/
typedef struct
{
    uint8_t   TimeToLive;
    uint8_t   IpHeaderFlags;
    uint8_t   TypeOfService;

}   IPv4HdrParams_T;

typedef struct
{
    uint8_t GenEvent;
    uint8_t ThreshNum;
    uint16_t ResetInterval;
    uint16_t LockoutInterval;
} BadPassword_T;

typedef struct
{
	uint8_t EthIndex;
	uint8_t MACAddress[MAC_ADDR_LEN];
} EnableSetMACAddress_T;

typedef struct
{
    uint8_t Interface;
    uint8_t PackageId;
    uint8_t ChannelId;
}  NCSIPortConfig_T;

typedef struct
{
    uint8_t Interface;
    uint8_t NCSIMode;
}  NCSIModeConfig_T;

typedef struct
{
    uint8_t Command;
    uint8_t Interface;
    uint8_t VetoBit;
}  NCSIPHYConfigSet_T;

typedef struct
{
    uint8_t Interface;
    uint8_t VetoBit;
}  NCSIPHYConfigGet_T;

/**
 * @struct IPv6Addr_T
 * @brief Setting Multiple static IPv6 address
**/
typedef struct
{
    uint8_t               IPv6_Cntr;
    uint8_t               IPv6_IPAddr [IP6_ADDR_LEN];
}IPv6Addr_T;

/**
 * @struct IPv6Prefix_T
 * @brief Setting Multiple static IPv6 prefix length
**/
typedef struct
{
    uint8_t               IPv6_Prepos;
    uint8_t               IPv6_PrefixLen;
}IPv6Prefix_T;

typedef struct
{
    uint8_t AutoNegotiationEnable;
    uint16_t Speed;
    uint8_t Duplex;
    uint8_t Interface;
    uint8_t CapabilitiesSupported;
}   PHYConfig_T;

/**
* @struct LANConfigUn_T
* @brief LAN Configuration Parameters.
**/
typedef union {

   uint8_t               SetInProgress;
   uint8_t               AuthTypeSupport;
   AuthTypeEnables_T   AuthTypeEnables;
   uint8_t               IPAddr [4];
   uint8_t               IPAddrSrc;
   uint8_t               MACAddr [6];
   uint8_t               SubNetMask [4];
   IPv4HdrParams_T     Ipv4HdrParam;
   uint16_t              PrimaryRMCPPort;
   uint16_t              SecondaryPort;
   uint8_t               BMCGeneratedARPControl;
   uint8_t               GratitousARPInterval;
   uint8_t               DefaultGatewayIPAddr [IP_ADDR_LEN];
   uint8_t               DefaultGatewayMACAddr [MAC_ADDR_LEN];
   uint8_t               BackupGatewayIPAddr [IP_ADDR_LEN];
   uint8_t               BackupGatewayMACAddr [MAC_ADDR_LEN];
   uint8_t               CommunityStr [MAX_COMM_STRING_SIZE];
   uint8_t               NumDest;
   LANDestType_T       DestType;
   LANDestAddr_T       DestAddr;
   LANDestv6Addr_T     Destv6Addr;
   uint16_t              VLANID;
   uint8_t               VLANPriority;
   uint8_t               CipherSuiteSup;
   uint8_t               CipherSuiteEntries [17];
   uint8_t               CipherSuitePrivLevels [MAX_NUM_CIPHER_SUITE_PRIV_LEVELS];
   BadPassword_T       BadPasswd;
   uint8_t               EthIndex;
   uint8_t               ChangeMACEnabled;
   uint8_t               IPv6_Enable;
   uint8_t               IPv6_IPAddrSrc;
   uint8_t               IPv6_LinkAddr [IP6_ADDR_LEN];
   IPv6Addr_T          IPv6Addr;
   IPv6Prefix_T        IPv6Prefix;
   uint8_t               IPv6_LinkAddrPrefix;
   uint8_t               IPv6_GatewayIPAddr[IP6_ADDR_LEN];
   uint8_t               NumNCSIPortConfigs;
   NCSIPortConfig_T    NCSIPortConfig;
   PHYConfig_T         PHYConfig;
   uint8_t               SSI2ndPriEthMACAddr[MAC_ADDR_LEN];
   uint8_t               SSILinkControl;
   uint8_t               CMMIPAddr[IP_ADDR_LEN];
   uint16_t              MTU_size;
   NCSIModeConfig_T	NCSIModeConfig;
   NCSIPHYConfigSet_T	NCSIPHYConfigSet;
   NCSIPHYConfigGet_T	NCSIPHYConfigGet;
} LANConfigUn_T;


/* GetLanCCRev_T */
typedef struct
{
    uint8_t   CompletionCode;
    uint8_t   ParamRevision;

}   GetLanCCRev_T;


/* GetLanConfigReq_T */
typedef struct 
{
    uint8_t   ChannelNum;
    uint8_t   ParameterSelect;
    uint8_t   SetSelect;
    uint8_t   BlockSelect;

}   GetLanConfigReq_T;


///* GetLanConfigRes_T */
//typedef struct
//{
//    GetLanCCRev_T   CCParamRev;
//    LANConfigUn_T   ConfigData;

//}   GetLanConfigRes_T;

/* GetLanConfigOEM_T */
typedef struct
{
    GetLanCCRev_T   CCParamRev;
    /* OEM parameter should be added below*/
}  GetLanConfigOEMRes_T;

/* SetLanConfigReq_T */
typedef struct
{
    uint8_t           ChannelNum;
    uint8_t           ParameterSelect;
    /* OEM parameter should be added below*/
}   SetLanConfigOEMReq_T;

/* SetLanConfigReq_T */
typedef struct 
{
   uint8_t           ChannelNum;
   uint8_t           ParameterSelect;
   LANConfigUn_T   ConfigData;

}   SetLanConfigReq_T;


/* SetLanConfigRes_T */
typedef struct 
{
    uint8_t   CompletionCode;

}   SetLanConfigRes_T;


/* SuspendBMCArpsReq_T */
typedef struct 
{
    uint8_t   ChannelNo;
    uint8_t   ArpSuspend;

}   SuspendBMCArpsReq_T;


/* SuspendBMCArpsRes_T  */
typedef struct 
{
    uint8_t   CompletionCode;
    uint8_t   ArpSuspendStatus;

}   SuspendBMCArpsRes_T;


/* GetIPUDPRMCPStatsReq_T */
typedef struct 
{
    uint8_t   ChannelNo;
    uint8_t   ClearStatus;

}   GetIPUDPRMCPStatsReq_T;

/* GetIPUDPRMCPStatsRes_T  */
typedef struct 
{
    uint8_t   CompletionCode;
    uint16_t   IPPacketsRecv;
    uint16_t   IPHeaderErr;
    uint16_t   IPAddrErr;
    uint16_t   FragIPPacketsRecv;
    uint16_t   IPPacketsTrans;
    uint16_t   UDPPacketsRecv;
    uint16_t   ValidRMCPPackets;

}   GetIPUDPRMCPStatsRes_T;


typedef struct
{
    int16_t  RegValue;
    uint8_t   RegNumber;
    uint8_t   IsReplace;

}   SetPHYReg_T;


#pragma pack()
#endif /* IPMI_LANCONFIG_H */
