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,212 +0,0 @@
1
-/*
2
- * Copyright (C) 2005-2006 iptelorg GmbH
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
-/*!
22
- * \file
23
- * \brief Kamailio core :: Selcct Framework
24
- * \author mma
25
- * \ingroup core
26
- * Module: \ref core
27
- */
28
-
29
- 
30
-#ifndef _SELECT_H
31
-#define _SELECT_H
32
-
33
-#include "str.h"
34
-#include "parser/msg_parser.h"
35
-
36
-#define MAX_SELECT_PARAMS 32
37
-#define MAX_NESTED_CALLS  4
38
-
39
-/* Flags for parser table FLAG bitfiels 
40
- */
41
-#define DIVERSION_MASK   0x00FF
42
-
43
-/* if DIVERSION is set and the function is accepted
44
- * the param is changed into SEL_PARAM_DIV and the value is set to (flags & DIVERSION_MASK)
45
- *  - it is valuable for STR params (saves parsing time)
46
- *  - does not release the memory occupied by the parameter
47
- */
48
-#define DIVERSION        1<<8
49
-
50
-/* set if any parameter is expected at this stage
51
- * (the function must be resolved further)
52
- */
53
-#define SEL_PARAM_EXPECTED   1<<9
54
-
55
-/* accept if following parameter is STR (any)
56
- * consume that extra parameter in one step
57
- */
58
-#define CONSUME_NEXT_STR 1<<10
59
-
60
-/* accept if following parameter is INT
61
- * consume that extra parameter in one ste
62
- */
63
-#define CONSUME_NEXT_INT 1<<11
64
-
65
-/* accept all the following parameters
66
- * without checking them
67
- */
68
-#define CONSUME_ALL	1<<12
69
-
70
-/* next parameter is optional (use with CONSUME_NEXT_STR or CONSUME_NEXT_INT
71
- * resolution is accepted even if there is no other parameter
72
- * or the parameter is of wrong type
73
- */
74
-#define OPTIONAL         1<<13
75
-
76
-/* left function is noted to be called
77
- * rigth function continues in resolution
78
- * NOTE: the parameter is not consumed for PARENT, 
79
- * so you can leave it as ..,SEL_PARAM_INT, 0,..
80
- *
81
- * run_select then calls all functions with PARENT flag
82
- * in the order of resolution until the final call or 
83
- * the result is != 0 (<0 error, 1 null str) 
84
- * the only one parameter passed between nested calls
85
- * is the result str*
86
- */
87
-#define NESTED		1<<14
88
-
89
-/* "fixup call" would be done, when the structure is resolved to this node
90
- * which means call with res and msg NULL
91
- *
92
- * if the fixup call return value <0, the select resolution will fail
93
- */
94
-#define FIXUP_CALL	1<<15
95
-
96
-/*
97
- * Selector call parameter
98
- */
99
-typedef enum {
100
-	SEL_PARAM_INT,  /* Integer parameter */
101
-	SEL_PARAM_STR,  /* String parameter */
102
-	SEL_PARAM_DIV,  /* Integer value got from parsing table */
103
-	SEL_PARAM_PTR   /* void* data got from e.g. fixup call */
104
-} select_param_type_t;
105
-	
106
-typedef union {
107
-	int i;  /* Integer value */
108
-	str s;  /* String value */
109
-	void* p;/* Any data ptr */
110
-} select_param_value_t;
111
-	
112
-typedef struct sel_param {
113
-        select_param_type_t type;
114
-        select_param_value_t v;
115
-} select_param_t;
116
-
117
-struct select;
118
-
119
-typedef int (*select_f)(str* res, struct select* s, struct sip_msg* msg);
120
-
121
-typedef struct select {
122
-	select_f f[MAX_NESTED_CALLS];
123
-	int param_offset[MAX_NESTED_CALLS+1];
124
-	/* contains broken down select string (@foo.bar[-2].foo -> 4 entries) */
125
-	select_param_t params[MAX_SELECT_PARAMS];
126
-	/* how many elements are used in 'params' */
127
-	int n;
128
-} select_t;
129
-
130
-typedef struct {
131
-	select_f curr_f;
132
-	select_param_type_t type;
133
-	str name;
134
-	select_f new_f;
135
-	int flags;
136
-} select_row_t;
137
-
138
-typedef struct select_table {
139
-  select_row_t *table;
140
-  struct select_table *next;
141
-} select_table_t;
142
-
143
-/* the level of the select call that is beeing evaluated
144
- * by the child process
145
- */
146
-extern int select_level;
147
-
148
-/* pointer to the SIP uri beeing processed.
149
- * Nested function calls can pass information to each
150
- * other using this pointer. Only for performace reasons.
151
- * (Miklos)
152
- */
153
-extern struct sip_uri	*select_uri_p;
154
-
155
-/*
156
- * Lookup corresponding select function based on
157
- * the select parameters
158
- */
159
-int resolve_select(select_t* s);
160
-
161
-/*
162
- * Run the select function
163
- */
164
-int run_select(str* res, select_t* s, struct sip_msg* msg);
165
-
166
-/*
167
- * Print select for debugging purposes 
168
- */
169
-void print_select(select_t* s);
170
-
171
-/*
172
- * Register modules' own select parser table
173
- */
174
-int register_select_table(select_row_t *table);
175
-
176
-/*
177
- * Tries to parse string pointed by *p (up to first non alpha char) into select structure
178
- * if parsing succeeded, call resolve_select
179
- * if resolving passes, returns final structure
180
- * *p moves to first unused char
181
- * return 0
182
- *
183
- * if memory allocation fails, returns -1
184
- * if parsing or resolving fails, returns -2
185
- */
186
-int parse_select (char** p, select_t** s);
187
-
188
-/**
189
- * Frees the select obtained with parse_select().
190
- */
191
-void free_select(select_t *s);
192
-/*
193
- * Select parser, result is stored in SHARED memory
194
- * 
195
- * If you call this, you must ensure, that the string which
196
- * is beeing parsed MUST be at the same place for all child
197
- * processes, e.g. allocated in the shared memory as well
198
- *
199
- * parameters and results same as parse_select
200
- */
201
-int shm_parse_select (char** p, select_t** s);
202
-
203
-/**
204
- * Frees the select obtained with shm_parse_select().
205
- */
206
-void shm_free_select(select_t *s);
207
-
208
-
209
-#define SELECT_F(function) extern int function (str* res, select_t* s, struct sip_msg* msg);
210
-#define ABSTRACT_F(function) int function (str* res, select_t* s, struct sip_msg* msg) {return -1;}
211
-
212
-#endif /* _SELECT_H */
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) 2005-2006 iptelorg GmbH
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,10 +17,13 @@
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
  *
27
- * History:
28
- * --------
29
- *  2005-12-19  select framework (mma)
30
- *  2006-01-19  multiple nested calls, IS_ALIAS -> NESTED flag renamed (mma)
20
+ */
21
+/*!
22
+ * \file
23
+ * \brief Kamailio core :: Selcct Framework
24
+ * \author mma
25
+ * \ingroup core
26
+ * Module: \ref core
31 27
  */
32 28
 
33 29
  
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
  * History:
28 28
  * --------
Browse code

selects: shm_free_select wrapper added

shm_free_select() function is added that frees the select
parsed by shm_parse_select().

Miklos Tirpak authored on 09/11/2009 16:08:08
Showing 1 changed files
... ...
@@ -204,6 +204,12 @@ void free_select(select_t *s);
204 204
  */
205 205
 int shm_parse_select (char** p, select_t** s);
206 206
 
207
+/**
208
+ * Frees the select obtained with shm_parse_select().
209
+ */
210
+void shm_free_select(select_t *s);
211
+
212
+
207 213
 #define SELECT_F(function) extern int function (str* res, select_t* s, struct sip_msg* msg);
208 214
 #define ABSTRACT_F(function) int function (str* res, select_t* s, struct sip_msg* msg) {return -1;}
209 215
 
Browse code

Avoid parsing the Request URI when it is not necessary.

When @ruri.user was executed, the first select call set
the value of the URI in str format regardless of whether
or not it had already been parsed. The second function call
took the str value, and parsed the URI to get its user part.

This patch introduces a global pointer variable that can be set
to the already parsed URI being processed. Any nested select
function can check this pointer and access the parsed URI if
possible.

Miklos Tirpak authored on 15/05/2009 07:42:29
Showing 1 changed files
... ...
@@ -149,6 +149,13 @@ typedef struct select_table {
149 149
  */
150 150
 extern int select_level;
151 151
 
152
+/* pointer to the SIP uri beeing processed.
153
+ * Nested function calls can pass information to each
154
+ * other using this pointer. Only for performace reasons.
155
+ * (Miklos)
156
+ */
157
+extern struct sip_uri	*select_uri_p;
158
+
152 159
 /*
153 160
  * Lookup corresponding select function based on
154 161
  * the select parameters
Browse code

Introducing CONSUME_ALL flag: all the subsequent parameters are accepted without resolving or checking them Can be used to implement selects with more than one parameter

Miklos Tirpak authored on 11/01/2008 16:30:30
Showing 1 changed files
... ...
@@ -66,11 +66,16 @@
66 66
  */
67 67
 #define CONSUME_NEXT_INT 1<<11
68 68
 
69
+/* accept all the following parameters
70
+ * without checking them
71
+ */
72
+#define CONSUME_ALL	1<<12
73
+
69 74
 /* next parameter is optional (use with CONSUME_NEXT_STR or CONSUME_NEXT_INT
70 75
  * resolution is accepted even if there is no other parameter
71 76
  * or the parameter is of wrong type
72 77
  */
73
-#define OPTIONAL         1<<12
78
+#define OPTIONAL         1<<13
74 79
 
75 80
 /* left function is noted to be called
76 81
  * rigth function continues in resolution
... ...
@@ -83,14 +88,14 @@
83 88
  * the only one parameter passed between nested calls
84 89
  * is the result str*
85 90
  */
86
-#define NESTED		1<<13
91
+#define NESTED		1<<14
87 92
 
88 93
 /* "fixup call" would be done, when the structure is resolved to this node
89 94
  * which means call with res and msg NULL
90 95
  *
91 96
  * if the fixup call return value <0, the select resolution will fail
92 97
  */
93
-#define FIXUP_CALL	1<<14
98
+#define FIXUP_CALL	1<<15
94 99
 
95 100
 /*
96 101
  * Selector call parameter
Browse code

fixes SER-345 - patch accepted

Michal Matyska authored on 07/01/2008 12:45:30
Showing 1 changed files
... ...
@@ -120,7 +120,9 @@ typedef int (*select_f)(str* res, struct select* s, struct sip_msg* msg);
120 120
 typedef struct select {
121 121
 	select_f f[MAX_NESTED_CALLS];
122 122
 	int param_offset[MAX_NESTED_CALLS+1];
123
+	/* contains broken down select string (@foo.bar[-2].foo -> 4 entries) */
123 124
 	select_param_t params[MAX_SELECT_PARAMS];
125
+	/* how many elements are used in 'params' */
124 126
 	int n;
125 127
 } select_t;
126 128
 
... ...
@@ -175,6 +177,10 @@ int register_select_table(select_row_t *table);
175 177
  */
176 178
 int parse_select (char** p, select_t** s);
177 179
 
180
+/**
181
+ * Frees the select obtained with parse_select().
182
+ */
183
+void free_select(select_t *s);
178 184
 /*
179 185
  * Select parser, result is stored in SHARED memory
180 186
  * 
Browse code

Level of the select call is moved to a global variable form the structure in order to make the select calls shared memory-safe. Fixes SER-318

Miklos Tirpak authored on 03/10/2007 14:56:32
Showing 1 changed files
... ...
@@ -122,7 +122,6 @@ typedef struct select {
122 122
 	int param_offset[MAX_NESTED_CALLS+1];
123 123
 	select_param_t params[MAX_SELECT_PARAMS];
124 124
 	int n;
125
-	int lvl;
126 125
 } select_t;
127 126
 
128 127
 typedef struct {
... ...
@@ -138,6 +137,11 @@ typedef struct select_table {
138 137
   struct select_table *next;
139 138
 } select_table_t;
140 139
 
140
+/* the level of the select call that is beeing evaluated
141
+ * by the child process
142
+ */
143
+extern int select_level;
144
+
141 145
 /*
142 146
  * Lookup corresponding select function based on
143 147
  * the select parameters
Browse code

select_buf: - get_static_buffer (meant for select calls which need extra space

- internal reset_static_buffer called before any request is processed

select_core:
select_uri_hostport returns host:port notation (default port value based on uri type)

select:
select structure contains new array param_offset and lvl - the nested level
number of params or particular nested level could be obtained by
param_offset[lvl+1]-param_offset[lvl]

Michal Matyska authored on 21/06/2006 19:11:58
Showing 1 changed files
... ...
@@ -119,8 +119,10 @@ typedef int (*select_f)(str* res, struct select* s, struct sip_msg* msg);
119 119
 
120 120
 typedef struct select {
121 121
 	select_f f[MAX_NESTED_CALLS];
122
+	int param_offset[MAX_NESTED_CALLS+1];
122 123
 	select_param_t params[MAX_SELECT_PARAMS];
123 124
 	int n;
125
+	int lvl;
124 126
 } select_t;
125 127
 
126 128
 typedef struct {
Browse code

Parsing of select framework syntax moved to the select core; serdev doc showing how to extend select framework within module.

Michal Matyska authored on 09/06/2006 16:46:53
Showing 1 changed files
... ...
@@ -157,6 +157,29 @@ void print_select(select_t* s);
157 157
  */
158 158
 int register_select_table(select_row_t *table);
159 159
 
160
+/*
161
+ * Tries to parse string pointed by *p (up to first non alpha char) into select structure
162
+ * if parsing succeeded, call resolve_select
163
+ * if resolving passes, returns final structure
164
+ * *p moves to first unused char
165
+ * return 0
166
+ *
167
+ * if memory allocation fails, returns -1
168
+ * if parsing or resolving fails, returns -2
169
+ */
170
+int parse_select (char** p, select_t** s);
171
+
172
+/*
173
+ * Select parser, result is stored in SHARED memory
174
+ * 
175
+ * If you call this, you must ensure, that the string which
176
+ * is beeing parsed MUST be at the same place for all child
177
+ * processes, e.g. allocated in the shared memory as well
178
+ *
179
+ * parameters and results same as parse_select
180
+ */
181
+int shm_parse_select (char** p, select_t** s);
182
+
160 183
 #define SELECT_F(function) extern int function (str* res, select_t* s, struct sip_msg* msg);
161 184
 #define ABSTRACT_F(function) int function (str* res, select_t* s, struct sip_msg* msg) {return -1;}
162 185
 
Browse code

Void data ptr introduced as select parameter type, to be used e.g. by fixup call

Michal Matyska authored on 20/02/2006 18:59:34
Showing 1 changed files
... ...
@@ -99,11 +99,13 @@ typedef enum {
99 99
 	SEL_PARAM_INT,  /* Integer parameter */
100 100
 	SEL_PARAM_STR,  /* String parameter */
101 101
 	SEL_PARAM_DIV,  /* Integer value got from parsing table */
102
+	SEL_PARAM_PTR   /* void* data got from e.g. fixup call */
102 103
 } select_param_type_t;
103 104
 	
104 105
 typedef union {
105 106
 	int i;  /* Integer value */
106 107
 	str s;  /* String value */
108
+	void* p;/* Any data ptr */
107 109
 } select_param_value_t;
108 110
 	
109 111
 typedef struct sel_param {
Browse code

Select framework extended to "fixup call" if demanded using flag FIXUP_CALL.

When this flag is included in the flags column, then during the select
resolution, the "fixup" call to the resolved function is done.

During this call the res & msg parameters set to NULL.
The function can change the parsed select structure, e.g. param.type from
SEL_PARAM_STR into SEL_PARAM_DIV, etc.

Currently used for select_anyheader:
- changes _ into - to support headers including dashes (use e.g. @msg.max_forwards)
- calls parse_hname2 to speed-up headers lookup for known headers

Michal Matyska authored on 17/02/2006 12:50:41
Showing 1 changed files
... ...
@@ -85,6 +85,13 @@
85 85
  */
86 86
 #define NESTED		1<<13
87 87
 
88
+/* "fixup call" would be done, when the structure is resolved to this node
89
+ * which means call with res and msg NULL
90
+ *
91
+ * if the fixup call return value <0, the select resolution will fail
92
+ */
93
+#define FIXUP_CALL	1<<14
94
+
88 95
 /*
89 96
  * Selector call parameter
90 97
  */
Browse code

- multiple nested calls allowed - default MAX_NESTED_CALLS set to 4 (select was supposed to be fast :-) - IS_ALIAS renamed to NESTED flag - DIVERSION flag is processed at resolve_select

Michal Matyska authored on 19/01/2006 19:44:40
Showing 1 changed files
... ...
@@ -27,6 +27,7 @@
27 27
  * History:
28 28
  * --------
29 29
  *  2005-12-19  select framework (mma)
30
+ *  2006-01-19  multiple nested calls, IS_ALIAS -> NESTED flag renamed (mma)
30 31
  */
31 32
 
32 33
  
... ...
@@ -37,25 +38,52 @@
37 38
 #include "parser/msg_parser.h"
38 39
 
39 40
 #define MAX_SELECT_PARAMS 32
41
+#define MAX_NESTED_CALLS  4
40 42
 
41
-// Flags for parser table FLAG bitfiels
43
+/* Flags for parser table FLAG bitfiels 
44
+ */
42 45
 #define DIVERSION_MASK   0x00FF
43
-// if DIVERSION is set and the function is accepted and has STR param
44
-// the param is changed into SEL_PARAM_DIV and the value is set to (flags & DIVERSION_MASK)
46
+
47
+/* if DIVERSION is set and the function is accepted
48
+ * the param is changed into SEL_PARAM_DIV and the value is set to (flags & DIVERSION_MASK)
49
+ *  - it is valuable for STR params (saves parsing time)
50
+ *  - does not release the memory occupied by the parameter
51
+ */
45 52
 #define DIVERSION        1<<8
46
-// if any parameter is expected at this stage
53
+
54
+/* set if any parameter is expected at this stage
55
+ * (the function must be resolved further)
56
+ */
47 57
 #define SEL_PARAM_EXPECTED   1<<9
48
-// accept if following parameter is STR (any)
58
+
59
+/* accept if following parameter is STR (any)
60
+ * consume that extra parameter in one step
61
+ */
49 62
 #define CONSUME_NEXT_STR 1<<10
50
-// accept if following parameter is INT
63
+
64
+/* accept if following parameter is INT
65
+ * consume that extra parameter in one ste
66
+ */
51 67
 #define CONSUME_NEXT_INT 1<<11
52
-// next parameter is optional (use with CONSUME_NEXT_STR or CONSUME_NEXT_INT
68
+
69
+/* next parameter is optional (use with CONSUME_NEXT_STR or CONSUME_NEXT_INT
70
+ * resolution is accepted even if there is no other parameter
71
+ * or the parameter is of wrong type
72
+ */
53 73
 #define OPTIONAL         1<<12
54
-// if conversion to common alias is needed
55
-// up-to now parsed function would be stored in parent_f
56
-// NOTE: the parameter is not consumed for ALIAS, 
57
-// so you can leave it as ..,SEL_PARAM_INT, STR_NULL,..
58
-#define IS_ALIAS         1<<13
74
+
75
+/* left function is noted to be called
76
+ * rigth function continues in resolution
77
+ * NOTE: the parameter is not consumed for PARENT, 
78
+ * so you can leave it as ..,SEL_PARAM_INT, 0,..
79
+ *
80
+ * run_select then calls all functions with PARENT flag
81
+ * in the order of resolution until the final call or 
82
+ * the result is != 0 (<0 error, 1 null str) 
83
+ * the only one parameter passed between nested calls
84
+ * is the result str*
85
+ */
86
+#define NESTED		1<<13
59 87
 
60 88
 /*
61 89
  * Selector call parameter
... ...
@@ -81,8 +109,7 @@ struct select;
81 109
 typedef int (*select_f)(str* res, struct select* s, struct sip_msg* msg);
82 110
 
83 111
 typedef struct select {
84
-	select_f f;
85
-	select_f parent_f;
112
+	select_f f[MAX_NESTED_CALLS];
86 113
 	select_param_t params[MAX_SELECT_PARAMS];
87 114
 	int n;
88 115
 } select_t;
Browse code

PARAM_xxx changed into SEL_PARAM_xxx to avoid conflict with global definitions

Michal Matyska authored on 07/01/2006 16:29:01
Showing 1 changed files
... ...
@@ -41,10 +41,10 @@
41 41
 // Flags for parser table FLAG bitfiels
42 42
 #define DIVERSION_MASK   0x00FF
43 43
 // if DIVERSION is set and the function is accepted and has STR param
44
-// the param is changed into PARAM_DIV and the value is set to (flags & DIVERSION_MASK)
44
+// the param is changed into SEL_PARAM_DIV and the value is set to (flags & DIVERSION_MASK)
45 45
 #define DIVERSION        1<<8
46 46
 // if any parameter is expected at this stage
47
-#define PARAM_EXPECTED   1<<9
47
+#define SEL_PARAM_EXPECTED   1<<9
48 48
 // accept if following parameter is STR (any)
49 49
 #define CONSUME_NEXT_STR 1<<10
50 50
 // accept if following parameter is INT
... ...
@@ -54,16 +54,16 @@
54 54
 // if conversion to common alias is needed
55 55
 // up-to now parsed function would be stored in parent_f
56 56
 // NOTE: the parameter is not consumed for ALIAS, 
57
-// so you can leave it as ..,PARAM_INT, STR_NULL,..
57
+// so you can leave it as ..,SEL_PARAM_INT, STR_NULL,..
58 58
 #define IS_ALIAS         1<<13
59 59
 
60 60
 /*
61 61
  * Selector call parameter
62 62
  */
63 63
 typedef enum {
64
-	PARAM_INT,  /* Integer parameter */
65
-	PARAM_STR,  /* String parameter */
66
-	PARAM_DIV,  /* Integer value got from parsing table */
64
+	SEL_PARAM_INT,  /* Integer parameter */
65
+	SEL_PARAM_STR,  /* String parameter */
66
+	SEL_PARAM_DIV,  /* Integer value got from parsing table */
67 67
 } select_param_type_t;
68 68
 	
69 69
 typedef union {
Browse code

History rewritten, new files GPLized

Michal Matyska authored on 20/12/2005 01:52:40
Showing 1 changed files
... ...
@@ -1,3 +1,35 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2005-2006 iptelorg GmbH
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
26
+ *
27
+ * History:
28
+ * --------
29
+ *  2005-12-19  select framework (mma)
30
+ */
31
+
32
+ 
1 33
 #ifndef _SELECT_H
2 34
 #define _SELECT_H
3 35
 
Browse code

New script element, Jan's select function framework (@xxx), extended for modular use. In the script it can be used as value assigned to AVP and in the string comparision, RE matching, like: $my_avp=@my.function[1]; if (@via.protocol=="UDP")...

The name to called function conversion is implemented as tree in a table,
modules can register their own tables in module initialization function.

Description of the construction of the table expected to follow soon in the
documentation files...

Michal Matyska authored on 20/12/2005 00:49:32
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,95 @@
1
+#ifndef _SELECT_H
2
+#define _SELECT_H
3
+
4
+#include "str.h"
5
+#include "parser/msg_parser.h"
6
+
7
+#define MAX_SELECT_PARAMS 32
8
+
9
+// Flags for parser table FLAG bitfiels
10
+#define DIVERSION_MASK   0x00FF
11
+// if DIVERSION is set and the function is accepted and has STR param
12
+// the param is changed into PARAM_DIV and the value is set to (flags & DIVERSION_MASK)
13
+#define DIVERSION        1<<8
14
+// if any parameter is expected at this stage
15
+#define PARAM_EXPECTED   1<<9
16
+// accept if following parameter is STR (any)
17
+#define CONSUME_NEXT_STR 1<<10
18
+// accept if following parameter is INT
19
+#define CONSUME_NEXT_INT 1<<11
20
+// next parameter is optional (use with CONSUME_NEXT_STR or CONSUME_NEXT_INT
21
+#define OPTIONAL         1<<12
22
+// if conversion to common alias is needed
23
+// up-to now parsed function would be stored in parent_f
24
+// NOTE: the parameter is not consumed for ALIAS, 
25
+// so you can leave it as ..,PARAM_INT, STR_NULL,..
26
+#define IS_ALIAS         1<<13
27
+
28
+/*
29
+ * Selector call parameter
30
+ */
31
+typedef enum {
32
+	PARAM_INT,  /* Integer parameter */
33
+	PARAM_STR,  /* String parameter */
34
+	PARAM_DIV,  /* Integer value got from parsing table */
35
+} select_param_type_t;
36
+	
37
+typedef union {
38
+	int i;  /* Integer value */
39
+	str s;  /* String value */
40
+} select_param_value_t;
41
+	
42
+typedef struct sel_param {
43
+        select_param_type_t type;
44
+        select_param_value_t v;
45
+} select_param_t;
46
+
47
+struct select;
48
+
49
+typedef int (*select_f)(str* res, struct select* s, struct sip_msg* msg);
50
+
51
+typedef struct select {
52
+	select_f f;
53
+	select_f parent_f;
54
+	select_param_t params[MAX_SELECT_PARAMS];
55
+	int n;
56
+} select_t;
57
+
58
+typedef struct {
59
+	select_f curr_f;
60
+	select_param_type_t type;
61
+	str name;
62
+	select_f new_f;
63
+	int flags;
64
+} select_row_t;
65
+
66
+typedef struct select_table {
67
+  select_row_t *table;
68
+  struct select_table *next;
69
+} select_table_t;
70
+
71
+/*
72
+ * Lookup corresponding select function based on
73
+ * the select parameters
74
+ */
75
+int resolve_select(select_t* s);
76
+
77
+/*
78
+ * Run the select function
79
+ */
80
+int run_select(str* res, select_t* s, struct sip_msg* msg);
81
+
82
+/*
83
+ * Print select for debugging purposes 
84
+ */
85
+void print_select(select_t* s);
86
+
87
+/*
88
+ * Register modules' own select parser table
89
+ */
90
+int register_select_table(select_row_t *table);
91
+
92
+#define SELECT_F(function) extern int function (str* res, select_t* s, struct sip_msg* msg);
93
+#define ABSTRACT_F(function) int function (str* res, select_t* s, struct sip_msg* msg) {return -1;}
94
+
95
+#endif /* _SELECT_H */