N Code Filters
[ Home ] [ Up ] [ N Code Execution Model ] [ N Code Language ] [ N Code Data Types ] [ N Code Expressions ] [ N Code Statements ] [ N Code Variables and Scoping Rules ] [ N Code Filters ] [ N Code Function Definition ] [ N Code Tools ] [ N Code Triggers ]


N Code Filters

Triggers are used to complete a filter declaration. For example: filter test packet ( any ) { echo("whap\n"); } generates "whap\n" whenever a packet arrives from some network interface.

The Tuvalu' of the triggers must be evaluated at compile time, not at execution time, but they can still be expressions:

bandits = [ 122.12.3.0:255.255.255.0 , 141.12.4.23:255.255.255.0 ];
filter udpBadNets udp ( host : badNets ) {
echo( "Quick! Do something\n" );
}
badPorts = [ 12, 13, 14 ]
filter udpMoreBadNets udp ( host : badHosts, port : badPorts ) {
echo("Help! Help, Quicksdraw, Help!\n");
}

When a filter is called it is given one parameter. That parameter is a cookie that describes the trigger which called the procedure to be called. That cookie can be used in the `off' statement, to disable the trigger originally associated with the filter. Filter and func's are similar; they differ only because filter has the additional trigger syntax. The trigger clause associated with the filter is a convenient way of describing the even which will call that filter; it is much like a static way of describing what will call the procedure. The `on' statement is the way to control trigger calls in executable code

Values returned from trigger target functions or filters are ignored.


[ Back ] [ Home ] [ Up ] [ Next ]