36
Application Note ENT-AN1047 July 2015 1 © 2015 Microsemi Corporation ICLI Command Generation This document describes how to write script files to auto-generate C and H files for command auto- registration. Registration is required before a command can be used on an ICLI engine. Table of Contents Generation Flow The following illustration shows the flow of command generation. The command generation flow is as follows: 1. Write the script file (xx.icli). 2. Use command generation utility to do the following: Automatically generate the corresponding C and H files (xx_icli.c and xx_icli.h). Automatically register commands into ICLI engine (icli_cmd_reg.c). Automatically generate the command reference guide in HTML (cmd_ref.htm). The advantage of writing script files instead of hard-coding in C are as follows: Easy writing A script file enables focus on the implementation of commands. All other tasks and details such as command registration, parsing, variable types, and memory utilization are processed by the command generation utility. Reduced coding effort and cost Generation Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Script File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Make on eCos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Variable Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 ICLI Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Figure 1 • Command Generation Flow ICLI Engine Script file xxx.icli xxx.h icli_cmd_reg.c Parsing & Generation Register Command Generation Utility xxx.c xxx.htm xxx.txt cmd_ref.htm cmd_ref.txt

ICLI Command Generation

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Application Note ENT-AN1047

ICLI Command Generation

This document describes how to write script files to auto-generate C and H files for command auto-registration. Registration is required before a command can be used on an ICLI engine.

Table of Contents

Generation FlowThe following illustration shows the flow of command generation.

The command generation flow is as follows:

1. Write the script file (xx.icli).

2. Use command generation utility to do the following:

– Automatically generate the corresponding C and H files (xx_icli.c and xx_icli.h).

– Automatically register commands into ICLI engine (icli_cmd_reg.c).

– Automatically generate the command reference guide in HTML (cmd_ref.htm).

The advantage of writing script files instead of hard-coding in C are as follows:

• Easy writing

A script file enables focus on the implementation of commands. All other tasks and details such ascommand registration, parsing, variable types, and memory utilization are processed by thecommand generation utility.

• Reduced coding effort and cost

Generation Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Script File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Make on eCos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Variable Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22ICLI Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Figure 1 • Command Generation Flow

ICLIEngine

Script filexxx.icli

xxx.h

icli_cmd_reg.c

Parsing & Generation Register

Command Generation Utility

xxx.c

xxx.htmxxx.txt

cmd_ref.htmcmd_ref.txt

July 2015 1

© 2015 Microsemi Corporation

ICLI Command Generation ICLI Command Generation

A script file enables writing just the implementation portion of source code. The rest of the sourcecode is generated by the utility to minimize coding errors, effort, inconsistencies, and cost.

• Ignore implementation details such as coding conventions

• Generate command reference guide automatically

Command SyntaxA script consists of a set of well structured commands where each command follows a defined syntax.Some of the basic building blocks of a script, along with their definitions, are as follows:

CommandA command consists of several words with a space used to separate each word. A word can be akeyword or a variable. As a rule, the first word in a command must be a keyword and cannot be avariable.

Syntax: keyword word word …

Word

Word in a command can be either a keyword or a variable.

Keyword

A keyword in a command is a constant word.

Variable

The variable is a variable type enclosed by a set of angle brackets (<>), and the variable typerepresents the type of the user input. The ICLI engine parses and checks whether the user inputmeets the corresponding variable type.

Syntax: <variable type>

Example:ip address <ipv4_addr> <ipv4_netmask>Words: ip, address, <ipv4_addr>, and <ipv4_netmask>

Keywords: ip and address

Variables: <ipv4_addr> and <ipv4_netmask>

So, the user must provide strings as inputs to meet the type of <ipv4_addr> and <ipv4_netmask>.

Valid command can be: ip address 10.1.1.1 255.255.0.0 where 10.1.1.1 is for<ipv4_addr> and 255.255.0.0 is for <ipv4_netmask>.

The following syntax elements allow module designers to customize their commands with flexibility andefficiency.

Variable "< >"In command syntax, a variable is always depicted as enclosed by "< >" It represents the type of thevariable the ICLI engine expects as input. The user needs to input a string that meets the variable type.For more information about available variable types, see "Variable Types" on page 22.

Exclusive OR "|"An exclusive OR makes it mandatory to choose only one of the words. This should be used with

Mandatory {} or Optional [].

Mandatory "{ }"Exactly one of the words enclosed within the braces {}must be input. Individual words inside the bracesmust be separated by the exclusion operator |. For example, for the command, a { b | c

} d, the valid user inputs are as follows:

22

Command SyntaxCommand Syntax

a b d

a c d

The following is an invalid user input:

a d

Note: If {} does not cooperate with |, then it is legal but it has no effect.

Optional "[ ]"It is optional for the user whether to pass any of the words enclosed in square brackets [] as input.Individual words must be separated by the exclusion operator |. For example, for the command, a [ b| c ] d , the valid user inputs are as follows:

• a b d

• a c d

• a d

Random Optional "[ ] [ ] ... [ ]"Optional input that is continuous without being mandatory is called random optional. The input in suchcases can be out of sequence. For example, for the command, a [b] [c] [d], [b] [c] [ d] israndom optional and the valid user inputs are as follows:

• a

• a d

• a c b

• a d b

• a b c d

• a d c b

Use {} for one or more specific optional at fixed locations. For example, for the command, a [b] {

[c]} [d] [e], [b] {[c]} [d] [e] is not random optional, because {[c]} is mandatory at thatlocation, whereas [d] [e] is random optional. The valid user inputs are as follows:

• a

• a c

• a b c

• a b e d

• a c e d

• a b c e d

The following is an invalid user input:

• a

• c

• b

Random Must "{[ ] [ ] ... [ ]}*n"The random optional allows no input. For example, for the command, a [b] [c] [d], the user input ais valid because b, c, and d are not mandatory. However, if you need random optional and also want atleast one word as input, then the syntax of random must provide the feature. This syntax for the randommust has the following rules:

• Enclose random option by mandatory as { random optional }

• Ensure that *n follows the last curly brace } and there is no space between them. where n is for asingle digit only.

• Use *n to indicate at least n words in random optional should be provided as input

33

ICLI Command Generation ICLI Command Generation

For example, for the command a {[b] [c] [d]}*1, {[b] [c] [d]}*1 is random must and at leastone of b, c and d must be provided as input. The following are valid random must syntax:

• a {[b] [c] [d]}*1

• a {[b] [c] [d]}*3

• a {[b] [c] [d]}*9

• a {b | {[c] [d]}*1}

• a {[b] | {[c] [d]}*1}

• a {b | {[c] [d {[e] [f] [g]}*2]}*1}

The following are not valid random must syntax:

• a {[b] [c] [d]} *1 (space is not allowed between } and *1)

• a {[b] [c] [d]}*10 (*10 is more than 1 digit)

• a {[b] [c] [d]}*1a (*1a is not single digit)

Note: Though these commands are not valid random must syntax, they are still valid commands. In thesecommands, *1, *10, and *1a are regarded as separated keywords. On the other hand, if n islarger than the total number, m, of random optional, then m will be applied. For example, if {[b][c] [d]}*9 is valid and it is the same as {[b] [c] [d]}*3, that means all b, c, and d shouldbe used as input.

Repeat "..."The syntax repeats the input times in [ | ] or { | } automatically. The number of repeat times is thenumber of selection in [ | ] or { | }.

The examples for all syntax are as follows:

• {{a|b|c} … } is equivalent to {a|b|c} {a|b|c} {a|b|c}.

• {[a|b|c] … } is equivalent to {{a|b|c} [{a|b|c} [{a|b|c}]]}.

• [{a|b|c} … ] is equivalent to [{a|b|c} {a|b|c} {a|b|c}].

• [[a|b|c] … ] is equivalent to [{a|b|c} [{a|b|c} [{a|b|c}]]].

Loop "( )*N"This sub command is enclosed by () and N means the sub command can be iterated 1..N times. Thecorresponding variables will be declared as arrays so you can use an array index to get the values. Thefollowing code is an example.

CMD_BEGINCOMMAND = debug loop ( uint )*3... CMD_VAR = CMD_VAR =CMD_VAR = bCMD_VAR = value... CMD_ENDThen the variables will be generated as follows. BOOL b[3];u32 value[3];Therefore, you can use array index to get the user input for each loop input. On the other hand, thenumber of loop, N, can be a constant defined in code as follows:

COMMAND = debug loop ( uint )*_CONST_NUM_

Where,

_CONST_NUM_ is defined in the ICLI file or other header file.

LimitationsICLI engine parsing does not allow the same words that overlap in mandatory{} or optional []. Thefollowing examples illustrate the limitation.

44

Script FileScript File

Example 1snmp client version <uint>snmp { server | client } address <ipv4_ucast>The keyword client overlaps illegally because client is mandatory {} in the second command.

Example 2snmp client version <uint>snmp [client] address <ipv4_ucast>The keyword client overlaps illegally because client is optional [ ] in the second command. Thefollowing redesigned examples avoid the issue.

Redesigned Example 1snmp client { version <uint> | address <ipv4_ucast> } snmp server address <ipv4_ucast>

Redesigned Example 2snmp client { version <uint> | address <ipv4_ucast> }snmp address <ipv4_ucast>In other words, use the same flat prefix as far as possible. snmp client is the same flat prefix in theexamples.

Another example is as follows.

• a b x

• a c x

• a d x

• a b y

• a c y

Because of the limitation, the following design is not allowed:

• a { b | c | d } x

• a { b | c } y

Instead, the following design, from left to right, is allowed.

• a b { x | y }

• a c { x | y }

• a d x

Script FileThe file extension of a script file is .icli. Each script file is composed of segments with each segmentcomprising of tags. For a tag with value, use = to assign a value to the tag, for example, TAG =TAG_VALUE. You must not omit TAG_VALUE for a tag with a value. If you omit it, it is as good as notspecifying the tag. For a long TAG_VALUE, you can use \ to concatenate the next line.

Each segment has two tags, XXX_BEGIN and XXX_END. Each segment can also have sub-segmentsinside. To comment a line inside a script file, you can use !, #, or // at the beginning of the line.

There are the following four segments in the script file:

• Module

• Include

• Function

• Command

The Command segment has sub-segments, such as: VARIABLE sub-segment and Code

sub-segment. The following is a representation of the segmented structure of a typical script file:

Module Segment | MODULE_IF_FLAG =| INCLUDE_BEGIN

Include Segment | ...| INCLUDE_END

55

ICLI Command Generation ICLI Command Generation

| FUNCTION_BEGINFunction Segment| ...

| FUNCTION_END| CMD_BEGIN| COMMAND =| FUNC_NAME =| ...| VARIBALE_BEGIN || ... | Variable| VARIABLE_END | Sub_Segment| CODE_BEGIN || ... | Code| CODE_END | Sub-Segment| CMD_END

A typical script file has the following aspects:

Module SegmentUse this segment to control the module-wide settings. There is only one tag for this segment:

MODULE_IF_FLAG =

(Optional)

The value of this tag helps to find whether all the commands of this module are registered or thegenerated C/H file is compiled.

The tag value is appended to an #if directive in icli_cmd_reg.c and the generated C/H files.Therefore, if the tag value does not evaluate to TRUE, then the commands will not be registered and eventhe source code will not be compiled.

Example:In stp.icli, the tag value is VTSS_SW_OPTION_STP.

MODULE_IF_FLAG = defined(VTSS_SW_OPTION_STP)

……In icli_cmd_reg.c, the auto-registration is enclosed by the tag value.…

#if defined(VTSS_SW_OPTION_STP)

&stp_icli_cmd_register,#elseNULL,#endif…In the generated C/H files, the whole context is enclosed by the tag value.#if defined(VTSS_SW_OPTION_STP)………#endif

Include SegmentUse this segment to specify the include files required to compile the body of the generated C file(s).

icli_api.h is auto-included by the generator and should not be specified here. The content inside thesegment is exactly pasted to the generated C file. There are these following two tags for this segment:

• INCLUDE_BEGIN

66

Script FileScript File

This tag is optional. It marks the beginning of Include segment.

• INCLUDE_END

This tag is mandatory if the tag, INCLUDE_BEGIN exists. This tag marks the end of Include segment.

Function SegmentUse this segment to do the following:

• Write the local functions used in the Command segment

• Declare the constants, macros, data types, or static variables for the functions or the commandbodies

The content is pasted as is to the generated C file. This segment has the following two tags:

• FUNCTION_BEGIN

This is an optional tag. The tag marks the beginning of a function segment.

• FUNCTION_END

This tag is mandatory if there exist FUNCTION_BEGIN tag. The tag marks the end of functionsegment.

Command SegmentThis segment defines the implementation of the command; one segment for one command. Theimplementation contains privilege, work mode, command property, help, and execution instance.

The followings are the tags in Command segment:

Figure 2 • Include Segment Structure

Figure 3 • Function Segment Structure

INCLUDE_BEGIN

#include <stdio.h># if STP_MODE_RSTP#include “rstp.h”#endif

INCLUDE_END

This content will be pasted exactly to

the generated C file

FUNCTION_BEGIN

#define _IS_TRUE (x) ( (x) == TRUE)

static i32 svariable;

Static i32 _vid_get (void) {

return vlan_id;}

BOOL vid_set (i32 vid) {

vlad_id = vid;

return TRUE;}

FUNCTION_END

This content has to be pasted exactly

as is to the generated C file.

77

ICLI Command Generation ICLI Command Generation

CMD_BEGINThis is a mandatory tag. It marks the beginning of command segment.

CMD_ENDThis is a mandatory tag. It marks the end of command segment.

DOC_CMD_DESC =This is an optional tag. Use '\' to concatenate lines for one-line descriptions. Use multiple

DOC_CMD_DESC for each description of a longer description.

DOC_CMD_DEFAULT =This is an optional tag.

DOC_CMD_USAGE =This is an optional tag. Use '\' to concatenate lines for one-line descriptions. Use multiple

DOC_CMD_DESC for each description of a longer description.

DOC_CMD_EXAMPLE =This is an optional tag. Use '\' to concatenate lines for one-line descriptions. Use multiple

DOC_CMD_DESC for each description of a longer description.

COMMAND =This is a mandatory tag. You can flexibly define the command string with the syntax of mandatory ([]),optional ({}), or (|) and variables (<>).

FUNC_NAME =This is an optional tag. It names the command execution function. The ICLI command generation utilityuses the value of the tag to automatically generate the corresponding static function in the generated Cfile. This static function, the command execution function, is executed when the user inputs a validcommand.

If FUNC_NAME is not defined, then the ICLI command generation utility randomly generates a name.

FUNC_REUSE =This is an optional tag. The tag defines the name of the reused execution function of another

command. The FUNC_REUSE tag reuses the code body of another command, where the code body

includes the Variable sub-segment and the Code sub-segment. So, when a command reuses the codebody of another command, the command can define its own command properties, such as: privilege andhelp string. Then, you do not need to write the Variable sub-segment and the Code sub-segment.

In the following example, cmd 2 reuses the code body of cmd 1. At the same time, cmd 2 has defined itsown help strings and other command properties.

CMD_BEGINCOMMAND= test-cmd 1 FUNC_NAME = _cmd_1_cb HELP= Test command

Table 1 • DOC_CMD Descriptions

Command (DOC_CMD_DESC)

Syntax Description command syntax

Default (DOC_CMD_DEFAULT)

Command Mode Command Mode

Privilege Level Privilege

Usage Guideline (DOC_CMD_USAGE)

Example (DOC_CMD_EXAMPLE)

88

Script FileScript File

HELP= Command 1 VARIABLE_BEGIN...VARIABLE_END CODE_BEGIN... CODE_END CMD_END CMD_BEGINCOMMAND= debug-cmd 2 FUNC_REUSE = _cmd_1_cb HELP= Debug commandHELP= Command 2 CMD_END

PRIVILEGE =This is a mandatory tag. It defines the privilege level of the command, ICLI_PRIVILEGE_XX, defined inthe icli_porting.h file. The available privilege levels range from ICLI_PRIVILEGE_0 toICLI_PRIVILEGE_15. The larger the number, the higher the privilege level of the command. Thecommand can be executed only by a session with a higher or equal privilege.

For example, if the privilege of a command is ICLI_PRIVILEGE_7, then the sessions with privilegelevel ICLI_PRIVILEGE_0~ICLI_PRIVILEGE_6 can not access the command. The sessions withprivilege level ICLI_PRIVILEGE_7~ICLI_PRIVILEGE_15 can only access the command.

PROPERTY =This is an optional tag. This tag defines the properties of the command, ICLI_CMD_PROP_XXXX, definedin the icli_types.h file. There are eight command properties that can be defined by this tag. Thedefault property is defined as 0x00. Use | to separate properties.

Table 2 • Property Command Descriptions

Property Name Characteristics

ICLI_CMD_PROP_ENABLE This property indicates whether the command is executable or not

. When the user provides a valid command as input, the ICLI enginechecks for this property to decide whether the corresponding commandexecution function is able to be executed. If the property isICLI_CMD_PROP_ENABLE, then the command execution function isexecutable.

ICLI_CMD_PROP_ENABLE and ICLI_CMD_PROP_DISABLE are

mutually exclusive properties.

Syntax:

#define ICLI_CMD_PROP_ENABLE0x00

ICLI_CMD_PROP_DISABLE This property indicates whether the command is executable or not

. When the user provides a valid command as input, the ICLI enginechecks for this property to decide whether the corresponding commandexecution function is able to be executed. If the property isICLI_CMD_PROP_DISABLE, then the command execution function isnot executable.

ICLI_CMD_PROP_ENABLE and ICLI_CMD_PROP_DISABLE are

mutually exclusive properties.

Syntax:

#define ICLI_CMD_PROP_DISABLE0x01

99

ICLI Command Generation ICLI Command Generation

.

ICLI_CMD_PROP_VISIBLE This property indicates whether the command is visible to users. Whena user presses the TAB key or types '?' for help, the ICLI engine checksthis property to decide whether or not to display the command to theuser. If the property is ICLI_CMD_PROP_VISIBLE, then the commandis displayed.

ICLI_CMD_PROP_VISIBLE and ICLI_CMD_PROP_INVISIBLE

are mutually exclusive properties.

Syntax:

#define ICLI_CMD_PROP_VISIBLE0x00

ICLI_CMD_PROP_INVISIBLE This property indicates whether the command is visible to users. Whena user presses the TAB key or types '?' for help, the ICLI engine checksthis property to decide whether or not to display the command to theuser. If the property is ICLI_CMD_PROP_INVISIBLE, then thecommand is not displayed to the user.

ICLI_CMD_PROP_VISIBLE and ICLI_CMD_PROP_INVISIBLE

are mutually exclusive properties.

Syntax:

#define ICLI_CMD_PROP_INVISIBLE 0x02

ICLI_CMD_PROP_GREP This property indicates whether the command has the grep function toformat the output. If the property is ICLI_CMD_PROP_GREP, then thecommand has the grep function. If the property isICLI_CMD_PROP_NOT_GREP, then the command do not have the grepfunction.

ICLI_CMD_PROP_GREP and ICLI_CMD_PROP_NOT_GREP are

mutually exclusive properties.

Syntax:

#define ICLI_CMD_PROP_GREP0x04

ICLI_CMD_PROP_NOT_GREP This property indicates whether the command has the grep function toformat the output. If the property is ICLI_CMD_PROP_NOT_GREP, thenthe command do not have the grep function.

ICLI_CMD_PROP_GREP and ICLI_CMD_PROP_NOT_GREP are

mutually exclusive properties.

Syntax:

#define ICLI_CMD_PROP_NOT_GREP0x00

ICLI_CMD_PROP_LOOSELY This property ICLI_CMD_PROP_LOOSELY indicates that the extrawords are allowed after the complete valid command string.

ICLI_CMD_PROP_LOOSELY and ICLI_CMD_PROP_STRICTLY

are mutually exclusive properties.

Syntax:

#define ICLI_CMD_PROP_LOOSELY0x08

ICLI_CMD_PROP_STRICTLY This property indicates whether the ICLI engine allows extra wordsafter the complete valid command string. If the property isICLI_CMD_PROP_STRICTLY, then the command string becomesinvalid. ICLI_CMD_PROP_LOOSELY andICLI_CMD_PROP_STRICTLY are mutually exclusive propertiesSyntax:

#define ICLI_CMD_PROP_STRICTLY0x00

Table 2 • Property Command Descriptions (continued)

Property Name Characteristics

1010

Script FileScript File

Example:COMMAND= ip dhcp snooping...PROPERTY= ICLI_CMD_PROP_LOOSELY... CMD_ENDIn this case, the command string "ip dhcp snooping is to enable ip dhcp snoopingfunction" is valid because of the following reasons:

• ip dhcp snooping is a valid command

• ICLI_CMD_PROP_LOOSELY asks the ICLI engine to ignore the extra string, "is to enable ipdhcp snooping function"

But if the property is ICLI_CMD_PROP_STRICTLY, then this command string is invalid. The ICLI enginestill parses the string "is to enable ip dhcp snooping function” but it identifies the commandas invalid. In case the tag value is ignored, the default value is 0 then the default property is:

ICLI_CMD_PROP_ENABLE | ICLI_CMD_PROP_VISIBLE | ICLI_CMD_PROP_NOT_GREP | ICLI_CMD_PROP_STRICTLYNote: The value of ICLI_CMD_PROP_ENABLE is 0 and the value of ICLI_CMD_PROP_VISIBLE

is also 0. For the command property ICLI_CMD_PROP_ENABLE | ICLI_CMD_PROP_VISIBLE |ICLI_CMD_PROP_GREP simply define PROPERTY = ICLI_CMD_PROP_GREP.

CMD_MODE =This is a mandatory tag. It defines the command mode, ICLI_CMD_MODE_XXXX, defined in theicli_porting.h, that the command works at. The command mode is a method to categorize the commands.A command is visible and can be executed only in the work mode. So, the module designer must beaware of the deployment of each of the commands.

You can define a command in multiple command modes if the command works in multiple commandmodes.

COMMAND= temperature { get | set <0-100> }...CMD_MODE= ICLI_CMD_MODE_EXECCMD_MODE= ICLI_CMD_MODE_GLOBAL_CONFIG... CMD_ENDNote: There are two ways to reuse a command: FUNC_NAME/FUNC_REUSE and CMD_MODE. Use

CMD_MODE if a command works in different command modes and all properties of the commandare the same in the different command modes-same privilege, same help, same byword. UseFUNC_NAME/FUNC_REUSE for all other cases.

GOTO_MODE =This is an optional tag. It identifies the command mode executing the command. This tag is not only forcommand execution, but also for parsing. Parsing and execution are affected when it is not definedcorrectly. It is automatically generated by the SUB_MODE tag.

SUB_MODE =This is an optional tag. Command mode, ICLI_CMD_MODE_XXXX defined in icli_porting.h, that thecommand will create and go into after execution. If this tag is defined, the following tasks areimplemented automatically. In other words, all necessary tasks to create a sub mode can be doneautomatically through this tag.

1. Generate command in ICLI_CMD_MODE_GLOBAL_CONFIG.

2. Generate commands in all sub modes with the property of INVISIBLE.

3. Generate the following commands in this sub mode.

– exit

– end

– help

– do <line>

1111

ICLI Command Generation ICLI Command Generation

IF_FLAG =This tag is optional. This tag lets the #if conditional flag enclose the command. The tag value appears asa post-fix to the #if directive. For example, IF_FLAG = defined(VTSS), then the tag value is #ifdefined(VTSS). Use this tag to define the conditions command execution depends on. For example, todisable this command, define IF_FLAG = 0 to enclose the command by #if 0.

CMD_VAR =This tag is optional. It defines the C variable for the corresponding word of command string. The tagallows one-to-one mapping for each word in the command string.

Example:COMMAND = a [ b | c ] d CMD_VAR = v1CMD_VAR = v2 CMD_VAR = v3 CMD_VAR = v4

Where,

v1 is mapped to a

v2 is mapped to b

v3 is mapped to c

and v4 is mapped to d

If you do not need command variables for a and c, then you can ignore the tag values. But you still needthe tags for keeping the correspondence on.

COMMAND = a [ b | c ] d CMD_VAR =CMD_VAR = v2CMD_VAR =CMD_VAR = v4

v2 is mapped to b

v4 is mapped to d

The C variable will be auto-declared in command execution function of generated C file according to theword type in command string COMMAND. For the first example, because a, b, c and d are keywords, thecorresponding C type is BOOL. The declarations in command execution function of generated C file areas follows:

BOOL v1 = FALSE;

BOOL v2 = FALSE;

BOOL v3 = FALSE;

BOOL v4 = FALSE;

For the second example, the declarations in command execution function of generated C file are asfollows.

BOOLv2 = FALSE;

BOOLv4 = FALSE;

For the syntax Repeat(…), the variables will be generated automatically and mapping to the repeatcommand words.

For example,

• COMMAND = a { {b|c|d} … }

• CMD_VAR = a

• CMD_VAR = b

• CMD_VAR = c

• CMD_VAR = d

The command is equivalent to a {b|c|d} {b|c|d} {b|c|d}. For the red command words, three Cvariables, b_1, c_1, and d_1, are automatically generated by ICLI engine for mapping. For the green

1212

Script FileScript File

command words, three C variables, b_2, c_2, and d_2, are automatically generated by ICLI engine formapping.

Through the CMD_VAR, you can know that the input value of this command from the user and use theseC variables in CODE sub-segment.

The C data type of each command variable declared for each of the corresponding variable type is listedin "Variable Types" on page 22.

RUNTIME =This tag is optional. It defines the callback for the runtime check on the corresponding word of commandstring COMMAND, that is, this is one-to-one mapping to each word of command string. The mapping rule isidentical to the rule for CMD_VAR.

The callback is invoked at the time of:

• command execution

• pressing TAB

• typing '?'

It asks for present check, byword, help, and run time value range. The prototype of the callback

icli_runtime_cb_t is as the follows:

ICLI_ASK_PRESENT : ask if the word is present or notICLI_ASK_BYWORD : ask byword, and this works on non-keywordICLI_ASK_HELP : ask help stringICLI_ASK_RANGE : ask integer range for signed or unsigned,this works on variables for all signed andunsigned integer or integet listICLI_ASK_PORT_RANGE : ask port type and list for the port range,this works on <port_type_id>, <port_type_list>,<port_type>, <port_id>, <port_list>ICLI_ASK_CWORD : ask all possible customized words for <cword>use 'NULL' for the endICLI_ASK_VCAP_VR : ask range for vcap_vr*/typedef enum {ICLI_ASK_PRESENT,ICLI_ASK_BYWORD,ICLI_ASK_HELP,ICLI_ASK_RANGE,ICLI_ASK_PORT_RANGE,ICLI_ASK_CWORD,ICLI_ASK_VCAP_VR,} icli_runtime_ask_t;typedef union {BOOL present;char byword[ICLI_RUNTIME_MAX_LEN + 4];char help[ICLI_RUNTIME_MAX_LEN + 4];icli_range_t range;icli_stack_port_range_t port_range;char *cword[ICLI_CWORD_MAX_CNT];icli_ask_vcap_vr_t vcap_vr;} icli_runtime_t;INPUTsession_id: ID of the session.ask : query string at run timeOUTPUTruntimeICLI_ASK_PRESENT : runtime.present

1313

ICLI Command Generation ICLI Command Generation

ICLI_ASK_BYWORD : runtime.bywordICLI_ASK_HELP : runtime.helpICLI_ASK_VALUE : runtime.rangeICLI_ASK_PORT_RANGE : runtime.port_rangeICLI_ASK_CWORD : runtime.cwordICLI_ASK_VCAP_VR : runtime.vcap_vrRETURNTRUEICLI engine checks the value at run time.ICLI_ASK_PRESENT : runtime.present == TRUE, enable thewordruntime.present == FALSE, disable thewordICLI_ASK_BYWORD : use runtime.bywordICLI_ASK_HELP : use runtime.helpICLI_ASK_VALUE : use runtime.rangeICLI_ASK_PORT_RANGE : use runtime.port_rangeICLI_ASK_CWORD : use runtime.cwordICLI_ASK_VCAP_VR : use runtime.vcap_vrFALSEICLI engine ignores the value at the run time.ICLI_ASK_PRESENT : the word is presentICLI_ASK_BYWORD : use original one in *.icliICLI_ASK_HELP : use original one in *.icliICLI_ASK_VALUE : use original one in *.icliICLI_ASK_PORT_RANGE : use system port rangeICLI_ASK_CWORD : <cword> works as <word>ICLI_ASK_VCAP_VR : no range limit*/typedef BOOL (icli_runtime_cb_t)(IN u32 session_id,IN icli_runtime_ask_t ask,OUT icli_runtime_t *runtime);Use the run time check in the following cases:

1. The word in command is enabled or disabled at run time. For example, the correspondingcomponent is enabled or disabled.

2. The range of value is changed at run time. In this case, you can change the byname and help thecorrespondingly to show the user.

For each ask type, it may works on some specific word types only.

ICLI_ASK_PRESENT: for keyword and all variable types

ICLI_ASK_BYWORD: for all variable types, but not for keyword

ICLI_ASK_HELP: for keyword and all variable types

ICLI_ASK_VALUE: only for the variable types of <range_lsit>, <int>, <uint>, <word>, <

kword>, <string>, and <line>.

ICLI_ASK_PORT_RANGE: for <port_type_id> and <port_type_list>

ICLI_ASK_CWORD: only for <cword>

ICLI_ASK_VCAP_VR : only for <vcap_vr>

An example is as follows. RSTP may be enabled or disabled at run time, so the word rstp has a

runtime check for it.

FUNCTION_BEGINstatic BOOL _rstp_runtime(IN u32 session_id,IN icli_runtime_ask_t ask,OUT icli_runtime_t *runtime

1414

Script FileScript File

){switch ( ask ) {case ICLI_ASK_PRESENT:if ( rstp_enable() ) {runtime.present = TRUE;} else {runtime.present = FALSE;}return TRUE;default:break;}return FALSE;}FUNCTION_ENDCMD_BEGINCOMMAND = stp mode [ mstp | rstp | mrstp ]...RUNTIME =RUNTIME =RUNTIME =RUNTIME = _rstp_runtimeRUNTIME =...CMD_ENDBy using ICLI_ASK_PRESENT on the first keyword of a command, this command can be enabled+

visible and disabled_invisible at run time. The following example shows that the command isenabled and visible when STP mode is enabled. Otherwise, the command is disabled and invisible.

FUNCTION_BEGINstatic BOOL _stp_runtime(IN u32 session_id,IN icli_runtime_ask_t ask,OUT icli_runtime_t *runtime){switch ( ask ) {case ICLI_ASK_PRESENT:if ( stp_enable() ) {runtime.present = TRUE;} else {runtime.present = FALSE;}return TRUE;default:break;}return FALSE;}FUNCTION_ENDCMD_BEGINCOMMAND = stp mode [ mstp | rstp | mrstp ]...RUNTIME = _stp_runtimeRUNTIME =RUNTIME =RUNTIME =RUNTIME =

1515

ICLI Command Generation ICLI Command Generation

...CMD_END

BYWORD =This tag is optional. It defines the alternative word, which represents the corresponding word of

command string when the user presses TAB key or ‘?’. Generally, the word displayed when pressing

TAB or ‘?’ is the word in COMMAND. If the corresponding BYWORD is defined, then this byword is

displayed, but not the word in COMMAND.

On the other hand, the BYWORD works on variables only, but not on keyword. The byword can be

retrieved at run time through RUNTIME.

Example without byword:COMMAND = temperature set <0-100>...BYWORD =BYWORD =BYWORD =...CMD_ENDUser input.

switch> temperature set ?<0-100>

Example with byword:COMMAND = temperature set <0-100>...BYWORD =BYWORD =BYWORD = <CelsiusDegree>...CMD_ENDUser input.

switch> temperature set ?

<CelsiusDegree>

HELP =This tag is optional. It defines the help string for the corresponding word of the command string. The

help string appears when the user presses ‘?’ to get the full descriptions for the next possible

command words.

If the help string is long, you may use ‘\’ to concatenate lines. Remember that you can also get the

help string at run time through RUNTIME.

Example:COMMAND = temperature { get | set <0-100> }...BYWORD =BYWORD =BYWORD =BYWORD = <CelsiusDegree>HELP =HELP = get the current temperature in Celsius degreeHELP =HELP = the range of degree is from 0 to 100...CMD_ENDWhere the user inputs are as follows:

switch> temperature ?

1616

Script FileScript File

get get the current temperature in Celsius.

set

switch> temperature set ?

<CelsiusDegree> the range of degree from 0 to 100.

set does not have a help string to display because the tag value of its corresponding HELP is empty.

On the other hand, the BYWORD of set does not work because set is a keyword, not a variable.

MODE_VAR =This tag is optional. It defines the C variable for the variable in the mode entry command. This does

not need to be one-to-one mapping as CMD_VAR to COMMAND, but the ICLI engine helps to search the

variable in the mode entry command and to map to it. The C variable is auto-declared in command

execution function of the generated C file according to the variable type in the mode entry command.

MODE_VAR = vid

The example is in Section 0 and the mode entry command is interface vlan <1-4094>. The

ICLI engine automatically finds vid for <1-4094>. Therefore, we can get the VLAN ID through the Cvariable vid. In this example, use vid to set ip address on the correct.

VARIABLE_BEGIN/VARIABLE_ENDThese tags are optional. They mark the beginning and the end of the variable sub-segment.

The sub-segment declares the variables that are used in the following Code sub-segment and you

may also initialize variables of CMD_VAR and MODE_VAR here.

CODE_BEGIN/CODE_ENDThese tags are optional. They mark the beginning and end of code sub-segment. This sub-segment

contains the code body that implements the function of the command. There is a C variable,

session_id, which can be used in this segment. session_id is an input parameter of command

execution function and identifies the current ICLI session. On the other hand, you need session_id

for the use of APIs exported in icli_api.h because it always is the first input parameter of APIs in

icli_api.h.

Example:icli_session_printf(session_id, “test”);

NO_FORM TagsThe following tags are optional. The usage of these tags are same as those of the tags such as:

DOC_CMD_DESC, DOC_CMD_DEFAULT, DOC_CMD_USAGE, DOC_CMD_EXAMPLE, VARIABLE_BEGIN,

VARIABLE_END, CODE_BEGIN, and CODE_END. But, these tags defines the HTML descriptions and

the code body for no form command.

• NO_FORM_DOC_CMD_DESC

• NO_FORM_DOC_CMD_DEFAULT

• NO_FORM_DOC_CMD_USAGE

• NO_FORM_DOC_CMD_EXAMPLE

• NO_FORM_VARIABLE_BEGIN

• NO_FORM_VARIABLE_END

• NO_FORM_CODE_BEGIN

• NO_FORM_CODE_END

If and only if there are codes in Code sub-segment, NO_FORM_CODE_BEGIN and

NO_FORM_CODE_END, the no form command is auto-generated by the ICLI engine. In the following

example, no arp inspection is auto-generated by the ICLI engine, and the duplicate words arp

inspection uses the same command properties defined previously.

1717

ICLI Command Generation ICLI Command Generation

CMD_BEGINCOMMAND = arp inspection...HELP = ARP configurationHELP = Arp Inspection configuration...VARIABLE_BEGIN...VARIABLE_ENDCODE_BEGIN/* enable ARP inspection */...CODE_ENDNO_FORM_CODE_BEGIN/* disable ARP inspection */...NO_FORM_CODE_ENDCMD_END

DEFAULT_FORM TagsThe following tags are optional. The usage of these tags are same as those of the tags such as:

DOC_CMD_DESC, DOC_CMD_DEFAULT, DOC_CMD_USAGE, DOC_CMD_EXAMPLE, VARIABLE_BEGIN,VARIABLE_END, CODE_BEGIN, and CODE_END. But, these tags defines the HTML descriptions and

the code body for no form command.

• DEFAULT_FORM_DOC_CMD_DESC

• DEFAULT_FORM_DOC_CMD_DEFAULT

• DEFAULT_FORM_DOC_CMD_USAGE

• DEFAULT_FORM_DOC_CMD_EXAMPLE

• DEFAULT_FORM_VARIABLE_BEGIN

• DEFAULT_FORM_VARIABLE_END

• DEFAULT_FORM_CODE_BEGIN

• DEFAULT_FORM_CODE_END

If and only if there are codes in Code sub-segment, NO_FORM_CODE_BEGIN and

NO_FORM_CODE_END, the no form command is auto-generated by the ICLI engine. In the following

example, no arp inspection is auto-generated by the ICLI engine, and the duplicate words arp

inspection uses the same command properties defined previously.

CMD_BEGINCOMMAND = arp inspection...HELP = ARP configurationHELP = Arp Inspection configuration...VARIABLE_BEGIN...VARIABLE_ENDCODE_BEGIN/* enable ARP inspection */...CODE_ENDDEFAULT_FORM_CODE_BEGIN/* reset ARP inspection to be default*/...DEFAULT_FORM_CODE_ENDCMD_ENDWhen deploying no/default form command, ensure that the command syntax of the normal command

1818

Script FileScript File

and no/default form command is identical.

For example, the normal command of ARP inspection is arp inspection and its no form command isno arp inspection. Except “no”, they have the same syntax so it can use no form.

However, the normal command of IGMP is ip igmp {V1|V2|V3} and its no form command is no

ip igmp. The no form command does not have the syntax {V1|V2|V3}; their syntaxes are different

so the no form can not be applied.

Defining Constant StringA constant string can be defined across all the segments in a script file, except in the following areas:

• Include Segment

• Function Segment

• Variable Intial Sub-segment

• Code Sub-segment

The reason is that these areas are pasted with codes exactly as the generated C and H files, so the

ICLI engine does not take care of any thing in these areas.

In other words, if there is a TAG-VALUE defined outside these areas and the tag is not reserved by theICLI engine, then the TAG-VALUE is taken as a constant string definition whether it is in upper or lowercase. When it is referred, the prefix ## is needed to indicate that the following string is a name ofconstant string. This feature makes the string easily reused, for example, HELP string.

In the following examples, SHOW_HELP_str is defined at the middle and last line, but it still can be

used in the commands.

Example:SHOW_HELP_str = show system informationCOMMAND = show ip interface...HELP = ##SHOW_HELP_strHELP =HELP =...CMD_ENDCOMMAND = show mac address...HELP = ##SHOW_HELP_strHELP =HELP =...CMD_ENDOn the other hand, no matter where the constant string is defined in the script, it can be used across

the complete scope in the script.

Example:COMMAND = show ip interface...HELP = ##SHOW_HELP_strHELP =HELP =...CMD_ENDSHOW_HELP_str = show system informationCOMMAND = show mac address...HELP = ##SHOW_HELP_strHELP =HELP =

1919

ICLI Command Generation ICLI Command Generation

...CMD_ENDFor example,COMMAND = show ip interface...HELP = ##SHOW_HELP_strHELP =HELP =...CMD_ENDCOMMAND = show mac address...HELP = ##SHOW_HELP_strHELP =HELP =...CMD_ENDSHOW_HELP_str = show system information

Command Segment ExampleThe following example uses ! for line comment.

! Start of Command segmentCMD_BEGIN! command descriptionDOC_CMD_DESC = this command is used to set management ip interface.! default valueDOC_CMD_DEFAULT = the default IP is 192.168.0.1/255.255.255.0! usage descriptionDOC_CMD_USAGE = when the default IP does not work on your network,\you can use this command to modify the IP for yournetwork.! exampleDOC_CMD_EXAMPLE = if you wants to set ip and netmask to be 10.1.1.1/255.0.0.0,\you can execute the command as follows.DOC_CMD_EXAMPLE = Switch# ip address 10.1.1.1 255.0.0.0! Command stringCOMMAND = ip address <ipv4_ucast> <ipv4_netmask>! Privilege level of the commandPRIVILEGE = ICLI_PRIVILEGE_8! Command propertyPROPERTY = ICLI_CMD_PROP_ENABLE | ICLI_CMD_PROP_VISIBLE! C variable for “ip”CMD_VAR =! C variable for “address”CMD_VAR =! C variable for “<ipv4_ucast>”CMD_VAR = ip! C variable for “<ipv4_netmask>”CMD_VAR = netmask! Help string for “ip”HELP = ip interface! Help string for “address”HELP = ip address set! Help string for “<ipv4_ucast>”HELP = unicast IP address! Help string for “<ipv4_netmask>”

2020

Make on eCosMake on eCos

HELP = netmask! The command works at interface VLAN mode.CMD_MODE = ICLI_CMD_MODE_INTERFACE_VLAN! C variable for “<1-4094>”MODE_VAR = vid! Variable declaration and initializationVARIABLE_BEGINchar ip_str[20];char netmask_str[20];VARIABLE_END! Command implementation bodyCODE_BEGIN//translate IP and netmask to string formaticli_ipv4_to_str(ip, ip_str);icli_ipv4_to_str(netmask, netmask_str);ICLI_PRINTF(“Set %s/%s on VLAN %d successfully\n”,ip_str, netmask_str, vid);CODE_END! End of Command segmentCMD_END

Make on eCos

Make FileTo automatically generate and register ICLI commands, copy the following two lines into the

component make file, module_x.in.

# Built-in ICLI$(eval $(call add_icli,$(foreach m, x_0 x_1,$(DIR_x_script)/$(m).icli)))where

x_0 and x_1 refer to the ICLI script files x_0.icli and x_1.icli

DIR_x_script is the directory where x_0.icli and x_1.icli are stored.

2121

ICLI Command Generation ICLI Command Generation

Variable TypesThe following table lists the available variable types.

Table 3 • Variable Types

Variable Type C Type Description Legal Input

mac_addr vtss_mac_t Any Ethernet MAC

address.

‘h’ is a hex digit.

ICLI_ALIKE_C in the

format of

hhhh.hhhh.hhhh

ICLI_ALIKE_Z in the

format of

hh:hh:hh:hh:hh:hh

ICLI_ALIKE_C

0011.2abc.def9

1.46.53a

ICLI_ALIKE_Z

00:11:2a:bc:de

:f9

0:1:0:46:5:3a

mac_ucast vtss_mac_t Unicast MAC address

‘h’ is a hex digit.

ICLI_ALIKE_C in the

format of

hhhh.hhhh.hhhh

where hh & 0x01 !=

0x01

ICLI_ALIKE_Z in the

format of

hh:hh:hh:hh:hh:hh

where hh & 0x01 !=

0x01

ICLI_ALIKE_C

0011.2abc.def9

1.46.53a

ICLI_ALIKE_Z

02:11:2a:bc:de

:f9

0:1:0:46:5:3a

mac_mcast vtss_mac_t Multicast MAC

address

‘h’ is a hex digit.

ICLI_ALIKE_C in

the format of

hhhh.hhhh.hhhh

where hh & 0x01 ==

0x01

ICLI_ALIKE_Z in

the format of

hh:hh:hh:hh:hh:hh

where hh & 0x01 ==

0x01

ICLI_ALIKE_C

0101.2abc.87f6

501.46.53a

ICLI_ALIKE_Z

03:11:2a:bc:45

:fd

b:1:0:46:5:3a

ipv4_addr vtss_ip_t Any IPv4 IP address in

the format of

ddd.ddd.ddd.ddd

where d is a decimal digit.

0.0.0.0

1.2.3.4

2222

Variable TypesVariable Types

ipv4_netmask vtss_ip_t IPv4 Netmask in the

format of

ddd.ddd.ddd.ddd

where d is a decimal digit.

0.0.0.0

255.255.255.0

255.252.0.0

ipv4_ucast vtss_ip_t Unicast IPv4 IP address

in the format of

ddd.ddd.ddd.ddd where ‘

d’ is a decimal digit.

The following 3 cases are

illegal:

1. In the range of

224.0.0.0 to

239.255.255.255

2. ddd.ddd.ddd.0

3. ddd.ddd.ddd.255

0.0.1.2

223.255.255.254

240.0.0.1

ipv4_nmcast vtss_ip_t Non-multicast IPv4 IP

address in the format of

ddd.ddd.ddd.dddwhere, d is a decimal digit.And, the IP address is the

address not in the range

of 224.0.0.0 to

239.255.255.255.

0.0.1.255

223.255.255.254

240.0.0.0

ipv4_mcast vtss_ip_t Multicast IPv4 IP address

in the format of

ddd.ddd.ddd.dddwhere,

d is a decimal digit. It is

in the range of

224.0.0.0 to

239.255.255.255.

224.0.0.0

230.254.255.0

239.255.255.255

ipv4_abc vtss_ip_t IPv4 IP address in the

format of

ddd.ddd.ddd.ddd

where, d is a decimal

digit and the address

must be in class A, B, or

C. If it is in class D or E,

then it is invalid.

1.0.0.0

10.254.255.0

223.255.255.255

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

2323

ICLI Command Generation ICLI Command Generation

ipv4_subnet icli_ipv4_subnet_t IPv4 Subnet address in 2

formats, where, d is a

decimal digit.

IP/netmask:

ddd.ddd.ddd.ddd/

ddd.ddd.ddd.ddd

IP/prefix-length:

ddd.ddd.ddd.ddd/dd

Where IP is unicast IP

address and prefix length

dd is from 0 to 32.

10.1.1.1/

255.0.0.0

10.1.1.1/0

10.1.1.1/32

223.255.255.254

/8

ipv4_prefix u32 IPv4 prefix length, in the

format of /n, when n is in

the range of 0 and 32.

/0

/32

/0010

ipv6_addr vtss_ipv6_t Any IPv6 IP address, in

the format of hhhh:hhhh

:hhhh:hhhh:hhhh:

hhhh:hhhh:hhhh,

where, h is a hex digit. :

: can be used to skip

some hex digits, but it

can happen once only.

::

::1

0:0:0:0:0:0:0:

0

1234::5678:

90ab

1234::

::5678:90ab

ipv6_netmask vtss_ipv6_t IPv6 Netmask, in the

format of hhhh:hhhh:

hhhh:hhhh:hhhh:

hhhh:hhhh:hhhh,

where, h is a hex digit. :

: can be used to skip

some hex digits, but it

can happen once only.

FF00::

FFF0::

FFFF:FF00::

FFFF:FFFF:FC00

::

ipv6_ucast vtss_ipv6_t Unicast IPv6 IP address,

in the format of hhhh:

hhhh:hhhh:hhhh:

hhhh:hhhh:hhhh:

hhhh, where, h is a hex

digit. :: can be used to

skip some hex digits, but

it can happen once only.

But, the first hh must

NOT be 0xFF.

::

FF0::

3F55::1

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

2424

Variable TypesVariable Types

ipv6_mcast vtss_ipv6_t Multicast IPv6 IP address

, in the format of hhhh:

hhhh:hhhh:hhhh:

hhhh:hhhh:hhhh:

hhhh, where ‘h’ is a hex

digit. :: can be used to

skip some hex digits, but

it can happen once only.

But, the first hh must be

0xFF.

FF00::

FF55::1

FF34::cd:82

FF81:5678::ab

ipv6_subnet icli_ipv6_subnet_t IPv6 Subnet address, IP/

Netmask or IP/mask-bits

::/FF00::

::1/FFFF:FF00:

:

0:0:0:0:0:0:0:

0/33

1234::5678:

90ab/1

1234::/128

::5678:90ab/

F000::

Ipv6_prefix u32 IPv6 prefix length, in the

format of /n, when, n is

in the range of 0 and 128.

/0

/128

/0000101

int i32 32-bit signed integer, the

range is -2147483648 to

2147483647.

This has

RUNTIME.range feature.

-100

-0

1234567890

int16 i16 16-bit signed integer, the

range is -32768 to 32767

.

-100

-0

23456

int8 i8 8-bit signed integer, the

range is -128 to 127.

-100

-0

123

uint u32 32-bit unsigned integer,

the range is 0 to

4294967295.

This has

RUNTIME.range feature.

0

100

4294967295

uint16 u16 16-bit unsigned integer,

the range is 0 to 65535.

0

100

29496

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

2525

ICLI Command Generation ICLI Command Generation

uint8 u8 8-bit unsigned integer,

the range is 0 to 255.

0

100

254

a-b,c,d-e u32 Integer in a range. The

range is separated by ,

and each block between

, can be a single decimal

integer or a range value.

The range value uses -

to indicate the range. In

this case, a, b, c, d, and

e are decimal integers

and a < b and d < e.The maximum number of

range blocks is 8.

Assume, -5--3,20,-1-

0,6,15-119,-4 has 6

range blocks.

So the legal input value

should be either (>= -5

&& <= -3), (>= -1 &

& <=0), or (==6), or (

>=15 && <= 119).

Except to be digital

numbers, a and b can

also be constants. If it is

a constant, then it needs

to be enclosed by single

quote; for example <1-‘

ACL_MAX_CNT’> or <’

MIN_NUM’-‘MAX_NUM’

>.

-4

0

6

17

118

range_list icli_range_t * A list of range, the max

number of range blocks

in the list is 8. System

allows only incremental

input.

This has

RUNTIME.range feature.

-5

-5--3,-1-

0,6,10-99

1,2,3,4,5,6,7,8

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

2626

Variable TypesVariable Types

a~b If with negtive

icli_signed_range_t *

if withoutnegative

icli_unsigned_range_t *

A list of range in the

range of a and b, where

a < b, the max numberof range blocks in the listis 8. An example is

<-9~90>.

a and b can be digital

numbers or constant. If

they are constants, then

they need to be enclosed

by single quote; for

example, <1~‘

ACL_MAX_CNT’>.

-5

0,0,0,0

-5--3,-1-

0,6,10-90

1,3,4,6,7,8,5,2

<1~‘MAX_NUM’>

port_type icli_port_type_t Specify the port types in

the device. There are

three supported port

types: FastEthernet,

GigabitEthernet, and

TenGigabitEthernet.

It depends on the port

setting at run-time. Port

settings can be changed

through

icli_port_range_set

().

Assume the device has

GigabitEthernet ports and

TenGigabitEthernet ports

, but no FastEthernet

ports.

GigabitEthernet

TenGigabitEthernet

port_id icli_switch_port_range_t

Single port ID in the

format of switch-id/port-id

.

The valid input depends

on the run-time port

settings. The ID number

starts from 1.

It is assume that the

stacking switches have

two switches and each

switch has 24 ports.

1/1

1/15

2/23

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

2727

ICLI Command Generation ICLI Command Generation

port_list icli_stack_port_range_t *

Port list in the format of a

list of switch-list/port-list.

The list is separated by ;

.

The valid input depends

on run-time port settings.

The ID number starts

from 1.

It is assumed that the

stacking switches has

two switches and each

switch has 24 ports.

2/13

2/13,13;

1/1,3-6,23

1,2/1,3-6,23

1/4,6;2/9,17-

23

port_type_id icli_switch_port_range_t

The same as<port_type><port_id>.

Gi 1/1

Fast 1/15

tengi 2/23

port_type_list icli_stack_port_range_t

*

The same as any number

of repeating<port_type><port_list>.

gi 2/13

gi 2/13,13;

tengi 1/1

fast 1/3-6,9,7

gi 1/5

tengi 1/5 fast

1/7 gi 1/3

ten 1/4,6;2/

9,17-23 gi 1/

1,3,5 fast 1/

2,4-8;3/5,7

vlan_id u32 VLAN ID, an unsigned

integer in the range of

min_vlan_id to

max_vlan_id, where

min_vlan_id and

max_vlan_id is

configurable at run-time.

Assume min_vlan_id

is 1 and max_vlan_id

is 4094.

1

9

24

4094

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

2828

Variable TypesVariable Types

vlan_list icli_unsigned_range_t *

VLAN ID List, a list of

range of blocks that must

be between

min_vlan_id to

max_vlan_id.

Assume that

min_vlan_id is 1 and

max_vlan_id is 4094.

1100

1,1,200,300,55

1,20-30,90-

2300

50,109,1010-

4000

time icli_time_t Time in hh:mm:ss, hh=0

-23, mm=0-59, ss=0-

59

00:00:00

05:05:05

23:15:59

hhmm icli_time_t Time in hh:mm, hh=

0-23, mm=0-59

00:00

05:05

23:15

date icli_date_t Date in yyyy/mm/dd,

yyyy=1970-2037, mm=1

-12, dd=1-31

1970/09/25

2011/05/26

2037/12/31

word char * A single word without

space inside.

This has

RUNTIME.range feature.

12345

ab2c3

_isoi34*(

wordn char * It is the same as <word>

, but the string length

must be <= n.

Assume <word5>

12345

ab

_

wordm-n char * It is the same as <word>

, but the string length

must be >= m and <= n.

Assume <word4-10>

12345

sentence

_isoi34*(

dword char * A single word with all

characters in numeric

letter, 0 - 9.

0203

1235

10000

dwordn char* It is the same as<dword>, but the stringlength must be <= n.

Assume <dword5>

12345

0123

0

dwordm-n char * It is the same as<dword>, but the stringlength must be >= m and<= n.

Assume <dword4-10>

1234

00123

1234567890

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

2929

ICLI Command Generation ICLI Command Generation

fword char * A single word with a

floating point.

0.203

12.35

1000.0

fwordm char * It is the same as<fword>, and thenumber of digits beforethe dot must be <= m.

Assume <fword5>

12345.067456

0.7368

125.87

fwordm.n char * It is the same as<fword>, , and thenumber of digits beforethe dot must be <= m andthe number of digits afterthe dot must be <= n.

Assume <fword4.5>

1234.00001

0.1

123.123

kword char * A single word, but must

begin with an alphabet,

A-Z or a-z, not a numeric

letter.

This has

RUNTIME.range feature.

ab2c3

f123

iso3456

kwordn char * It is the same as<kword>, but the stringlength

must be <= n.

Assume <kword5>

ab2c3

f123

iso34

kwordm-n char * It is the same as<kword>, but the stringlength must be >= m and<= n. Assume <kword4-10>

ab2c3

F123

iso34

string char * A string may contain

several words separated

by spaces, must

enclosed in double-quote

“”. This hasRUNTIME.range feature.

“123 45”

“12345”

“a 123”

stringn char * It is the same as<string>, but the string

length must be <= n.

Assume <string5>

“123 5”

“12345”

“a ”

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

3030

Variable TypesVariable Types

stringm-n char * It is the same with<string>, but the string

length must be >= m

and <= n.

Assume <string4-10>

“123 45”

“1234567”

“a 123”

line char * A string may contain

several words separated

by spaces. It accepts “”

too.

This has

RUNTIME.range feature.

This is a book

“This is a

book”

123 45

“123 45”

12345

“12345”

a 123

“a 123”

linen char * It is the same as<string>, but the string

length must be <= n.

Assume <string5>

123 5

“123 5”

12345

“12345”

A dog

“A dog”

linem-n char * It is the same as<string>, but the string

length must be >= m and

<= n.

Assume <string4-10>

12 3

123 45

“123 45”

open book

“open book

dpl u8 Drop Precedence Lvel. If

the platform is Juguar1,

the range is 0 to 3.

Otherwise, the range is 0

to 1.

0

1

2 (for Juguar1

)

3 (for Juguar1

)

dscp u8 It provides specific DSCP

PHBs. The valid PHbs

are: af11, af12, af13,af21, af22, af23, af31

, af32, af33, af41,

af42, af43, cs1, cs2,

cs3, cs4, cs5, cs6, cs7

, ef, va.

b

be

af13

cs6

e

ef

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

3131

ICLI Command Generation ICLI Command Generation

oui icli_oui_t Organizationally Unique

Identifier (OUI) is a 24-bit

number that is the first

three bytes of MAC

address. And, this should

be unicast.

00-01-02

14:05:07

ba:09:fe

pcp icli_unsigned_range_t *

Priority Code Point.

The valid inputs are

specific(0, 1, 2,

3, 4, 5, 6, 7) or

range(0-1, 2-3, 4-

5, 6-7, 0-3, 4-7) or

any(0-7)

5

2-3

6-7

0-7

hostname char * A valid hostname is a

string drawn from the

alphabet(A-Za-z), digits(0

-9), dot(.), hyphen(-).

Spaces are not allowed,

the first character must

be an alphanumeric

character, and the first

and last characters must

not be a dot or a hyphen.

The maximum length is

45 bytes.

Abc.00-999.com

Great-host

0.0.com

clock_id icli_clock_id_t The ID is an array of hex

value of 8 bytes.

00:01:02:03:04

:05:06:07

0-1-2-3-4b-5-6

-7

0-001-2-3:4:5:

006:7a

hexval icli_hexval_t A hex value begins with

0x or 0X, and its max

length is of128 bytes.

0x012345678

0X567890abcdfe

hexvaln icli_hexval_t It is the same as<hexval>, but its length

must be <=n.

Assume <hexval3>

0x010203

0x01

0x01020

hexvalm-n icli_hexval_t It is the same with<hexval>, but its length

must be >=m and <=n.

Assume <hexval2-3>

0x010

0x01020

0x010203

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

3232

ICLI GuidelinesICLI Guidelines

ICLI Guidelines

Duplicate WordThe ICLI engine parses from left to right. Parsing by the ICLI engine does not allow the same words

to overlap in mandatory{} or optional().

Example 1 (Illegal):

snmp client version <uint>snmp { server | client } address <ipv4_ucast>The keyword client overlaps illegally because client is mandatory{} in the second command.

Example 2 (Illegal):

snmp client version <uint>snmp [client] address <ipv4_ucast>The keyword client still overlaps illegally because client is optional[] in the second command.

The following two examples show the previous commands redesigned as legitimate.

Example 1 (Legal):

snmp client { version <uint> | address <ipv4_ucast> }snmp server address <ipv4_ucast>Example 2 (Legal):

snmp client { version <uint> | address <ipv4_ucast> }

vword char * A single word that allows

0-9a-zA-Z, but it does

not allow all in 0-9 only.

A123

123a

avcd

vwordn char * It is the same as <vword

>, but the string length

must be <=n.

Assume <vword3>

A123

123a

avcd

vwordm-n char * It is the same as <vword

>, but the string length

must be >=m and <=n.

Assume <vword2-4>

avc

switch_id u32 A single switch ID that

will be checked

according to the current

switch configuration.

Assume currently there

are switch 1,3,9

1

3

9

switch_list icli_unsigned_range_t

A list of switch IDs that

will be checked

according to the current

switch configuration.

Assume currently there

are switch 1,2,3,5,8,9

2

2-3,9,8

1-3,5,5,8-9

Table 3 • Variable Types (continued)

Variable Type C Type Description Legal Input

3333

ICLI Command Generation ICLI Command Generation

snmp address <ipv4_ucast>In other words, the trick is to use the same flat prefix as often as possible. snmp client is the

same flat prefix in the examples.

Multiple Optional BeginIf the command has the following designs, then the keyword x is multiple optional begin.

• a [[x]]

• a [ b | [x] ]

To solve this problem, a keyword should be added before [x].

For example,

• a [ k [x] ]

• a [ b | k [x] ]

Shortcut KeysThe following table lists the available shortcut keys.

Table 4 • Shortcut Keys

Function Shortcut Key Description

Line scroll Yes If the length of command exceeds the width ofwindows, then “$”

will be used to scroll the command input, but notdisplay to the

next line.

Cursor move LEFT Back one character to left.

RIGHT Forward one character to right.

HOME Go to the beginning of the line.

Ctrl-a

END Go to the end of the line.

Ctrl-e

Delete Ctrl-n The current line.

DEL A character at the cursor.

Ctrl-d

Backspace A character to the left of the cursor.

Ctrl-h

Ctrl-u All characters from the cursor to the beginning of theline.

Ctrl-x

Ctrl-k All characters from the cursor to the end of the line.

Ctrl-w A word from the cursor to the beginning of the word.

3434

Shortcut KeysShortcut Keys

Page More Spacebar Next page.

All other

keys

Enter Next line.

Ctrl-c Exit from more output.

q

g Go to the last line.

History UP Previous line.

Ctrl-p

DOWN Next line.

Context-Sensitive

Help

TAB Unique: complete the token.

Ambiguous: list all possible tokens.

Behind prompt: list all possible tokens.

? The first ‘?’ lists all possible tokens with helpdescriptions.

The second immediate ‘?’ lists all possible fullcommands.

Ctrl-q Display full command syntax.

Command Mode Ctrl-z Go back to Exec mode directly.

Table 4 • Shortcut Keys (continued)

Function Shortcut Key Description

3535

VPPD-03910. 2.9. July 2015

Microsemi makes no warranty, representation, or guarantee regarding the information contained herein orthe suitability of its products and services for any particular purpose, nor does Microsemi assume anyliability whatsoever arising out of the application or use of any product or circuit. The products soldhereunder and any other products sold by Microsemi have been subject to limited testing and should notbe used in conjunction with mission-critical equipment or applications. Any performance specifications arebelieved to be reliable but are not verified, and Buyer must conduct and complete all performance andother testing of the products, alone and together with, or installed in, any end-products. Buyer shall not relyon any data and performance specifications or parameters provided by Microsemi. It is the Buyer'sresponsibility to independently determine suitability of any products and to test and verify the same. Theinformation provided by Microsemi hereunder is provided “as is, where is” and with all faults, and the entirerisk associated with such information is entirely with the Buyer. Microsemi does not grant, explicitly orimplicitly, to any party any patent rights, licenses, or any other IP rights, whether with regard to suchinformation itself or anything described by such information. Information provided in this document isproprietary to Microsemi, and Microsemi reserves the right to make any changes to the information in thisdocument or to any products and services at any time without notice.

Power Matters.TM

Microsemi Corporation (Nasdaq: MSCC) offers a comprehensive portfolio of semiconductorand system solutions for communications, defense & security, aerospace and industrialmarkets. Products include high-performance and radiation-hardened analog mixed-signalintegrated circuits, FPGAs, SoCs and ASICs; power management products; timing andsynchronization devices and precise time solutions, setting the world's standard for time; voiceprocessing devices; RF solutions; discrete components; security technologies and scalableanti-tamper products; Ethernet solutions; Power-over-Ethernet ICs and midspans; as well ascustom design capabilities and services. Microsemi is headquartered in Aliso Viejo, Calif., andhas approximately 3,600 employees globally. Learn more at www.microsemi.com.

Microsemi Corporate HeadquartersOne Enterprise, Aliso Viejo,CA 92656 USA

Within the USA: +1 (800) 713-4113 Outside the USA: +1 (949) 380-6100Sales: +1 (949) 380-6136Fax: +1 (949) 215-4996E-mail: [email protected]

© 2015 Microsemi Corporation. Allrights reserved. Microsemi and theMicrosemi logo are trademarks ofMicrosemi Corporation. All othertrademarks and service marks are theproperty of their respective owners.