Integrator Resources

The official home for NAI Support

Not sure where to start? Try Quick Start Guide or ask a question below!

Toggle Components with Visual Button
JavaScript Form Processing

ESW Config

ESW Config

Explanation

About the Sample C Application for Configuring NAI Embedded Function Modules

This C application code is developed by North Atlantic Industries (NAI) for their Sample Software Kit (SSK). It is used to interact with various embedded function modules, particularly the Ethernet Switch (ESW) modules. The application illustrates methods to configure ESW modules, control drive outputs, and read registers using the NAI board access library (naibrd). Below is a detailed walk-through of the main components and functionalities of the provided code.

Included Libraries and Definitions

  1. Standard Libraries

    • <stdio.h>: Standard input/output library.

    • <stdlib.h>: Standard library including dynamic memory allocation and process control.

    • <string.h>: String handling functions.

    • <time.h>: Time manipulation functions.

    • <ctype.h>: Character type functions.

  2. NAI Specific Libraries

    • nai.h and naibrd.h: Core NAI header files.

    • naibrd_esw.h: Specific functions for ESW modules.

    • nai_ether_adv.h: Advanced Ethernet related functions.

    • Several include files for board access utilities, menus, queries, displays, and utilities within the include directory.

  3. Constants and Definitions

    • BACK_CHAR 'B': Defines the character used to go back in the menu.

    • CONFIG_FILE "default_ESW_Configuration.txt": Path to the configuration file.

    • DEF_ESW_PORT and DEF_ESW_VLAN_GROUP: Default port and VLAN group numbers.

  4. Global Variables

    • g_MaxESWPorts: Maximum number of Ethernet Switch Ports.

    • generation: Stores the generation of the board/module.

  5. Enumerations

    • esw_config_commands, esw_port_config_commands, esw_vlan_config_commands: Enumerations to define various command options for the menu.

Core Functions Overview

  1. Main Function (main or ESW_Config)

    • The entry point of the application. This initializes variables and enters a loop where it queries the user for a card index and module number, and runs the ESW configuration menu.

  2. Run_ESW_Config

    • Manages the high-level menu for ESW configuration.

    • Calls specific functions for handling port configuration, VLAN configuration, or built-in test (BIT) commands based on user input.

  3. Handle_ESW_PortConfig

    • Manages the configuration of Ethernet Switch Port settings including link duplex mode, link speed, and link gigabit capability.

    • Opens a menu for users to set or read these values.

  4. Handle_ESW_VLANConfig

    • Manages the configuration of VLAN settings. Users can set VLAN IDs, enable or disable VLANs, define VLAN types, confirm flags, modify control words, and configure IP addresses and network masks.

    • Functions are available to clear VLAN statuses individually or for all groups.

  5. Utility Functions

    • ESW_DisplayPortCfg: Displays the current port configurations.

    • ESW_DisplayVLANCfg: Displays the current VLAN configurations.

    • CheckESWModule: Verifies if a module is an ESW module and retrieves relevant module information.

    • GetPortNumber and GetVLANGroupNumber: Helpers to get port numbers and VLAN group numbers from the user.

Command Handling and Input Query

  • The application employs a command-response mechanism to navigate through different menus. Commands are mapped to their respective functions via command tables (naiapp_cmdtbl_params_t structures).

  • selecting commands:

  • Queries user input for commands using naiapp_utils_LoadParamMenuCommands and naiapp_query_ForQuitResponse.

Configuration Setup and Execution

  • Before running ESW routines, system configuration routines from nai_sys_cfg.c are executed, which include:

  • ConfigDevice: Configures the device.

  • DisplayDeviceCfg: Displays the device’s configuration.

  • GetBoardSNModCfg: Retrieves board configuration such as serial number and module configuration.

  • CheckModule: Validates the module.

The provided sample code walks users through setting up and running configurations for NAI’s ESW modules. It demonstrates modular design, command handling, validation, and peripheral interaction, essential for configuring embedded systems using NAI’s hardware and software toolkit.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>

/* Common Sample Program include files */
#include "include/naiapp_boardaccess_menu.h"
#include "include/naiapp_boardaccess_query.h"
#include "include/naiapp_boardaccess_access.h"
#include "include/naiapp_boardaccess_display.h"
#include "include/naiapp_boardaccess_utils.h"

/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_esw.h"
#include "advanced/nai_ether_adv.h"

#define BACK_CHAR 'B'

static const int8_t *CONFIG_FILE = (const int8_t *)"default_ESW_Configuration.txt";

/* Function prototypes */
static bool_t Run_ESW_Config( int32_t cardIndex, int32_t module );

static nai_status_t Handle_ESW_PortConfig(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANConfig(int32_t paramCount, int32_t* p_params);

static nai_status_t Handle_ESW_VLANID(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANClearReturnStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANClearReturnStatusAllGroups(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANType(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANConfirm(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANControlWord(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANMembers(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANTagging(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANIPAddress(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_VLANNetworkMask(int32_t paramCount, int32_t* p_params);

static nai_status_t Handle_ESW_Duplex(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_Speed(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_Gigabit(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_DuplexWord(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_SpeedWord(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_ESW_GigabitWord(int32_t paramCount, int32_t* p_params);

void ESW_DisplayPortCfg( int32_t cardIndex, int32_t module, int32_t maxport );
void ESW_DisplayVLANCfg( int32_t cardIndex, int32_t module, int32_t maxgroup );
bool_t CheckESWModule( int32_t *pCardIndex, int32_t *pModule, uint32_t *pModid, int32_t GetPortCount( int32_t cardIndex, int32_t module ) );
bool_t GetPortNumber( int32_t cardIndex, int32_t module, int32_t MaxPort, int32_t DefPort, int32_t *Port );
bool_t GetVLANGroupNumber( int32_t cardIndex, int32_t module, int32_t MaxGroup, int32_t DefGroup, int32_t *Group );

static const int32_t DEF_ESW_PORT       = 1;
static const int32_t DEF_ESW_VLAN_GROUP = 1;

static int32_t g_MaxESWPorts = 0;
static uint32_t generation; /* generation of the board/module */

/****** Command Table *******/
enum esw_config_commands
{
   ESW_CONFIG_CMD_PORT_CONFIG,
   ESW_CONFIG_CMD_VLAN_CONFIG,
   ESW_CONFIG_CMD_COUNT
};

enum esw_port_config_commands
{
   ESW_PORT_CONFIG_CMD_DUPLEX,
   ESW_PORT_CONFIG_CMD_SPEED,
   ESW_PORT_CONFIG_CMD_GIGABIT,
   ESW_PORT_CONFIG_CMD_DUPLEX_WORD,
   ESW_PORT_CONFIG_CMD_SPEED_WORD,
   ESW_PORT_CONFIG_CMD_GIGABIT_WORD,
   ESW_PORT_CONFIG_CMD_COUNT
};

enum esw_vlan_config_commands
{
   ESW_VLAN_CONFIG_CMD_ID,
   ESW_VLAN_CONFIG_CMD_CLEAR_STATUS,
   ESW_VLAN_CONFIG_CMD_CLEAR_STATUS_ALL_GROUPS,
   ESW_VLAN_CONFIG_CMD_ENABLE,
   ESW_VLAN_CONFIG_CMD_TYPE,
   ESW_VLAN_CONFIG_CMD_CONFIRM,
   ESW_VLAN_CONFIG_CMD_CTRL_WORD,
   ESW_VLAN_CONFIG_CMD_MEMBERS,
   ESW_VLAN_CONFIG_CMD_TAGGING,
   ESW_VLAN_CONFIG_CMD_IP_ADDRESS,
   ESW_VLAN_CONFIG_CMD_NET_MASK,
   ESW_VLAN_CONFIG_CMD_COUNT
};

/****** Command Tables *******/
naiapp_cmdtbl_params_t ESW_ConfigMenuCmds[] =
{
   {"PORT",      "ESW Port Configuration Functions",      ESW_CONFIG_CMD_PORT_CONFIG,       Handle_ESW_PortConfig},
   {"VLAN",      "ESW VLAN Configuration Functions",      ESW_CONFIG_CMD_VLAN_CONFIG,       Handle_ESW_VLANConfig}
};

naiapp_cmdtbl_params_t ESW_PortConfigMenuCmds[] =
{
   {"DUPLEX",      "Set Link Duplex Mode of Port",                             ESW_PORT_CONFIG_CMD_DUPLEX,                  Handle_ESW_Duplex},
   {"SPEED",       "Set Link Speed of Port",                                   ESW_PORT_CONFIG_CMD_SPEED,                   Handle_ESW_Speed},
   {"GIGABIT",     "Set Link Gigabit Capability Advertise State of Port",      ESW_PORT_CONFIG_CMD_GIGABIT,                 Handle_ESW_Gigabit},
   {"RDUPLEX",     "Set Raw Link Duplex Mode Register",                        ESW_PORT_CONFIG_CMD_DUPLEX_WORD,             Handle_ESW_DuplexWord},
   {"RSPEED",      "Set Raw Link Speed Group Registers",                       ESW_PORT_CONFIG_CMD_SPEED_WORD,              Handle_ESW_SpeedWord},
   {"RGIGABIT",    "Set Raw Link Gigabit Capability Advertise Register Value", ESW_PORT_CONFIG_CMD_GIGABIT_WORD,            Handle_ESW_GigabitWord}
};

naiapp_cmdtbl_params_t ESW_VLANConfigMenuCmds[] =
{
   {"ID",           "Set VLAN ID",                                 ESW_VLAN_CONFIG_CMD_ID,                      Handle_ESW_VLANID},
   {"CLEAR",        "Clear VLAN Return Status",                    ESW_VLAN_CONFIG_CMD_CLEAR_STATUS,            Handle_ESW_VLANClearReturnStatus},
   {"GROUP CLEAR",  "Clear VLAN Return Status All Groups",         ESW_VLAN_CONFIG_CMD_CLEAR_STATUS_ALL_GROUPS, Handle_ESW_VLANClearReturnStatusAllGroups},
   {"ENABLE",       "Enable/disable VLAN",                         ESW_VLAN_CONFIG_CMD_ENABLE,                  Handle_ESW_VLANEnable},
   {"TYPE",         "Set VLAN Type",                               ESW_VLAN_CONFIG_CMD_TYPE,                    Handle_ESW_VLANType},
   {"VLAN CONFIRM", "Set VLAN Confirm Flag Value",                 ESW_VLAN_CONFIG_CMD_CONFIRM,                 Handle_ESW_VLANConfirm},
   {"RAW CTRL",     "Set VLAN Control Reg Value",                  ESW_VLAN_CONFIG_CMD_CTRL_WORD,               Handle_ESW_VLANControlWord},
   {"MEMBERS",      "Set VLAN Members",                            ESW_VLAN_CONFIG_CMD_MEMBERS,                 Handle_ESW_VLANMembers},
   {"PACKET",       "Set VLAN Packet-Tagging Members",             ESW_VLAN_CONFIG_CMD_TAGGING,                 Handle_ESW_VLANTagging},
   {"ADDRESS",      "Set VLAN IP Address",                         ESW_VLAN_CONFIG_CMD_IP_ADDRESS,              Handle_ESW_VLANIPAddress},
   {"NET MASK",     "Set VLAN Network Mask",                       ESW_VLAN_CONFIG_CMD_NET_MASK,                Handle_ESW_VLANNetworkMask}
};

/**************************************************************************************************************/
/**
<summary>
The purpose of ESW_Config is to illustrate the methods to call in the naibrd library to configure ESW
modules for configuration setup, controlling the drive outputs, and reading the registers.

The following system configuration routines from the nai_sys_cfg.c file are called to assist with the configuration
setup for this program prior to calling the naibrd ESW routines.
 - ConfigDevice
 - DisplayDeviceCfg
 - GetBoardSNModCfg
 - CheckModule
</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t ESW_Config(void)
#else
int32_t main(void)
#endif
{
   bool_t stop = FALSE;
   int32_t cardIndex;
   int32_t moduleCnt;
   int32_t module;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
   {
      while (stop != TRUE)
      {
         /* Query the user for the card index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Query the user for the module number */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != TRUE)
            {
               Run_ESW_Config(cardIndex, module);

            }
         }

         printf("\nType Q to quit or Enter key to restart application:\n");
         stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      }
   }

   printf("\nType the Enter key to exit the program: ");
   naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   naiapp_access_CloseAllOpenCards();

   return 0;
}

/**************************************************************************************************************/
/**
<summary>
This function runs the ESW Configuration program.  It controls the top level menu of the ESW_Config
program and calls Handle_ESW_PortConfig, Handle_ESW_VLANConfig, or Handle_ESW_BIT, depending on what the
user specifies.
</summary>
*/
/**************************************************************************************************************/
static bool_t Run_ESW_Config( int32_t cardIndex, int32_t module )
{
   bool_t bQuit = FALSE;
   bool_t bContinue = TRUE;
   bool_t bCmdFound = FALSE;
   int32_t cmd;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   naiapp_AppParameters_t  esw_params;
   p_naiapp_AppParameters_t esw_config_params = &esw_params;
   esw_config_params->cardIndex = cardIndex;
   esw_config_params->module = module;

   /* Get the Maximum number of ESW Ports */
   g_MaxESWPorts = naibrd_ESW_GetPortCount( cardIndex, module );
   esw_config_params->channel = g_MaxESWPorts;
   /* Get the generation of the board and module */
   naibrd_GetBoardGen( cardIndex, &generation );

   while (bContinue)
   {
      naiapp_utils_LoadParamMenuCommands( ESW_CONFIG_CMD_COUNT, ESW_ConfigMenuCmds );
      while (bContinue)
      {
         naiapp_utils_LoadParamMenuCommands( ESW_CONFIG_CMD_COUNT, ESW_ConfigMenuCmds ); /* reload main menu */
         naiapp_display_ParamMenuCommands( (int8_t *)"ESW Configuration Menu" );
         printf( "\nType ESW command or %c to quit : main >", NAI_QUIT_CHAR );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if ( inputResponseCnt > 0 )
            {
               bCmdFound = naiapp_utils_GetParamMenuCmdNum( inputResponseCnt, inputBuffer, &cmd );
               if (bCmdFound)
               {
                  switch (cmd)
                  {
                  case ESW_CONFIG_CMD_PORT_CONFIG:
                  case ESW_CONFIG_CMD_VLAN_CONFIG:
                     ESW_ConfigMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)esw_config_params);
                     break;
                  default:
                     printf( "Invalid command entered\n" );
                     break;
                  }
               }
               else
                  printf( "Invalid command entered\n" );
            }
         }
         else
            bContinue = FALSE;
      }
   }
   return bQuit;
}

/**************************************************************************************************************/
/**
<summary>
This function is called if the user chooses to configure ESW Ethernet Port Settings. ESW Ethernet Port
Settings can be read from the menu opened by this function, and there are options to set Link Duplex Mode,
Link Speed, and Link Gigabit Capability Advertise State. These values can be set per port, and the registers
that hold the values of the Link Duplex Mode, Link Speed, and Link Gigabit Capability Advertise State for all
ports on the module can also be set in one call.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_PortConfig(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   bool_t bQuit = FALSE;
   bool_t bContinue = TRUE;
   bool_t bCmdFound = FALSE;
   int32_t cmd;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   while (bContinue)
   {
      naiapp_utils_LoadParamMenuCommands( ESW_PORT_CONFIG_CMD_COUNT, ESW_PortConfigMenuCmds );
      while (bContinue)
      {
         ESW_DisplayPortCfg( cardIndex, module, g_MaxESWPorts );
         naiapp_display_ParamMenuCommands( (int8_t *)"ESW Port Configuration Menu" );
         printf( "\nType ESW command or %c to go back : Port Cfg >", BACK_CHAR );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), BACK_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if ( inputResponseCnt > 0 )
            {
               bCmdFound = naiapp_utils_GetParamMenuCmdNum( inputResponseCnt, inputBuffer, &cmd );
               if (bCmdFound)
               {
                  switch (cmd)
                  {
                  case ESW_PORT_CONFIG_CMD_DUPLEX:
                  case ESW_PORT_CONFIG_CMD_SPEED:
                  case ESW_PORT_CONFIG_CMD_GIGABIT:
                  case ESW_PORT_CONFIG_CMD_DUPLEX_WORD:
                  case ESW_PORT_CONFIG_CMD_SPEED_WORD:
                  case ESW_PORT_CONFIG_CMD_GIGABIT_WORD:
                     ESW_PortConfigMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)p_esw_params);
                     break;
                  default:
                     printf( "Invalid command entered\n" );
                     break;
                  }
               }
               else
                  printf( "Invalid command entered\n" );
            }
         }
         else
            bContinue = FALSE;
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function is called if the user chooses to configure ESW VLAN Settings. ESW VLAN Settings can be read
from the menu opened by this function, and there are options to set the VLAN ID, VLAN Enable value, VLAN
Type, VLAN Confirm Flag, VLAN Control word (VLAN register value that contains a VLAN Group's VLAN Enable
value, VLAN Type, and VLAN Confirm Flag), VLAN Members value, VLAN Packet-Tagging Members value, and VLAN
IP Address of each VLAN Group on the module. In addition, one can clear the VLAN Return Status of any of the
VLAN Groups individually or of all of the VLAN Groups at once.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANConfig(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t bContinue = TRUE;
   bool_t bCmdFound = FALSE;
   int32_t cmd;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   while (bContinue)
   {
      naiapp_utils_LoadParamMenuCommands( ESW_VLAN_CONFIG_CMD_COUNT, ESW_VLANConfigMenuCmds );
      while (bContinue)
      {
         ESW_DisplayVLANCfg( cardIndex, module, maxGroup );
         naiapp_display_ParamMenuCommands( (int8_t *)"ESW VLAN Configuration Menu" );
         printf( "\nType ESW command or %c to go back : VLAN Cfg >", BACK_CHAR );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), BACK_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if ( inputResponseCnt > 0 )
            {
               bCmdFound = naiapp_utils_GetParamMenuCmdNum( inputResponseCnt, inputBuffer, &cmd );
               if (bCmdFound)
               {
                  switch (cmd)
                  {
                  case ESW_VLAN_CONFIG_CMD_ID:
                  case ESW_VLAN_CONFIG_CMD_CLEAR_STATUS:
                  case ESW_VLAN_CONFIG_CMD_CLEAR_STATUS_ALL_GROUPS:
                  case ESW_VLAN_CONFIG_CMD_ENABLE:
                  case ESW_VLAN_CONFIG_CMD_TYPE:
                  case ESW_VLAN_CONFIG_CMD_CONFIRM:
                  case ESW_VLAN_CONFIG_CMD_CTRL_WORD:
                  case ESW_VLAN_CONFIG_CMD_MEMBERS:
                  case ESW_VLAN_CONFIG_CMD_TAGGING:
                  case ESW_VLAN_CONFIG_CMD_IP_ADDRESS:
                  case ESW_VLAN_CONFIG_CMD_NET_MASK:
                     ESW_VLANConfigMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)p_esw_params);
                     break;
                  default:
                     printf( "Invalid command entered\n" );
                     break;
                  }
               }
               else
                  printf( "Invalid command entered\n" );
            }
         }
         else
            bContinue = FALSE;
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the VLAN ID of the specified VLAN Group to the value specified by the user and then
displays all of the VLAN Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANID(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   uint32_t vlanid;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type VLAN Group ID hexadecimal value to set (example:ffff): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt > 0 )
         {
            vlanid = strtol( (const char *)inputBuffer, NULL, 16 );
            check_status( naibrd_ESW_SetVLANID( cardIndex, module, vlan, vlanid ) );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function clears the VLAN Return Status of the specified VLAN Group and then displays all of the VLAN
Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANClearReturnStatus(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Are you sure you want to clear the return status of VLAN Group %d? ('Y' for Yes or 'N' for No)(default:Y): ", vlan );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( ( inputBuffer[0] == 'Y' ) || ( inputBuffer[0] == 'y' ) || ( inputResponseCnt == 0 ) )
         {
            check_status( naibrd_ESW_ClearVLANReturnStatus( cardIndex, module, vlan ) );
            printf( "\nReturn Status for VLAN Group %d has been cleared.\n", vlan );
         }
         else if ( ( inputBuffer[0] == 'N' ) || ( inputBuffer[0] == 'n' ) )
         {
            printf( "\nNo Return Statuses have been cleared.\n" );
         }
         else
         {
            printf( "\nERROR! The response you entered was invalid.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function clears the VLAN Return Statuses of all of the VLAN Groups on the module and then displays all
of the VLAN Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANClearReturnStatusAllGroups(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   bool_t bQuit = FALSE;
   int32_t numVLANGroups = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   printf( "Are you sure you want to clear the return statuses of all of the VLAN Groups on the module? ('Y' for Yes or 'N' for No)(default:Y): " );
   bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
   if (!bQuit)
   {
      if ( ( inputBuffer[0] == 'Y' ) || ( inputBuffer[0] == 'y' ) || ( inputResponseCnt == 0 ) )
      {
         for ( vlan = 1; vlan <= numVLANGroups; vlan++ )
         {
            check_status( naibrd_ESW_ClearVLANReturnStatus( cardIndex, module, vlan ) );
         }
         printf( "\nReturn Statuses for all VLAN Groups have been cleared.\n" );
      }
      else if ( ( inputBuffer[0] == 'N' ) || ( inputBuffer[0] == 'n' ) )
      {
         printf( "\nNo Return Statuses have been cleared.\n" );
      }
      else
      {
         printf( "\nERROR! The response you entered was invalid.\n" );
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function Enables/Disables VLAN for the specified VLAN Group and then displays all of the VLAN
Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANEnable(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   bool_t vlanEnable;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type VLAN Enabled/Disabled State value to set ('0' for Disable, '1' for Enable)(default:1): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt == 0 )
         {
            vlanEnable = TRUE;
         }
         else if ( inputResponseCnt > 0 )
         {
            vlanEnable = (bool_t)( atoi( (const char *)inputBuffer ) );
         }
         else
         {
            vlanEnable = FALSE;
            errFlag = TRUE;
         }

         if ( ( ( vlanEnable == TRUE ) || ( vlanEnable == FALSE ) ) && ( errFlag == FALSE ) )
         {
            check_status( naibrd_ESW_SetVLANControlEnable( cardIndex, module, vlan, vlanEnable ) );
         }
         else
         {
            printf( "\nERROR! Invalid VLAN Enable value.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the VLAN Type of the specified VLAN Group to the type specified by the user and then
displays all of the VLAN Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANType(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   nai_esw_vlan_type_t vlanType;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type VLAN Type value to set ('0' for port based, '1' for subnet based)(default:0): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt == 0 )
         {
            vlanType = NAI_ESW_VLAN_TYPE_PORT_BASED;
         }
         else if ( inputResponseCnt > 0 )
         {
            vlanType = (nai_esw_vlan_type_t)( atoi( (const char *)inputBuffer ) );
         }
         else
         {
            vlanType = NAI_ESW_VLAN_TYPE_PORT_BASED;
            errFlag = TRUE;
         }

         if ( ( ( vlanType == NAI_ESW_VLAN_TYPE_SUBNET_BASED ) || ( vlanType == NAI_ESW_VLAN_TYPE_PORT_BASED ) ) && ( errFlag == FALSE ) )
         {
            check_status( naibrd_ESW_SetVLANControlType( cardIndex, module, vlan, vlanType ) );
         }
         else
         {
            printf( "\nERROR! Invalid VLAN Control Type.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the VLAN Confirm Flag of the specified VLAN Group to the value specified by the user and
then displays all of the VLAN Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANConfirm(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   bool_t confirm;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type VLAN Confirm Flag value to set ('1' for confirm, '0' for not confirm)(default:1): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt == 0 )
         {
            confirm = TRUE;
         }
         else if ( inputResponseCnt > 0 )
         {
            confirm = (bool_t)( atoi( (const char *)inputBuffer ) );
         }
         else
         {
            confirm = FALSE;
            errFlag = TRUE;
         }

         if ( ( ( confirm == TRUE ) || ( confirm == FALSE ) ) && ( errFlag == FALSE ) )
         {
            check_status( naibrd_ESW_SetVLANControlConfirm( cardIndex, module, vlan, confirm ) );
         }
         else
         {
            printf( "\nERROR! Invalid VLAN Confirm Flag Value.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the raw VLAN Control Word register value of the specified VLAN Group to the value
specified by the user and then displays all of the VLAN Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANControlWord(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   nai_esw_vlan_ctrl_t control;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type Raw VLAN Control hexadecimal value to set (example:ffff): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt > 0 )
         {
            control = strtol( (const char *)inputBuffer, NULL, 16 );
            check_status( naibrd_ESW_SetVLANControlWord( cardIndex, module, vlan, control ) );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the register value that indicates which ports are part of the specified VLAN Group to the
value specified by the user and then displays all of the VLAN Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANMembers(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   uint32_t vlanMembers;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type VLAN Members hexadecimal value to set (example:ffff): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt > 0 )
         {
            vlanMembers = strtol( (const char *)inputBuffer, NULL, 16 );
            check_status( naibrd_ESW_SetVLANMembers( cardIndex, module, vlan, vlanMembers ) );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the register value that indicates which members of the specified VLAN Group will tag
packets as they ingress to the value specified by the user and then displays all of the VLAN Configuration
data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANTagging(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   uint32_t vlanTaggingMembers;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type VLAN Packet-Tagging Members hexadecimal value to set (example:ffff): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt > 0 )
         {
            vlanTaggingMembers = strtol( (const char *)inputBuffer, NULL, 16 );
            check_status( naibrd_ESW_SetVLANMemberTagPkt( cardIndex, module, vlan, vlanTaggingMembers ) );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the VLAN IP Address of the specified VLAN Group to the value specified by the user and
then displays all of the VLAN Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANIPAddress(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   uint8_t AddrToWrite[10];
   int32_t IPv6Version = 0;
   int32_t parseFuncStatus;
   uint16_t ipBits63to48;
   uint16_t ipBits47to32;
   uint16_t ipBits31to16;
   uint16_t ipBits15to0;
   int32_t port = 0;
   int8_t* ipText;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type VLAN IP Address to set in either IPv4 or IPv6 format (for IPv6, only type in the upper 64 bits of the address, " );
      printf( "as the lower 64 bits are not used)(IPv4 example: 255.255.255.255, IPv6 example: FFFF:FFFF:FFFF:FFFF): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         ipText = &inputBuffer[0];
         parseFuncStatus = ParseIPv4orIPv6( (const char **)&ipText, AddrToWrite, &port, &IPv6Version );
         if ( parseFuncStatus == 1 )
         {
            if ( IPv6Version == TRUE )
            {
               ipBits63to48 = ( AddrToWrite[0] << 8 ) | ( AddrToWrite[1] );
               ipBits47to32 = ( AddrToWrite[2] << 8 ) | ( AddrToWrite[3] );
               ipBits31to16 = ( AddrToWrite[4] << 8 ) | ( AddrToWrite[5] );
               ipBits15to0 = ( AddrToWrite[6] << 8 ) | ( AddrToWrite[7] );
            }
            else
            {
               ipBits63to48 = 0;
               ipBits47to32 = 0;
               ipBits31to16 = ( AddrToWrite[0] << 8 ) | ( AddrToWrite[1] );
               ipBits15to0 = ( AddrToWrite[2] << 8 ) | ( AddrToWrite[3] );
            }
            check_status( naibrd_ESW_SetVLANIPAddress( cardIndex, module, vlan, ipBits63to48, ipBits47to32, ipBits31to16, ipBits15to0 ) );
         }
         else
         {
            printf( "\nERROR! Invalid IP Address.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the VLAN Network Mask of the specified VLAN Group to the value specified by the user and
then displays all of the VLAN Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_VLANNetworkMask(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   uint8_t AddrToWrite[10];
   int32_t IPv6Version = 0;
   int32_t parseFuncStatus;
   uint16_t netBits63to48;
   uint16_t netBits47to32;
   uint16_t netBits31to16;
   uint16_t netBits15to0;
   int32_t port = 0;
   int8_t* ipText;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t vlan = p_esw_params->channel;
   int32_t maxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetVLANGroupNumber( cardIndex, module, maxGroup, DEF_ESW_VLAN_GROUP, &vlan );
   if (!bQuit)
   {
      printf( "Type VLAN Network Mask to set in either IPv4 or IPv6 format (for IPv6, only type in the upper 64 bits of the mask, " );
      printf( "as the lower 64 bits are not used)(IPv4 example: 255.255.255.255, IPv6 example: FFFF:FFFF:FFFF:FFFF): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         ipText = &inputBuffer[0];
         parseFuncStatus = ParseIPv4orIPv6( (const char **)&ipText, AddrToWrite, &port, &IPv6Version );
         if ( parseFuncStatus == 1 )
         {
            if ( IPv6Version == TRUE )
            {
               netBits63to48 = ( AddrToWrite[0] << 8 ) | ( AddrToWrite[1] );
               netBits47to32 = ( AddrToWrite[2] << 8 ) | ( AddrToWrite[3] );
               netBits31to16 = ( AddrToWrite[4] << 8 ) | ( AddrToWrite[5] );
               netBits15to0 = ( AddrToWrite[6] << 8 ) | ( AddrToWrite[7] );
            }
            else
            {
               netBits63to48 = 0;
               netBits47to32 = 0;
               netBits31to16 = ( AddrToWrite[0] << 8 ) | ( AddrToWrite[1] );
               netBits15to0 = ( AddrToWrite[2] << 8 ) | ( AddrToWrite[3] );
            }
            check_status( naibrd_ESW_SetVLANNetworkMask( cardIndex, module, vlan, netBits63to48, netBits47to32, netBits31to16, netBits15to0 ) );
         }
         else
         {
            printf( "\nERROR! Invalid Network Mask.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the Link Duplex Mode of the specified port to the mode specified by the user and then
displays all of the Ethernet Port Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_Duplex(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   nai_esw_link_duplex_t duplex;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t port = p_esw_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetPortNumber( cardIndex, module, g_MaxESWPorts, DEF_ESW_PORT, &port );
   if (!bQuit)
   {
      printf( "Type Link Duplex value to set ('0' for Half Duplex, '1' for Full Duplex)(default:0): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt == 0 )
         {
            duplex = NAI_ESW_LINK_HALF_DUPLEX;
         }
         else if ( inputResponseCnt > 0 )
         {
            duplex = (nai_esw_link_duplex_t)( atoi( (const char *)inputBuffer ) );
         }
         else
         {
            duplex = NAI_ESW_LINK_HALF_DUPLEX;
            errFlag = TRUE;
         }

         if ( ( ( duplex == NAI_ESW_LINK_HALF_DUPLEX ) || ( duplex == NAI_ESW_LINK_FULL_DUPLEX ) ) && ( errFlag == FALSE ) )
         {
            check_status( naibrd_ESW_SetLinkDuplex( cardIndex, module, port, duplex ) );
         }
         else
         {
            printf( "\nERROR! Invalid Link Duplex value.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the Link Speed of the specified port to the speed specified by the user and then displays
all of the Ethernet Port Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_Speed(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   nai_esw_link_speed_t speed;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t port = p_esw_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetPortNumber( cardIndex, module, g_MaxESWPorts, DEF_ESW_PORT, &port );
   if (!bQuit)
   {
      printf( "Type Link Speed value to set ('0' for Auto, '1' for 10, '2' for 100, '3' for 1G, '15' for disable)(default:0): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt == 0 )
         {
            speed = NAI_ESW_LINK_SPEED_AUTO;
         }
         else if ( inputResponseCnt > 0 )
         {
            speed = (nai_esw_link_speed_t)( atoi( (const char *)inputBuffer ) );
         }
         else
         {
            speed = NAI_ESW_LINK_SPEED_DISABLE;
            errFlag = TRUE;
         }

         if ( ( ( speed == NAI_ESW_LINK_SPEED_AUTO ) || ( speed == NAI_ESW_LINK_SPEED_10 ) || ( speed == NAI_ESW_LINK_SPEED_100 ) || ( speed == NAI_ESW_LINK_SPEED_1G ) || ( speed == NAI_ESW_LINK_SPEED_DISABLE ) ) && ( errFlag == FALSE ) )
         {
            check_status( naibrd_ESW_SetLinkSpeed( cardIndex, module, port, speed ) );
         }
         else
         {
            printf( "\nERROR! Invalid Link Speed value.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the Link Gigabit Capability Advertise State of the specified port to the state specified
by the user and then displays all of the Ethernet Port Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_Gigabit(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   nai_esw_link_gig_adv_t linkGigAdv;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int32_t port = p_esw_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = GetPortNumber( cardIndex, module, g_MaxESWPorts, DEF_ESW_PORT, &port );
   if (!bQuit)
   {
      printf( "Type Link Gigabit Capability Advertise state to set ('0' for Off, '1' for On)(default:0): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if ( inputResponseCnt == 0 )
         {
            linkGigAdv = NAI_ESW_LINK_GIG_ADV_OFF;
         }
         else if ( inputResponseCnt > 0 )
         {
            linkGigAdv = (nai_esw_link_gig_adv_t)( atoi( (const char *)inputBuffer ) );
         }
         else
         {
            linkGigAdv = NAI_ESW_LINK_GIG_ADV_OFF;
            errFlag = TRUE;
         }

         if ( ( ( linkGigAdv == NAI_ESW_LINK_GIG_ADV_OFF ) || ( linkGigAdv == NAI_ESW_LINK_GIG_ADV_ON ) ) && ( errFlag == FALSE ) )
         {
            check_status( naibrd_ESW_SetLinkGigCapAdv( cardIndex, module, port, linkGigAdv ) );
         }
         else
         {
            printf( "\nERROR! Invalid Link Gigabit Capability Advertise State.\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the raw Link Duplex register value that contains the values of the Link Duplex modes of
all of the ports on the module to the value specified by the user and then displays all of the Ethernet
Port Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_DuplexWord(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   uint32_t duplexWord;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   printf( "Type Raw Link Duplex value to set (example:ffff): " );
   bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
   if (!bQuit)
   {
      if ( inputResponseCnt > 0 )
      {
         duplexWord = strtol( (const char *)inputBuffer, NULL, 16 );
         check_status( naibrd_ESW_SetLinkDuplexWord( cardIndex, module, duplexWord ) );
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the raw Link Speed register value that contains the values of the Link Speeds of all of
the ports on the module to the value specified by the user and then displays all of the Ethernet Port
Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_SpeedWord(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   uint32_t speedWord;
   int32_t group;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   printf( "Would you like to set the Raw Link Speed value for ports 1-4, 5-8, or 9-12? ('1' for 1-4, '2' for 5-8, '3' for 9-12)(default:1): " );
   bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
   if (!bQuit)
   {
      if ( inputResponseCnt > 0 )
      {
         group = atoi( (const char *)inputBuffer );
         if ( ( group > 3 ) || ( group < 1 ) )
         {
            printf( "\nERROR! Invalid group number.\n" );
            bQuit = TRUE;
         }
      }
      else if ( inputResponseCnt == 0 )
      {
         group = 1;
      }
      else
      {
         group = 0xFFFF;
         printf( "\nERROR!\n" );
         bQuit = TRUE;
      }

      if (!bQuit)
      {
         printf( "Type Raw Link Speed value to set (example:ffff): " );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if ( inputResponseCnt > 0 )
            {
               speedWord = strtol( (const char *)inputBuffer, NULL, 16 );
               check_status( naibrd_ESW_SetLinkSpeedWord( cardIndex, module, group, speedWord ) );
            }
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the raw Link Gigabit Capability Advertise state register value that contains the values
of the Link Gigabit Capability Advertise states of all of the ports on the module to the value specified by
the user and then displays all of the Ethernet Port Configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_ESW_GigabitWord(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   uint32_t gigabitWord;
   p_naiapp_AppParameters_t p_esw_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_esw_params->cardIndex;
   int32_t module = p_esw_params->module;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   printf( "Type Raw Link Gigabit Capability Advertise state to set (example:ffff): " );
   bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
   if (!bQuit)
   {
      if ( inputResponseCnt > 0 )
      {
         gigabitWord = strtol( (const char *)inputBuffer, NULL, 16 );
         check_status( naibrd_ESW_SetLinkGigCapAdvWord( cardIndex, module, gigabitWord ) );
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function displays the ESW Port Configuration settings.
</summary>
*/
/**************************************************************************************************************/
void ESW_DisplayPortCfg( int32_t cardIndex, int32_t module, int32_t maxport )
{
   int32_t port;
   nai_esw_link_status_t status;
   nai_esw_link_duplex_t duplex;
   nai_esw_link_duplex_t duplexStatus;
   nai_esw_link_speed_t speed;
   nai_esw_link_speed_t speedStatus;
   nai_esw_link_gig_adv_t gigabit;
   nai_esw_link_mdix_mode_t mdix;
   nai_esw_bit_status_t bitStatus;
   uint32_t statusWord;
   uint32_t duplexWord;
   uint32_t duplexStatusWord;
   uint32_t speedWord14;
   uint32_t speedWord58;
   uint32_t speedWord912;
   uint32_t speedStatusWord14;
   uint32_t speedStatusWord58;
   uint32_t speedStatusWord912;
   uint32_t gigabitWord;
   uint32_t mdixWord;
   uint32_t bitStatusWord;
   char* sStatus;
   char* sDuplex;
   char* sDuplexStatus;
   char* sSpeed;
   char* sSpeedStatus;
   char* sGigabit;
   char* sMdix;
   char* sBitStatus;

   printf( "\n\nESW Port Configuration:\n" );
   printf( "                         Duplex                         Speed                        BIT\n" );
   printf( "Port   Status   Duplex   Status                Speed    Status    Gigabit   MDI/X   Status\n" );
   printf( "----------------------------------------------------------------------------------------------\n" );

   check_status( naibrd_ESW_GetLinkStatusWord( cardIndex, module, &statusWord ) );
   check_status( naibrd_ESW_GetLinkDuplexWord( cardIndex, module, &duplexWord ) );
   check_status( naibrd_ESW_GetLinkDuplexStatusWord( cardIndex, module, &duplexStatusWord ) );
   check_status( naibrd_ESW_GetLinkSpeedWord( cardIndex, module, 1, &speedWord14 ) );
   check_status( naibrd_ESW_GetLinkSpeedWord( cardIndex, module, 2, &speedWord58 ) );
   check_status( naibrd_ESW_GetLinkSpeedWord( cardIndex, module, 3, &speedWord912 ) );
   check_status( naibrd_ESW_GetGroupLinkSpeedStatus( cardIndex, module, 1, &speedStatusWord14 ) );
   check_status( naibrd_ESW_GetGroupLinkSpeedStatus( cardIndex, module, 2, &speedStatusWord58 ) );
   check_status( naibrd_ESW_GetGroupLinkSpeedStatus( cardIndex, module, 3, &speedStatusWord912 ) );
   check_status( naibrd_ESW_GetLinkGigCapAdvWord( cardIndex, module, &gigabitWord ) );
   check_status( naibrd_ESW_GetLinkMDIXModeWord( cardIndex, module, &mdixWord ) );
   check_status( naibrd_ESW_GetBITStatusWord( cardIndex, module, &bitStatusWord ) );

   for ( port = 1; port <= maxport; port++ )
   {
      check_status( naibrd_ESW_GetLinkStatus( cardIndex, module, port, &status ) );
      switch (status)
      {
      case NAI_ESW_LINK_DOWN:
         sStatus = " DOWN ";
         break;
      case NAI_ESW_LINK_UP:
         sStatus = "  UP  ";
         break;
      default:
         sStatus = " ERROR";
         break;
      }

      check_status( naibrd_ESW_GetLinkDuplex( cardIndex, module, port, &duplex ) );
      switch (duplex)
      {
      case NAI_ESW_LINK_HALF_DUPLEX:
         sDuplex = " HALF ";
         break;
      case NAI_ESW_LINK_FULL_DUPLEX:
         sDuplex = " FULL ";
         break;
      default:
         sDuplex = " ERROR";
         break;
      }

      check_status( naibrd_ESW_GetLinkDuplexStatus( cardIndex, module, port, &duplexStatus ) );
      switch (duplexStatus)
      {
      case NAI_ESW_LINK_HALF_DUPLEX:
         sDuplexStatus = " HALF ";
         break;
      case NAI_ESW_LINK_FULL_DUPLEX:
         sDuplexStatus = " FULL ";
         break;
      default:
         sDuplexStatus = " ERROR";
         break;
      }

      check_status( naibrd_ESW_GetLinkSpeed( cardIndex, module, port, &speed ) );
      switch (speed)
      {
      case NAI_ESW_LINK_SPEED_AUTO:
         sSpeed = " AUTO  ";
         break;
      case NAI_ESW_LINK_SPEED_10:
         sSpeed = "  10   ";
         break;
      case NAI_ESW_LINK_SPEED_100:
         sSpeed = "  100  ";
         break;
      case NAI_ESW_LINK_SPEED_1G:
         sSpeed = "  1G   ";
         break;
      case NAI_ESW_LINK_SPEED_DISABLE:
         sSpeed = "DISABLE";
         break;
      default:
         sSpeed = " ERROR ";
         break;
      }

      check_status( naibrd_ESW_GetLinkSpeedStatus( cardIndex, module, port, &speedStatus ) );
      switch (speedStatus)
      {
      case NAI_ESW_LINK_SPEED_AUTO:
         sSpeedStatus = " AUTO  ";
         break;
      case NAI_ESW_LINK_SPEED_10:
         sSpeedStatus = "  10   ";
         break;
      case NAI_ESW_LINK_SPEED_100:
         sSpeedStatus = "  100  ";
         break;
      case NAI_ESW_LINK_SPEED_1G:
         sSpeedStatus = "  1G   ";
         break;
      case NAI_ESW_LINK_SPEED_DISABLE:
         sSpeedStatus = "DISABLE";
         break;
      default:
         sSpeedStatus = " ERROR ";
         break;
      }

      check_status( naibrd_ESW_GetLinkGigCapAdv( cardIndex, module, port, &gigabit ) );
      switch (gigabit)
      {
      case NAI_ESW_LINK_GIG_ADV_OFF:
         sGigabit = " OFF  ";
         break;
      case NAI_ESW_LINK_GIG_ADV_ON:
         sGigabit = "  ON  ";
         break;
      default:
         sGigabit = " ERROR";
         break;
      }

      check_status( naibrd_ESW_GetLinkMDIXMode( cardIndex, module, port, &mdix ) );
      switch (mdix)
      {
      case NAI_ESW_LINK_MDI_MODE:
         sMdix = " MDI  ";
         break;
      case NAI_ESW_LINK_MDIX_MODE:
         sMdix = " MDIX ";
         break;
      default:
         sMdix = " ERROR";
         break;
      }

      check_status( naibrd_ESW_GetBITStatus( cardIndex, module, port, &bitStatus ) );
      switch (bitStatus)
      {
      case NAI_ESW_LOOPBACK_PASSED:
         sBitStatus = "PASSED";
         break;
      case NAI_ESW_LOOPBACK_FAILED:
         sBitStatus = "FAILED";
         break;
      default:
         sBitStatus = "ERROR ";
         break;
      }

      printf( "%4d   %s   %s   %s               %s   %s   %s   %s   %s\n", port, sStatus, sDuplex, sDuplexStatus, sSpeed, sSpeedStatus, sGigabit, sMdix, sBitStatus );
   }
   printf( "\n" );
   printf( "All    0x%04X   0x%04X   0x%04X   Ports 1-4:  0x%04X    0x%04X    0x%04X   0x%04X   0x%04X\n", statusWord, duplexWord, duplexStatusWord, speedWord14, speedStatusWord14, gigabitWord, mdixWord, bitStatusWord );
   printf( "                                  Ports 5-8:  0x%04X    0x%04X\n", speedWord58, speedStatusWord58 );
   printf( "                                  Ports 9-12: 0x%04X    0x%04X\n", speedWord912, speedStatusWord912 );
}

/**************************************************************************************************************/
/**
<summary>
This function displays the ESW VLAN Configuration settings.
</summary>
*/
/**************************************************************************************************************/
void ESW_DisplayVLANCfg( int32_t cardIndex, int32_t module, int32_t maxgroup )
{
   int32_t group;
   uint32_t vlanID;
   uint32_t vlanReturnStatus;
   bool_t vlanConfirm;
   nai_esw_vlan_ctrl_t vlanControlWord;
   bool_t vlanEnable;
   nai_esw_vlan_type_t vlanType;
   uint32_t vlanMembers;
   uint32_t vlanTaggingMembers;
   uint16_t vlanIPBits63to48;
   uint16_t vlanIPBits47to32;
   uint16_t vlanIPBits31to16;
   uint16_t vlanIPBits15to0;
   uint8_t IPv4Bits31to24;
   uint8_t IPv4Bits23to16;
   uint8_t IPv4Bits15to8;
   uint8_t IPv4Bits7to0;
   uint16_t IPv6Bits127to112;
   uint16_t IPv6Bits111to96;
   uint16_t IPv6Bits95to80;
   uint16_t IPv6Bits79to64;
   uint16_t vlanNetMaskBits63to48;
   uint16_t vlanNetMaskBits47to32;
   uint16_t vlanNetMaskBits31to16;
   uint16_t vlanNetMaskBits15to0;
   uint8_t IPv4NetBits31to24;
   uint8_t IPv4NetBits23to16;
   uint8_t IPv4NetBits15to8;
   uint8_t IPv4NetBits7to0;
   uint16_t IPv6NetBits127to112;
   uint16_t IPv6NetBits111to96;
   uint16_t IPv6NetBits95to80;
   uint16_t IPv6NetBits79to64;
   char* sVlanEnable;
   char* sVlanType;
   char* sVlanConfirm;

   printf( "\n\nESW VLAN Configuration:\n" );
   printf( "                                                                                          IPv4                          IPv6                        \n" );
   printf( "                 VLAN                                  Control                            Address/                      Address/                    \n" );
   printf( "                 Return                      Control   Register                           Network                       Network                     \n" );
   printf( "Group     ID     Status   Enabled    Type    Confirm   Value      Members   Tagging       Mask                          Mask                        \n" );
   printf( "----------------------------------------------------------------------------------------------------------------------------------------------------\n" );

   for ( group = 1; group <= maxgroup; group++ )
   {
      check_status( naibrd_ESW_GetVLANID( cardIndex, module, group, &vlanID ) );
      check_status( naibrd_ESW_GetVLANReturnStatus( cardIndex, module, group, &vlanReturnStatus ) );

      check_status( naibrd_ESW_GetVLANControlEnable( cardIndex, module, group, &vlanEnable ) );
      switch (vlanEnable)
      {
      case TRUE:
         sVlanEnable = " YES   ";
         break;
      case FALSE:
         sVlanEnable = " NO    ";
         break;
      default:
         sVlanEnable = " ERROR ";
         break;
      }

      check_status( naibrd_ESW_GetVLANControlType( cardIndex, module, group, &vlanType ) );
      switch (vlanType)
      {
      case NAI_ESW_VLAN_TYPE_PORT_BASED:
         sVlanType = " PORT ";
         break;
      case NAI_ESW_VLAN_TYPE_SUBNET_BASED:
         sVlanType = "SUBNET";
         break;
      default:
         sVlanType = "ERROR ";
         break;
      }

      check_status( naibrd_ESW_GetVLANControlConfirm( cardIndex, module, group, &vlanConfirm ) );
      switch (vlanConfirm)
      {
      case TRUE:
         sVlanConfirm = " YES   ";
         break;
      case FALSE:
         sVlanConfirm = "  NO   ";
         break;
      default:
         sVlanConfirm = " ERROR ";
         break;
      }

      check_status( naibrd_ESW_GetVLANControlWord( cardIndex, module, group, &vlanControlWord ) );
      check_status( naibrd_ESW_GetVLANMembers( cardIndex, module, group, &vlanMembers ) );
      check_status( naibrd_ESW_GetVLANMemberTagPkt( cardIndex, module, group, &vlanTaggingMembers ) );

      check_status( naibrd_ESW_GetVLANIPAddress( cardIndex, module, group, &vlanIPBits63to48, &vlanIPBits47to32, &vlanIPBits31to16, &vlanIPBits15to0 ) );
      IPv4Bits31to24 = (uint8_t)( ( vlanIPBits31to16 & 0xff00 ) >> 8 );
      IPv4Bits23to16 = (uint8_t)( vlanIPBits31to16 & 0xff );
      IPv4Bits15to8 = (uint8_t)( ( vlanIPBits15to0 & 0xff00 ) >> 8 );
      IPv4Bits7to0 = (uint8_t)( vlanIPBits15to0 & 0xff );
      IPv6Bits127to112 = vlanIPBits63to48;
      IPv6Bits111to96 = vlanIPBits47to32;
      IPv6Bits95to80 = vlanIPBits31to16;
      IPv6Bits79to64 = vlanIPBits15to0;

      check_status( naibrd_ESW_GetVLANNetworkMask( cardIndex, module, group, &vlanNetMaskBits63to48, &vlanNetMaskBits47to32, &vlanNetMaskBits31to16, &vlanNetMaskBits15to0 ) );
      IPv4NetBits31to24 = (uint8_t)( ( vlanNetMaskBits31to16 & 0xff00 ) >> 8 );
      IPv4NetBits23to16 = (uint8_t)( vlanNetMaskBits31to16 & 0xff );
      IPv4NetBits15to8 = (uint8_t)( ( vlanNetMaskBits15to0 & 0xff00 ) >> 8 );
      IPv4NetBits7to0 = (uint8_t)( vlanNetMaskBits15to0 & 0xff );
      IPv6NetBits127to112 = vlanNetMaskBits63to48;
      IPv6NetBits111to96 = vlanNetMaskBits47to32;
      IPv6NetBits95to80 = vlanNetMaskBits31to16;
      IPv6NetBits79to64 = vlanNetMaskBits15to0;

      printf( "%5d   0x%04X   0x%04X   %s   %s   %s    0x%04X    0x%04X    0x%04X    %03d.%03d.%03d.%03d   %04X:%04X:%04X:%04X:0000:0000:0000:0000\n", group, vlanID, vlanReturnStatus,
         sVlanEnable, sVlanType, sVlanConfirm, vlanControlWord, vlanMembers, vlanTaggingMembers, IPv4Bits31to24, IPv4Bits23to16, IPv4Bits15to8, IPv4Bits7to0, IPv6Bits127to112,
         IPv6Bits111to96, IPv6Bits95to80, IPv6Bits79to64 );
      printf( "                                                                                      %03d.%03d.%03d.%03d   %04X:%04X:%04X:%04X:0000:0000:0000:0000\n",
         IPv4NetBits31to24, IPv4NetBits23to16, IPv4NetBits15to8, IPv4NetBits7to0, IPv6NetBits127to112, IPv6NetBits111to96, IPv6NetBits95to80, IPv6NetBits79to64 );
   }
}

/**************************************************************************************************************/
/**
<summary>
CheckESWModule determines whether the ESW Module was successfully opened. Assigns the module's specs to card index,
module number, and module id if opened. Returns TRUE if the module was not recognized as a valid ESW module type.
</summary>
*/
/**************************************************************************************************************/
bool_t CheckESWModule( int32_t *pCardIndex, int32_t *pModule, uint32_t *pModid, int32_t GetPortCount( int32_t cardIndex, int32_t module ) )
{
   bool_t bQuit = FALSE;
   int32_t MAX_MODULE, MAX_PORT;
   uint32_t modid, modver, modrev, special;
   int32_t cardIndex = -1, module = 1;

   bQuit = naiapp_query_CardIndex( naiapp_GetBoardCnt(), 0, &cardIndex );      /* Query user on the Card and Module to use for this example */
   if (!bQuit)
   {
      check_status( naibrd_GetModuleCount( cardIndex, &MAX_MODULE ) );
      bQuit = naiapp_query_ModuleNumber( MAX_MODULE, 1, &module );
      if (!bQuit)
      {
         naibrd_GetModuleInfo( cardIndex, module, &modid, &modver, &modrev, &special );
         MAX_PORT = GetPortCount( cardIndex, module );

         if ( MAX_PORT <= 0 )
         {
            printf( " *** Module selection not recognized as valid module type for this application. ***\n\n" );
            bQuit = TRUE;
         }
         *pCardIndex = cardIndex;
         *pModule = module;
         *pModid = modid;
      }
   }
   return bQuit;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the value that the pointer reference parameter "Port" points to to the number of ports on
the ESW module.  This value is returned by reference to the calling function.
</summary>
*/
/**************************************************************************************************************/
bool_t GetPortNumber( int32_t cardIndex, int32_t module, int32_t MaxPort, int32_t DefPort, int32_t *Port )
{
   bool_t bQuit = FALSE;
   bool_t bContinue = TRUE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   MaxPort = naibrd_ESW_GetPortCount( cardIndex, module );

   if ( MaxPort > 1 )
   {
      while (bContinue)
      {
         printf( "\nPlease select port to access [default=%d]: ", DefPort );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if ( inputResponseCnt == 0 )
               *Port = DefPort;
            else
               *Port = (int32_t)atol( (const char*)inputBuffer );
            if ( ( *Port <= 0 ) || ( *Port > MaxPort ) )
               printf( "ERROR: Invalid port value.\n\n" );
            else
               bContinue = FALSE;
         }
         else
         {
            bContinue = FALSE;
         }
      }
   }
   else
      *Port = 1;
   return bQuit;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the value that the pointer reference parameter "Group" points to to the number of VLAN
Groups on the ESW module. This value is returned by reference to the calling function.
</summary>
*/
/**************************************************************************************************************/
bool_t GetVLANGroupNumber( int32_t cardIndex, int32_t module, int32_t MaxGroup, int32_t DefGroup, int32_t *Group )
{
   bool_t bQuit = FALSE;
   bool_t bContinue = TRUE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   MaxGroup = naibrd_ESW_GetVLANCount( cardIndex, module );

   if ( MaxGroup > 1 )
   {
      while (bContinue)
      {
         printf( "\nPlease select VLAN Group to access [default=%d]: ", DefGroup );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if ( inputResponseCnt == 0 )
               *Group = DefGroup;
            else
               *Group = (int32_t)atol( (const char*)inputBuffer );
            if ( ( *Group <= 0 ) || ( *Group > MaxGroup ) )
               printf( "ERROR: Invalid VLAN Group value.\n\n" );
            else
               bContinue = FALSE;
         }
         else
         {
            bContinue = FALSE;
         }
      }
   }
   else
      *Group = 1;
   return bQuit;
}

Help Bot

X