Detailed Description
This section specifies the syntax and semantics for the macro command. This command is supported for all feature sets.
The syntax for macros is shown below.
<MacroAction> ::= 'DefineMacro' '(' <MacroName> ',' <MacroDefinition> ')' <MacroName> ::= '"' <IdentifierDefinition> '"' <IdentifierDefinition> ::= <Ascii char reduced> { <Ascii char reduced> } <MacroDefinition> ::= '"' <MacroDefinitionElement> { <MacroDefinitionElement> } '"' <MacroDefinitionElement> ::= ( <Ascii char> | <ArgumentDefinition> ) <ArgumentDefinition> ::= '$' <ArgumentNumber> <ArgumentNumber> ::= '1' | '2' | ... | '5'
Macros can be used to simplify commands or to build more sophisticated commands. Macros can be defined using variable arguments. Such macros can be called later using specific arguments.
Note: You cannot define the same macro more than once. To redefine a macro, delete the existing macro and define a new.
Each Macro command defines a macro. <MacroName> specifies a name for the macro. <MacroDefinition> specifies the content of the macro. When using <MacroName> in a command, it is replaced by <MacroDefinition> when the command is executed.
<ArgumentDefinition> can be used for defining variable arguments. <MacroName> must then be called followed by the argument(s) in parenthesis.
Note: Up to 5 arguments can be specified in a macro definition as $1, $2, ..., $5, and they can be used in any order and even reused, if needed.
Note: All commands are run through the macro expander as the first action before being run through the parser.
Deleting or cancelling a macro
A Macro command is cancelled or deleted by issuing an empty empty macro with <MacroName> where <MacroDefinition> is empty.
Macro Example
This section describes an example of defining a macro with an argument. The example illustrates how to set up a filter that captures all traffic with the UDP source port set to 80.
The macro NTPL example is shown below.
DefineMacro("mUdpSrcPort","Data[DynOffset=DynOffUDPFrame;Offset=0;DataType=ByteStr2] == $1")
Assign[StreamId = 1] = mUdpSrcPort(80)
This macro result in: Assign[StreamId = 1] = Data[DynOffset=DynOffUDPFrame;Offset=0;DataType=ByteStr2] == 80
The macro is deleted by: DefineMacro("mUdpSrcPort","")
Modules | |
More Macro Examples | |