![]() Length-Prefixed Stream Format |
![]() DEVELOPER |
![]() |
Length-Prefixed Stream Format is a variation of the Delimiter Separated List Format that resolves the limitations of the Delimiter Separated List Stream Format. However, it is not supported by third party applications, and so is only useful when the P4API caller is directly processing that data.
Rather than a delimiter character being used to separate parameters, there is a parameter length (a byte count) in front of each parameter, and in front of each parameter name. The parameter names are passed separately, rather than including them at the front of each parameter, because this simplifies use of multilingual character sets (avoiding issues when the '=' character might be part of the parameter name). The length prefix will be a 2-byte binary length, in more significant byte first order. An example of this format is:
L1AccountIdL212345L3AccountNameL4Big AcctL5CmdL6ADDL7AmountL8123.45
Where L1 is the length of the first field 'AccountId' (two byte hex value 00,09), L2 is the length of the second field '12345' (value 00,05) and so on.
Entire arrays have two extra fields to specify the length of all the array elements and the number of array elements. The Task parameter name has open/close parentheses '( )' appended to the name to indicate an entire array parameter. For example:
L1Address()L2N1L3Element1L4Element2L5Element3L6Element4L7Element5
Where L1 is the length of the array name, including the appended parentheses '( )', (two byte hex value 00,09). L2 is the length of all the array element data including the number of elements, (two byte hex value, 00, 34). N1 is the number of elements, (two byte hex value 00, 05). L3 is the length of the first element, (two byte hex value 00, 08) an so on.
Indicate individual elements of an array by appending the Task parameter name with open/close parentheses and the element number (one relative).
L1Address(1)L2123 Any StreetL3Address(2)L4Suite AL5Address(3)L6Hometown
Where L1 is the length of the first field 'Address(1)' (two byte hex value 00,0A), L2 is the length of the second field '123 Any Street' (value 00,0E) and so on.
The nParamLenIn parameter of p4TaskExec() is used to indicate the end of the parameter list. On return, the parameter list will just contain a list of the OUT parameters.
For additional information and examples, see Task/Function Parameter Definitions and P4API Parameter Passing.
Topic ID: 540082