#ifndef __AL_NETWORK_CTRL_H__
#define __AL_NETWORK_CTRL_H__

#include "al_basictypes.h"

#define RECNUM 5

#define APPWDefault {0,0,{0},{0},{0,0,0,0,0,0}}

typedef enum {
    e_AL_Network_Mode_None,
    e_AL_Network_Mode_Ethernet,
    e_AL_Network_Mode_Wireless,
    e_AL_Network_Mode_End,
}e_AL_Network_Mode; //mapping to E_MID_NWSI_CONNECT_TYPE

typedef enum { //force sync with E_MID_NWSI_ENCRYPTIONTYPE @ "netsetting_if.h"
    e_AL_ENCRYPTIONTYPE_OFF = 0,
    e_AL_ENCRYPTIONTYPE_WEP = 0x1,
    e_AL_ENCRYPTIONTYPE_WPA = 0x2,
    e_AL_ENCRYPTIONTYPE_WPA2 = 0x4,
}e_AL_Encryption_Type; //mapping to E_MID_NWSI_ENCRYPTIONTYPE

typedef enum {
		e_AL_IPMode_None,
    e_AL_IPMode_Manual,
    e_AL_IPMode_Auto,
    e_AL_IPMode_End,
}e_AL_IPMode; //mapping to E_MID_NWSI_IP_TYPE

typedef struct _Al_IP_t{
    al_uint8 IPA;
    al_uint8 IPB;
    al_uint8 IPC;
    al_uint8 IPD;
}Al_IP_t;

typedef struct _Al_NetMask_t{
    al_uint8 MaskA;
    al_uint8 MaskB;
    al_uint8 MaskC;
    al_uint8 MaskD;
}Al_NetMask_t;

typedef struct _Al_Gateway_t{
    al_uint8 GwA;
    al_uint8 GwB;
    al_uint8 GwC;
    al_uint8 GwD;
}Al_Gateway_t;

typedef struct _Al_DNS_t{
    al_uint8 DNSA;
    al_uint8 DNSB;
    al_uint8 DNSC;
    al_uint8 DNSD;
}Al_DNS_t;


typedef struct _Al_MAC_t{
    al_uint8 MACA;
    al_uint8 MACB;
    al_uint8 MACC;
    al_uint8 MACD;
    al_uint8 MACE;
    al_uint8 MACF;    
}Al_MAC_t;

typedef struct _Al_IPSET_t{
    Al_IP_t IP;
    Al_NetMask_t NetMask;
    Al_Gateway_t GateWay;
    Al_DNS_t DNS1;
    Al_DNS_t DNS2;   
}Al_IPSET_t;

typedef struct _Al_APInfo_t{
    al_int8 name[64];
    al_uint8 channel;
    al_int8 quality;
    al_uint8 encryption;
    Al_MAC_t mac;
    al_uint8 conntected;
}Al_APInfo_t;

typedef struct _APPW_t
{
	al_uint8 PWlen;
	al_uint8 EncryptionType;
	al_uint8 Name[64];
	al_int8 PassWord[64];
	Al_MAC_t mac;
} Al_APPW_t;

typedef struct _Al_WiFiPwd_t
{
	al_uint8 curRecAPIndex;
	al_uint8 LastRecAPIndex;
	Al_APPW_t APPW[RECNUM];
} Al_WiFiPwd_t;

AL_Return_t Al_Network_Ctrl_Init(al_void);
al_void Al_Network_Ctrl_Set_ConnectMode(e_AL_Network_Mode mode);
AL_Return_t Al_Network_Ctrl_Destroy(al_void);

AL_Return_t Al_Network_Ctrl_SetIP(Al_IP_t *pIP);
AL_Return_t Al_Network_Ctrl_SetNetMask(Al_NetMask_t *pNetMask);
AL_Return_t Al_Network_Ctrl_SetGateway(Al_Gateway_t *pGateWay);
AL_Return_t Al_Network_Ctrl_SetDNS(Al_DNS_t *pDNS1,Al_DNS_t *pDNS2);
AL_Return_t Al_Network_Ctrl_SetDhcpStatic(e_AL_Network_Mode cType, e_AL_IPMode ipType, Al_IPSET_t *pIPSet);
AL_Return_t Al_Network_Ctrl_GetIP(Al_IP_t *pIP);
AL_Return_t Al_Network_Ctrl_GetNetMask(Al_NetMask_t *pNetMask);
AL_Return_t Al_Network_Ctrl_GetGateway(Al_Gateway_t *pGateway);
AL_Return_t Al_Network_Ctrl_GetDNS(Al_DNS_t *pDNS1, Al_DNS_t *pDNS2);
AL_Return_t Al_Network_Ctrl_GetMAC(Al_MAC_t *pMac);
al_int32 Al_Network_Ctrl_GetMTU(al_void);

al_int32 Al_Network_Ctrl_GetAPNum(al_void);
al_int32 Al_Network_Ctrl_QueryAPData(al_int32 from, al_int32 to,Al_APInfo_t *pAPInfo);
al_void Al_Network_Ctrl_SetIPMode(e_AL_IPMode IPMode);
AL_Return_t Al_Network_Ctrl_ConnectAP(Al_APInfo_t APInfo, al_uint8 keylen, al_int8 pKey[]);
AL_Return_t Al_Network_Ctrl_DisconnectAP(void);
al_bool AL_Network_Ctrl_GetConnectStatus();
al_bool Al_Network_Ctrl_GetConnectAPData(Al_APInfo_t *pConnectedAPInfo);
AL_Return_t Al_Network_Ctrl_CheckWireless(void);
al_int8 Al_Network_Ctrl_GetAPQuailty(void);
al_int8 Al_Network_Ctrl_GetP2PQuailty(void);


#endif //__AL_NETWORK_CTRL_H__


