Browse code

- added test configs & packets

Andrei Pelinescu-Onciul authored on 21/09/2001 21:42:52
Showing 6 changed files
... ...
@@ -5,7 +5,10 @@
5 5
 # WARNING: requires gmake (GNU Make)
6 6
 #
7 7
 
8
-sources= $(wildcard *.c)
8
+lex_f=lex.yy.c
9
+yacc_f=cfg.tab.c
10
+sources= $(filter-out $(lex_f) $(yacc_f), $(wildcard *.c)) $(lex_f) \
11
+$(yacc_f) 
9 12
 objs= $(sources:.c=.o)
10 13
 depends= $(sources:.c=.d)
11 14
 
... ...
@@ -15,8 +18,8 @@ NAME=sip_router
15 15
 CC=gcc
16 16
 CFLAGS=-O2 -Wcast-align  #-Wmissing-prototypes  -Wall
17 17
 LEX=lex
18
-YACC=bison
19
-YACC_FLAGS=-d
18
+YACC=yacc
19
+YACC_FLAGS=-d -b cfg
20 20
 # on linux and freebsd keep it empty (e.g. LIBS= )
21 21
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
22 22
 LIBS=-lfl -L/usr/local/lib
... ...
@@ -235,6 +235,7 @@ static int comp_ip(unsigned a, void* param, int op, int subtype)
235 235
 			ret=(a&((struct net*)param)->mask)==((struct net*)param)->ip;
236 236
 			break;
237 237
 		case STRING_ST:
238
+		case RE_ST:
238 239
 			/* 1: compare with ip2str*/
239 240
 			ret=comp_str(inet_ntoa(*(struct in_addr*)&a), param, op,
240 241
 						subtype);
241 242
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+" unterminated string
0 1
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+# config file for centauri
1
+
2
+route{
3
+	(src_ip==192.168.46.0/24 or src_ip~="^dorian") forward("fox.iptel.org");
4
+	src_ip=="centauri.fokus.gmd.de" log("Possible loop, dropping\n"); drop
5
+	src_ip==0.0.0.0/0 log("forwarding denied\n"); drop
6
+}
0 7
new file mode 100644
... ...
@@ -0,0 +1,5 @@
0
+INVITE sip:andrei@localhost SIP/2.0/UDP
1
+Via: SIP/2.0/UDP localhost
2
+
3
+
4
+
0 5
new file mode 100644
... ...
@@ -0,0 +1,34 @@
0
+# test config file
1
+
2
+/* C style comment */
3
+
4
+/*
5
+ * same thing but on multiple lines
6
+ */
7
+
8
+/*
9
+  /* Nested
10
+    comment */
11
+*/
12
+
13
+
14
+debug=1
15
+dns=true #comment on the same line
16
+
17
+route{
18
+	(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");
19
+	( uri~="test\n" &  ! src_ip~="dorian") forward(dorian.fokus.gmd.de);
20
+
21
+	(src_ip==192.168.0.0/255.255.0.0 or dst_ip==127.0.0.1 and uri~="s$") \
22
+		error("440","not forwarding"); log(2,"droping..."); drop;
23
+
24
+	src_ip==127.0.0.1 route(3); drop;
25
+}
26
+
27
+fork=no
28
+
29
+route[3]{
30
+	(src_ip==0.0.0.0/0) exec('/bin/ls >/tmp/x'); send(4.3.2.1,8000); /* catch all */
31
+}
32
+
33
+/* eof */