tableUdf

tableUdf - manage table UDFs.

SYNOPSIS

tableUdf sub-command options

DESCRIPTION

The tableUdf command is used to define tables of data that is applied at the same time as other UDFs. The tableUdf feature is only available for selected ports; the availability of the feature may be tested with the port isValidFeature... portFeatureTableUDF command.

The feature is enabled with the enable option. Tables consist of rows and columns. Columns define the locations within a packet that are to be modified, while rows hold the data that is simultaneously applied at the locations indicated by the columns. Columns are defined with tableUdfColumn; column attributes include:

Columns are then added to the table using the addColumn sub-command of this command.

Once columns have been defined, data is added to the table, row by row, using the addRow sub-command.

Table UDF configurations, including row data, may be saved to disk using the export sub-command; a comma separated values (csv) file format is used. Table UDF configurations may be retrieved using the import sub-command.

STANDARD OPTIONS
enable true | false

Enables the table UDF. (default = false)

maxRowSize

Retrieves the maximum size of rows in the table UDF. This command can only be used after the set command.

maxNumRows

Retrieves the maximum number of rows in the table UDF. This command can only be used after the set command.

numColumns

Read-only. The total number of currently defined columns.

numRows

Read-only. The total number of currently defined rows.

COMMANDS

The tableUdf command is invoked with the following sub-commands. If no sub-command is specified, returns a list of all sub-commands available.

tableUdf addColumn

Adds a table UDF column as defined in the tableUdfColumn command. If a column is added after several other columns have been added and addRow has been called for those columns, default data for the existing number of rows for the new column is filled in for the new column. Specific errors are:

tableUdf addRow rowValueList

Adds a row's worth of data to the tableUdf. rowValueList must contain an entry for each defined column in the table. Each column must be correctly formatted as per the formatType and customFormat options of the column in the tableUdfColumn command at the time that the column was defined. Specific errors are:

tableUdf cget option

Returns the current value of the configuration option given by option. Option may have any of the values accepted by the tableUdf command.

tableUdf clearColumns

Deletes all of the column definitions and all row data.

tableUdf clearRows

Deletes all of the row data. Column definitions are not affected.

tableUdf config option value

Modify the table UDF options. If no option is specified, returns a list describing all of the available options (see STANDARD OPTIONS).

tableUdf delColumn

Deletes the current column selected through calls to getFirstColumn/getNextColumn. Specific errors are:

tableUdf delRow

Deletes the current row selected through calls to getFirstRow/getNextRow. Specific errors are:

tableUdf export filename

Exports the table UDF configuration to the file indicated by filename. Specific errors are:

tableUdf get chasID cardID portID

Gets the current configuration of the tableUdf for port with id portID on card cardID, chassis chasID from its hardware. Note that stream get must be called before this sub-command. Call this command before calling tableUdf cget option value to get the value of the configuration option. Specific errors are:

tableUdf getFirstColumn

Finds the first column in the column list and places the values in the options of the tableUdfColumn command. Specific errors are:

tableUdf getFirstRow

Finds the first row in the table and returns a list with the values from the row. Specific errors are:

tableUdf getNextColumn

Finds the next column in the column list and places the values in the options of the tableUdfColumn command. getFirstColumn must have been called before this call. Specific errors are:

tableUdf getNextRow

Finds the next row in the table and returns a list with the values from the row. getFirstRow must have been called before this call. Specific errors are:

tableUdf import filename [chasID cardID portID]

Imports the table UDF configuration from the file indicated by filename. If chasID, cardID and portID are provided, then this sub-command performs a tableUdf set operation as well, committing the values to the hardware. Specific errors are:

tableUdf reserveRows numberOfRows

Reserves a number of rows. This may improve performance by reserving some memory ahead of time so that the process of adding the rows can run faster.

tableUdf set chasID cardID portID

Sets the configuration of the tableUdf in IxHAL for a port by reading the configuration option values set by the tableUdf config option value command. Specific errors are:

tableUdf setDefault

Sets to IxTclHal default values for all configuration options.

EXAMPLES

package req IxTclHal

set hostname loopback

set retCode "PASS"

if {[ixConnectToChassis $hostname]} {

errorMsg "error connecting $hostname chassis"

return "FAIL"

}

set chassId [chassis cget -id]

set cardId 56

set portId 1

set customFormat "8b;3d;16x"

set columnItemList { \

{"Hex Value" 0 8 formatTypeHex } \

{"Ascii" 20 9 formatTypeAscii} \

{"Mac Address" 40 6 formatTypeMAC } \

{"Binary Value" 55 2 formatTypeBinary} \

{"IPV4 Address" 60 4 formatTypeIPv4 } \

{"Ipv6 Address" 70 16 formatTypeIPv6 } \

{"Decimal" 90 3 formatTypeDecimal} \

{"Custom Field" 100 4 formatTypeCustom }}

set rowValueListArray(1) {{21 11 11 11 11 11 11 12 } hellooooo {12 12 12 12 12 12 } {00000011 11111111} 1.1.1.2 3A37:3737:373A:3939:3939:3A39:3939:3900 1234 {10000001;4;13DA} }

set rowValueListArray(2) {{31 11 19 99 99 05 00 02 } {arev dzez} {13 13 13 13 13 13 } {01111111 11111111} 1.1.1.3 3A36:3746:463A:4645:3333:3A31:3233:3400 1235 {10000011;5;CFDF}}

set rowValueListArray(3) {{14 14 14 14 15 15 15 15 } { tgha ari} {00 14 14 14 14 14 } {00000000 10101010} 1.1.1.4 3A36:3746:463A:4645:3333:3A32:3334:3500 1238 {10000111;6;ABCD}}

set rowValueListArray(4) {{0A CF DB AB AB AB 00 04 } ..mer))_+ {00 15 15 15 15 15 } {00011111 11110001} 1.1.1.5 3A36:3746:463A:4645:3333:3A33:3435:3600 1237 {01001111;7;00AB}}

set rowValueListArray(5) {{21 77 77 77 77 77 77 78 } ...kyank= {00 00 16 16 16 16 } {00111111 00001111} 1.1.1.6 3A36:3746:463A:4645:3333:3A31:3233:3400 1239 {00000000;0;0AAA}}

set portList [list [list $chassId $cardId $portId]]

set numColumns [llength $columnItemList]

set columnIndex 1

tableUdf setDefault

tableUdf clearColumns

tableUdf config -enable $::true

foreach formatItem $columnItemList {

tableUdfColumn setDefault

tableUdfColumn config -name [lindex $formatItem 0]

tableUdfColumn config -offset [lindex $formatItem 1]

tableUdfColumn config -size [lindex $formatItem 2]

tableUdfColumn config -formatType [lindex $formatItem 3]

tableUdfColumn config -customFormat $customFormat

if {[tableUdf addColumn]} {

errorMsg "Error adding a column with formatType: \

[lindex $headerItem 3] : $::ixErrorInfo"

set retCode "FAIL"

break

}

incr columnIndex

}

set rowIndex 1

foreach rowItem [array names rowValueListArray] {

if {[tableUdf addRow $rowValueListArray($rowItem) ]} {

errorMsg "Error adding row $rowIndex : $::ixErrorInfo"

set retCode "FAIL"

break

}

}

 

if { $retCode == "FAIL" } {

return $retCode

}

if {[tableUdf set $chassId $cardId $portId]} {

errorMsg "Error setting tableUdf: $::ixErrorInfo"

return "FAIL"

}

stream setDefault

stream config -name "tableUdfTester"

stream config -framesize 300

if [stream set $chassId $cardId $portId 1] {

errorMsg "Error setting stream on port \

$chassId $cardId $portId 1"

return "FAIL"

}

if [stream get $chassId $cardId $portId 1] {

errorMsg "Error getting stream on port $chassId $cardId $portId 1"

set retCode "FAIL"

break

}

if [tableUdf get $chassId $cardId $portId] {

errorMsg "Error getting tableUdf: $::ixErrorInfo"

return "FAIL"

}

if {[ tableUdf cget -enable] } {

if {[tableUdf cget -enable] } {

ixPuts "tableUdf cget -enable: [tableUdf cget -enable]"

set columnIndex 1

if { ![tableUdf getFirstColumn] } {

ixPuts "***** Column $columnIndex *****"

set fType [tableUdfColumn cget -formatType]

ixPuts "tableUdfColumn cget -formatType: $fType"

if {$fType == $::formatTypeCustom} {

ixPuts "tableUdfColumn cget -customFormat: \

[tableUdfColumn cget -customFormat]"

}

ixPuts "tableUdfColumn cget -name: \

[tableUdfColumn cget -name]"

ixPuts "tableUdfColumn cget -offset: \

[tableUdfColumn cget -offset]"

ixPuts "tableUdfColumn cget -size: \

[tableUdfColumn cget -size]"

while {![tableUdf getNextColumn]} {

incr columnIndex

ixPuts "***** Column $columnIndex *****"

set fType [tableUdfColumn cget -formatType]

ixPuts "tableUdfColumn cget -formatType: $fType"

if {$fType == $::formatTypeCustom} {

ixPuts "tableUdfColumn cget -customFormat: \

[tableUdfColumn cget -customFormat]"

}

ixPuts "tableUdfColumn cget -name: \

[tableUdfColumn cget -name]"

ixPuts "tableUdfColumn cget -offset: \

[tableUdfColumn cget -offset]"

ixPuts "tableUdfColumn cget -size: \

[tableUdfColumn cget -size]"

}

set rowIndex 1

set numRows [tableUdf cget -numRows]

if {$numRows > 0 } {

set rowValueList [tableUdf getFirstRow]

while {[llength $rowValueList]} {

ixPuts "***** Row $rowIndex *****"

ixPuts "$rowValueList"

set rowValueList [tableUdf getNextRow]

incr rowIndex

}

}

}

}

}

SEE ALSO

udf, tableUdfColumn, stream