- added test configs & packets
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 21 Sep 2001 21:42:52 +0000 (21:42 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 21 Sep 2001 21:42:52 +0000 (21:42 +0000)
Makefile
route.c
test/bad_eof.cfg [new file with mode: 0644]
test/centauri.cfg [new file with mode: 0644]
test/req1.sip [new file with mode: 0644]
test/test1.cfg [new file with mode: 0644]

index 4bb0e32..54c5595 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,10 @@
 # WARNING: requires gmake (GNU Make)
 #
 
-sources= $(wildcard *.c)
+lex_f=lex.yy.c
+yacc_f=cfg.tab.c
+sources= $(filter-out $(lex_f) $(yacc_f), $(wildcard *.c)) $(lex_f) \
+$(yacc_f) 
 objs= $(sources:.c=.o)
 depends= $(sources:.c=.d)
 
@@ -15,8 +18,8 @@ NAME=sip_router
 CC=gcc
 CFLAGS=-O2 -Wcast-align  #-Wmissing-prototypes  -Wall
 LEX=lex
-YACC=bison
-YACC_FLAGS=-d
+YACC=yacc
+YACC_FLAGS=-d -b cfg
 # on linux and freebsd keep it empty (e.g. LIBS= )
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
 LIBS=-lfl -L/usr/local/lib
diff --git a/route.c b/route.c
index c96bc73..cd8c345 100644 (file)
--- a/route.c
+++ b/route.c
@@ -235,6 +235,7 @@ static int comp_ip(unsigned a, void* param, int op, int subtype)
                        ret=(a&((struct net*)param)->mask)==((struct net*)param)->ip;
                        break;
                case STRING_ST:
+               case RE_ST:
                        /* 1: compare with ip2str*/
                        ret=comp_str(inet_ntoa(*(struct in_addr*)&a), param, op,
                                                subtype);
diff --git a/test/bad_eof.cfg b/test/bad_eof.cfg
new file mode 100644 (file)
index 0000000..0d523a7
--- /dev/null
@@ -0,0 +1 @@
+" unterminated string
diff --git a/test/centauri.cfg b/test/centauri.cfg
new file mode 100644 (file)
index 0000000..e79a623
--- /dev/null
@@ -0,0 +1,7 @@
+# config file for centauri
+
+route{
+       (src_ip==192.168.46.0/24 or src_ip~="^dorian") forward("fox.iptel.org");
+       src_ip=="centauri.fokus.gmd.de" log("Possible loop, dropping\n"); drop
+       src_ip==0.0.0.0/0 log("forwarding denied\n"); drop
+}
diff --git a/test/req1.sip b/test/req1.sip
new file mode 100644 (file)
index 0000000..80343b0
--- /dev/null
@@ -0,0 +1,5 @@
+INVITE sip:andrei@localhost SIP/2.0/UDP
+Via: SIP/2.0/UDP localhost
+
+
+
diff --git a/test/test1.cfg b/test/test1.cfg
new file mode 100644 (file)
index 0000000..24d3604
--- /dev/null
@@ -0,0 +1,34 @@
+# test config file
+
+/* C style comment */
+
+/*
+ * same thing but on multiple lines
+ */
+
+/*
+  /* Nested
+    comment */
+*/
+
+
+debug=1
+dns=true #comment on the same line
+
+route{
+       (method==invite and src_ip==1.2.3.4 or (src_ip==4.3.2.1 and src_ip==11.12.13.14/24) ) log("test log\n"); forward("ape");
+       ( uri~="test\n" &  ! src_ip~="dorian") forward(dorian.fokus.gmd.de);
+
+       (src_ip==192.168.0.0/255.255.0.0 or dst_ip==127.0.0.1 and uri~="s$") \
+               error("440","not forwarding"); log(2,"droping..."); drop;
+
+       src_ip==127.0.0.1 route(3); drop;
+}
+
+fork=no
+
+route[3]{
+       (src_ip==0.0.0.0/0) exec('/bin/ls >/tmp/x'); send(4.3.2.1,8000); /* catch all */
+}
+
+/* eof */