/*****************************************************************************
* Copyright (c) 2005 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
*
*****************************************************************************/
#ifndef IAM_HH
#define IAM_HH

#ifdef IAM_ENABLED
#include "sockapi.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef NDS_SPECIFIC
#define NA_IAM_INTERFACE_MAX      1
#else
#define NA_IAM_INTERFACE_MAX      4
#endif

#define MAX_IF_NAMELEN                 20
#define MAX_IP_ADDR_STR_LEN            48
#define IPV4_ADDR(a) a.addr.ipv4.sin_addr.s_addr
#define IPV4_ADDR_STR_LEN 17

#define NA_IAM_CONFIG_VERSION     0

/*ad*
 * Maximum number of homes per interface. For IPv6, the total number
 * of IP addresses available per interface is double this number 
 * to account for stateless auto-configured addresses, which are stores
 * at multihome indexes equal to or greater than NA_MAX_HOMES_PER_IF.  
 *
 * @external
 * @include  "iam.hh"
 * @category Networking:IAM:iam_params
 * @since 7.0
*ad*/
#define NA_MAX_HOMES_PER_IF 4


/*ad*
 * Interface home index used in NET+OS for Static IPv6 address. 
 * The corresponding interface name is eth0:1 or wln0:1.
 *
 * @external
 * @include  "iam.hh"
 * @category Networking:IAM:iam_params
 * @since 7.5
*ad*/
#define NA_IAM_STATICV6_INDEX	2

/*ad*
 * Interface home index used in NET+OS for DHCPv6 address.
 * The corresponding interface name is "eth0:7" or "wln0:7".
 *
 * @external
 * @include  "iam.hh"
 * @category Networking:IAM:iam_params
 * @since 7.5
*ad*/
#define NA_IAM_DHCPV6_INDEX		8

/*ad*
 * Length of the DHCP options buffer in bytes.
 *
 * @external
 * @include  "iam.hh"
 * @category Networking:IAM:iam_params
 * @since 7.0
*ad*/
#define NA_IAM_DHCP_OPTIONS_BUFFER_LEN 256

/*ad*
 * This flag notifies the IAM manager that an acquired IPv4 address has been
 * found to be in conflict with another LAN node. It is passed into the 
 * @link naIamAcquire routine when called by a user defined IAM client. 
 *
 * @external
 * @include     "iam.hh"
 * @category Networking:IAM:iam_params
 * @since 7.0
*ad*/
#define NA_IAM_ADDR_INITIAL_CONFLICT_FLAG    0x1

/*ad*
 * This flag instructs the IAM manager to perform ongoing address conflict 
 * detection(ACD) for a specific IPv4 address. It is passed into the @link naIamAcquire
 * routine when called by a user defined IAM client.
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
*ad*/
#define NA_IAM_ENABLE_ACD_FLAG               0x2

/*ad*
 * This event signals the loss of an IP address for a specific interface/multihome 
 * pair. The return value from the application callback is ignored.
 * 
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
*ad*/
#define NA_IAM_ADDR_LOST                2

/*ad*
 * IPv4 only. This event signals the acquisition of a new configuration for a 
 * specific interface/multihome pair. A return value of NA_IAM_STATUS_ERROR from
 * the application callback results in this IPv4 configuration not being used to
 * configure the interface.    
 * 
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *ad*/
#define NA_IAM_ADDR_ACQUIRED            3

/*ad*
 * This event signals that a specific interface/multihome pair has been
 * configured with the given IP address. 
 * 
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *ad*/
#define NA_IAM_ADDR_CONFIGURED          4

/*ad*
 * This event signals an offer from a DHCP server. The "optionsBuffer" member of structure 
 * acquiredCfg points to the raw DHCPOFFER packet data of optionsLength length in bytes. 
 * This data buffer is not guaranteed to persist after the application callback returns.
 * A return value of NA_IAM_STATUS_SUCCESS from the application callback uses this DHCP 
 * server offer to configure the interface while NA_IAM_STATUS_ERROR sends a DHCPDECLINE 
 * message to the DHCP server.     
 * 
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *ad*/
#define NA_IAM_ADDR_OFFER               5

/*ad*
 * This event signals that a duplicate IP address has been detected on the network.    
 * A return value of NA_IAM_STATUS_ERROR from the application callback stops
 * ongoing address conflict detection(ACD) for IPv4, but does not unconfigure the IP
 * address in conflict, which can be accomplished by calling @link naIamRelease or
 * @link naIamDisable depending on the application needs. For IPv6, return values
 * from the application callback are ignored.   
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *ad*/
#define NA_IAM_ADDR_CONFLICT            6

/*ad*
 * This event signals that an acquired IP address has a duplicate on the network.
 * The acquired IP address in conflict has not been used to configure the interface,
 * hence it is in initial conflict. For IPv4, the application callback can choose to ignore 
 * the conflict and configure the interface with this IPv4 address by returning 
 * NA_IAM_STATUS_SUCCESS. Returning NA_IAM_STATUS_ERROR discards the acquired configuration.
 * For IPv6, this event is informational only and any return values are ignored. 
 * In addition, when this event is generated for a stateless auto-configured link-local
 * IPv6 address, a random interface ID is generated to form a new IPv6 link-local address,
 * which is then tested again for conflicts and configured if IPv6 Duplicate Address
 * Detection(DAD) succeeds. This auto-recovery procedure is repeated until a valid 
 * IPv6 link-local address is configured on an interface.     
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *ad*/
#define NA_IAM_ADDR_INITIAL_CONFLICT    7

/*ad*
 * This event signals that the link on an interface has gone down.  Typically, this means
 * that the Ethernet cable has been pulled out.  This could be due to a number of external
 * things in the environment.
 *
 * <list type="unordered">
 *  <item>The network hub/switch may have gone down.</item>
 *  <item>The user may be moving the connection to a different hub/switch, which may be on
 *        a different network.</item>
 *  <item>A momentary glitch on the network may have caused the MAC to incorrectly sense 
 *        a link failure.</item>
 * </list>
 *
 * There are two issues that impact us.  First, any packets sent out the interface while the
 * cable is disconnected will be lost.  Secondly, when the interface comes back up, the old IP
 * address assigned to it may no longer be valid.  This can happen if the user plugs the cable
 * into a different hub/switch on a different subnet.
 *
 * The call back function must set a return
 * value that indicates how IAM should handle this event.
 * <list type="unordered">
 *  <item>Return NA_IAM_STATUS_SUCCESS if IAM should do nothing.  This may cause the stack
 *        to continue to send packets out the interface even though the link is down.  This
 *        prevent your application from communicating with some devices on the network that
 *        it should be able to do so over another interface.</item>
 *  <item>Return NA_IAM_DISCONNECT_INTERFACE to disable the interface.  In addition, if
 *        the default router was associated with this interface, the router on the next highest
 *        priority interface is assigned to be the default router.  This has the effect of routing
 *        transmit packets around the downed interface.  It also has the side effect of losing
 *        the IP address assigned to the downed interface.  Any sockets opened and bound to that
 *        IP address will have to be closed and reopened.  IAM will automatically reenable the
 *        interface and restart the address acquisition process when the link comes back up.  
 *        However, if the address was assigned through a dynamic protocol, such as DHCP, it is
 *        possible that a different IP address will be assigned.  You can use the other call back
 *        events to determine when the address is assigned and what the new address is.</item>
 *  <item>Return NA_IAM_SWITCH_DEFAULT_ROUTER to leave the interface enabled, but switch the
 *        default router to the next highest priority interface.  This prevents the interface
 *        from losing its IP address, however packets transmitted to this interface's subnet
 *        may be sent to this interface and lost.</item>
 * </list>
 *        
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *ad*/
#define NA_IAM_ADDR_LINK_DOWN           (8)



/*ad*
 * Static IPv4 address method configuration structure for a particular
 * interface/multihome pair.
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param isEnabled     TRUE if this method is enabled for the interface/multihome.
 * @param ipAddress     IP address in network byte order.
 * @param subnetMask    Subnet mask.
 * @param gateway       Default gateway IP address in network byte order.	
 * @param primaryDns    Primary DNS server IP address in network byte order.
 * @param secondaryDns 	Secondary DNS server IP address in network byte order.
 * @param initialAcd    TRUE if IAM is to perform initial address conflict detection
 *                      for this method.
 * @param ongoingAcd    TRUE if IAM is to perform ongoing address conflict detection
 *                      for this method.    
*ad*/
typedef struct 
{
    BOOLEAN isEnabled; 
    struct  sockaddr_storage ipAddress;
    WORD32  subnetMask;
    struct  sockaddr_storage gateway;
    struct  sockaddr_storage primaryDns;
    struct  sockaddr_storage secondaryDns;
    BOOLEAN initialAcd;
    BOOLEAN ongoingAcd;
} NaIamStaticCfg_t;

/*ad*
 * DHCPv4 method configuration structure for a particular 
 * interface/multihome pair. 
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param isEnabled      TRUE if this method is enabled for the interface/multihome.
 * @param optionsBuffer  Pointer to the formatted options buffer in network byte order.
 * @param optionsLength  Length of options buffer in bytes.
 * @param ongoingAcd     TRUE if IAM is to perform ongoing address conflict detection
 *                       for this method.      
*ad*/
typedef struct 
{
    BOOLEAN isEnabled; 
    char    optionsBuffer[NA_IAM_DHCP_OPTIONS_BUFFER_LEN];
    WORD32  optionsLength;
    BOOLEAN ongoingAcd; 
} NaIamDhcpCfg_t;


/*ad*
 * AutoIP method configuration structure for a particular
 * interface/multihome pair. 
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param isEnabled      TRUE if this method is enabled for the interface/multihome.
*ad*/
typedef struct 
{
    BOOLEAN isEnabled; 
} NaIamAutoipCfg_t;


/*ad*
 * IAM method settings structures used in routine @link customizeIamGetSettingsCallback
 * to retrieve NVRAM settings.
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param  staticCfg        Static method configuration.
 * @param  dhcpCfg          DHCP method configuration.
 * @param  autoipCfg        AutoIP method configuration.
 * @param  cfg              Union name.
 * @param  numProbes        Number of ARP probes to send for initial address conflict
 *                          detection(ACD). When set to zero four probes are sent unless 
 *                          initial ACD is disabled for the static method. DHCP and Auto IP
 *                          always perform initial ACD.
 * @param  probeInterval    Interval, in milliseconds, between consecutive ARP probes used
 *                          during initial ACD. When set to zero, 200ms is used unless 
 *                          initial ACD is disabled for the static method. DHCP and Auto IP
 *                          always perform initial ACD.
 * @param  numAnnouncements Number of ARP announcements to send after an IPv4 address has
 *                          been configured on an interface. IAM always sends one ARP
 *                          announcement, hence setting this value to one, will send out 
 *                          a total of two.
 * @param  announcementsInterval Interval, in milliseconds, between consecutive ARP 
 *                               announcements sent after an IPv4 address has been configured
 *                               on an interface. When set to zero, 200ms is used.    
 *
*ad*/
typedef struct
{
    union
    {
        NaIamStaticCfg_t staticCfg;
        NaIamDhcpCfg_t   dhcpCfg;
        NaIamAutoipCfg_t autoipCfg;
    } cfg;

    WORD32  numProbes;
    WORD32  probeInterval;
    WORD32  numAnnouncements;
    WORD32  announcementsInterval;
} NaIamCfg_t;

/*ad*
 * IAM method IPv4 ACD settings structures used by Auto IP in routine 
 * @link customizeIamGetV4AcdSettingsCallback.
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.5
 *
 * @param  numProbes			Number of ARP probes to send for initial address conflict
 *								detection(ACD). 
 * @param  probeIntervalMin		Minimum delay until repeated ARP probe, in milliseconds, 
 *								during initial ACD. 
 * @param  probeIntervalMax		Maximum delay until repeated ARP probe, in milliseconds, 
 *								during initial ACD. 
 * @param  probeWait			Initial random delay in milliseconds.
 * @param  numAnnouncements		Number of ARP announcements to send after an IPv4 address has
 *								been configured on an interface. 
 * @param  announceInterval		Interval, in milliseconds, between consecutive ARP 
 *								announcements sent after an IPv4 address has been configured
 *								on an interface. 
 * @param  announceWait			Delay before announcing in milliseconds.
 * @param  rateLimitInterval	Delay between successive attempts, after reaching maxConflicts.
 * @param  defendInterval		Minimum interval between defensive ARPs.
 * @param  maxConflicts			Max conflicts before rate-limiting
 *
*ad*/
typedef struct 
{
    WORD32  numProbes;
    WORD32  probeIntervalMin;
	WORD32  probeIntervalMax;
	WORD32  probeWait;
    WORD32  numAnnouncements;
    WORD32  announceInterval;	
	WORD32  announceWait;
	WORD32  rateLimitInterval;
	WORD32  defendInterval;
	WORD32  maxConflicts;
	
} NaIamV4AcdConfig_t;


/*ad*
 * Proposed acquired method configuration for a particular interface/multihome. If non-DHCP, 
 * optionsBuffer is set to NULL. This configuration can be rejected by the application in the
 * user callback.
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param  ipAddress     IP address in network byte order.
 * @param  gateway       Default gateway IP address in network byte order.	
 * @param  primaryDns    Primary DNS server IP address in network byte order.
 * @param  secondaryDns  Secondary DNS server IP address in network byte order.
 * @param  subnetMask    Subnet mask.	 
 * @param  optionsBuffer Pointer to a raw DHCP offer packet buffer.  
 * @param  optionsLength Length of DHCP options buffer.
 * @param  numAnnouncements Number of ARP announcements to send after IPv4 address is configured.
 * @param  announcementsInterval Time, in milliseconds, between consecutive ARP announcements.
 *
*ad*/
typedef struct
{
    struct  sockaddr_storage ipAddress;
    struct  sockaddr_storage gateway;
    struct  sockaddr_storage primaryDns;
    struct  sockaddr_storage secondaryDns;
    WORD32  subnetMask;
    const   unsigned char * optionsBuffer; 
    WORD32  optionsLength; 
    WORD32  numAnnouncements;
    WORD32  announcementsInterval;
} NaIamAcquiredCfg_t;


/*ad*
 * IAM return values. 
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param	NA_IAM_STATUS_ERROR						General error.                
 * @param	NA_IAM_STATUS_SUCCESS					General success.
 * @param	NA_IAM_STATUS_INVALID_METHOD_LIST		Invalid method information list.
 * @param	NA_IAM_STATUS_IF_INVALID_HANDLE         Invalid interface handle.
 * @param	NA_IAM_STATUS_IF_INVALID_HOME           Invalid multihome index.            
 * @param	NA_IAM_STATUS_IF_LIMIT                  Interface could not be opened because the allowable number
 *                                                  of interfaces has been reached.
 * @param	NA_IAM_STATUS_IF_NOT_OPENED             Interface/home pair has not been previously opened with a call
 *                                                  to the @link naIamStart routine.
 * @param	NA_IAM_STATUS_METHOD_LOW_PRIORITY       Cannot enable method because it has a lower priority than
 *                                                  the currently configured method.
 * @param	NA_IAM_STATUS_METHOD_INVALID            Unknown method.
 * @param	NA_IAM_STATUS_METHOD_NOT_DISABLED       Cannot enable method because it has not been previously disabled.
 * @param	NA_IAM_STATUS_METHOD_NOT_ENABLED        Method already disabled.       
 * @param	NA_IAM_STATUS_METHOD_NOT_CURRENT        Method not released because it is not currently configured.
 * @param	NA_IAM_STATUS_ACQUIRED_CFG_REJECTED     Application has rejected the acquired configuration.
 * @param	NA_IAM_STATUS_ALREADY_CONFIGURED        Current configuration matches the acquired configuration.
 * @param	NA_IAM_STATUS_ALREADY_STARTED           IAM has been previously started for this interface/mulithome.
 * @param   NA_IAM_STATUS_IF_NOT_CONFIGURED         Interface does not have a configured ip address.
 * @param   NA_IAM_DISCONNECT_INTERFACE             Return this value from the NA_IAM_ADDR_LINK_DOWN call back
 *                                                  to disable the interface.  When the link comes back up, the
 *                                                  the interface will be automatically reenabled and the address
 *                                                  acquisition process will be restarted.  It is possible this 
 *                                                  will cause the IP address to change.
 * @param NA_IAM_SWITCH_DEFAULT_ROUTER              Return this value from the NA_IAM_ADDR_LINK_DOWN call back to
 *                                                  leave the interface enabled, but change the default router if
 *                                                  it is associated with this interface and another gateway on 
 *                                                  on another interface is available.
 *
*ad*/
typedef enum iam_status_t {
    NA_IAM_STATUS_ERROR,                  
    NA_IAM_STATUS_SUCCESS,                
    NA_IAM_STATUS_INVALID_METHOD_LIST,
    NA_IAM_STATUS_IF_INVALID_HANDLE,
    NA_IAM_STATUS_IF_INVALID_HOME,
    NA_IAM_STATUS_IF_LIMIT,
    NA_IAM_STATUS_IF_NOT_OPENED,
    NA_IAM_STATUS_METHOD_LOW_PRIORITY,
    NA_IAM_STATUS_METHOD_INVALID,
    NA_IAM_STATUS_METHOD_NOT_DISABLED,
    NA_IAM_STATUS_METHOD_NOT_ENABLED,
    NA_IAM_STATUS_METHOD_NOT_CURRENT,
    NA_IAM_STATUS_ACQUIRED_CFG_REJECTED,
    NA_IAM_STATUS_ALREADY_CONFIGURED,
    NA_IAM_STATUS_ALREADY_STARTED,
    NA_IAM_STATUS_IF_NOT_CONFIGURED,
    NA_IAM_DISCONNECT_INTERFACE,
    NA_IAM_SWITCH_DEFAULT_ROUTER
} NaIamStatus_t;

/*ad*
 * IAM commands passed into the user defined callback during different stages
 * of operation.  
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param   NA_IAM_COMMAND_INITIALIZE   Initialize this method context.
 * @param   NA_IAM_COMMAND_RELEASE      Release the address from this method context.
 * @param   NA_IAM_COMMAND_ACQUIRE      Acquire an address in this method context. 
 *
*ad*/
typedef enum {
    NA_IAM_COMMAND_INITIALIZE,
    NA_IAM_COMMAND_RELEASE,
    NA_IAM_COMMAND_ACQUIRE        
} NaIamCommand_t;

/*ad*
 * IAM method identifiers. A user defined method client has to use NA_IAM_METHOD_USER.
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param   NA_IAM_METHOD_STATIC       Static method.
 * @param   NA_IAM_METHOD_DHCP         DHCP method.
 * @param   NA_IAM_METHOD_AUTOIP       AUTOIP method.
 * @param   NA_IAM_METHOD_USER         User defined method.
 * @param   NA_IAM_METHOD_COUNT        Used to count the number of methods that have callbacks.
 * @param   NA_IAM_METHOD_IPV6_AUTOCFG Autoconfigured IPv6 method. 
 * @param   NA_IAM_METHOD_DHCPV6       DHCPv6 configured IPv6 method. 
 * @param   NA_IAM_METHOD_STATICV6     Static IPv6 method. 
 * @param   NA_IAM_METHOD_NONE         Unidentified method.
 *
*ad*/
typedef enum {
    NA_IAM_METHOD_STATIC,
    NA_IAM_METHOD_DHCP,
    NA_IAM_METHOD_AUTOIP,
    NA_IAM_METHOD_USER,
    NA_IAM_METHOD_COUNT,
    NA_IAM_METHOD_IPV6_AUTOCFG,
    NA_IAM_METHOD_DHCPV6,
	NA_IAM_METHOD_STATICV6,
    NA_IAM_METHOD_NONE
} NaIamMethod_t;

/*ad*
 * IAM method context callback type. This callback is passed into @link naIamStart in the 
 * @link NaIamMethodInfo_t structure "cb" member and is called by IAM at different
 * stages of the method's operation. NET+OS supported callbacks are defined by the 
 * following macros: NA_IAM_DEFAULT_DHCP_METHOD_CB, NA_IAM_DEFAULT_STATIC_METHOD_CB,
 * NA_IAM_DEFAULT_AUTOIP_METHOD_CB, and NA_IAM_NULL_METHOD_CB.   
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param ifname        nul-terminated interface name string in the "ethx:x" format. 
 * @param command       Method context command.
 * @param userData      Pointer to user context data passed into @link naIamStart in 
 *                      the @link NaIamMethodInfo_t data member. 
 * 
 * @return  NA_IAM_STATUS_SUCCESS   Success.
 * @return  NA_IAM_STATUS_ERROR     Error.          
 *
*ad*/
typedef NaIamStatus_t (* NaIamMethodCb_t)(const char * ifname,  NaIamCommand_t command, void * userData);

/*ad*
 * Application callback for a particular interface/multihome passed into @link naIamStart. This callback
 * is called for the following events:
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * <list type="unordered">
 *      <item>@link NA_IAM_ADDR_LOST                </item>
 *      <item>@link NA_IAM_ADDR_ACQUIRED(IPv4 Only) </item>
 *      <item>@link NA_IAM_ADDR_CONFIGURED          </item>
 *      <item>@link NA_IAM_ADDR_OFFER               </item>
 *      <item>@link NA_IAM_ADDR_CONFLICT            </item>
 *      <item>@link NA_IAM_ADDR_INITIAL_CONFLICT    </item>
 *      <item>@link NA_IAM_ADDR_LINK_DOWN           </item>
 * </list>
 *   
 * @param ifname        nul-terminated interface name string in the "ethx:x" format.
 * @param  method       Acquisition method identifier.
 * @param  event        IAM event.
 * @param  acquiredCfg  Acquired configuration including a DHCP offer.
 * @param  userData     Pointer to application context data passed into the callback when called by IAM.
 *
 * @return Various      See definition of the events for this callback for appropriate return values. 
 *
*ad*/
typedef NaIamStatus_t (* NaIamAppCb_t)(const char * ifname, int method, int event, NaIamAcquiredCfg_t * acquiredCfg, void * userData);

/*ad*
 * Method information type. A list of these types is passed into @link naIamStart with the last element
 * of the list setting the "cb" member to @link NA_IAM_NULL_METHOD_CB to mark its end. data is
 * passed into the user defined method context callback if one is defined. 
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 * @param  cb      Method context callback either user defined or NET+OS supported. 
 * @param  data    Pointer to user context data passed into the user defined method context callback.
 * @param  method  Method identifier.
 *
*ad*/   
typedef struct
{
    NaIamMethodCb_t   cb;
    void *            data;
    int               method;
} NaIamMethodInfo_t;


NaIamStatus_t naIamStart(const char * ifname, 
                         NaIamMethodInfo_t  *method_info_list,
                         int                flag,
                         int                buffersPerFrameCount,
                         void               *user_data,
                         NaIamAppCb_t       app_cb);

NaIamStatus_t naIamAcquire(const char * ifname,
                           int                 method,
                           NaIamAcquiredCfg_t  *acquired_cfg,
                           int                 flags);

NaIamStatus_t naIamRelease(const char * ifname, int  method);
 
NaIamStatus_t naIamEnable(const char * ifname, int  method);

NaIamStatus_t naIamDisable(const char * ifname, int  method);

NaIamStatus_t customizeIamGetSettingsCallback(const char * ifname, 
                                              int method,
                                              NaIamCfg_t * cfg);

NaIamStatus_t customizeIamGetV4AcdSettingsCallback(const char * ifname, 
												   int method, 
												   NaIamV4AcdConfig_t * cfg);

NaIamStatus_t naIamGetCurrentMethod(const char * ifname, int * method);
NaIamMethod_t naIamGetCurrentHomeMethod(void * interfaceHandle, unsigned multiHome);
NaIamMethod_t naIamGetCurrentMethodV6(const char * ifname);
NaIamMethod_t naIamGetCurrentHomeMethodV6(void * interfaceHandle, unsigned multiHome);

NaIamStatus_t naIamGetIpv6Gateway(void * interfaceHandle, unsigned int home, struct sockaddr_storage * ipv6GatewayPtr);


/* Ethernet callbacks */
NaIamStatus_t iam_static_callback(const char *, NaIamCommand_t, void *);
NaIamStatus_t iam_dhcp_callback(const char *,   NaIamCommand_t, void *);
NaIamStatus_t iam_autoip_callback(const char *, NaIamCommand_t, void *);

void iamInstallCallback(void *interface);

/*ad*
 * NET+OS supported DHCP method context callback passed into @link naIamStart in order
 * or priority in the "cb" member of the method information structure of type @link NaIamMethodInfo_t.  
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
*ad*/   
#define NA_IAM_DEFAULT_DHCP_METHOD_CB        iam_dhcp_callback

/*ad*
 * NET+OS supported static method context callback passed into @link naIamStart in order
 * or priority in the "cb" member of the method information structure of type @link NaIamMethodInfo_t.  
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
 *
*ad*/
#define NA_IAM_DEFAULT_STATIC_METHOD_CB      iam_static_callback

/*ad*
 * NET+OS supported AutoIP method context callback passed into @link naIamStart in order
 * or priority in the "cb" member of the method information structure of type @link NaIamMethodInfo_t.  
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
*ad*/
#define NA_IAM_DEFAULT_AUTOIP_METHOD_CB      iam_autoip_callback

/*ad*
 * NULL method context callback passed into @link naIamStart as the last callback to mark the
 * end of the list of @link NaIamMethodInfo_t structures.   
 *
 * @external
 * @include "iam.hh"
 * @category Networking:IAM:core
 * @since 7.0
 *
*ad*/
#define NA_IAM_NULL_METHOD_CB                NULL

#ifdef NDS_SPECIFIC
#include "iam_nds.hh"
#include "libutils.h"
#else
#include "iam_params.h"
#include "iam_netos.hh"
#endif

#ifdef __cplusplus
}
#endif

#endif
#endif


