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,221 +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 :: Route structure
23
- * \ingroup core
24
- * Module: \ref core
25
- * \author andrei, bogdan
26
- */
27
-
28
-#ifndef route_struct_h
29
-#define route_struct_h
30
-
31
-#include <sys/types.h>
32
-#include <regex.h>
33
-#include "select.h"
34
-#include "usr_avp.h"
35
-
36
-#define EXPR_DROP -127  /* used only by the expression and if evaluator */
37
-/*
38
- * Other important values (no macros for them yet):
39
- * expr true = 1
40
- * expr false = 0 (used only inside the expression and if evaluator)
41
- *
42
- * action continue  or if used in condition true = 1
43
- * action drop/quit/stop script processing = 0
44
- * action error or if used in condition false = -1 (<0 and !=EXPR_DROP)
45
- *
46
- */
47
-
48
-
49
-/* expression type */
50
-enum expr_type { EXP_T=1, ELEM_T };
51
-enum expr_op {
52
-	/* expression operator if type==EXP_T */
53
-	LOGAND_OP=1, LOGOR_OP, NOT_OP, BINAND_OP, BINOR_OP,
54
-	/* expression operator if type==ELEM_T */
55
-	EQUAL_OP=10, MATCH_OP, GT_OP, LT_OP, GTE_OP, LTE_OP, DIFF_OP, NO_OP
56
-};
57
-/* expression left member "special" type (if type==ELEM_T)
58
-  (start at 51 for debugging purposes: it's better to not overlap with 
59
-   expr_r_type)
60
-*/
61
-enum _expr_l_type{
62
-	   METHOD_O=51, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
63
-	   DSTIP_O, DSTPORT_O, PROTO_O, AF_O, MSGLEN_O, ACTION_O,
64
-	   NUMBER_O, AVP_O, SNDIP_O, SNDPORT_O, TOIP_O, TOPORT_O, SNDPROTO_O,
65
-	   SNDAF_O, RETCODE_O, SELECT_O, PVAR_O, RVEXP_O, SELECT_UNFIXED_O};
66
-/* action types */
67
-enum action_type{
68
-		FORWARD_T=1, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
69
-		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
70
-		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T, SET_HOSTALL_T,
71
-		SET_USERPHONE_T,
72
-		IF_T, SWITCH_T /* only until fixup*/,
73
-		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T, MATCH_COND_T, WHILE_T,
74
-		/* module function calls with string only parameters */
75
-		MODULE0_T, MODULE1_T, MODULE2_T, MODULE3_T, MODULE4_T, MODULE5_T,
76
-		MODULE6_T, MODULEX_T,
77
-		/* module function calls, that have some RVE parameters */
78
-		MODULE1_RVE_T, MODULE2_RVE_T, MODULE3_RVE_T,
79
-		MODULE4_RVE_T, MODULE5_RVE_T, MODULE6_RVE_T, MODULEX_RVE_T,
80
-		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
81
-		AVPFLAG_OPER_T,
82
-		LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
83
-		APPEND_BRANCH_T, REMOVE_BRANCH_T, CLEAR_BRANCHES_T,
84
-		REVERT_URI_T,
85
-		FORWARD_TCP_T,
86
-		FORWARD_UDP_T,
87
-		FORWARD_TLS_T,
88
-		FORWARD_SCTP_T,
89
-		FORCE_RPORT_T,
90
-		ADD_LOCAL_RPORT_T,
91
-		SET_ADV_ADDR_T,
92
-		SET_ADV_PORT_T,
93
-		FORCE_TCP_ALIAS_T,
94
-		LOAD_AVP_T,
95
-		AVP_TO_URI_T,
96
-		FORCE_SEND_SOCKET_T,
97
-		ASSIGN_T,
98
-		ADD_T,
99
-		UDP_MTU_TRY_PROTO_T,
100
-		SET_FWD_NO_CONNECT_T,
101
-		SET_RPL_NO_CONNECT_T,
102
-		SET_FWD_CLOSE_T,
103
-		SET_RPL_CLOSE_T,
104
-		CFG_SELECT_T,
105
-		CFG_RESET_T
106
-};
107
-
108
-#define is_mod_func(a) ((a)->type>=MODULE0_T && (a)->type<=MODULEX_RVE_T)
109
-
110
-/* parameter types for actions or types for expression right operands
111
-   (WARNING right operands only, not working for left operands) */
112
-enum _operand_subtype{
113
-		NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
114
-		EXPR_ST, ACTIONS_ST, MODEXP_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
115
-		MYSELF_ST, STR_ST, SOCKID_ST, SOCKETINFO_ST, ACTION_ST, AVP_ST,
116
-		SELECT_ST, PVAR_ST,
117
-		LVAL_ST,  RVE_ST,
118
-		RETCODE_ST, CASE_ST,
119
-		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST,
120
-		SELECT_UNFIXED_ST,
121
-		STRING_RVE_ST /* RVE converted to a string (fparam hack) */,
122
-		RVE_FREE_FIXUP_ST /* (str)RVE fixed up by a reversable fixup */,
123
-		FPARAM_DYN_ST /* temporary only (fparam hack) */,
124
-		CFG_GROUP_ST
125
-};
126
-
127
-typedef enum _expr_l_type expr_l_type;
128
-typedef enum _operand_subtype expr_r_type;
129
-typedef enum _operand_subtype action_param_type;
130
-
131
-/* run flags */
132
-#define EXIT_R_F   1
133
-#define RETURN_R_F 2
134
-#define BREAK_R_F  4
135
-#define DROP_R_F   8
136
-#define IGNORE_ON_BREAK_R_F 256
137
-
138
-
139
-struct cfg_pos{
140
-	int s_line;
141
-	int e_line;
142
-	unsigned short s_col;
143
-	unsigned short e_col;
144
-	char *fname;
145
-	char *rname;
146
-};
147
-
148
-
149
-/* Expression operand */
150
-union exp_op {
151
-	void* param;
152
-	long numval; /* must have the same size as a void*/
153
-	struct expr* expr;
154
-	char* string;
155
-	avp_spec_t* attr;
156
-	select_t* select;
157
-	regex_t* re;
158
-	struct net* net;
159
-	struct _str str;
160
-};
161
-
162
-struct expr{
163
-	enum expr_type type; /* exp, exp_elem */
164
-	enum expr_op op; /* and, or, not | ==,  =~ */
165
-	expr_l_type l_type;
166
-	expr_r_type r_type;
167
-	union exp_op l;
168
-	union exp_op r;
169
-};
170
-
171
-typedef struct {
172
-	action_param_type type;
173
-	union {
174
-		long number;
175
-		char* string;
176
-		struct _str str;
177
-		void* data;
178
-		avp_spec_t* attr;
179
-		select_t* select;
180
-	} u;
181
-} action_u_t;
182
-
183
-/* maximum internal array/params
184
- * for module function calls val[0] and val[1] store a pointer to the
185
- * function and the number of params, the rest are the function params 
186
- */
187
-#define MAX_ACTIONS (2+6)
188
-
189
-struct action{
190
-	int cline;
191
-	char *cfile;
192
-	char *rname;
193
-	enum action_type type;  /* forward, drop, log, send ...*/
194
-	int count;
195
-	struct action* next;
196
-	action_u_t val[MAX_ACTIONS];
197
-};
198
-
199
-typedef struct action cfg_action_t;
200
-
201
-struct expr* mk_exp(int op, struct expr* left, struct expr* right);
202
-struct expr* mk_elem(int op, expr_l_type ltype, void* lparam,
203
-							 expr_r_type rtype, void* rparam);
204
-
205
-/* @param type - type of the action
206
-   @param count - count of couples {type,val} (variable number of parameters)*/
207
-struct action* mk_action(enum action_type type, int count, ...);
208
-
209
-struct action* append_action(struct action* a, struct action* b);
210
-
211
-void print_action(struct action* a);
212
-void print_actions(struct action* a);
213
-void print_expr(struct expr* exp);
214
-
215
-/** joins to cfg file positions into a new one. */
216
-void cfg_pos_join(struct cfg_pos* res,
217
-							struct cfg_pos* pos1, struct cfg_pos* pos2);
218
-
219
-struct action *get_action_from_param(void **param, int param_no);
220
-#endif
221
-
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,22 +1,14 @@
1 1
 /*
2
- * $Id$
3
- *
4
- *
5 2
  * Copyright (C) 2001-2003 FhG Fokus
6 3
  *
7
- * This file is part of ser, a free SIP server.
4
+ * This file is part of Kamailio, a free SIP server.
8 5
  *
9
- * ser is free software; you can redistribute it and/or modify
6
+ * Kamailio is free software; you can redistribute it and/or modify
10 7
  * it under the terms of the GNU General Public License as published by
11 8
  * the Free Software Foundation; either version 2 of the License, or
12 9
  * (at your option) any later version
13 10
  *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
11
+ * Kamailio is distributed in the hope that it will be useful,
20 12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 14
  * GNU General Public License for more details.
... ...
@@ -25,20 +17,14 @@
25 17
  * along with this program; if not, write to the Free Software
26 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
27 19
  */
28
-/* History:
29
- * --------
30
- *
31
- *  2003-04-12  FORCE_RPORT_T added (andrei)
32
- *  2003-04-22  strip_tail added (jiri)
33
- *  2003-10-10  >,<,>=,<=, != and MSGLEN_O added (andrei)
34
- *  2003-10-28  FORCE_TCP_ALIAS added (andrei)
35
- *  2004-02-24  added LOAD_AVP_T and AVP_TO_URI_T (bogdan)
36
- *  2005-12-11  added SND{IP,PORT,PROTO,AF}_O & TO{IP,PORT}_O (andrei)
37
- *  2005-12-19  select framework added SELECT_O and SELECT_ST (mma)
38
- *  2008-12-17  added UDP_MTU_TRY_PROTO_T (andrei)
20
+/*!
21
+ * \file
22
+ * \brief Kamailio core :: Route structure
23
+ * \ingroup core
24
+ * Module: \ref core
25
+ * \author andrei, bogdan
39 26
  */
40 27
 
41
-
42 28
 #ifndef route_struct_h
43 29
 #define route_struct_h
44 30
 
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
... ...
@@ -23,7 +23,7 @@
23 23
  *
24 24
  * You should have received a copy of the GNU General Public License
25 25
  * along with this program; if not, write to the Free Software
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
27 27
  */
28 28
 /* History:
29 29
  * --------
Browse code

core: add route name to action struct

Victor Seva authored on 07/06/2014 07:19:03
Showing 1 changed files
... ...
@@ -156,6 +156,7 @@ struct cfg_pos{
156 156
 	unsigned short s_col;
157 157
 	unsigned short e_col;
158 158
 	char *fname;
159
+	char *rname;
159 160
 };
160 161
 
161 162
 
... ...
@@ -202,6 +203,7 @@ typedef struct {
202 203
 struct action{
203 204
 	int cline;
204 205
 	char *cfile;
206
+	char *rname;
205 207
 	enum action_type type;  /* forward, drop, log, send ...*/
206 208
 	int count;
207 209
 	struct action* next;
Browse code

core/corex: move send()/send_tcp() to corex module

As suggested by miconda on sr-dev, move send() and send_tcp() out of core
and into the new corex module in order to make them support pseudo variables.
This changes:

- drops SEND and SEND_TCP tokens from config parser
- remove related config parser code relying on SEND_T and SEND_TCP_T
- augment corex module to provide the functions removed from core
- update corex docs

Richard Fuchs authored on 30/11/2012 19:00:09
Showing 1 changed files
... ...
@@ -79,7 +79,7 @@ enum _expr_l_type{
79 79
 	   SNDAF_O, RETCODE_O, SELECT_O, PVAR_O, RVEXP_O, SELECT_UNFIXED_O};
80 80
 /* action types */
81 81
 enum action_type{
82
-		FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
82
+		FORWARD_T=1, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
83 83
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
84 84
 		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T, SET_HOSTALL_T,
85 85
 		SET_USERPHONE_T,
... ...
@@ -100,7 +100,6 @@ enum action_type{
100 100
 		FORWARD_UDP_T,
101 101
 		FORWARD_TLS_T,
102 102
 		FORWARD_SCTP_T,
103
-		SEND_TCP_T,
104 103
 		FORCE_RPORT_T,
105 104
 		ADD_LOCAL_RPORT_T,
106 105
 		SET_ADV_ADDR_T,
Browse code

core: Removed unused enum (crept in during WebSocket implementation)

Peter Dunkley authored on 12/07/2012 21:45:32
Showing 1 changed files
... ...
@@ -136,8 +136,7 @@ enum _operand_subtype{
136 136
 		STRING_RVE_ST /* RVE converted to a string (fparam hack) */,
137 137
 		RVE_FREE_FIXUP_ST /* (str)RVE fixed up by a reversable fixup */,
138 138
 		FPARAM_DYN_ST /* temporary only (fparam hack) */,
139
-		CFG_GROUP_ST,
140
-		WEBSOCKET_ST
139
+		CFG_GROUP_ST
141 140
 };
142 141
 
143 142
 typedef enum _expr_l_type expr_l_type;
Browse code

core: added support for WS keyword for use in conditionals with proto and snd_proto

Peter Dunkley authored on 28/06/2012 16:57:44
Showing 1 changed files
... ...
@@ -136,7 +136,8 @@ enum _operand_subtype{
136 136
 		STRING_RVE_ST /* RVE converted to a string (fparam hack) */,
137 137
 		RVE_FREE_FIXUP_ST /* (str)RVE fixed up by a reversable fixup */,
138 138
 		FPARAM_DYN_ST /* temporary only (fparam hack) */,
139
-		CFG_GROUP_ST
139
+		CFG_GROUP_ST,
140
+		WEBSOCKET_ST
140 141
 };
141 142
 
142 143
 typedef enum _expr_l_type expr_l_type;
Browse code

core: new parameters to control and alert on time consuming ops

- latency_log - log level to print the messages related to latency
- latency_limit_db - limit of latency in ms for db operations. If a db
operation executed via DB API v1 takes longer that its value, a
message is printed in the logs, showing the first 50 characters of the
db query
- latency_limit_action - limit of latency in ms for config actions. If a
config action executed by cfg interpreter takes longer than its value,
a message is printed in the logs, showing config path, line and action
name when it is a module function, as well as intenal action id

Daniel-Constantin Mierla authored on 25/03/2012 11:39:20
Showing 1 changed files
... ...
@@ -119,6 +119,9 @@ enum action_type{
119 119
 		CFG_SELECT_T,
120 120
 		CFG_RESET_T
121 121
 };
122
+
123
+#define is_mod_func(a) ((a)->type>=MODULE0_T && (a)->type<=MODULEX_RVE_T)
124
+
122 125
 /* parameter types for actions or types for expression right operands
123 126
    (WARNING right operands only, not working for left operands) */
124 127
 enum _operand_subtype{
Browse code

core: add functions remove_branch(int) and clear_branches()

remove_branch(int) - removes the specified branch from the destination set.
If the parameter is absent, the last branch is removed.

clear_branches() - empties the destination set.

Alex Hermann authored on 05/08/2011 12:49:16
Showing 1 changed files
... ...
@@ -94,7 +94,7 @@ enum action_type{
94 94
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
95 95
 		AVPFLAG_OPER_T,
96 96
 		LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
97
-		APPEND_BRANCH_T,
97
+		APPEND_BRANCH_T, REMOVE_BRANCH_T, CLEAR_BRANCHES_T,
98 98
 		REVERT_URI_T,
99 99
 		FORWARD_TCP_T,
100 100
 		FORWARD_UDP_T,
Browse code

core: typedef'ed struct action to cfg_action_t

Daniel-Constantin Mierla authored on 26/06/2011 09:26:48
Showing 1 changed files
... ...
@@ -206,6 +206,8 @@ struct action{
206 206
 	action_u_t val[MAX_ACTIONS];
207 207
 };
208 208
 
209
+typedef struct action cfg_action_t;
210
+
209 211
 struct expr* mk_exp(int op, struct expr* left, struct expr* right);
210 212
 struct expr* mk_elem(int op, expr_l_type ltype, void* lparam,
211 213
 							 expr_r_type rtype, void* rparam);
Browse code

core: function to return action struct from param

- moved the function from xlog module to core to be used by other
modules
- get_action_from_param(param, param_no) can return the pointer to
action structure when the pointer to pointer param and param no is
provided (like in the fixup of module functions)

Daniel-Constantin Mierla authored on 25/06/2011 19:07:31
Showing 1 changed files
... ...
@@ -223,5 +223,7 @@ void print_expr(struct expr* exp);
223 223
 /** joins to cfg file positions into a new one. */
224 224
 void cfg_pos_join(struct cfg_pos* res,
225 225
 							struct cfg_pos* pos1, struct cfg_pos* pos2);
226
+
227
+struct action *get_action_from_param(void **param, int param_no);
226 228
 #endif
227 229
 
Browse code

Merge remote branch 'origin/tirpi/cfg_framework_multivalue'

* origin/tirpi/cfg_framework_multivalue: (33 commits)
cfg framework: fix uninitialized group_inst pointers
xmlrpc: scan resets the error code
cfg_rpc: group can be specified for cfg.list
cfg_rpc: cfg.set and cfg.set_delayed commands added
ctl: rpc->scan does not immediately send out errors
cfg_rpc: documentation update - group instances
cfg framework: multiple group instances is documented
cfg framework: timer must reset the handles more frequently
cfg framework: cfg_select() and cfg_reset() added
cfg framework: group handle can be moved runtime
cfg framework: group instance support in the script
cfg framework: apply the values in the order they are set
cfg framework: translate_pointer bugfix
cfg framework: apply additional var list bugfix
cfg framework: apply the additional variable list
cfg framework: group instance support before forking
cfg framework: CFG_GROUP_UNKNOWN group type
cfg framework: cfg_commit() log message fixes
cfg_db: updated to the cfg framework changes
cfg_db: updated to the cfg framework changes
...

Miklos Tirpak authored on 27/10/2010 11:03:59
Showing 0 changed files
Browse code

cfg framework: cfg_select() and cfg_reset() added

cfg_select("group_name", "var_name") can be used to move a group
handle to a specifig group instance in the script. Evey variable
access within that group will be made from the new group instance
until the handle is reset, practically until the end of the script
unless cfg_reset("group_name") is explicitely called.
This is true both for custom, module, and core variables, i.e. every
configuration group can have multiple set of values.

Miklos Tirpak authored on 04/10/2010 13:35:59
Showing 1 changed files
... ...
@@ -115,7 +115,9 @@ enum action_type{
115 115
 		SET_FWD_NO_CONNECT_T,
116 116
 		SET_RPL_NO_CONNECT_T,
117 117
 		SET_FWD_CLOSE_T,
118
-		SET_RPL_CLOSE_T
118
+		SET_RPL_CLOSE_T,
119
+		CFG_SELECT_T,
120
+		CFG_RESET_T
119 121
 };
120 122
 /* parameter types for actions or types for expression right operands
121 123
    (WARNING right operands only, not working for left operands) */
... ...
@@ -130,7 +132,8 @@ enum _operand_subtype{
130 132
 		SELECT_UNFIXED_ST,
131 133
 		STRING_RVE_ST /* RVE converted to a string (fparam hack) */,
132 134
 		RVE_FREE_FIXUP_ST /* (str)RVE fixed up by a reversable fixup */,
133
-		FPARAM_DYN_ST /* temporary only (fparam hack) */
135
+		FPARAM_DYN_ST /* temporary only (fparam hack) */,
136
+		CFG_GROUP_ST
134 137
 };
135 138
 
136 139
 typedef enum _expr_l_type expr_l_type;
Browse code

core: fix end-script commands in expr. leaks

When having commands that end the script immediately in
assignments (e.g. $foo = { drop; }) or in expressions
(e.g. if ($v + { drop; } > 0)), the script was terminated
immediately via longjmp. However this might leave some un-freed
variables.
This fix introduces a safe version of run_actions()
(run_actions_safe()) that will not use longjmp() to immediately
end the whole script on drop, returning instead to its caller.

Andrei Pelinescu-Onciul authored on 29/09/2010 14:30:40
Showing 1 changed files
... ...
@@ -142,6 +142,7 @@ typedef enum _operand_subtype action_param_type;
142 142
 #define RETURN_R_F 2
143 143
 #define BREAK_R_F  4
144 144
 #define DROP_R_F   8
145
+#define IGNORE_ON_BREAK_R_F 256
145 146
 
146 147
 
147 148
 struct cfg_pos{
Browse code

Merge remote branch 'origin/andrei/rve_f_params'

Automatic support for expressions or variables in lots of module
functions. It applies to all the module functions declared without
a fixup, with a fixup and the corresponding free_fixup function or
with a compatible ser or kamailio style standard fixup (declared
in sr_module.h or mod_fix.h).
E.g.: f($a, "b = " + $b); t_set_fr($v + 2 + $x).
t_set_fr($foo) (equivalent now with t_set_fr("$foo")).

If the expression is constant, then there is no restriction, all the
module functions can take it as parameter.
E.g.: f("7 *" +" 6 = " + 7 * 6) # equivalent to f("7 * 6 = 42")

* origin/andrei/rve_f_params: (21 commits)
NEWS: notes about expressions in function parameters
core: enable RVE fixup support when fixup_free is present
core: automatically fill known fixup_free functions
core: functions to get a fixup corresp. fixup_free function
core: k style fixup_free fixes
core: added generic fparam fixup_free functions
core: pvapi: added pv_spec_free_contents()
core: fix "unsigned" bug in sint2str*()
core: fix auto-deref. for vars in fparam fixups
perl(k): use sr31_cmd_export_t
app_python: use sr31_cmd_export_t
core: internal module interface changes
print(s): fparam fixup example
core: support for RVEs in fparam fixups
core: rval - don't use static buffer for int conversions
core: ut.* - BSD licence
core: ut.h: added sint2strbuf()
perl(k): update api calls: s/MODULE_T/MODULE2_T/
app_python: update api calls: s/MODULE_T/MODULE2_T
print(s): more module function examples
core: support for expressions/variables in function parameters

Conflicts:
NEWS
action.c
modules/app_python/python_msgobj.c
modules_k/perl/openserxs.xs
pkg/kamailio/debian-lenny
pvapi.c
route.c
route_struct.h
sr_module.c

Andrei Pelinescu-Onciul authored on 11/08/2010 20:18:06
Showing 0 changed files
Browse code

core: enable RVE fixup support when fixup_free is present

RVEs can now be used transparently in all module functions that
have registered free_fixup function or that have standard fixup
functions with known corresponding free_fixups. This means all the
module functions that use ser-like fparam style fixups
(sr_module.h) or kamailio style fixups (mod_fix.h).

E.g.:
texops(k):
$del="From";
remove_hf_re("^"+$del);
set_body($body, $content_type);

Andrei Pelinescu-Onciul authored on 05/08/2010 22:22:05
Showing 1 changed files
... ...
@@ -128,6 +128,7 @@ enum _operand_subtype{
128 128
 		RETCODE_ST, CASE_ST,
129 129
 		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST,
130 130
 		STRING_RVE_ST /* RVE converted to a string (fparam hack) */,
131
+		RVE_FREE_FIXUP_ST /* (str)RVE fixed up by a reversable fixup */,
131 132
 		FPARAM_DYN_ST /* temporary only (fparam hack) */
132 133
 };
133 134
 
Browse code

core: fix auto-deref. for vars in fparam fixups

When an expression was fixed-up at runtime by the core and the
module had fparam-type fixup, the fparam fixup re-evaluated
the result, e.g.:
$bar=test;
$foo="$bar";
f($foo) => "test" instead of "$bar".

Now all the RVE-enabled fparam fixups will avoid this case.

Andrei Pelinescu-Onciul authored on 04/08/2010 13:51:46
Showing 1 changed files
... ...
@@ -127,7 +127,8 @@ enum _operand_subtype{
127 127
 		LVAL_ST,  RVE_ST,
128 128
 		RETCODE_ST, CASE_ST,
129 129
 		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST,
130
-		FPARAM_DYN_ST /* temporary only */
130
+		STRING_RVE_ST /* RVE converted to a string (fparam hack) */,
131
+		FPARAM_DYN_ST /* temporary only (fparam hack) */
131 132
 };
132 133
 
133 134
 typedef enum _expr_l_type expr_l_type;
Browse code

core: fix selects in optimized rvalue expressions

- do not attempt to resolve_select() twice the same select. This
happened when a rve containing only a select was optimized,
the select moved out of the rve and fix_expr() tried to "fix"
the already resolved select later.
- changed BUG() messages for failed resolve_select() into ERR().

Andrei Pelinescu-Onciul authored on 18/06/2010 20:22:59
Showing 1 changed files
... ...
@@ -76,7 +76,7 @@ enum _expr_l_type{
76 76
 	   METHOD_O=51, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
77 77
 	   DSTIP_O, DSTPORT_O, PROTO_O, AF_O, MSGLEN_O, ACTION_O,
78 78
 	   NUMBER_O, AVP_O, SNDIP_O, SNDPORT_O, TOIP_O, TOPORT_O, SNDPROTO_O,
79
-	   SNDAF_O, RETCODE_O, SELECT_O, PVAR_O, RVEXP_O};
79
+	   SNDAF_O, RETCODE_O, SELECT_O, PVAR_O, RVEXP_O, SELECT_UNFIXED_O};
80 80
 /* action types */
81 81
 enum action_type{
82 82
 		FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
... ...
@@ -121,7 +121,8 @@ enum _operand_subtype{
121 121
 		SELECT_ST, PVAR_ST,
122 122
 		LVAL_ST,  RVE_ST,
123 123
 		RETCODE_ST, CASE_ST,
124
-		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST
124
+		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST,
125
+		SELECT_UNFIXED_ST
125 126
 };
126 127
 
127 128
 typedef enum _expr_l_type expr_l_type;
Browse code

core: support for RVEs in fparam fixups

Hack to allow using RVEs in "safe" fparam fixups. This way all the
module functions using them will automatically have var support
(most ser modules that already supported variables as quoted
parameter, support now any variable expression, without quotes
too).
The cleanup is done by the core (this is the "hack" part).

E.g.:
t_set_fr($v + 2 + $x) should work now
(it uses fixup_var_int_1 which is RVE-safe).

t_set_fr("$v") is now equivalent with t_set_fr($v).

Andrei Pelinescu-Onciul authored on 02/06/2010 16:24:05
Showing 1 changed files
... ...
@@ -126,7 +126,8 @@ enum _operand_subtype{
126 126
 		SELECT_ST, PVAR_ST,
127 127
 		LVAL_ST,  RVE_ST,
128 128
 		RETCODE_ST, CASE_ST,
129
-		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST
129
+		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST,
130
+		FPARAM_DYN_ST /* temporary only */
130 131
 };
131 132
 
132 133
 typedef enum _expr_l_type expr_l_type;
Browse code

core: support for expressions/variables in function parameters

- all module functions that do not have fixups can now be called
with variables, avps or expressions. They will be converted to
string, either on startup (if the expression is constant, e.g.
"a"+"b") or at runtime (if the expression is not constant, .e.g.
$a, $b+$var(foo)+"test").
E.g.: f("1+1=" + 1 + 1, "v=" + $v).
- slightly faster module function calls (eliminated some
never-triggered sanity tests).

Andrei Pelinescu-Onciul authored on 15/03/2010 19:05:49
Showing 1 changed files
... ...
@@ -85,7 +85,12 @@ enum action_type{
85 85
 		SET_USERPHONE_T,
86 86
 		IF_T, SWITCH_T /* only until fixup*/,
87 87
 		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T, MATCH_COND_T, WHILE_T,
88
-		MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,
88
+		/* module function calls with string only parameters */
89
+		MODULE0_T, MODULE1_T, MODULE2_T, MODULE3_T, MODULE4_T, MODULE5_T,
90
+		MODULE6_T, MODULEX_T,
91
+		/* module function calls, that have some RVE parameters */
92
+		MODULE1_RVE_T, MODULE2_RVE_T, MODULE3_RVE_T,
93
+		MODULE4_RVE_T, MODULE5_RVE_T, MODULE6_RVE_T, MODULEX_RVE_T,
89 94
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
90 95
 		AVPFLAG_OPER_T,
91 96
 		LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
Browse code

core: new close after send and reuse only script functions

Added new script functions for setting send options for the
current message or its replies:

- set_forward_no_connect() - the message will be forwarded only if
there is already an open connection to the destination.
- set_reply_no_connect() - like above but for replies to the
current message.
- set_forward_close() - hint that after forwarding the current
message the connection should be closed.
- set reply_close() - like above but for replies.

Andrei Pelinescu-Onciul authored on 15/09/2009 15:47:33
Showing 1 changed files
... ...
@@ -106,7 +106,11 @@ enum action_type{
106 106
 		FORCE_SEND_SOCKET_T,
107 107
 		ASSIGN_T,
108 108
 		ADD_T,
109
-		UDP_MTU_TRY_PROTO_T
109
+		UDP_MTU_TRY_PROTO_T,
110
+		SET_FWD_NO_CONNECT_T,
111
+		SET_RPL_NO_CONNECT_T,
112
+		SET_FWD_CLOSE_T,
113
+		SET_RPL_CLOSE_T
110 114
 };
111 115
 /* parameter types for actions or types for expression right operands
112 116
    (WARNING right operands only, not working for left operands) */
Browse code

core: action struct holds cfg file name and line

- useful to print cfg file position for runtime action errors

Daniel-Constantin Mierla authored on 26/08/2009 08:51:51
Showing 1 changed files
... ...
@@ -181,6 +181,8 @@ typedef struct {
181 181
 #define MAX_ACTIONS (2+6)
182 182
 
183 183
 struct action{
184
+	int cline;
185
+	char *cfile;
184 186
 	enum action_type type;  /* forward, drop, log, send ...*/
185 187
 	int count;
186 188
 	struct action* next;
Browse code

core: support for include file in cfg

- syntax:
include path/to/file
- example:
include checks.cfg
- path can be absolute or relative
- if path is relative:
- first attempt is to open the file relative to current directory
- second attempt is to open the file relative to the directory
of the file including it
- if include file fails, then print error and exit
- cfg syntax error messages print file name
- there is no restriction where 'include' can be used, can have
global parameters, module configs or entire/parts of route blocks

Daniel-Constantin Mierla authored on 25/08/2009 16:27:01
Showing 1 changed files
... ...
@@ -136,6 +136,7 @@ struct cfg_pos{
136 136
 	int e_line;
137 137
 	unsigned short s_col;
138 138
 	unsigned short e_col;
139
+	char *fname;
139 140
 };
140 141
 
141 142
 
Browse code

core: support to add rport parameter to local via hdr

- new cfg function - add_local_rport() - to add rport parameter to local
via header (rfc3581)

Daniel-Constantin Mierla authored on 20/08/2009 09:57:01
Showing 1 changed files
... ...
@@ -97,6 +97,7 @@ enum action_type{
97 97
 		FORWARD_SCTP_T,
98 98
 		SEND_TCP_T,
99 99
 		FORCE_RPORT_T,
100
+		ADD_LOCAL_RPORT_T,
100 101
 		SET_ADV_ADDR_T,
101 102
 		SET_ADV_PORT_T,
102 103
 		FORCE_TCP_ALIAS_T,
Browse code

core: script engine cleanups

Use named enums for action types, expression types, expressions
left operands, expression right operands and action parameter
types. This should avoid future type mismatching bugs (like trying
to compare a left expr. operand type with a type that can exist
only on the right part) by triggering compile time warnings.
For extra protection the expression left operands and right
operands possible value do not overlap anymore.

Andrei Pelinescu-Onciul authored on 18/07/2009 09:05:05
Showing 1 changed files
... ...
@@ -60,15 +60,26 @@
60 60
  */
61 61
 
62 62
 
63
-enum { EXP_T=1, ELEM_T };
64
-enum { LOGAND_OP=1, LOGOR_OP, NOT_OP, BINAND_OP, BINOR_OP };
65
-enum { EQUAL_OP=10, MATCH_OP, GT_OP, LT_OP, GTE_OP, LTE_OP, DIFF_OP, NO_OP };
66
-enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
67
-	   DSTIP_O, DSTPORT_O, PROTO_O, AF_O, MSGLEN_O, DEFAULT_O, ACTION_O,
63
+/* expression type */
64
+enum expr_type { EXP_T=1, ELEM_T };
65
+enum expr_op {
66
+	/* expression operator if type==EXP_T */
67
+	LOGAND_OP=1, LOGOR_OP, NOT_OP, BINAND_OP, BINOR_OP,
68
+	/* expression operator if type==ELEM_T */
69
+	EQUAL_OP=10, MATCH_OP, GT_OP, LT_OP, GTE_OP, LTE_OP, DIFF_OP, NO_OP
70
+};
71
+/* expression left member "special" type (if type==ELEM_T)
72
+  (start at 51 for debugging purposes: it's better to not overlap with 
73
+   expr_r_type)
74
+*/
75
+enum _expr_l_type{
76
+	   METHOD_O=51, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
77
+	   DSTIP_O, DSTPORT_O, PROTO_O, AF_O, MSGLEN_O, ACTION_O,
68 78
 	   NUMBER_O, AVP_O, SNDIP_O, SNDPORT_O, TOIP_O, TOPORT_O, SNDPROTO_O,
69 79
 	   SNDAF_O, RETCODE_O, SELECT_O, PVAR_O, RVEXP_O};
70
-
71
-enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
80
+/* action types */
81
+enum action_type{
82
+		FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
72 83
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
73 84
 		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T, SET_HOSTALL_T,
74 85
 		SET_USERPHONE_T,
... ...
@@ -96,7 +107,10 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
96 107
 		ADD_T,
97 108
 		UDP_MTU_TRY_PROTO_T
98 109
 };
99
-enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
110
+/* parameter types for actions or types for expression right operands
111
+   (WARNING right operands only, not working for left operands) */
112
+enum _operand_subtype{
113
+		NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
100 114
 		EXPR_ST, ACTIONS_ST, MODEXP_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
101 115
 		MYSELF_ST, STR_ST, SOCKID_ST, SOCKETINFO_ST, ACTION_ST, AVP_ST,
102 116
 		SELECT_ST, PVAR_ST,
... ...
@@ -105,6 +119,10 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
105 119
 		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST
106 120
 };
107 121
 
122
+typedef enum _expr_l_type expr_l_type;
123
+typedef enum _operand_subtype expr_r_type;
124
+typedef enum _operand_subtype action_param_type;
125
+
108 126
 /* run flags */
109 127
 #define EXIT_R_F   1
110 128
 #define RETURN_R_F 2
... ...
@@ -134,15 +152,16 @@ union exp_op {
134 152
 };
135 153
 
136 154
 struct expr{
137
-	int type; /* exp, exp_elem */
138
-	int op; /* and, or, not | ==,  =~ */
139
-	int l_type, r_type;
155
+	enum expr_type type; /* exp, exp_elem */
156
+	enum expr_op op; /* and, or, not | ==,  =~ */
157
+	expr_l_type l_type;
158
+	expr_r_type r_type;
140 159
 	union exp_op l;
141 160
 	union exp_op r;
142 161
 };
143 162
 
144 163
 typedef struct {
145
-	int type;
164
+	action_param_type type;
146 165
 	union {
147 166
 		long number;
148 167
 		char* string;
... ...
@@ -160,16 +179,20 @@ typedef struct {
160 179
 #define MAX_ACTIONS (2+6)
161 180
 
162 181
 struct action{
163
-	int type;  /* forward, drop, log, send ...*/
182
+	enum action_type type;  /* forward, drop, log, send ...*/
164 183
 	int count;
165 184
 	struct action* next;
166 185
 	action_u_t val[MAX_ACTIONS];
167 186
 };
168 187
 
169 188
 struct expr* mk_exp(int op, struct expr* left, struct expr* right);
170
-struct expr* mk_elem(int op, int ltype, void* lparam, int rtype, void* rparam);
189
+struct expr* mk_elem(int op, expr_l_type ltype, void* lparam,
190
+							 expr_r_type rtype, void* rparam);
191
+
192
+/* @param type - type of the action
193
+   @param count - count of couples {type,val} (variable number of parameters)*/
194
+struct action* mk_action(enum action_type type, int count, ...);
171 195
 
172
-struct action* mk_action(int type, int count/* of couples {type,val} */, .../* int type1, void *val1 [, int type2, void *val2, ...] */);
173 196
 struct action* append_action(struct action* a, struct action* b);
174 197
 
175 198
 void print_action(struct action* a);
Browse code

core: internal difference between cfg drop and exit

- drop sets the flag for exit and one extra: EXIT_R_F and DROP_R_F
- no difference in processing right now (DROP_R_F not tested anywhere
yet)

Daniel-Constantin Mierla authored on 08/07/2009 21:24:52
Showing 1 changed files
... ...
@@ -109,6 +109,7 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
109 109
 #define EXIT_R_F   1
110 110
 #define RETURN_R_F 2
111 111
 #define BREAK_R_F  4
112
+#define DROP_R_F   8
112 113
 
113 114
 
114 115
 struct cfg_pos{
Browse code

Merge commit 'origin/ser_core_cvs'

* commit 'origin/ser_core_cvs':
tcp: minor optimization
sercmd: minor makefile fix
tcp internal: send timeout is now kept only in ticks
core: typo fix
tcp: typo & minor optimization
Rename Contact parameter select 'method' to 'methods'
Rename Contact parameter 'method' to 'methods'
make install: avoid re-linking lib dependent modules
build system: avoid libraries re-compiling
fixing missing $ in ser_mysql.sh script
Debian packaging - fixing path to mysql sql files in my_create.sh script
The fixup function prototypes of the config variables have been
Strip, prefix, rewriteuser, ... all the SET_* actions preserve the
core: check & fix Content-Length when sending on tcp
tcp: config option for the async write block size
tcp: config option for the read buffer size
tcp: dyn. config fix for tcp_con_lifetime
tcp: diff. connect timeout for async & states cleanup

Conflicts:
Makefile.rules
action.c
cfg.lex
cfg.y
route_struct.h

Andrei Pelinescu-Onciul authored on 20/03/2009 20:47:32
Showing 0 changed files
Browse code

Add support for SET_HOSTALL_T action.

This patch adds support for SET_HOSTALL_T action which can be used to
rewrite the hostname, port, parameters, and headers parts of the
Request-URI, all at once.

Jan Janak authored on 17/03/2009 22:06:02
Showing 1 changed files
... ...
@@ -70,7 +70,7 @@ enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
70 70
 
71 71
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
72 72
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
73
-		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
73
+		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T, SET_HOSTALL_T,
74 74
 		IF_T, SWITCH_T /* only until fixup*/,
75 75
 		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T, MATCH_COND_T, WHILE_T,
76 76
 		MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,
Browse code

Strip, prefix, rewriteuser, ... all the SET_* actions preserve the original URI scheme unless the host name is rewritten. If the host name is set, then tel: and tels: URIs are converted to sip: or sips:, and the user=phone parameter is added.

A script function, userphone(), is introduced: It adds the "user=phone"
parameter to a sip: or sips: RURI if the param is not yet present.
(Does not change tel: and tels: URIs).

(Patch has been created with cooperation with Michal Matyska.)
Fixes SER-435.

Miklos Tirpak authored on 10/03/2009 16:26:35
Showing 1 changed files
... ...
@@ -70,7 +70,7 @@ enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
70 70
 
71 71
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
72 72
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
73
-		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
73
+		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T, SET_USERPHONE_T,
74 74
 		IF_T, MODULE_T,
75 75
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
76 76
 		AVPFLAG_OPER_T,
Browse code

Merge commit 'origin/andrei/switch'

* commit 'origin/andrei/switch':
script parsing: string switch support
script engine: string switch optimization and fixup
script engine: string switch execution
rvalues: fix rval_new( empty string )
core: sint2str check for space before adding the sign

Andrei Pelinescu-Onciul authored on 20/02/2009 17:20:20
Showing 0 changed files
Browse code

Merge branch 'ser_core_cvs'

* ser_core_cvs:
tcp: fix compilation problem on solaris (FIONREAD)
core: fix bad level name in new LOG()
t_check_status() checks also the blind UACs if t_pick_branch()
Documenting t_lookup_cancel() script function.
Removing set_t() from t_lookup_cancel() function, and introducing
updated udp_mtu handling code - fixes SER-433
documenting t_is_expired() function
t_is_expired() script function is introduced.
* logging API updated (see doc/logging-api.txt for details)
- AS support disabled by default.
When building the route set of ACKs for local UACs, only the reply is now
In case the AVP is a regexp, an allocation is required to build an AVP
Currently, SER matches E2E ACKs only if there is an equality between From HF
The calculate_routeset_length() produces an invalid result in the case
'memapp' and 'append_mem_block' are now both only used in source
"Route :" prefix (and separator) is used some more time across the
script: udp_mtu fallback script config & commands
core: forward: tcp fallback for big udp packets

Conflicts:
action.c
cfg.y
cfg_core.c
cfg_core.h
dprint.h - updated to the new logging api from ser, while
keeping the kamailio compatibility macros and
CRIT().
usr_avp.h

Andrei Pelinescu-Onciul authored on 20/02/2009 16:22:16
Showing 0 changed files
Browse code

script engine: string switch execution

- support for matching strings and regular expressions in a string
switch (MATCH_T).

Andrei Pelinescu-Onciul authored on 19/02/2009 22:38:37
Showing 1 changed files
... ...
@@ -71,7 +71,7 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
71 71
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
72 72
 		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
73 73
 		IF_T, SWITCH_T /* only until fixup*/,
74
-		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T, WHILE_T,
74
+		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T, MATCH_COND_T, WHILE_T,
75 75
 		MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,
76 76
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
77 77
 		AVPFLAG_OPER_T,
... ...
@@ -99,7 +99,7 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
99 99
 		SELECT_ST, PVAR_ST,
100 100
 		LVAL_ST,  RVE_ST,
101 101
 		RETCODE_ST, CASE_ST,
102
-		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST
102
+		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST
103 103
 };
104 104
 
105 105
 /* run flags */
Browse code

script engine: while() support

- support the same while() loops as kamailio (the only difference
being that max_while_loops can be changed at runtime):
while(<int expr>) { .... } with break exiting the while.

Andrei Pelinescu-Onciul authored on 10/02/2009 21:21:12
Showing 1 changed files
... ...
@@ -71,7 +71,7 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
71 71
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
72 72
 		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
73 73
 		IF_T, SWITCH_T /* only until fixup*/,
74
-		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T,
74
+		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T, WHILE_T,
75 75
 		MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,
76 76
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
77 77
 		AVPFLAG_OPER_T,
Browse code

script engine: switch() and break execution

- support for executing optimized switch()ed (by fix_switch())
- proper break handling:
- exit a switch() on break (even if the break is inside an if() block)
- if the break is outside a switch, exit the route block
(compatibility with older versions, for new scripts using exit or
drop instead of break is recommended)

Andrei Pelinescu-Onciul authored on 09/02/2009 18:01:35
Showing 1 changed files
... ...
@@ -105,6 +105,7 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
105 105
 /* run flags */
106 106
 #define EXIT_R_F   1
107 107
 #define RETURN_R_F 2
108
+#define BREAK_R_F  4
108 109
 
109 110
 
110 111
 struct cfg_pos{
Browse code

script parsing: C style switch() & case support

- support for parsing C style switch() & case, e.g.:
switch($var){
case 1:
log(1, "1\n");
break;
case 2:
case 3:
default:
log(1, "default\n");
}
(note: this is different from kamailio/openser switch())

Andrei Pelinescu-Onciul authored on 04/02/2009 19:44:26
Showing 1 changed files
... ...
@@ -70,7 +70,9 @@ enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
70 70
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
71 71
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
72 72
 		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
73
-		IF_T, MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,
73
+		IF_T, SWITCH_T /* only until fixup*/,
74
+		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T,
75
+		MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,
74 76
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
75 77
 		AVPFLAG_OPER_T,
76 78
 		LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
... ...
@@ -96,7 +98,9 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
96 98
 		MYSELF_ST, STR_ST, SOCKID_ST, SOCKETINFO_ST, ACTION_ST, AVP_ST,
97 99
 		SELECT_ST, PVAR_ST,
98 100
 		LVAL_ST,  RVE_ST,
99
-		RETCODE_ST};
101
+		RETCODE_ST, CASE_ST,
102
+		BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST
103
+};
100 104
 
101 105
 /* run flags */
102 106
 #define EXIT_R_F   1
Browse code

script parsing: helper function updated & moved

- helper function for computing the file position of an expression

Andrei Pelinescu-Onciul authored on 19/12/2008 13:20:41
Showing 1 changed files
... ...
@@ -167,5 +167,8 @@ void print_action(struct action* a);
167 167
 void print_actions(struct action* a);
168 168
 void print_expr(struct expr* exp);
169 169
 
170
+/** joins to cfg file positions into a new one. */
171
+void cfg_pos_join(struct cfg_pos* res,
172
+							struct cfg_pos* pos1, struct cfg_pos* pos2);
170 173
 #endif
171 174
 
Browse code

script: udp_mtu fallback script config & commands

new config variables:
- udp_mtu = number - size in bytes after which fallback to
another protocol will be attempted. Default 0 (off),
recommended 1300.
- udp_mtu_try_proto = TCP|TLS|SCTP|UDP - protocol to fallback to.
Default: UDP (off).
- force_rport = yes|no - global force_rport().

new script commands:
- udp_mtu_try_proto(TCP|TLS|SCTP|UDP) - like udp_mtu_try_proto
above but works on a per packet basis and not globally.


Author: Andrei Pelinescu-Onciul <andrei@iptel.org>

Andrei Pelinescu-Onciul authored on 18/12/2008 16:09:16
Showing 1 changed files
... ...
@@ -35,6 +35,7 @@
35 35
  *  2004-02-24  added LOAD_AVP_T and AVP_TO_URI_T (bogdan)
36 36
  *  2005-12-11  added SND{IP,PORT,PROTO,AF}_O & TO{IP,PORT}_O (andrei)
37 37
  *  2005-12-19  select framework added SELECT_O and SELECT_ST (mma)
38
+ *  2008-12-17  added UDP_MTU_TRY_PROTO_T (andrei)
38 39
  */
39 40
 
40 41
 
... ...
@@ -89,7 +90,8 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
89 90
 		AVP_TO_URI_T,
90 91
 		FORCE_SEND_SOCKET_T,
91 92
 		ASSIGN_T,
92
-		ADD_T
93
+		ADD_T,
94
+		UDP_MTU_TRY_PROTO_T
93 95
 };
94 96
 enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
95 97
 		EXPR_ST, ACTIONS_ST, MODEXP_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
Browse code

script parsing: better expression error reporting

- report bad expression position on type mismatch
e.g.:
*** PARSE ERROR *** (42,8-18): bad expression: type
mismatch: str instead of int at (42,16)

Andrei Pelinescu-Onciul authored on 15/12/2008 22:13:20
Showing 1 changed files
... ...
@@ -102,6 +102,15 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
102 102
 #define EXIT_R_F   1
103 103
 #define RETURN_R_F 2
104 104
 
105
+
106
+struct cfg_pos{
107
+	int s_line;
108
+	int e_line;
109
+	unsigned short s_col;
110
+	unsigned short e_col;
111
+};
112
+
113
+
105 114
 /* Expression operand */
106 115
 union exp_op {
107 116
 	void* param;
Browse code

script engine: rvalue support in logical expr.

- hard coded expressions elements (e.g. method==xxx) support now
rvalues as operands (e.g. uri=="sip:"+$a)
- small cleanups

Andrei Pelinescu-Onciul authored on 09/12/2008 15:15:21
Showing 1 changed files
... ...
@@ -65,7 +65,7 @@ enum { EQUAL_OP=10, MATCH_OP, GT_OP, LT_OP, GTE_OP, LTE_OP, DIFF_OP, NO_OP };
65 65
 enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
66 66
 	   DSTIP_O, DSTPORT_O, PROTO_O, AF_O, MSGLEN_O, DEFAULT_O, ACTION_O,
67 67
 	   NUMBER_O, AVP_O, SNDIP_O, SNDPORT_O, TOIP_O, TOPORT_O, SNDPROTO_O,
68
-	   SNDAF_O, RETCODE_O, SELECT_O};
68
+	   SNDAF_O, RETCODE_O, SELECT_O, PVAR_O, RVEXP_O};
69 69
 
70 70
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
71 71
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
... ...
@@ -94,8 +94,8 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
94 94
 enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
95 95
 		EXPR_ST, ACTIONS_ST, MODEXP_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
96 96
 		MYSELF_ST, STR_ST, SOCKID_ST, SOCKETINFO_ST, ACTION_ST, AVP_ST,
97
-		SELECT_ST, /* obsolete */
98
-		LVAL_ST, RVE_ST,
97
+		SELECT_ST, PVAR_ST,
98
+		LVAL_ST,  RVE_ST,
99 99
 		RETCODE_ST};
100 100
 
101 101
 /* run flags */
Browse code

script engine: lvalue/rvalue assignment and fixups

Andrei Pelinescu-Onciul authored on 04/12/2008 00:12:46
Showing 1 changed files
... ...
@@ -93,7 +93,9 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
93 93
 };
94 94
 enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
95 95
 		EXPR_ST, ACTIONS_ST, MODEXP_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
96
-		MYSELF_ST, STR_ST, SOCKID_ST, SOCKETINFO_ST, ACTION_ST, AVP_ST, SELECT_ST,
96
+		MYSELF_ST, STR_ST, SOCKID_ST, SOCKETINFO_ST, ACTION_ST, AVP_ST,
97
+		SELECT_ST, /* obsolete */
98
+		LVAL_ST, RVE_ST,
97 99
 		RETCODE_ST};
98 100
 
99 101
 /* run flags */
Browse code

script: variable number of params for functions

- support for true variable number of parameters module functions
( f(sip_msg, param_no, param_array[]) )
- support for functions with 3-6 parameters using kamailio extended
interface. The implementation is however different: while in kamailio
all module functions where called with 6 parameters (even if they
declared only 2), this version will generate different function
calls (small performance benefit by avoiding unneeded stack pushes
and register saving for the most common 2 parameter functions and
works also with other calling conventions).
For performance reasons, a separate script engine command is now
generated for each type of function: module functions calls with 0-2
parameters (MODULE_T), 3 (MODULE3_T), 4 (MODULE4_T), 5 (MODULE5_T)
and 6 (MODULE6_T) parameters.
In case of name conflicts with variable param. number function,
it's undefined which actual function will get executed (it will be
the "first" one, but the order depends on the module loading order
a.s.o.).

Andrei Pelinescu-Onciul authored on 18/11/2008 23:10:46
Showing 1 changed files
... ...
@@ -70,7 +70,7 @@ enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
70 70
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
71 71
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
72 72
 		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
73
-		IF_T, MODULE_T,
73
+		IF_T, MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,
74 74
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
75 75
 		AVPFLAG_OPER_T,
76 76
 		LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
... ...
@@ -133,13 +133,17 @@ typedef struct {
133 133
 	} u;
134 134
 } action_u_t;
135 135
 
136
-#define MAX_ACTIONS 4
136
+/* maximum internal array/params
137
+ * for module function calls val[0] and val[1] store a pointer to the
138
+ * function and the number of params, the rest are the function params 
139
+ */
140
+#define MAX_ACTIONS (2+6)
137 141
 
138 142
 struct action{
139 143
 	int type;  /* forward, drop, log, send ...*/
140 144
 	int count;
141
-	action_u_t val[MAX_ACTIONS];
142 145
 	struct action* next;
146
+	action_u_t val[MAX_ACTIONS];
143 147
 };
144 148
 
145 149
 struct expr* mk_exp(int op, struct expr* left, struct expr* right);
Browse code

- core sctp support

Andrei Pelinescu-Onciul authored on 08/08/2008 20:47:53
Showing 1 changed files
... ...
@@ -79,6 +79,7 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
79 79
 		FORWARD_TCP_T,
80 80
 		FORWARD_UDP_T,
81 81
 		FORWARD_TLS_T,
82
+		FORWARD_SCTP_T,
82 83
 		SEND_TCP_T,
83 84
 		FORCE_RPORT_T,
84 85
 		SET_ADV_ADDR_T,
... ...
@@ -86,10 +87,9 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
86 87
 		FORCE_TCP_ALIAS_T,
87 88
 		LOAD_AVP_T,
88 89
 		AVP_TO_URI_T,
89
-                FORCE_SEND_SOCKET_T,
90
-                ASSIGN_T,
91
-                ADD_T
92
-
90
+		FORCE_SEND_SOCKET_T,
91
+		ASSIGN_T,
92
+		ADD_T
93 93
 };
94 94
 enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
95 95
 		EXPR_ST, ACTIONS_ST, MODEXP_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
Browse code

- RURI is not parsed again if parsed_uri_ok=1

- new action type, SET_HOSTPORTTRANS_T, and the corresponding
script actions are introduced: sethostporttrans() and
rewritehostporttrans()

This action accepts an optional transport parameter, and clears the
previous transport param if there was any. It is safer to use this action
instead of SET_HOSTPORT_T in some cases, even if the transport param is
omitted, because the latter can leave the parameter in the RURI
causing troubles.

Miklos Tirpak authored on 17/04/2008 16:22:18
Showing 1 changed files
... ...
@@ -69,7 +69,8 @@ enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
69 69
 
70 70
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
71 71
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
72
-		SET_PORT_T, SET_URI_T, IF_T, MODULE_T,
72
+		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
73
+		IF_T, MODULE_T,
73 74
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
74 75
 		AVPFLAG_OPER_T,
75 76
 		LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
Browse code

- fix for script numeric compares on 64 bit big endian systems

Andrei Pelinescu-Onciul authored on 09/12/2007 13:15:24
Showing 1 changed files
... ...
@@ -101,15 +101,15 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
101 101
 
102 102
 /* Expression operand */
103 103
 union exp_op {
104
+	void* param;
105
+	long numval; /* must have the same size as a void*/
104 106
 	struct expr* expr;
105
-	struct _str str;
106 107
 	char* string;
107
-	void* param;
108
-	int intval;
109 108
 	avp_spec_t* attr;
110 109
 	select_t* select;
111 110
 	regex_t* re;
112 111
 	struct net* net;
112
+	struct _str str;
113 113
 };
114 114
 
115 115
 struct expr{
Browse code

- added AVP flags feature.

Every AVP may by flaged from script via setavpflag(avpid, flag) (it's similar like message flags setflags,resetflags,isflagset). AVP flags must be declared using avpflags statement. Flags may be tested via isavpflagset(avpid, flag). Both the setting and testing may also be processed in a module. It's currently used in the "rr" module for dialog_cookies. Such module should register flag using register_avpflag(flag_id).

Example:
avpflags myflag, dialog_cookie;

$a = 123;
setavpflag($a, "myflag");

if (isavpflagset($a, "myflag")) {
....

$dlg_foo = "foo";
$dlg_bar = "bar";
setavpflag("$f./^dlg_", "dialog_cookie");

Tomas Mandys authored on 31/05/2006 23:02:46
Showing 1 changed files
... ...
@@ -71,6 +71,7 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
71 71
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
72 72
 		SET_PORT_T, SET_URI_T, IF_T, MODULE_T,
73 73
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
74
+		AVPFLAG_OPER_T,
74 75
 		LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
75 76
 		APPEND_BRANCH_T,
76 77
 		REVERT_URI_T,
Browse code

corrected problems reported by Warren McCoubrey with compilation problems on Redhat 9 with gcc 3.2.2 and bison 1.35 (bison++)

Vaclav Kubart authored on 01/03/2006 07:40:07
Showing 1 changed files
... ...
@@ -41,6 +41,7 @@
41 41