Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,114 +0,0 @@
1
-/*
2
- * Copyright (C) 2001-2003 FhG Fokus
3
- *
4
- * This file is part of Kamailio, a free SIP server.
5
- *
6
- * Kamailio is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version
10
- *
11
- * Kamailio is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
18
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
- */
20
-/*!
21
-* \file
22
-* \brief Kamailio core :: Message routing
23
-* \ingroup core
24
-* Module: \ref core
25
-*/
26
-
27
-
28
-#ifndef route_h
29
-#define route_h
30
-
31
-#include <sys/types.h>
32
-#include <regex.h>
33
-#include <netdb.h>
34
-
35
-#include "config.h"
36
-#include "error.h"
37
-#include "route_struct.h"
38
-#include "action.h"
39
-#include "parser/msg_parser.h"
40
-#include "str_hash.h"
41
-
42
-/*#include "cfg_parser.h" */
43
-
44
-/* Various types of route sections, make sure that the values defined in the
45
- * macros below occupy disjunct bits so that they can also be used as flags
46
- */
47
-#define REQUEST_ROUTE (1 << 0)
48
-#define FAILURE_ROUTE (1 << 1)
49
-#define TM_ONREPLY_ROUTE (1 << 2)
50
-#define BRANCH_ROUTE  (1 << 3)
51
-#define ONSEND_ROUTE  (1 << 4)
52
-#define ERROR_ROUTE   (1 << 5)
53
-#define LOCAL_ROUTE   (1 << 6)
54
-#define CORE_ONREPLY_ROUTE (1 << 7)
55
-#define BRANCH_FAILURE_ROUTE (1 << 8)
56
-#define ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
57
-#define EVENT_ROUTE   REQUEST_ROUTE
58
-#define ANY_ROUTE     (0xFFFFFFFF)
59
-
60
-/* The value of this variable is one of the route types defined above and it
61
- * determines the type of the route being executed, module functions can use
62
- * this value to determine the type of the route they are being executed in
63
- */
64
-extern int route_type;
65
-
66
-#define set_route_type(type) \
67
-	do {					 \
68
-		route_type = (type); \
69
-	} while(0)
70
-
71
-#define get_route_type()	route_type
72
-
73
-#define is_route_type(type) (route_type & (type))
74
-
75
-struct route_list{
76
-	struct action** rlist;
77
-	int idx; /* first empty entry */ 
78
-	int entries; /* total number of entries */
79
-	struct str_hash_table names; /* name to route index mappings */
80
-};
81
-
82
-
83
-/* main "script table" */
84
-extern struct route_list main_rt;
85
-/* main reply route table */
86
-extern struct route_list onreply_rt;
87
-extern struct route_list failure_rt;
88
-extern struct route_list branch_rt;
89
-extern struct route_list onsend_rt;
90
-extern struct route_list event_rt;
91
-
92
-/* script optimization level */
93
-extern int scr_opt_lev;
94
-
95
-int init_routes(void);
96
-void destroy_routes(void);
97
-int route_get(struct route_list* rt, char* name);
98
-int route_lookup(struct route_list* rt, char* name);
99
-
100
-void push(struct action* a, struct action** head);
101
-int add_actions(struct action* a, struct action** head);
102
-void print_rls(void);
103
-int fix_rls(void);
104
-
105
-int eval_expr(struct run_act_ctx* h, struct expr* e, struct sip_msg* msg);
106
-
107
-
108
-/* fixup functions*/
109
-int fix_actions(struct action* a);
110
-int fix_expr(struct expr* exp);
111
-
112
-
113
-
114
-#endif
Browse code

Core Update of doxygen, removal of history, changing "ser" to "kamailio"

Olle E. Johansson authored on 03/01/2015 14:03:24
Showing 1 changed files
... ...
@@ -1,21 +1,14 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2001-2003 FhG Fokus
5 3
  *
6
- * This file is part of ser, a free SIP server.
4
+ * This file is part of Kamailio, a free SIP server.
7 5
  *
8
- * ser is free software; you can redistribute it and/or modify
6
+ * Kamailio is free software; you can redistribute it and/or modify
9 7
  * it under the terms of the GNU General Public License as published by
10 8
  * the Free Software Foundation; either version 2 of the License, or
11 9
  * (at your option) any later version
12 10
  *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18
- * ser is distributed in the hope that it will be useful,
11
+ * Kamailio is distributed in the hope that it will be useful,
19 12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 14
  * GNU General Public License for more details.
... ...
@@ -24,6 +17,12 @@
24 17
  * along with this program; if not, write to the Free Software 
25 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 19
  */
20
+/*!
21
+* \file
22
+* \brief Kamailio core :: Message routing
23
+* \ingroup core
24
+* Module: \ref core
25
+*/
27 26
 
28 27
 
29 28
 #ifndef route_h
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -22,7 +22,7 @@
22 22
  *
23 23
  * You should have received a copy of the GNU General Public License 
24 24
  * along with this program; if not, write to the Free Software 
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 26
  */
27 27
 
28 28
 
Browse code

core: Add defines required for a new branch_failure_route type

Hugh Waite authored on 26/03/2013 11:43:35
Showing 1 changed files
... ...
@@ -53,6 +53,7 @@
53 53
 #define ERROR_ROUTE   (1 << 5)
54 54
 #define LOCAL_ROUTE   (1 << 6)
55 55
 #define CORE_ONREPLY_ROUTE (1 << 7)
56
+#define BRANCH_FAILURE_ROUTE (1 << 8)
56 57
 #define ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
57 58
 #define EVENT_ROUTE   REQUEST_ROUTE
58 59
 #define ANY_ROUTE     (0xFFFFFFFF)
Browse code

Revert "core: Initial revision of branch_failure_route"

Remove new branch_failure_route in favour of an event_route

This reverts commit a5946574cb9917f0a9a90ea547c9357f3f6477bd.

Hugh Waite authored on 26/03/2013 11:22:31
Showing 1 changed files
... ...
@@ -53,7 +53,6 @@
53 53
 #define ERROR_ROUTE   (1 << 5)
54 54
 #define LOCAL_ROUTE   (1 << 6)
55 55
 #define CORE_ONREPLY_ROUTE (1 << 7)
56
-#define BRANCH_FAILURE_ROUTE (1 << 8)
57 56
 #define ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
58 57
 #define EVENT_ROUTE   REQUEST_ROUTE
59 58
 #define ANY_ROUTE     (0xFFFFFFFF)
... ...
@@ -86,7 +85,6 @@ extern struct route_list main_rt;
86 85
 /* main reply route table */
87 86
 extern struct route_list onreply_rt;
88 87
 extern struct route_list failure_rt;
89
-extern struct route_list branch_failure_rt;
90 88
 extern struct route_list branch_rt;
91 89
 extern struct route_list onsend_rt;
92 90
 extern struct route_list event_rt;
Browse code

core: Initial revision of branch_failure_route

- New branch_failure_route defined
- cfg route is called but xlog() causes segfault

Hugh Waite authored on 19/03/2013 15:43:46
Showing 1 changed files
... ...
@@ -53,6 +53,7 @@
53 53
 #define ERROR_ROUTE   (1 << 5)
54 54
 #define LOCAL_ROUTE   (1 << 6)
55 55
 #define CORE_ONREPLY_ROUTE (1 << 7)
56
+#define BRANCH_FAILURE_ROUTE (1 << 8)
56 57
 #define ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
57 58
 #define EVENT_ROUTE   REQUEST_ROUTE
58 59
 #define ANY_ROUTE     (0xFFFFFFFF)
... ...
@@ -85,6 +86,7 @@ extern struct route_list main_rt;
85 86
 /* main reply route table */
86 87
 extern struct route_list onreply_rt;
87 88
 extern struct route_list failure_rt;
89
+extern struct route_list branch_failure_rt;
88 90
 extern struct route_list branch_rt;
89 91
 extern struct route_list onsend_rt;
90 92
 extern struct route_list event_rt;
Browse code

core: Added void to declarations of functions with empty argument list

In C language, a declaration in the form int f(); is equivalent to int f(...);, thus being able to accept an indefinit number of parameters. With the -Wstrict-prototypes GCC options, these declarations are reported as "function declaration isn’t a prototype".
On some cases, this may trick the compiler into generating unoptimized code (like preparing to handle variadic argument list).
In all cases having a declaration int f() and a definition inf f(int) is missleading, even if standard compliant.
This is still Work in Progress. (maybe adding the -Wstrict-prototypes option to default is desireable)

Marius Zbihlei authored on 02/04/2012 14:19:17
Showing 1 changed files
... ...
@@ -92,15 +92,15 @@ extern struct route_list event_rt;
92 92
 /* script optimization level */
93 93
 extern int scr_opt_lev;
94 94
 
95
-int init_routes();
96
-void destroy_routes();
95
+int init_routes(void);
96
+void destroy_routes(void);
97 97
 int route_get(struct route_list* rt, char* name);
98 98
 int route_lookup(struct route_list* rt, char* name);
99 99
 
100 100
 void push(struct action* a, struct action** head);
101 101
 int add_actions(struct action* a, struct action** head);
102
-void print_rls();
103
-int fix_rls();
102
+void print_rls(void);
103
+int fix_rls(void);
104 104
 
105 105
 int eval_expr(struct run_act_ctx* h, struct expr* e, struct sip_msg* msg);
106 106
 
Browse code

core: distinct core and tm onreply route tests

- added TM_ONREPLY_ROUTE and CORE_ONREPLY_ROUTE to the possible
route types. This allows to distinguish between the main reply
route (executed by the core) and onreply routes executed by tm.
ONREPLY_ROUTE was changed to TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE,
so that is_route_type(ONREPLY_ROUTE) will return true both for
CORE_ONREPLY_ROUTE and TM_ONREPLY_ROUTE.

- onreply_route[0] {} is equivalent with onreply_route{}.

- use different route types when parsing the script for
onreply_route{} (CORE_ONREPLY_ROUTE) and onreply_route[x]{},
where x!=0 (TM_ONREPLY_ROUTE).

Andrei Pelinescu-Onciul authored on 22/02/2010 13:49:37
Showing 1 changed files
... ...
@@ -47,11 +47,13 @@
47 47
  */
48 48
 #define REQUEST_ROUTE (1 << 0)
49 49
 #define FAILURE_ROUTE (1 << 1)
50
-#define ONREPLY_ROUTE (1 << 2)
50
+#define TM_ONREPLY_ROUTE (1 << 2)
51 51
 #define BRANCH_ROUTE  (1 << 3)
52 52
 #define ONSEND_ROUTE  (1 << 4)
53 53
 #define ERROR_ROUTE   (1 << 5)
54 54
 #define LOCAL_ROUTE   (1 << 6)
55
+#define CORE_ONREPLY_ROUTE (1 << 7)
56
+#define ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
55 57
 #define EVENT_ROUTE   REQUEST_ROUTE
56 58
 #define ANY_ROUTE     (0xFFFFFFFF)
57 59
 
... ...
@@ -68,7 +70,7 @@ extern int route_type;
68 70
 
69 71
 #define get_route_type()	route_type
70 72
 
71
-#define is_route_type(type) (route_type == (type))
73
+#define is_route_type(type) (route_type & (type))
72 74
 
73 75
 struct route_list{
74 76
 	struct action** rlist;
Browse code

route_type: branch and onsend route bugs corrected

- Branch and onsend routes did not restore the original
route_type after they have finished the execution,
so subsequent functions that need the route_type failed.
(For example t_relay() in the second branch did not work
if branch or onsend routes of the first branch were executed.)
- get_route_type() macro added.

Miklos Tirpak authored on 03/06/2009 08:38:42
Showing 1 changed files
... ...
@@ -66,6 +66,8 @@ extern int route_type;
66 66
 		route_type = (type); \
67 67
 	} while(0)
68 68
 
69
+#define get_route_type()	route_type
70
+
69 71
 #define is_route_type(type) (route_type == (type))
70 72
 
71 73
 struct route_list{
Browse code

core: support for event_route

- a new type of route available in config
- prototye: event_route[groupid:eventid]
- groupid should be the name of the module that triggers the event
- eventid some meaningful short text describing the event
- the route is not executed from other routes, but internally when some
events happen
- to be used to get error_route and local_route K functionalities
- ex: event_route[core:request-parse-error]
- ex: event_route[tm:local-request]
- note: those are not implemented yet
- the approach has the benefit of not needing to alter the grammer if
new routes need to be defined
- still to-do:
- module that executes the event should export contraints of what
route type the functions must obey if used inside (for now
REQUEST_ROUTE functions can be used)
- first implementation is in htable module
- event route after all modules are initialized

Daniel-Constantin Mierla authored on 19/05/2009 16:55:12
Showing 1 changed files
... ...
@@ -52,6 +52,7 @@
52 52
 #define ONSEND_ROUTE  (1 << 4)
53 53
 #define ERROR_ROUTE   (1 << 5)
54 54
 #define LOCAL_ROUTE   (1 << 6)
55
+#define EVENT_ROUTE   REQUEST_ROUTE
55 56
 #define ANY_ROUTE     (0xFFFFFFFF)
56 57
 
57 58
 /* The value of this variable is one of the route types defined above and it
... ...
@@ -82,6 +83,7 @@ extern struct route_list onreply_rt;
82 83
 extern struct route_list failure_rt;
83 84
 extern struct route_list branch_rt;
84 85
 extern struct route_list onsend_rt;
86
+extern struct route_list event_rt;
85 87
 
86 88
 /* script optimization level */
87 89
 extern int scr_opt_lev;
Browse code

define ANY_ROUTE

- defined as 0xffffffff to match any route type

Daniel-Constantin Mierla authored on 27/04/2009 11:00:44
Showing 1 changed files
... ...
@@ -52,6 +52,7 @@
52 52
 #define ONSEND_ROUTE  (1 << 4)
53 53
 #define ERROR_ROUTE   (1 << 5)
54 54
 #define LOCAL_ROUTE   (1 << 6)
55
+#define ANY_ROUTE     (0xFFFFFFFF)
55 56
 
56 57
 /* The value of this variable is one of the route types defined above and it
57 58
  * determines the type of the route being executed, module functions can use
Browse code

New global variable route_type with the type of route being executed

This patch adds a new global variable called route_type. This value of
the variable is one of the *_ROUTE values defined in route.h. Those
defines have been moved from sr_module.h, originally they were used
as the flags for functions in module exports but we can use them here
for the global route_type variable as well.

The variable route_type is meant to be used by module functions, in
some cases they need to test for the type of the route being executed
to know what functions are available and whether the sip message being
process is stored in shared memory or private memory.

The tm module contained similar variable (which was exported through
the tm module API), but it makes more sense to keep it in sip-router
core, because the core can execute two route types, the request route
and the onreply route, even if the tm module is not used.

Jan Janak authored on 07/03/2009 00:42:04
Showing 1 changed files
... ...
@@ -42,6 +42,29 @@
42 42
 
43 43
 /*#include "cfg_parser.h" */
44 44
 
45
+/* Various types of route sections, make sure that the values defined in the
46
+ * macros below occupy disjunct bits so that they can also be used as flags
47
+ */
48
+#define REQUEST_ROUTE (1 << 0)
49
+#define FAILURE_ROUTE (1 << 1)
50
+#define ONREPLY_ROUTE (1 << 2)
51
+#define BRANCH_ROUTE  (1 << 3)
52
+#define ONSEND_ROUTE  (1 << 4)
53
+#define ERROR_ROUTE   (1 << 5)
54
+#define LOCAL_ROUTE   (1 << 6)
55
+
56
+/* The value of this variable is one of the route types defined above and it
57
+ * determines the type of the route being executed, module functions can use
58
+ * this value to determine the type of the route they are being executed in
59
+ */
60
+extern int route_type;
61
+
62
+#define set_route_type(type) \
63
+	do {					 \
64
+		route_type = (type); \
65
+	} while(0)
66
+
67
+#define is_route_type(type) (route_type == (type))
45 68
 
46 69
 struct route_list{
47 70
 	struct action** rlist;
Browse code

script engine: expression optimizations

- optimizations for logical expressions
( exp(rval(v)) -> exp(v), exp_elem(x, rval(v)) -> exp_elem(x, v) )
- comp_rve() fix

Andrei Pelinescu-Onciul authored on 10/12/2008 13:43:58
Showing 1 changed files
... ...
@@ -59,6 +59,8 @@ extern struct route_list failure_rt;
59 59
 extern struct route_list branch_rt;
60 60
 extern struct route_list onsend_rt;
61 61
 
62
+/* script optimization level */
63
+extern int scr_opt_lev;
62 64
 
63 65
 int init_routes();
64 66
 void destroy_routes();
Browse code

script engine: lvalue/rvalue assignment and fixups

Andrei Pelinescu-Onciul authored on 04/12/2008 00:12:46
Showing 1 changed files
... ...
@@ -73,7 +73,9 @@ int fix_rls();
73 73
 int eval_expr(struct run_act_ctx* h, struct expr* e, struct sip_msg* msg);
74 74
 
75 75
 
76
-
76
+/* fixup functions*/
77
+int fix_actions(struct action* a);
78
+int fix_expr(struct expr* exp);
77 79
 
78 80
 
79 81
 
Browse code

- fix: run_actions() & friends used some static variables to save some internal state (run_flags, last_ret a.s.o). Problems would appear when different routes (e.g. main route and an onsend route) would execute in the same process (e.g. an onsend route return would exit also the main route). Now run_actions(), do_action() and eval_expr() take an extra "context" parameter (which must be initialized before use).

Andrei Pelinescu-Onciul authored on 14/06/2007 23:12:26
Showing 1 changed files
... ...
@@ -36,6 +36,7 @@
36 36
 #include "config.h"
37 37
 #include "error.h"
38 38
 #include "route_struct.h"
39
+#include "action.h"
39 40
 #include "parser/msg_parser.h"
40 41
 #include "str_hash.h"
41 42
 
... ...
@@ -69,7 +70,7 @@ int add_actions(struct action* a, struct action** head);
69 70
 void print_rls();
70 71
 int fix_rls();
71 72
 
72
-int eval_expr(struct expr* e, struct sip_msg* msg);
73
+int eval_expr(struct run_act_ctx* h, struct expr* e, struct sip_msg* msg);
73 74
 
74 75
 
75 76
 
Browse code

- hash cleanup/cosmetics: - use the "raw" hash functions from hashes.h as base for the other hashes (e.g. tm hash). This doesn't change the hash functions, just removes some extra copies. - split old hashes.h into hashes.h (more generic stuff) and str_hash.h - new_hash() is safer now (nobody uses it, but just in case...)

Andrei Pelinescu-Onciul authored on 13/12/2006 22:50:46
Showing 1 changed files
... ...
@@ -37,7 +37,7 @@
37 37
 #include "error.h"
38 38
 #include "route_struct.h"
39 39
 #include "parser/msg_parser.h"
40
-#include "hashes.h"
40
+#include "str_hash.h"
41 41
 
42 42
 /*#include "cfg_parser.h" */
43 43
 
Browse code

- added route_lookup (like route_get(), but doesn't create a new route if not found) -- patch from Miklos Tirpak <miklos@iptel.org>

-fixed route_new_list() not init. realloc'ed chunk bug, found by
Bogdan Pintea <bogdan.pintea@iptel.org>

Andrei Pelinescu-Onciul authored on 30/05/2006 19:20:51
Showing 1 changed files
... ...
@@ -62,6 +62,7 @@ extern struct route_list onsend_rt;
62 62
 int init_routes();
63 63
 void destroy_routes();
64 64
 int route_get(struct route_list* rt, char* name);
65
+int route_lookup(struct route_list* rt, char* name);
65 66
 
66 67
 void push(struct action* a, struct action** head);
67 68
 int add_actions(struct action* a, struct action** head);
Browse code

- tcp accounting: connections_no decreased on error - parse_uri: missing break for r2 - tm: enabled tm stats

Andrei Pelinescu-Onciul authored on 24/02/2006 18:35:35
Showing 1 changed files
... ...
@@ -45,7 +45,7 @@
45 45
 struct route_list{
46 46
 	struct action** rlist;
47 47
 	int idx; /* first empty entry */ 
48
-	int entries; /* total number if entries */
48
+	int entries; /* total number of entries */
49 49
 	struct str_hash_table names; /* name to route index mappings */
50 50
 };
51 51
 
Browse code

- named routes support in core and tm (t_on_*). e.g.: route{ route(bar); t_on_reply("reply_route"); route(1); # == route("1") ... } route[foo]{ ... } route["bar"]{ ... } route[1]{ ... } onreply_route[reply_route]{ ... }

route(bar);

Andrei Pelinescu-Onciul authored on 07/02/2006 01:14:57
Showing 1 changed files
... ...
@@ -37,22 +37,35 @@
37 37
 #include "error.h"
38 38
 #include "route_struct.h"
39 39
 #include "parser/msg_parser.h"
40
+#include "hashes.h"
40 41
 
41 42
 /*#include "cfg_parser.h" */
42 43
 
43 44
 
45
+struct route_list{
46
+	struct action** rlist;
47
+	int idx; /* first empty entry */ 
48
+	int entries; /* total number if entries */
49
+	struct str_hash_table names; /* name to route index mappings */
50
+};
51
+
52
+
44 53
 /* main "script table" */
45
-extern struct action* rlist[RT_NO];
54
+extern struct route_list main_rt;
46 55
 /* main reply route table */
47
-extern struct action* onreply_rlist[ONREPLY_RT_NO];
48
-extern struct action* failure_rlist[FAILURE_RT_NO];
49
-extern struct action* branch_rlist[BRANCH_RT_NO];
50
-extern struct action* onsend_rlist[ONSEND_RT_NO];
56
+extern struct route_list onreply_rt;
57
+extern struct route_list failure_rt;
58
+extern struct route_list branch_rt;
59
+extern struct route_list onsend_rt;
60
+
51 61
 
62
+int init_routes();
63
+void destroy_routes();
64
+int route_get(struct route_list* rt, char* name);
52 65
 
53 66
 void push(struct action* a, struct action** head);
54 67
 int add_actions(struct action* a, struct action** head);
55
-void print_rl();
68
+void print_rls();
56 69
 int fix_rls();
57 70
 
58 71
 int eval_expr(struct expr* e, struct sip_msg* msg);
Browse code

- tm: t_relay will not stop script execution anymore in case of send error - added onsend_route: special route executed before forwarding a message, when the final destination is known. Only a limited number of commands are allowed ( if (expr) {}else{}, drop, flags manipulations, send(), log()). Usefull to catch more easily unauthorized attempts to relay/bounce message to protected destinations (e.g PSTN gateways) - new onsend checks: to_{ip,port}, snd_{ip,port,proto,af}. to= to whom the message will be sent to. snd=how ser will send it (socket ip/port,proto,af). - msg:len in onsend_route will containg the "new" message len - textops: search() onsend_route support (it will use the new, freshly constructed message and not the original one)

Example:
onsend_route{
# allow messages from 10.0.0.0/8 to 1.2.3.4 only if flag 10 was set
# from the script
if (to_ip==1.2.3.4 && src_ip==10.0.0.0/8 && !isflagset(10)){
log("msg dropped\n");
drop;
}
# drop all messages that contain banned_user in from
if (search("From|f[ ]*:.*banned_user")) drop;
}

Andrei Pelinescu-Onciul authored on 11/12/2005 22:46:38
Showing 1 changed files
... ...
@@ -44,9 +44,10 @@
44 44
 /* main "script table" */
45 45
 extern struct action* rlist[RT_NO];
46 46
 /* main reply route table */
47
-extern struct action* onreply_rlist[RT_NO];
48
-extern struct action* failure_rlist[RT_NO];
49
-extern struct action* branch_rlist[RT_NO];
47
+extern struct action* onreply_rlist[ONREPLY_RT_NO];
48
+extern struct action* failure_rlist[FAILURE_RT_NO];
49
+extern struct action* branch_rlist[BRANCH_RT_NO];
50
+extern struct action* onsend_rlist[ONSEND_RT_NO];
50 51
 
51 52
 
52 53
 void push(struct action* a, struct action** head);
Browse code

- Suppor for branch_route sections in the configuration file.

Jan Janak authored on 18/08/2005 15:46:46
Showing 1 changed files
... ...
@@ -46,6 +46,7 @@ extern struct action* rlist[RT_NO];
46 46
 /* main reply route table */
47 47
 extern struct action* onreply_rlist[RT_NO];
48 48
 extern struct action* failure_rlist[RT_NO];
49
+extern struct action* branch_rlist[RT_NO];
49 50
 
50 51
 
51 52
 void push(struct action* a, struct action** head);
Browse code

- Spelling checked - READMEs updated

Jan Janak authored on 24/08/2004 08:45:09
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * $Id$
3 3
  *
4
- * Copyright (C) 2001-2003 Fhg Fokus
4
+ * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6 6
  * This file is part of ser, a free SIP server.
7 7
  *
Browse code

s/reply_route/failure_route, onreply_route introduced

Jiri Kuthan authored on 07/04/2003 06:36:56
Showing 1 changed files
... ...
@@ -44,7 +44,8 @@
44 44
 /* main "script table" */
45 45
 extern struct action* rlist[RT_NO];
46 46
 /* main reply route table */
47
-extern struct action* reply_rlist[RT_NO];
47
+extern struct action* onreply_rlist[RT_NO];
48
+extern struct action* failure_rlist[RT_NO];
48 49
 
49 50
 
50 51
 void push(struct action* a, struct action** head);
Browse code

GPLization banner introduced to *.[hc] files

Jiri Kuthan authored on 19/09/2002 12:23:52
Showing 1 changed files
... ...
@@ -1,7 +1,31 @@
1 1
 /*
2 2
  * $Id$
3
+ *
4
+ * Copyright (C) 2001-2003 Fhg Fokus
5
+ *
6
+ * This file is part of ser, a free SIP server.
7
+ *
8
+ * ser is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * For a license to use the ser software under conditions
14
+ * other than those described here, or to purchase support for this
15
+ * software, please contact iptel.org by e-mail at the following addresses:
16
+ *    info@iptel.org
17
+ *
18
+ * ser is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License 
24
+ * along with this program; if not, write to the Free Software 
25
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
3 26
  */
4 27
 
28
+
5 29
 #ifndef route_h
6 30
 #define route_h
7 31
 
Browse code

bignag change -- lot of things primarily added in relationship with refurbushing TM; see [sr] archive (2002-08-14) -- "ser update" and "TM update" for a long list of details

Jiri Kuthan authored on 15/08/2002 08:13:29
Showing 1 changed files
... ...
@@ -19,6 +19,8 @@
19 19
 
20 20
 /* main "script table" */
21 21
 extern struct action* rlist[RT_NO];
22
+/* main reply route table */
23
+extern struct action* reply_rlist[RT_NO];
22 24
 
23 25
 
24 26
 void push(struct action* a, struct action** head);
Browse code

TM callbacks, acc, flags

Jiri Kuthan authored on 13/05/2002 01:15:40
Showing 1 changed files
... ...
@@ -12,7 +12,7 @@
12 12
 #include "config.h"
13 13
 #include "error.h"
14 14
 #include "route_struct.h"
15
-#include "msg_parser.h"
15
+#include "parser/msg_parser.h"
16 16
 
17 17
 /*#include "cfg_parser.h" */
18 18
 
Browse code

- new config style: if expr cmd else cmd; - expr can now contain commands (e.g: forward("proxy") && src_ip==1.2.3.4) - introduced boolean values in expr. (yes/no; true/false; on/off; 1/0) e.g.: if ( true ) log("..."); - changed name to ser, ser.cfg - bumped ver. no (0.7)

Andrei Pelinescu-Onciul authored on 11/10/2001 23:03:42
Showing 1 changed files
... ...
@@ -17,31 +17,17 @@
17 17
 /*#include "cfg_parser.h" */
18 18
 
19 19
 
20
+/* main "script table" */
21
+extern struct action* rlist[RT_NO];
20 22
 
21
-struct route_elem{
22
-	struct route_elem* next;
23 23
 
24
-	struct expr* condition;
25
-	struct action* actions;
26
-
27
-	int ok; /* set to 0 if an error was found sendig a pkt*/
28
-	/*counters*/
29
-	int errors;
30
-	int tx;
31
-	int tx_bytes;
32
-};
33
-
34
-/* main "routing table" */
35
-extern struct route_elem* rlist[RT_NO];
24
+void push(struct action* a, struct action** head);
25
+int add_actions(struct action* a, struct action** head);
26
+void print_rl();
27
+int fix_rls();
36 28
 
29
+int eval_expr(struct expr* e, struct sip_msg* msg);
37 30
 
38
-void free_re(struct route_elem* re);
39
-struct route_elem* init_re();
40
-void push(struct route_elem* re, struct route_elem** head);
41
-void clear_rlist(struct route_elem** rl);
42
-int add_rule(struct expr* e, struct action* a, struct route_elem** head);
43
-struct route_elem* route_match(struct sip_msg* msg,struct route_elem** rl);
44
-void print_rl();
45 31
 
46 32
 
47 33
 
Browse code

- still to do action,c

Andrei Pelinescu-Onciul authored on 20/09/2001 17:17:26
Showing 1 changed files
... ...
@@ -9,20 +9,21 @@
9 9
 #include <regex.h>
10 10
 #include <netdb.h>
11 11
 
12
-#include "cfg_parser.h"
12
+#include "config.h"
13
+#include "error.h"
14
+#include "route_struct.h"
15
+#include "msg_parser.h"
16
+
17
+/*#include "cfg_parser.h" */
18
+
13 19
 
14
-#define E_OUT_OF_MEM  -2
15
-#define E_BAD_RE      -3
16
-#define E_BAD_ADDRESS -4
17 20
 
18 21
 struct route_elem{
19 22
 	struct route_elem* next;
20
-	regex_t method;
21
-	regex_t uri;
22
-	struct hostent host;
23
-	int current_addr_idx;
24
-	short int port;
25
-	short int reserved; /* pad */
23
+
24
+	struct expr* condition;
25
+	struct action* actions;
26
+
26 27
 	int ok; /* set to 0 if an error was found sendig a pkt*/
27 28
 	/*counters*/
28 29
 	int errors;
... ...
@@ -31,15 +32,16 @@ struct route_elem{
31 32
 };
32 33
 
33 34
 /* main "routing table" */
34
-extern struct route_elem* rlist;
35
+extern struct route_elem* rlist[RT_NO];
35 36
 
36 37
 
37 38
 void free_re(struct route_elem* re);
38 39
 struct route_elem* init_re();
39 40
 void push(struct route_elem* re, struct route_elem** head);
40 41
 void clear_rlist(struct route_elem** rl);
41
-int add_rule(struct cfg_line* cl, struct route_elem** head);
42
-struct route_elem* route_match(char* method, char* uri, struct route_elem** rl);void print_rl();
42
+int add_rule(struct expr* e, struct action* a, struct route_elem** head);
43
+struct route_elem* route_match(struct sip_msg* msg,struct route_elem** rl);
44
+void print_rl();
43 45
 
44 46
 
45 47
 
Browse code

First working release

Andrei Pelinescu-Onciul authored on 04/09/2001 20:55:41
Showing 1 changed files
... ...
@@ -21,6 +21,8 @@ struct route_elem{
21 21
 	regex_t uri;
22 22
 	struct hostent host;
23 23
 	int current_addr_idx;
24
+	short int port;
25
+	short int reserved; /* pad */
24 26
 	int ok; /* set to 0 if an error was found sendig a pkt*/
25 27
 	/*counters*/
26 28
 	int errors;
Browse code

Initial revision

Andrei Pelinescu-Onciul authored on 03/09/2001 21:27:11
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,46 @@
1
+/*
2
+ * $Id$
3
+ */
4
+
5
+#ifndef route_h
6
+#define route_h
7
+
8
+#include <sys/types.h>
9
+#include <regex.h>
10
+#include <netdb.h>
11
+
12
+#include "cfg_parser.h"
13
+
14
+#define E_OUT_OF_MEM  -2
15
+#define E_BAD_RE      -3
16
+#define E_BAD_ADDRESS -4
17
+
18
+struct route_elem{
19
+	struct route_elem* next;
20
+	regex_t method;
21
+	regex_t uri;
22
+	struct hostent host;
23
+	int current_addr_idx;
24
+	int ok; /* set to 0 if an error was found sendig a pkt*/
25
+	/*counters*/
26
+	int errors;
27
+	int tx;
28
+	int tx_bytes;
29
+};
30
+
31
+/* main "routing table" */
32
+extern struct route_elem* rlist;
33
+
34
+
35
+void free_re(struct route_elem* re);
36
+struct route_elem* init_re();
37
+void push(struct route_elem* re, struct route_elem** head);
38
+void clear_rlist(struct route_elem** rl);
39
+int add_rule(struct cfg_line* cl, struct route_elem** head);
40
+struct route_elem* route_match(char* method, char* uri, struct route_elem** rl);void print_rl();
41
+
42
+
43
+
44
+
45
+
46
+#endif