Added code for testing filters.
This commit is contained in:
parent
471bd6c30b
commit
7a86a8b08d
4 changed files with 34 additions and 5 deletions
|
@ -206,10 +206,14 @@ function_body:
|
|||
CF_ADDTO(conf, function_def)
|
||||
function_def:
|
||||
FUNCTION SYM { DBG( "Begining of function %s\n", $2->name ); cf_push_scope($2); } function_params function_body {
|
||||
extern struct f_inst *startup_func;
|
||||
extern struct f_inst *startup_func, *test1_func, *test2_func;
|
||||
cf_define_symbol($2, SYM_FUNCTION, $5);
|
||||
if (!strcasecmp($2->name, "__startup"))
|
||||
startup_func = $5;
|
||||
if (!strcasecmp($2->name, "__test1"))
|
||||
test1_func = $5;
|
||||
if (!strcasecmp($2->name, "__test2"))
|
||||
test2_func = $5;
|
||||
$2->aux = (int) $4;
|
||||
$2->aux2 = $5;
|
||||
DBG("Hmm, we've got one function here - %s\n", $2->name);
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
*
|
||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||
*
|
||||
* Notice that pair is stored as integer: first << 16 | second
|
||||
*
|
||||
*/
|
||||
|
||||
#define LOCAL_DEBUG
|
||||
|
@ -26,7 +24,7 @@
|
|||
|
||||
#define P(a,b) ((a<<8) | b)
|
||||
|
||||
struct f_inst *startup_func = NULL;
|
||||
struct f_inst *startup_func = NULL, *test1_func, *test2_func;
|
||||
|
||||
#define CMP_ERROR 999
|
||||
|
||||
|
@ -630,6 +628,9 @@ void
|
|||
filters_postconfig(void)
|
||||
{
|
||||
struct f_val res;
|
||||
|
||||
if (!i_same(test1_func, test2_func))
|
||||
bug("i_same does not work");
|
||||
if (startup_func) {
|
||||
debug( "Launching startup function...\n" );
|
||||
f_pool = lp_new(&root_pool, 1024);
|
||||
|
|
|
@ -99,7 +99,7 @@ void val_print(struct f_val v);
|
|||
/* User visible types, which fit in int */
|
||||
#define T_INT 0x10
|
||||
#define T_BOOL 0x11
|
||||
#define T_PAIR 0x12
|
||||
#define T_PAIR 0x12 /* Notice that pair is stored as integer: first << 16 | second */
|
||||
|
||||
/* Put enumerational types in 0x30..0x3f range */
|
||||
#define T_ENUM_LO 0x30
|
||||
|
|
|
@ -116,6 +116,30 @@ ip p;
|
|||
# print "*** FAIL: this is unreachable";
|
||||
}
|
||||
|
||||
function __test1()
|
||||
{
|
||||
if source = RTS_STATIC then {
|
||||
bgp_community = -empty-;
|
||||
bgp_community.add((65000,5678));
|
||||
if bgp_path ~ / 65000 / then
|
||||
bgp_path.prepend(65000);
|
||||
accept;
|
||||
}
|
||||
reject;
|
||||
}
|
||||
|
||||
function __test2()
|
||||
{
|
||||
if source = RTS_STATIC then {
|
||||
bgp_community = -empty-;
|
||||
bgp_community.add((65000,5678));
|
||||
if bgp_path ~ / 65000 / then
|
||||
bgp_path.prepend(65000);
|
||||
accept;
|
||||
}
|
||||
reject;
|
||||
}
|
||||
|
||||
filter testf
|
||||
int j;
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue