/*
 *  Copyright (c) 1996-2007 Digi International Inc., All Rights Reserved
 *
 *  This software contains proprietary and confidential information of Digi
 *  International Inc.  By accepting transfer of this copy, Recipient agrees
 *  to retain this software in confidence, to prevent disclosure to others,
 *  and to make no use of this software other than that for which it was
 *  delivered.  This is an unpublished copyrighted work of Digi International
 *  Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 *  prohibited.
 *
 *  Restricted Rights Legend
 *
 *  Use, duplication, or disclosure by the Government is subject to
 *  restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
 *  Technical Data and Computer Software clause at DFARS 252.227-7031 or
 *  subparagraphs (c)(1) and (2) of the Commercial Computer Software -
 *  Restricted Rights at 48 CFR 52.227-19, as applicable.
 *
 *  Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 *
 * =======================================================================
 *  This file contains the routines that read and write the development
 *  board configuration parameters in NVRAM.  THE CODE IN THIS FILE MUST 
 *  BE CUSTOMIZED TO SUPPORT YOUR APPLICATION HARDWARE.  The default 
 *  implementation supports the NET+OS development boards. This code should 
 *  NOT be used in customer end products since it generates Digi International 
 *  specific Ethernet MAC addresses.  At the very least, the routine 
 *  customizeGetMACAddress() must be rewritten to generate MAC addresses 
 *  in the range assigned to the customer by the IEEE.
 *
 *
 * Edit Date/Ver   Edit Description
 * ==============  ===================================================
 * ESun  07/20/00  Fixed a bug. Change " #define START_OF_FREE_NVRAM
 *                 size0f(developmentBoardinfoType);" to "#define START_OF_FREE_NVRAM
 *                 (START_OF_DEV_BOARD_PARAMETERS+sizeof (devBoardParamsType))"
 * PMJ   10/16/00  Included PPP NVRAM support.
 * PMJ   10/26/00  Removed private functions NASaveIP, NAResolve_MAC and
 *                 NAResolveIP from header.
 * PMJ   03/21/02  Included new members to the NVRAM default structure.
 * PMJ   03/29/02  Included NVRAM capabilities for SNTP Servers.
 * PMJ   04/09/02  Included Kerberos realm name into the NVRAM parameters.
 * DXL	 04/18/02  Define NASaveSerial () as a void; resolved compile warning
 * GAC	 06/07/07  Add wireless parameters and interface #defines
 * JZW   05/24/05  Removed kerberos references. No longer supported
 *
 */

#ifndef __boardparams_h
#define __boardparams_h

#include "Npttypes.h"
#include "sysAccess.h"
#include "NASecurity.h"
#include "ace_params.h"
#include "wln_api.h"
#include "iam.hh"
#include "iam_params.h"
#include "wps_def.h"
#include "spi_touch.h"
#include "mgmtconnection.h"
#include "mgmtnetwork.h"
#include "mgmtglobal.h"
#include "devicesecurity.h"

#ifdef __cplusplus
extern "C"
{
#endif


/*ad*
 * This return value indicates success.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
*ad*/
#define BP_SUCCESS              0

/*ad*
 * This return value indicates an error.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
*ad*/
#define BP_FAILURE              -1

/*ad*
 * This return value indicates that there is no configuration record for the 
 * selected interface.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
*ad*/
#define BP_NO_RECORD            -2

/*ad*
 * This return value indicates that the configuration record is of an 
 * unknown version.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
*ad*/
#define BP_WRONG_VERSION        -3

/*ad*
 * This return value indicates that there is no more room in the interface
 * table for another interface config.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
*ad*/
#define BP_FULL                 -4

/*ad*
 * Generic return value, indicating that one or more of the function 
 * arguments are invalid
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 7.0
*ad*/
#define BP_INVALID_ARGUMENT     -5

/*ad*
 * Generic return value, indicating that resources could not be allocated
 * to complete an operation.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 7.0
*ad*/
#define BP_NO_RESOURCES         -6

/*ad*
 * Length of serial number.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
*ad*/
#define BP_SERIAL_NUMBER_LENGTH     9

/*ad*
 * Name of Ethernet interface.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
*ad*/
#define BP_ETH_INTERFACE            "eth0"

/*ad*
 * Name of secondary Ethernet interface.  The secondary interface is used
 * to support an Auto-IP address.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
*ad*/
#define BP_ETH_0INTERFACE          "eth0:0"

/*
 * Name of wireless interface.
 *
 */
#define BP_WLN_INTERFACE            "wln0"

/*
 * Name of secondary wireless interface.  The secondary interface is used
 * to support an Auto-IP address.
 *
 */
#define BP_WLN_0INTERFACE          "wln0:0"

/*
 * Name of interface used for bridging. This is a virtual interface which
 * appears to the tcpip stack as a device interface, and appears to the
 * ethernet and wireless drivers as a protocol stack.
 *
 */
#define BP_EWB_INTERFACE          BP_ETH_INTERFACE
#define BP_EWB_0INTERFACE         BP_ETH_0INTERFACE

/*
 * This define is used to determine the length of the user data.
 * WARNING!! : Changing this length will corrupt the board paramater, unless
 * you are pretty sure to loose the board paramater, don't modify this value.
 */
#define BP_USER_DATA_LEN          292

/*ad*
 * This enum defines the possible values for the Ethernet duplex setting used
 * when the automatic negotiation process with the hub or switch fails.  Almost
 * all hubs and switches support automatic negotiation out of the box.  The typical
 * reasons why the process would fail are:
 *
 * <list type="unordered">
 *      <item>The end user is using an old 10-BASE-T hub that does not support
 *            auto-negotiation.  There are still a few of these around.  These
 *            hubs are usually half duplex.</item>
 *      <item>The end user has decided to randomly reconfigure his hub or switch
 *            just to see what happens.</item>
 * </list>
 *
 * When auto-negotiation fails, the PHY will still be able to determine the
 * link speed, but cannot determine the duplex level.  Most PHYs will default
 * to half duplex since this is what the old 10-BASE-T hubs support.  Since
 * old 10-BASE-T hubs are the main reason why the negotiation would fail, this
 * default works almost all of the time.  This is what bpDefaultDuplex selects,
 * and it is the recommended setting.
 *
 * If bpHalfDuplex is chosen, then the link is reset and then forced to half
 * duplex if auto-negotiation fails.  This is not the same as selecting 
 * bpDefaultDuplex, since the link is reset.
 * If bpFullDuplex is chosen, then the link will be reset and then forced to full
 * duplex if auto-negotiation fails.  In all cases, if we lose the link to the
 * hub (for example, someone pulls out the Ethernet cable), the Ethernet driver will always
 * restart the auto-negotiation process when the link is restored.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Device_Drivers:EthernetDriver 
 * @since 6.0
 * @see @link APP_DEFAULT_ETHERNET_DUPLEX
 *
 * @param bpHalfDuplex      Force the PHY to use a half duplex link, if auto-negotiation has failed.  
 * @param bpFullDuplex      Force the PHY to use a full duplex link, if auto-negotiation has failed
 * @param bpDefaultDuplex   Use the PHY's default duplex setting, keep auto-negotiation enabled.  
 *                          This is the recommended setting.  Most PHYs will default to half duplex.
*ad*/
typedef enum
{
    bpHalfDuplex = 0,
    bpFullDuplex = 1,
    bpDefaultDuplex = 2
} bpDuplexLevelType;

#define TIMEZONE_RULE_LENGTH	16

/*ad*
 * Time zone structure definition
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
 *
 * @param sync_time         Time in seconds between resynchronizations.
 * @param std_zone_offset   Offset of standard time zone from GMT.
 * @param dst_zone_offset   Offset of daylight savings time zone from GMT.
 * @param dst_start_rule    Indicates when to change to daylight saving time zone.
 * @param dst_end_rule      Indicates when to change back to standard time zone.
*ad*/
typedef struct timezone_t {
	unsigned int	sync_time;			
	int				std_zone_offset;	
	int				dst_zone_offset;	
	char			dst_start_rule[TIMEZONE_RULE_LENGTH];	
	char			dst_end_rule[TIMEZONE_RULE_LENGTH]; 	
} TIMEZONE_T;

/*ad*
 * Wireless parameters structure.
 * Used by both wireless driver and WPA application.
 *
 * @since 6.0
 * @category BSP:Device_Drivers:wireless
 * @external
 * @see @link naWlnSetParams
 * @see @link EncryptValues
 * @see @link EAPValues
 * @see @link WirelessOptionValues
 * @see @link wln_bss
 * @see @link WirelessBandNum
 * @see @link naWlnGetParams
 * @see @link naWlnSetParams
 * @see @link WirelessParam
 * @see @link WirelessChanIndex
 *
 * @param bss_type      Network type: one of @link wln_bss
 * @param ssid          Current service set ID.  (Size limited to WLN_SSID_SIZE.  See @link WirelessParam)
 * @param ssid_len      Service set ID length in bytes.  Set to 0 to search.  This length is limited to WLN_SSID_SIZE.  See @link WirelessParam.
 * @param channel       1 through WLN_CHAN_NUM or use 0 or WLN_CHAN_SCAN to scan all channels.  See @link WirelessChanIndex for details.
 * @param sta_addr      Station MAC address
 * @param authen        Authentication types allowed: one or more of @link WirelessAuthenParam
 * @param encrypt       Encryption types allowed: one or more of @link EncryptValues
 * @param wep_key_id    WEP key index: 0-3
 * @param wep_key_len   WEP key length: 0, 5, or 13
 * @param wep_key       WEP keys
 * @param wpa_psk       WPA pre-shared key
 * @param eap_methods   802.1x/EAP authentication methods allowed: one or more of @link EAPValues
 * @param identity      User identity (login), ASCII NUL terminated
 * @param password      User password, ASCII NUL terminated
 * @param options       Bitmap of options: one or more of @link WirelessOptionValues
 * @param chan_mask     Bitmap of allowed channels: bit 0 is channel 1, etc.
 * @param tx_rate       Max transmit rate (in 100 kbps), 0 to use any rate
 * @param rts_thresh    RTS threshold, 0 to use default of 2347. Its range is from 0 to 2347
 * @param frag_thresh   Fragmentation threshold, 0 to use default of 1536. Valid range is all even selections from 256 to 1536 bytes
 * @param power_mode    Desired Power management mode: 0-5.
 * @param tx_power      Transmit power, 0-16 dBm
 * @param band          Wireless band to use @link WirelessBandNum
 *
 * @note    Channels 1-14 are in the 2.4GHz band (802.11b/g).
 *
 *          WEP keys are used if WLN_AUTH_SHAREDKEY is set in authen,
 *          or if WLN_ENCR_WEP is set in encrypt and 802.1x authentication is not used.
 *          wpa_psk is used if WLN_AUTH_WPA_PSK is set in authen.
 *          identity and password are used if WLN_AUTH_WEP_8021X or WLN_AUTH_WPA_8021X
 *          is set in authen.
 *
 *          Not all hardware supports the power_mode member, thus the parameter
 *          could be ignored.
 *
 *          The tx_rate argument is in units of 100 kbps.  For example, a setting
 *          of 540 corresponds to 54000 kbps (54 mbps).  A setting of 0 will cause
 *          the driver to use the maximum allowed rate.
 *
*ad*/
typedef struct {
    wln_bss     bss_type;
    uint8       ssid[WLN_SSID_SIZE];
    int         ssid_len;
    int         channel;
    mac_addr    sta_addr;
    uint32      authen;
    uint32      encrypt;
    int         wep_key_id;
    int         wep_key_len;
    uint8       wep_key[WLN_KEY_NUM][WLN_WEP104_SIZE];
    uint8       wpa_psk[WLN_PSK_SIZE];
    uint32      eap_methods;
    char        identity[WLN_IDENT_SIZE+1];
    char        password[WLN_PWD_SIZE+1];
    uint32      options;
    uint32      chan_mask;
    int         tx_rate;
    int         rts_thresh;
    int         frag_thresh;
    int         power_mode;
    int         band;
    int         tx_power;
} NaWlnParams_t;

#define BOARD_PARAM_WLN_PAD_BYTES       32
#define POWER_CALIBRATION_DATA_SIZE     64


/*ad*
 * This structure contains extended wireless paramater list in development 
 * board paramaters.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 7.4
 *
 * @param wlnCountryCode    Wireless country code identity.
 * @param wpsParams         Wi-Fi Simple Configuration parameters.
 * @param wlnPowerCalibration  Wireless power calibration parameters.
 * @param dutyCycle         Wireless duty cycle to store ON and OFF period in milli seconds.
 * @param ext_chan_mask     Channel mask for 802.11a channels
 * @param wlnCustomFields   Can be used for the future enhancements
*ad*/
typedef struct 
{
    unsigned long   wlnCountryCode;
    NaWpsParams_t   wpsParams;
    wln_duty_cycle  dutyCycle;
    unsigned long   wlnPowerCalibration[POWER_CALIBRATION_DATA_SIZE];
    unsigned long   ext_chan_mask; 
    /* new wireless fileds goes here, make sure to reduce the padding size */
    unsigned long   wlnCustomFields[BOARD_PARAM_WLN_PAD_BYTES];
} NaWlnExtParams_t;


/* start use padding bytes until the total size reaches 6.3 record. So please update 
   BOARD_PARAM_PAD_BYTES for the new entry to help the smooth migration */
//#define BOARD_PARAM_PAD_BYTES  (sizeof (aceConfigInfo) - (sizeof (NaIamParamsInfo_t) + sizeof (NaWlnExtParams_t) + sizeof(TRANSFORM_MATRIX)))

/*
 * The value of "2" in NaMgmtConnectionGroup_t  mgmtconnection[2], was
 * NA_MCS_CONNECTION_TYPE_MAX, but we need to keep the config size the
 * same as the 1P release to avoid automatic factory default
 */

/*ad*
 * This structure contains iDigi Device Protocol configurations.
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 7.5
 * @see @link NaMgmtConnectionGroup_t
 * @see @link NaMgmtGlobalGroup_t
 * @see @link NaMgmtNetworkGroup_t
 * @see @link NaDeviceSecurityGroup_t
 * @see @link devBoardParamsType
 *
 * @param signature         Signature of the iDigi parameters.
 *                          A string of signature is written to this field
 *                          to indicate, iDigi parameters has be initialized.
 * @param checksum          CRC32 checksum of iDigi parameters. This excludes
 *                          signature and checksum fields.
 *                          The CRC32 is calcaulated to validate iDigi parameters.
 * @param sizeOfRecord      Size of the NaiDigiParams_t in bytes.
 * @param mgmtconnection    Array of Management Connection configurations.
 * @param mgmtglobal        Management configurations
 * @param mgmtnetwork       Management Network configuration
 * @param devicesecurity    Device Security configuration
*ad*/
typedef struct
{
    char                     signature[8];
    unsigned long            checksum;
    unsigned long            sizeOfRecord;
    NaMgmtConnectionGroup_t  mgmtconnection[NA_MCS_CONNECTION_TYPE_MAX];
    NaMgmtGlobalGroup_t      mgmtglobal;
    NaMgmtNetworkGroup_t     mgmtnetwork[NA_MGMT_NETWORK_COUNT];
    NaDeviceSecurityGroup_t  devicesecurity;
} NaiDigiParams_t;

/* 
#if ((BOARD_PARAM_PAD_BYTES) <= 0)
#error Please remove padding field from devBoardParamsType
#endif 
*/

/*ad*
 * Structure of development board parameters in NVRAM
 *
 * This structure defines how the development board parameters are
 * stored in NVRAM.  
 *
 * @external
 * @include     <boardParams.h>
 * @category BSP:Board_Params
 * @since 6.0
 *
 * @param serialNumber		Array holding serial number, 1 alpha char followed by 8 digits.
 * @param waitTime		    Amount of time to wait in seconds.
 * @param baudrate		    Baudrate for serial port.
 * @param telnetMagic		Telnet magic number.
 * @param sizeOfRecord		Used to sense expansion.
 * @param checksum		    Checksum for this structure.
 * @param ipAddrPpp1		PPP COM1 IP Address.
 * @param ipAddrPpp2		PPP COM2 IP Address.
 * @param ipAddrPpp1peer	PPP COM1 Peer IP Address.		
 * @param ipAddrPpp2peer	PPP COM2 Peer IP Address.
 * @param rootPassword		root Password (can be NULL).
 * @param userData          user data field, can be accessed using @link customizeGetUserParams 
 *                          and @link customizeSetUserParams
 * @param ipAddrSntp1		Primary SNTP IP Address.
 * @param ipAddrSntp2		Secondary SNTP IP Address.
 * @param ethernetMac       Array holding Ethernet MAC address.
 * @param defaultDuplexLevel    Indicates if Ethernet H/W should be configured for full or half
 *                              duplex if the switch does not autonegotiate.
 * @param timezone			Time zone.
 * @param snmpEngineBoots   Number of times SNMP agent has been rebooted.
 * @param wlnParams         802.11 wireless network parameters
 * @param iamParamsInfo     Holds IAM configuration record structure.
 * @param wlnExtParams      Holds newly added wireless paramaters
 * @param calibration_matrix Contains the calibration matrix used by the SPI touchscreen. 
 * @param idigiParams       iDigi Device Protocol configuration parameters.
 * @param iamExParams       Extra IAM parameters.
 * @see @link NASYSACC_STRLEN_PASSWORD
 * @see @link NASEC_MAX_FUTUSE_USERNAME_LENGTH
 * @see @link NASEC_MAX_FUTUSE_PASSWORD_LENGTH
 * @see @link NASEC_MAX_FUTUSE_REALM_NAME_LENGTH
*ad*/
typedef struct
{
    char serialNumber[BP_SERIAL_NUMBER_LENGTH+1];    
    unsigned long waitTime;                            
    unsigned long baudrate;                            
    unsigned long telnetMagic;                        
    unsigned long sizeOfRecord;                        
    unsigned long checksum;                           
    unsigned long ipAddrPpp1;                           
    unsigned long ipAddrPpp2;                           
    unsigned long ipAddrPpp1peer;                       
    unsigned long ipAddrPpp2peer;                       
    char rootPassword[NASYSACC_STRLEN_PASSWORD];
    unsigned char userData[BP_USER_DATA_LEN];
    unsigned long ipAddrSntp1;                          
    unsigned long ipAddrSntp2;
    unsigned char ethernetMac[6];
    bpDuplexLevelType defaultDuplexLevel;
    TIMEZONE_T	  timezone; 
    unsigned      snmpEngineBoots;
    NaWlnParams_t     wlnParams;
    NaIamParamsInfo_t iamParamsInfo;
    NaWlnExtParams_t  wlnExtParams;
	TRANSFORM_MATRIX  calibration_matrix;
    NaiDigiParams_t   idigiParams;
    NaIamExParams_t   iamExParams;
    
} devBoardParamsType;


/*
 * This define determines where in NVRAM the development board parameters
 * will be stored.It Specifies starting offset from the base of NVRAM
 */
#define START_OF_DEV_BOARD_PARAMETERS       0

/*ad*
 * Typedef for malloc function
 *
 * This typedef declares the malloc function type used by 
 * NABoardParamsSetMalloc().
 *
 * @include     <boardParams.h>
 * @category BSP:Board_Params  
 * @since 6.0
 * @external
 *
 * @param size      size of memory buffer to allocate
 *
 * @return  buffer      pointer to allocated buffer
 * @return NULL         out of memory
*ad*/
typedef void * (* boardParamsMallocFnType)(size_t size);


/*ad*
 * Typedef for free function
 *
 * This typedef declares the free function type used by
 * NABoardParamsSetMalloc().
 *
 * @include     <boardParams.h>
 * @category BSP:Board_Params  
 * @since 6.0
 * @external
 *
 * @param buffer        pointer to buffer to free
*ad*/
typedef void (* boardParamsFreeFnType)(void * buffer);


void NABoardParamsSetMalloc(boardParamsMallocFnType bpMallocFn, boardParamsFreeFnType bpFreeFn);

/*
 * This define can be used to indicate where free NVRAM starts.
 */
#define START_OF_FREE_NVRAM     (START_OF_DEV_BOARD_PARAMETERS+sizeof (devBoardParamsType))

int NAConvertMacAddressString(BYTE *dest, char *source);

int customizeSetMACAddress (BYTE *mac_addrp);

/*
 *
 *  Function: int customizeUseDefaultParams(devBoardParamsType *params)
 *
 *  Description:
 *
 *      This routine changes the params with the setting in the appconf.h
 *
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD SHOULD YOU DECIDE NOT TO
 *      USE THE SETTINGS IN APPCONF.H. YOU MAY USE THE SETTINGS IN STRUCTURE
 *      defaultParams, OR ANY OTHER WAYS.
 *  Parameters:
 *
 *      params      pointer to structure with development board parameters
 *
 *  Return Values:
 *
 *		 0       success
 *       -1      unable to read parameters
 */
int customizeUseDefaultParams(devBoardParamsType *params);


/*
 *
 *  Function: int customizeReadDevBoardParams (devBoardParamsType *params)
 *
 *  Description:
 *
 *      This routine reads the contents of the section of NVRAM that contains
 *      the development board's startup parameters.
 *
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      params          pointer to buffer to read parameters into
 *
 *  Return Values:
 *
 *      0       success
 *      -1      unable to read parameters
 */
int customizeReadDevBoardParams (devBoardParamsType *params);

/*
 *
 *  Function: int customizeWriteDevBoardParams (devBoardParamsType *params)
 *
 *  Description:
 *
 *      This function writes development board parameters to NVRAM.
 *
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      params      pointer to structure with parameters
 *
 *  Return Values:
 *
 *      0       success
 *      -1      unable to write to NVRAM
 *
 */

int customizeWriteDevBoardParams (devBoardParamsType *params);

/*
 * customizeGetMACAddress
 *
 *  Description:
 *
 *      This function determines our MAC address and returns it in 
 *      the buffer passed to us.  This routine converts a serial number
 *      into a valid Digi International ethernet MAC address. The MAC address is 
 *      determine from the board's serial number which is stored in NVRAM.  
 *      If we are unable to read NVRAM, then a default value is used.
 * 
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      mac_addrp  Pointer to destination of ethernet MAC address. This
 *                 pointer must point to storage containing at least 6 bytes.
 *
 */
int customizeGetMACAddress (BYTE *mac_addrp);

/*
 * customizeGetWirelessParameters
 *
 *  Description:
 *
 *      This function retrieves the wireless network parameters 
 *      from NVRAM and returns it in the buffer passed to us.  
 *      If we are unable to read NVRAM, then a default value is used.
 * 
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      params  Pointer to destination of wireless parameters.
 *
 */
int customizeGetWirelessParameters (wln_params *params);

/*
 * customizeSetWirelessParameters
 *
 *  Description:
 *
 *      This function saves the wireless network parameters 
 *      to NVRAM.
 * 
 *  Parameters:
 *
 *      params  Pointer to the wireless parameters.
 *
 */
int customizeSetWirelessParameters (wln_params *params);

/*
 * customizeGetIPParameters
 *
 *  Description:
 *
 *      This routine retrieves the IP address values (address, subnet maske and
 *      default gateway) from NVRAM. The caller is then able to make a determination
 *      if a valid IP address has been retrieved and stored in NVRAM. 
 *
 *      Zero values indicate that the addresses have not been initialized. 
 * 
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      ipptr     Points to destination of the retrieved IP address.
 *      subptr    Points to destination of the retrieved subnet mask.
 *      defgwptr  Points to the destination of the retrieved default gateway. 
 * 
 */ 
void customizeGetIPParameters (unsigned long *ipptr, unsigned long *subptr, unsigned long *defgwptr);

/*
 * customizeSaveIPParameters
 *
 *  Description:
 *
 *      This routine saves IP address parameters to NVRAM. 
 *
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      ipaddr       IP address to save
 *      submask      Subnet mask to save
 *      defgw        Default gateway to save
 *
 */
void customizeSaveIPParameters (unsigned long ipaddr, unsigned long submask, unsigned long defgw);

/*
 * customizeGetSerialNumber
 *
 *  Description:
 *
 *      This routine retrieves the serial number stored in a NET+ARM development
 *      board's NVRAM. 
 *
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      srln         Destination for stored serial number. This array must be a 
 *                 minimum of 8 bytes.
 *
 */ 
void customizeGetSerialNumber (char *srln);

/*
 * customizeSaveSerialNumber
 *
 *  Description:
 *
 *      This routine re-writes the serial number of NET+ARM development board.
 *
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      srln       Character pointer to the new serial number. The serial number
 *               must be composed of 6 decimal digits. 
 */
void customizeSaveSerialNumber (char *srln);


/*
 * customizeSaveEnable
 *
 *  Description:
 *
 *      This routine modifies the state of Static and DHCP setting in NVRAM
 *
 *  Notes:
 *
 *      THIS CODE MUST BE CUSTOMIZED FOR YOUR BOARD.  The implementation
 *      below is for NET+OS development boards only.
 *
 *  Parameters:
 *
 *      mode         DHCP Mode
 *
 */
void customizeSaveEnable (BOOLEAN mode);


/*
 * Description:
 *
 * Returns the MAC address stored in NVRAM for the interface identified
 * by ifname. When this function returns BP_FAILURE, a default mac address
 * was used because the NVRAM could not be read. BP_NO_RESOURCES is 
 * returned when memory could not be allocated to read the NVRAM. In this 
 * case, the buffer pointed to by mac_addrp has not been filled with
 * a default mac address.     
 *
 * Parameters:
 *
 * ifname       nul-terminated interface name string in the "eth0"/"wln0" format.
 * mac_addrp	Pointer to the MAC address buffer, filled in by this function,
 *              at least 6 bytes in length. 
 *
 * Return values:
 *
 * BP_SUCCESS           Success
 * BP_FAILURE           Unable to read NVRAM; a default value was used instead.
 * BP_NO_RESOURCES      Unable to allocate memory; a default value was not used.
 * BP_INVALID_ARGUMENT  Invalid argument(s)
 */
int customizeGetInterfaceMACAddress(const char * ifname, BYTE * mac_addrp);

bpDuplexLevelType customizeGetEthernetDuplexMode(void);
int customizeSetEthernetDuplexMode(bpDuplexLevelType duplex);
void customizeSetDefaultWlnPsk(unsigned char * psk);
unsigned long naBoardParamsComputeChecksum(devBoardParamsType * params);
int naBoardParamsCheckForInvalidData(devBoardParamsType * params, unsigned shouldFixBadParams, int * shouldSetChecksumError);

BOOLEAN customizeSaveInterfaceEnable(const char * ifname, BOOLEAN mode);
BOOLEAN customizeGetInterfaceIPParameters(const char * ifname, unsigned long * ipaddr, unsigned long * submask, unsigned long * defgw);
BOOLEAN customizeSaveInterfaceIPParameters(const char * ifname, unsigned long ipaddr, unsigned long submask, unsigned long defgw);

int customizeGetUserParams(void * data, int offset, int size);
int customizeSetUserParams(void * data, int offset, int size);

struct sockaddr_storage * customizeIamFindIpv6GatewayConfig(const char * ifname, devBoardParamsType * nvParamsPtr);
struct sockaddr_storage   customizeIamGetDefaultIpv6GatewayConfig(const char * ifname);
int customizeIamGetIpv6GatewayConfig(const char * ifname, struct sockaddr_storage * gatewayPtr);
int customizeIamSetIpv6GatewayConfig(const char * ifname, const struct sockaddr_storage * gatewayPtr);

/**
 * NVRAM Storage Identifiers for writing and reading data in NVRAM 
 * after development board's startup parameters.
 *
 * These are used for @link customizeWriteStorageParams, 
 * @link customizeReadStorageParams and @link customizeRemoveStorageParams.
 *
 * @include     <boardParams.h>
 * @category BSP:Board_Params  
 * @since 7.5
 * @external
 *
 * @param NVRAM_STORAGE_USER1_ID            Identifier1 for user's general purpose use
 * @param NVRAM_STORAGE_USER2_ID            Identifier2 for user's general purpose use
 * @param NVRAM_STORAGE_USER3_ID            Identifier3 for user's general purpose use
 * @param NVRAM_STORAGE_USER4_ID            Identifier4 for user's general purpose use
 * @param NVRAM_STORAGE_USER5_ID            Identifier5 for user's general purpose use
 * @param NVRAM_STORAGE_USER6_ID            Identifier6 for user's general purpose use
 * @param NVRAM_STORAGE_USER7_ID            Identifier7 for user's general purpose use
 * @param NVRAM_STORAGE_USER8_ID            Identifier8 for user's general purpose use
 * @param NVRAM_STORAGE_USER9_ID            Identifier9 for user's general purpose use
 * @param NVRAM_STORAGE_USER10_ID           Identifier10 for user's general purpose use
**/
typedef enum {
    NVRAM_STORAGE_USER1_ID,
    NVRAM_STORAGE_USER2_ID,
    NVRAM_STORAGE_USER3_ID,
    NVRAM_STORAGE_USER4_ID,
    NVRAM_STORAGE_USER5_ID,
    NVRAM_STORAGE_USER6_ID,
    NVRAM_STORAGE_USER7_ID,
    NVRAM_STORAGE_USER8_ID,
    NVRAM_STORAGE_USER9_ID,
    NVRAM_STORAGE_USER10_ID
} NaCustomizeStorageId_t;

NaStatus customizeWriteStorageParams(NaCustomizeStorageId_t id, void * data, unsigned short size);
NaStatus customizeReadStorageParams(NaCustomizeStorageId_t id, void * data, unsigned short size);
NaStatus customizeRemoveStorageParams(NaCustomizeStorageId_t id);


#ifdef __cplusplus
}
#endif

#endif


