summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/config.Y6
-rw-r--r--filter/filter.c7
-rw-r--r--filter/filter.h2
-rw-r--r--filter/test.conf24
4 files changed, 34 insertions, 5 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 2572501f..ffb9a74c 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -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);
diff --git a/filter/filter.c b/filter/filter.c
index 172e77bc..fd099a6c 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -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);
diff --git a/filter/filter.h b/filter/filter.h
index 86450591..e86aa02b 100644
--- a/filter/filter.h
+++ b/filter/filter.h
@@ -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
diff --git a/filter/test.conf b/filter/test.conf
index f1b3b66e..f0441778 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -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;
{