- 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)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,659 +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 |
-/** |
|
22 |
- * @file |
|
23 |
- * @brief Kamailio core :: modules loading, structures declarations and utilities |
|
24 |
- * @ingroup core |
|
25 |
- * Module: \ref core |
|
26 |
- */ |
|
27 |
- |
|
28 |
- |
|
29 |
-#ifndef sr_module_h |
|
30 |
-#define sr_module_h |
|
31 |
- |
|
32 |
-#include <dlfcn.h> |
|
33 |
- |
|
34 |
-#include "parser/msg_parser.h" /* for sip_msg */ |
|
35 |
-#include "ver_defs.h" |
|
36 |
-#include "rpc.h" |
|
37 |
-#include "route_struct.h" |
|
38 |
-#include "route.h" |
|
39 |
-#include "str.h" |
|
40 |
- |
|
41 |
-/* kamailio compat */ |
|
42 |
-#include "counters.h" |
|
43 |
-#include "mi/mi_types.h" |
|
44 |
-#include "pvar.h" |
|
45 |
- |
|
46 |
- |
|
47 |
- |
|
48 |
-#if defined KAMAILIO_MOD_INTERFACE || defined OPENSER_MOD_INTERFACE || \ |
|
49 |
- defined MOD_INTERFACE_V1 |
|
50 |
- |
|
51 |
-#define MODULE_INTERFACE_VER 1 |
|
52 |
-#define cmd_export_t kam_cmd_export_t |
|
53 |
-#define module_exports kam_module_exports |
|
54 |
- |
|
55 |
-#elif defined SER_MOD_INTERFACE || defined MOD_INTERFACE_V0 |
|
56 |
- |
|
57 |
-#define MODULE_INTERFACE_VER 0 |
|
58 |
-#define cmd_export_t ser_cmd_export_t |
|
59 |
-#define module_exports ser_module_exports |
|
60 |
- |
|
61 |
-#else |
|
62 |
- |
|
63 |
-/* do nothing for core */ |
|
64 |
- |
|
65 |
-#endif |
|
66 |
- |
|
67 |
-/** |
|
68 |
- * @brief type used for the mod_register function export |
|
69 |
- * |
|
70 |
- * mod_register is a function called when loading a module |
|
71 |
- * (if present), prior to registering the module exports. |
|
72 |
- * @param path path to the module, including file name |
|
73 |
- * @param dlflags pointer to the dlflags used when loading the module. |
|
74 |
- * If the value is changed to a different and non-zero value, the |
|
75 |
- * module will be reloaded with the new flags. |
|
76 |
- * @param reserved1 - reserved for future use. |
|
77 |
- * @param reserved2 - reserved for future use |
|
78 |
- * @return 0 on success, -1 on error, all the other values are reserved |
|
79 |
- * for future use (<0 meaning error and >0 success) |
|
80 |
- */ |
|
81 |
-typedef int (*mod_register_function)(char* path, int* dlflags, void* reserved1, void* reserved2); |
|
82 |
- |
|
83 |
-typedef struct module_exports* (*module_register)(void); |
|
84 |
- |
|
85 |
-/** |
|
86 |
- * @brief main two parameter module function |
|
87 |
- * |
|
88 |
- * Main two parameter module function, default and oldest version. |
|
89 |
- * @param sip_msg SIP message |
|
90 |
- * @param param1 first parameter |
|
91 |
- * @param param2 second parameter |
|
92 |
- * @return positive on success, negative on error, 0 to stop processing (drop message) |
|
93 |
- */ |
|
94 |
-typedef int (*cmd_function)(struct sip_msg*, char* param1, char* param2); |
|
95 |
-typedef int (*cmd_function3)(struct sip_msg*, char*, char*, char*); |
|
96 |
-typedef int (*cmd_function4)(struct sip_msg*, char*, char*, char*, char*); |
|
97 |
-typedef int (*cmd_function5)(struct sip_msg*, char*, char*, char*, |
|
98 |
- char*, char*); |
|
99 |
-typedef int (*cmd_function6)(struct sip_msg*, char*, char*, char*, |
|
100 |
- char*, char*, char*); |
|
101 |
-/** |
|
102 |
- * @brief variable number of parameter module function |
|
103 |
- * |
|
104 |
- * Variable number of parameter module function, takes as param the sip_msg, |
|
105 |
- * extra parameters number and a pointer to an array of parameters |
|
106 |
- * @param sip_msg SIP message |
|
107 |
- * @param no extra parameters number |
|
108 |
- * @param vals extra parameters |
|
109 |
- * @return positive on success, negative on error, 0 to stop processing (drop message) |
|
110 |
- */ |
|
111 |
-typedef int (*cmd_function_var)(struct sip_msg*, int no, action_u_t* vals ); |
|
112 |
-typedef int (*fixup_function)(void** param, int param_no); |
|
113 |
-typedef int (*free_fixup_function)(void** param, int param_no); |
|
114 |
- |
|
115 |
-/** |
|
116 |
- * @brief response module function prototype |
|
117 |
- * @param sip_msg SIP message |
|
118 |
- * @return positive if ok, 0 to stop processing |
|
119 |
- */ |
|
120 |
-typedef int (*response_function)(struct sip_msg*); |
|
121 |
-typedef void (*onbreak_function)(struct sip_msg*); |
|
122 |
-typedef void (*destroy_function)(void); |
|
123 |
- |
|
124 |
-typedef int (*init_function)(void); |
|
125 |
-typedef int (*child_init_function)(int rank); |
|
126 |
- |
|
127 |
- |
|
128 |
-#define PARAM_STRING (1U<<0) /**< String (char *) parameter type */ |
|
129 |
-#define PARAM_INT (1U<<1) /**< Integer parameter type */ |
|
130 |
-#define PARAM_STR (1U<<2) /**< struct str parameter type */ |
|
131 |
-#define PARAM_USE_FUNC (1U<<(8*sizeof(int)-1)) |
|
132 |
-#define PARAM_TYPE_MASK(_x) ((_x)&(~PARAM_USE_FUNC)) |
|
133 |
- |
|
134 |
-/* temporary, for backward compatibility only until all modules adjust it */ |
|
135 |
-#define STR_PARAM PARAM_STRING |
|
136 |
-#define INT_PARAM PARAM_INT |
|
137 |
-#define USE_FUNC_PARAM PARAM_USE_FUNC |
|
138 |
- |
|
139 |
-typedef unsigned int modparam_t; |
|
140 |
- |
|
141 |
-typedef int (*param_func_t)( modparam_t type, void* val); |
|
142 |
- |
|
143 |
-/* magic parameter number values */ |
|
144 |
- |
|
145 |
-#define NO_SCRIPT -1 /**< export not usable from scripts */ |
|
146 |
-#define VAR_PARAM_NO -128 /**< function has variable number of parameters |
|
147 |
- (see cmd_function_var for the prototype) */ |
|
148 |
- |
|
149 |
-/** |
|
150 |
- * special fixup function flags fparam fixup, rve ready, |
|
151 |
- * they are kept in the first 2 bits inside the pointer |
|
152 |
- */ |
|
153 |
-#define FIXUP_F_FPARAM_RVE (unsigned long)1 |
|
154 |
- |
|
155 |
-#define call_fixup(fixup, param, param_no) \ |
|
156 |
- ((fixup) ? (fixup)(param, param_no) : 0) |
|
157 |
- |
|
158 |
-/* Macros - used as rank in child_init function */ |
|
159 |
-#define PROC_MAIN 0 /**< Main ser process */ |
|
160 |
-#define PROC_TIMER -1 /**< Timer attendant process */ |
|
161 |
-#define PROC_RPC -2 /**< RPC type process */ |
|
162 |
-#define PROC_FIFO PROC_RPC /**< FIFO attendant process */ |
|
163 |
-#define PROC_TCP_MAIN -4 /**< TCP main process */ |
|
164 |
-#define PROC_UNIXSOCK -5 /**< Unix socket server */ |
|
165 |
-#define PROC_ATTENDANT -10 /**< main "attendant process */ |
|
166 |
-#define PROC_INIT -127 /**< special rank, the context is the main ser |
|
167 |
- process, but this is guaranteed to be executed |
|
168 |
- before any process is forked, so it can be used |
|
169 |
- to setup shared variables that depend on some |
|
170 |
- after mod_init available information (e.g. |
|
171 |
- total number of processes). |
|
172 |
- @warning child_init(PROC_MAIN) is again called |
|
173 |
- in the same process (main), but latter |
|
174 |
- (before tcp), so make sure you don't init things |
|
175 |
- twice, bot in PROC_MAIN and PROC_INT */ |
|
176 |
-#define PROC_NOCHLDINIT -128 /**< no child init functions will be called |
|
177 |
- if this rank is used in fork_process() */ |
|
178 |
- |
|
179 |
-#define PROC_SIPINIT 1 /**< First SIP worker - some modules do special |
|
180 |
- processing in this child, like loading db data */ |
|
181 |
-#define PROC_SIPRPC 127 /**< Used to init RPC worker as SIP commands |
|
182 |
- handler. Don't do any special processing in the |
|
183 |
- child init with this rank - just bare child |
|
184 |
- initialization */ |
|
185 |
- |
|
186 |
-#define PROC_MIN PROC_NOCHLDINIT /**< Minimum process rank */ |
|
187 |
- |
|
188 |
- |
|
189 |
-#define DEFAULT_DLFLAGS 0 /**< value that signals to module loader to |
|
190 |
- use default dlopen flags in Kamailio */ |
|
191 |
-#ifndef RTLD_NOW |
|
192 |
-/* for openbsd */ |
|
193 |
-#define RTLD_NOW DL_LAZY |
|
194 |
-#endif |
|
195 |
- |
|
196 |
-#define KAMAILIO_DLFLAGS RTLD_NOW |
|
197 |
- |
|
198 |
- |
|
199 |
-#define MODULE_VERSION \ |
|
200 |
- char *module_version=SER_FULL_VERSION; \ |
|
201 |
- char *module_flags=SER_COMPILE_FLAGS; \ |
|
202 |
- unsigned int module_interface_ver=MODULE_INTERFACE_VER; |
|
203 |
- |
|
204 |
-/** ser version */ |
|
205 |
-struct ser_cmd_export_ { |
|
206 |
- char* name; /**< null terminated command name */ |
|
207 |
- cmd_function function; /**< pointer to the corresponding function */ |
|
208 |
- int param_no; /**< number of parameters used by the function */ |
|
209 |
- fixup_function fixup; /**< pointer to the function called to "fix" the |
|
210 |
- parameters */ |
|
211 |
- unsigned int flags; /**< Function flags */ |
|
212 |
-}; |
|
213 |
- |
|
214 |
- |
|
215 |
-/** kamailo/openser version */ |
|
216 |
-struct kam_cmd_export_ { |
|
217 |
- char* name; /**< null terminated command name */ |
|
218 |
- cmd_function function; /**< pointer to the corresponding function */ |
|
219 |
- int param_no; /**< number of parameters used by the function */ |
|
220 |
- fixup_function fixup; /**< pointer to the function called to "fix" the |
|
221 |
- parameters */ |
|
222 |
- free_fixup_function free_fixup; /**< function called to free the "fixed" |
|
223 |
- parameters */ |
|
224 |
- unsigned int flags; /**< Function flags */ |
|
225 |
-}; |
|
226 |
- |
|
227 |
-/** sip-router version */ |
|
228 |
-struct sr31_cmd_export_ { |
|
229 |
- char* name; /**< null terminated command name */ |
|
230 |
- cmd_function function; /**< pointer to the corresponding function */ |
|
231 |
- int param_no; /**< number of parameters used by the function */ |
|
232 |
- fixup_function fixup; /**< pointer to the function called to "fix" the |
|
233 |
- parameters */ |
|
234 |
- free_fixup_function free_fixup; /**< function called to free the "fixed" |
|
235 |
- parameters */ |
|
236 |
- unsigned int flags; /**< Function flags */ |
|
237 |
- unsigned int fixup_flags; |
|
238 |
- void* module_exports; /**< pointer to module structure */ |
|
239 |
-}; |
|
240 |
- |
|
241 |
- |
|
242 |
-/** members situated at the same place in memory in both ser & kamailio |
|
243 |
- cmd_export */ |
|
244 |
-struct cmd_export_common_ { |
|
245 |
- char* name; |
|
246 |
- cmd_function function; |
|
247 |
- int param_no; |
|
248 |
- fixup_function fixup; |
|
249 |
-}; |
|
250 |
- |
|
251 |
- |
|
252 |
-struct param_export_ { |
|
253 |
- char* name; /**< null terminated param. name */ |
|
254 |
- modparam_t type; /**< param. type */ |
|
255 |
- void* param_pointer; /**< pointer to the param. memory location */ |
|
256 |
-}; |
|
257 |
- |
|
258 |
- |
|
259 |
-/* |
|
260 |
- * Allowed parameter types, the types _must_ be in "fallback" order, |
|
261 |
- * e.g. FPARAM_STR should be the last to allow fallback to it, |
|
262 |
- * F_PARAM_PVS should be in front of F_PARAM_AVP (so that |
|
263 |
- * for fix_param_types(FPARAM_AVP|FPARAM_PVS|FPARAM_STR, param) and $foo |
|
264 |
- * the pvars will be checked first and only if no pvar is found the |
|
265 |
- * param will be resolved to an avp) |
|
266 |
- */ |
|
267 |
-enum { |
|
268 |
- FPARAM_UNSPEC = 0, |
|
269 |
- FPARAM_INT = (1 << 0), |
|
270 |
- FPARAM_SELECT = (1 << 1), |
|
271 |
- FPARAM_PVS = (1 << 2), |
|
272 |
- FPARAM_AVP = (1 << 3), |
|
273 |
- FPARAM_STRING = (1 << 4), |
|
274 |
- FPARAM_STR = (1 << 5), |
|
275 |
- /* special types: no fallback between them possible */ |
|
276 |
- FPARAM_REGEX = (1 << 6), |
|
277 |
- FPARAM_SUBST = (1 << 7), |
|
278 |
- FPARAM_PVE = (1 << 8) |
|
279 |
-}; |
|
280 |
- |
|
281 |
-/** |
|
282 |
- * Function parameter |
|
283 |
- */ |
|
284 |
-typedef struct fparam { |
|
285 |
- char* orig; /**< The original value */ |
|
286 |
- int type; /**< Type of parameter */ |
|
287 |
- union { |
|
288 |
- char* asciiz; /**< Zero terminated ASCII string */ |
|
289 |
- struct _str str; /**< pointer/len string */ |
|
290 |
- int i; /**< Integer value */ |
|
291 |
- regex_t* regex; /**< Compiled regular expression */ |
|
292 |
- avp_ident_t avp; /**< AVP identifier */ |
|
293 |
- select_t* select; /**< select structure */ |
|
294 |
- struct subst_expr* subst; /**< Regex substitution */ |
|
295 |
- pv_spec_t* pvs; /**< kamailio pseudo-vars */ |
|
296 |
- pv_elem_t* pve; /**< kamailio pseudo-vars in a string */ |
|
297 |
- } v; |
|
298 |
- void *fixed; |
|
299 |
-} fparam_t; |
|
300 |
- |
|
301 |
- |
|
302 |
-typedef struct param_export_ param_export_t; |
|
303 |
-typedef struct ser_cmd_export_ ser_cmd_export_t; |
|
304 |
-typedef struct kam_cmd_export_ kam_cmd_export_t; |
|
305 |
-typedef struct cmd_export_common_ cmd_export_common_t; |
|
306 |
-typedef struct sr31_cmd_export_ sr31_cmd_export_t; |
|
307 |
- |
|
308 |
- |
|
309 |
-/** ser module exports version */ |
|
310 |
-struct ser_module_exports { |
|
311 |
- char* name; /**< null terminated module name */ |
|
312 |
- ser_cmd_export_t* cmds; /**< null terminated array of the exported |
|
313 |
- commands */ |
|
314 |
- rpc_export_t* rpc_methods; /**< null terminated array of exported rpc methods */ |
|
315 |
- param_export_t* params; /**< null terminated array of the exported |
|
316 |
- module parameters */ |
|
317 |
- init_function init_f; /**< Initialization function */ |
|
318 |
- response_function response_f; /**< function used for responses, |
|
319 |
- returns yes or no; can be null */ |
|
320 |
- destroy_function destroy_f; /**< function called when the module should |
|
321 |
- be "destroyed", e.g: on ser exit; |
|
322 |
- can be null */ |
|
323 |
- onbreak_function onbreak_f; |
|
324 |
- child_init_function init_child_f; /**< function called by all processes |
|
325 |
- after the fork */ |
|
326 |
-}; |
|
327 |
- |
|
328 |
- |
|
329 |
-/** kamailio/openser proc_export (missing from ser) */ |
|
330 |
-typedef void (*mod_proc)(int no); |
|
331 |
- |
|
332 |
-typedef int (*mod_proc_wrapper)(void); |
|
333 |
- |
|
334 |
-struct proc_export_ { |
|
335 |
- char *name; |
|
336 |
- mod_proc_wrapper pre_fork_function; |
|
337 |
- mod_proc_wrapper post_fork_function; |
|
338 |
- mod_proc function; |
|
339 |
- unsigned int no; |
|
340 |
-}; |
|
341 |
- |
|
342 |
-typedef struct proc_export_ proc_export_t; |
|
343 |
- |
|
344 |
- |
|
345 |
-/** kamailio/openser module exports version */ |
|
346 |
-struct kam_module_exports { |
|
347 |
- char* name; /**< null terminated module name */ |
|
348 |
- unsigned int dlflags; /**< flags for dlopen */ |
|
349 |
- kam_cmd_export_t* cmds; /**< null terminated array of the exported |
|
350 |
- commands */ |
|
351 |
- param_export_t* params; /**< null terminated array of the exported |
|
352 |
- module parameters */ |
|
353 |
- stat_export_t* stats; /**< null terminated array of the exported |
|
354 |
- module statistics */ |
|
355 |
- mi_export_t* mi_cmds; /**< null terminated array of the exported |
|
356 |
- MI functions */ |
|
357 |
- pv_export_t* items; /*!< null terminated array of the exported |
|
358 |
- module items (pseudo-variables) */ |
|
359 |
- proc_export_t* procs; /**< null terminated array of the |
|
360 |
- additional processes required by the |
|
361 |
- module */ |
|
362 |
- init_function init_f; /**< Initialization function */ |
|
363 |
- response_function response_f; /**< function used for responses, |
|
364 |
- returns yes or no; can be null */ |
|
365 |
- destroy_function destroy_f; /**< function called when the module should |
|
366 |
- be "destroyed", e.g: on ser exit; |
|
367 |
- can be null */ |
|
368 |
- child_init_function init_child_f; /**< function called by all processes |
|
369 |
- after the fork */ |
|
370 |
-}; |
|
371 |
- |
|
372 |
- |
|
373 |
- |
|
374 |
-/** |
|
375 |
- * @brief sr/ser 3.1+ module exports version |
|
376 |
- * |
|
377 |
- * sr/ser 3.1+ module exports version, Includes ser and kamailio versions, |
|
378 |
- * re-arraranged + some extras. |
|
379 |
- * @note Some of the members will be obsoleted and are kept only for |
|
380 |
- * backward compatibility (avoid re-writing all the modules exports |
|
381 |
- * declarations). |
|
382 |
- */ |
|
383 |
-struct sr31_module_exports { |
|
384 |
- char* name; /**< null terminated module name */ |
|
385 |
- sr31_cmd_export_t* cmds; /**< null terminated array of the exported |
|
386 |
- commands */ |
|
387 |
- param_export_t* params; /**< null terminated array of the exported |
|
388 |
- module parameters */ |
|
389 |
- init_function init_f; /**< Initialization function */ |
|
390 |
- response_function response_f; /**< function used for responses, |
|
391 |
- returns yes or no; can be null */ |
|
392 |
- destroy_function destroy_f; /**< function called when the module should |
|
393 |
- be "destroyed", e.g: on ser exit; |
|
394 |
- can be null */ |
|
395 |
- onbreak_function onbreak_f; |
|
396 |
- child_init_function init_child_f;/**< function called by all processes |
|
397 |
- after the fork */ |
|
398 |
- unsigned int dlflags; /**< flags for dlopen */ |
|
399 |
- /* ser specific exports |
|
400 |
- (to be obsoleted and replaced by register_...) */ |
|
401 |
- rpc_export_t* rpc_methods; /**< null terminated array of exported |
|
402 |
- rpc methods */ |
|
403 |
- /* kamailio specific exports |
|
404 |
- (to be obsoleted and replaced by register_...) */ |
|
405 |
- stat_export_t* stats; /**< null terminated array of the exported |
|
406 |
- module statistics */ |
|
407 |
- mi_export_t* mi_cmds; /**< null terminated array of the exported |
|
408 |
- MI functions */ |
|
409 |
- pv_export_t* items; /**< null terminated array of the exported |
|
410 |
- module items (pseudo-variables) */ |
|
411 |
- proc_export_t* procs; /**< null terminated array of the |
|
412 |
- additional processes required by the |
|
413 |
- module */ |
|
414 |
-}; |
|
415 |
- |
|
416 |
- |
|
417 |
- |
|
418 |
-/** module exports in the same place in memory in both ser & kamailio */ |
|
419 |
-struct module_exports_common { |
|
420 |
- char* name; |
|
421 |
-}; |
|
422 |
- |
|
423 |
- |
|
424 |
-union module_exports_u { |
|
425 |
- struct module_exports_common c; /**< common members for all the versions */ |
|
426 |
- struct ser_module_exports v0; |
|
427 |
- struct kam_module_exports v1; |
|
428 |
-}; |
|
429 |
- |
|
430 |
- |
|
431 |
-struct sr_module { |
|
432 |
- char* path; |
|
433 |
- void* handle; |
|
434 |
- unsigned int orig_mod_interface_ver; |
|
435 |
- struct sr31_module_exports exports; |
|
436 |
- struct sr_module* next; |
|
437 |
-}; |
|
438 |
- |
|
439 |
- |
|
440 |
-extern struct sr_module* modules; /**< global module list*/ |
|
441 |
-extern response_function* mod_response_cbks; /**< response callback array */ |
|
442 |
-extern int mod_response_cbk_no; /**< size of reponse callbacks array */ |
|
443 |
- |
|
444 |
-int register_builtin_modules(void); |
|
445 |
-int load_module(char* path); |
|
446 |
-sr31_cmd_export_t* find_export_record(char* name, int param_no, int flags, |
|
447 |
- unsigned *ver); |
|
448 |
-cmd_function find_export(char* name, int param_no, int flags); |
|
449 |
-cmd_function find_mod_export(char* mod, char* name, int param_no, int flags); |
|
450 |
-rpc_export_t* find_rpc_export(char* name, int flags); |
|
451 |
-void destroy_modules(void); |
|
452 |
-int init_child(int rank); |
|
453 |
-int init_modules(void); |
|
454 |
-struct sr_module* find_module_by_name(char* mod); |
|
455 |
- |
|
456 |
-/**< true if the module with name 'mod_name' is loaded */ |
|
457 |
-#define module_loaded(mod_name) (find_module_by_name(mod_name)!=0) |
|
458 |
- |
|
459 |
- |
|
460 |
-/** |
|
461 |
- * @brief Find a parameter with given type |
|
462 |
- * @param mod module |
|
463 |
- * @param name parameter name |
|
464 |
- * @param type_mask parameter mask |
|
465 |
- * @param param_type parameter type |
|
466 |
- * @return parameter address in memory, if there is no such parameter, NULL is returned |
|
467 |
- */ |
|
468 |
-void* find_param_export(struct sr_module* mod, char* name, modparam_t type_mask, modparam_t *param_type); |
|
469 |
- |
|
470 |
- |
|
471 |
-/** API function to get other parameters from fixup */ |
|
472 |
-action_u_t *fixup_get_param(void **cur_param, int cur_param_no, int required_param_no); |
|
473 |
-int fixup_get_param_count(void **cur_param, int cur_param_no); |
|
474 |
- |
|
475 |
-int fix_flag( modparam_t type, void* val, |
|
476 |
- char* mod_name, char* param_name, int* flag); |
|
477 |
- |
|
478 |
- |
|
479 |
-/* |
|
480 |
- * Common function parameter fixups |
|
481 |
- */ |
|
482 |
- |
|
483 |
-/** |
|
484 |
- * @brief Generic parameter fixup function |
|
485 |
- * |
|
486 |
- * Generic parameter fixup function which creates fparam_t structure. |
|
487 |
- * Type parameter contains allowed parameter types. |
|
488 |
- * @param type parameter type |
|
489 |
- * @param param fixed parameter |
|
490 |
- * @return 0 on success, -1 on error |
|
491 |
- */ |
|
492 |
-int fix_param(int type, void** param); |
|
493 |
-void fparam_free_contents(fparam_t* fp); |
|
494 |
- |
|
495 |
-/** fix a param to one of the given types (mask). |
|
496 |
- */ |
|
497 |
-int fix_param_types(int types, void** param); |
|
498 |
- |
|
499 |
-/** |
|
500 |
- * @brief Fixup variable string, |
|
501 |
- * |
|
502 |
- * Fixup variable string, the parameter can be AVP, SELECT, or ordinary |
|
503 |
- * string. AVP and select identifiers will be resolved to their values |
|
504 |
- * during runtime. The parameter value will be converted to fparam structure. |
|
505 |
- * @param param fixed parameter value |
|
506 |
- * @param param_no number of parameter |
|
507 |
- * @return 0 on success, -1 on an error |
|
508 |
- */ |
|
509 |
-int fixup_var_str_12(void** param, int param_no); |
|
510 |
- |
|
511 |
-/** Same as fixup_var_str_12 but applies to the 1st parameter only */ |
|
512 |
-int fixup_var_str_1(void** param, int param_no); |
|
513 |
- |
|
514 |
-/** Same as fixup_var_str_12 but applies to the 2nd parameter only */ |
|
515 |
-int fixup_var_str_2(void** param, int param_no); |
|
516 |
- |
|
517 |
-/** fixup variable-pve-only-string. */ |
|
518 |
-int fixup_var_pve_12(void** param, int param_no); |
|
519 |
- |
|
520 |
-/** fixup variable-pve-string. |
|
521 |
- * The parameter can be a PVAR, AVP, SELECT, PVE (pv based format string) |
|
522 |
- * or string. |
|
523 |
- */ |
|
524 |
-int fixup_var_pve_str_12(void** param, int param_no); |
|
525 |
- |
|
526 |
-/** same as fixup_var_pve_str_12 but applies to the 1st parameter only */ |
|
527 |
-int fixup_var_pve_str_1(void** param, int param_no); |
|
528 |
- |
|
529 |
-/** same as fixup_var_pve_str_12 but applies to the 2nd parameter only */ |
|
530 |
-int fixup_var_pve_str_2(void** param, int param_no); |
|
531 |
- |
|
532 |
-/** |
|
533 |
- * @brief Fixup variable integer |
|
534 |
- * |
|
535 |
- * Fixup variable integer, the parameter can be AVP, SELECT, or ordinary |
|
536 |
- * integer. AVP and select identifiers will be resolved to their values |
|
537 |
- * and converted to int if necessary during runtime. The parameter value will |
|
538 |
- * be converted to fparam structure |
|
539 |
- * @param param fixed parameter value |
|
540 |
- * @param param_no number of parameter |
|
541 |
- * @return 0 on success, -1 on an error |
|
542 |
- */ |
|
543 |
-int fixup_var_int_12(void** param, int param_no); |
|
544 |
- |
|
545 |
-/** Same as fixup_var_int_12 but applies to the 1st parameter only */ |
|
546 |
-int fixup_var_int_1(void** param, int param_no); |
|
547 |
- |
|
548 |
-/** Same as fixup_var_int_12 but applies to the 2nd parameter only */ |
|
549 |
-int fixup_var_int_2(void** param, int param_no); |
|
550 |
- |
|
551 |
-/** |
|
552 |
- * The parameter must be a regular expression which must compile, the |
|
553 |
- * parameter will be converted to compiled regex |
|
554 |
- */ |
|
555 |
-int fixup_regex_12(void** param, int param_no); |
|
556 |
- |
|
557 |
-/** Same as fixup_regex_12 but applies to the 1st parameter only */ |
|
558 |
-int fixup_regex_1(void** param, int param_no); |
|
559 |
- |
|
560 |
-/** Same as fixup_regex_12 but applies to the 2nd parameter only */ |
|
561 |
-int fixup_regex_2(void** param, int param_no); |
|
562 |
- |
|
563 |
-/** |
|
564 |
- * The string parameter will be converted to integer |
|
565 |
- */ |
|
566 |
-int fixup_int_12(void** param, int param_no); |
|
567 |
- |
|
568 |
-/** Same as fixup_int_12 but applies to the 1st parameter only */ |
|
569 |
-int fixup_int_1(void** param, int param_no); |
|
570 |
- |
|
571 |
-/** Same as fixup_int_12 but applies to the 2nd parameter only */ |
|
572 |
-int fixup_int_2(void** param, int param_no); |
|
573 |
- |
|
574 |
-/** |
|
575 |
- * Parse the parameter as static string, do not resolve |
|
576 |
- * AVPs or selects, convert the parameter to str structure |
|
577 |
- */ |
|
578 |
-int fixup_str_12(void** param, int param_no); |
|
579 |
- |
|
580 |
-/** Same as fixup_str_12 but applies to the 1st parameter only */ |
|
581 |
-int fixup_str_1(void** param, int param_no); |
|
582 |
- |
|
583 |
-/** Same as fixup_str_12 but applies to the 2nd parameter only */ |
|
584 |
-int fixup_str_2(void** param, int param_no); |
|
585 |
- |
|
586 |
-/** |
|
587 |
- * @brief Get the function parameter value as string |
|
588 |
- * @param dst string destination |
|
589 |
- * @param msg SIP message |
|
590 |
- * @param param function parameters |
|
591 |
- * @return 0 on success, 1 on error, e.g. cannot get value |
|
592 |
- */ |
|
593 |
-int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param); |
|
594 |
- |
|
595 |
-/** |
|
596 |
- * @brief Get the function parameter value as integer |
|
597 |
- * @param dst string destination |
|
598 |
- * @param msg SIP message |
|
599 |
- * @param param function parameters |
|
600 |
- * @return 0 on success, 1 on error, e.g. cannot get value |
|
601 |
- */ |
|
602 |
-int get_int_fparam(int* dst, struct sip_msg* msg, fparam_t* param); |
|
603 |
- |
|
604 |
-/** |
|
605 |
- * @brief Get the function parameter value as integer/string |
|
606 |
- * @param i_dst int destination |
|
607 |
- * @param s_dst string destination |
|
608 |
- * @param msg SIP message |
|
609 |
- * @param param function parameters |
|
610 |
- * @param flags flags to indicate destinations |
|
611 |
- * @return 0 on success, 1 on error, e.g. cannot get value |
|
612 |
- */ |
|
613 |
-int get_is_fparam(int* i_dst, str* s_dst, struct sip_msg* msg, fparam_t* param, unsigned int *flags); |
|
614 |
- |
|
615 |
-/** |
|
616 |
- * @brief Get the function parameter value as compiled regular expression |
|
617 |
- * @param dst string destination |
|
618 |
- * @param msg SIP message |
|
619 |
- * @param param function parameters |
|
620 |
- * @return 0 on success, 1 on error, e.g. cannot get value |
|
621 |
- */ |
|
622 |
-int get_regex_fparam(regex_t *dst, struct sip_msg* msg, fparam_t* param); |
|
623 |
- |
|
624 |
- |
|
625 |
-int is_fparam_rve_fixup(fixup_function f); |
|
626 |
- |
|
627 |
-/** |
|
628 |
- * @brief Generic free fixup type function for a fixed fparam |
|
629 |
- * |
|
630 |
- * Generic free fixup type function for a fixed fparam. It will free whatever |
|
631 |
- * was allocated during the initial fparam fixup and restore the original param |
|
632 |
- * value. |
|
633 |
- * @param param freed parameters |
|
634 |
- */ |
|
635 |
-void fparam_free_restore(void** param); |
|
636 |
-int fixup_free_fparam_all(void** param, int param_no); |
|
637 |
-int fixup_free_fparam_1(void** param, int param_no); |
|
638 |
-int fixup_free_fparam_2(void** param, int param_no); |
|
639 |
- |
|
640 |
-/** |
|
641 |
- * @brief returns the corresponding fixup_free* for various known fixup types |
|
642 |
- * |
|
643 |
- * Returns the corresponding fixup_free* for various known fixup types. |
|
644 |
- * Used to automatically fill in free_fixup* functions. |
|
645 |
- * @param f fixup function pointer |
|
646 |
- * @return free fixup function pointer on success, 0 on failure (unknown |
|
647 |
- * fixup or no free fixup function). |
|
648 |
- */ |
|
649 |
-free_fixup_function get_fixup_free(fixup_function f); |
|
650 |
- |
|
651 |
-void set_child_sip_rpc_mode(void); |
|
652 |
-void set_child_rpc_sip_mode(void); |
|
653 |
-int is_sip_worker(int rank); |
|
654 |
-int is_rpc_worker(int rank); |
|
655 |
- |
|
656 |
-unsigned int set_modinit_delay(unsigned int v); |
|
657 |
-int destroy_modules_phase(void); |
|
658 |
- |
|
659 |
-#endif /* sr_module_h */ |
- instead of kcore stats wrapers, use directly counters.h from core
- parse of sst header moved to sst module (only use)
- string helper functions compacted in strutils.h
- statistics helper functions used only by snmpstats module moved to it
... | ... |
@@ -607,7 +607,7 @@ int get_int_fparam(int* dst, struct sip_msg* msg, fparam_t* param); |
607 | 607 |
* @param s_dst string destination |
608 | 608 |
* @param msg SIP message |
609 | 609 |
* @param param function parameters |
610 |
- * @param flags flags to indicate destiantions |
|
610 |
+ * @param flags flags to indicate destinations |
|
611 | 611 |
* @return 0 on success, 1 on error, e.g. cannot get value |
612 | 612 |
*/ |
613 | 613 |
int get_is_fparam(int* i_dst, str* s_dst, struct sip_msg* msg, fparam_t* param, unsigned int *flags); |
- update Makefile.defs for recent versions of Solaris Studio
... | ... |
@@ -208,7 +208,7 @@ struct ser_cmd_export_ { |
208 | 208 |
int param_no; /**< number of parameters used by the function */ |
209 | 209 |
fixup_function fixup; /**< pointer to the function called to "fix" the |
210 | 210 |
parameters */ |
211 |
- int flags; /**< Function flags */ |
|
211 |
+ unsigned int flags; /**< Function flags */ |
|
212 | 212 |
}; |
213 | 213 |
|
214 | 214 |
|
... | ... |
@@ -221,7 +221,7 @@ struct kam_cmd_export_ { |
221 | 221 |
parameters */ |
222 | 222 |
free_fixup_function free_fixup; /**< function called to free the "fixed" |
223 | 223 |
parameters */ |
224 |
- int flags; /**< Function flags */ |
|
224 |
+ unsigned int flags; /**< Function flags */ |
|
225 | 225 |
}; |
226 | 226 |
|
227 | 227 |
/** sip-router version */ |
... | ... |
@@ -233,8 +233,8 @@ struct sr31_cmd_export_ { |
233 | 233 |
parameters */ |
234 | 234 |
free_fixup_function free_fixup; /**< function called to free the "fixed" |
235 | 235 |
parameters */ |
236 |
- int flags; /**< Function flags */ |
|
237 |
- int fixup_flags; |
|
236 |
+ unsigned int flags; /**< Function flags */ |
|
237 |
+ unsigned int fixup_flags; |
|
238 | 238 |
void* module_exports; /**< pointer to module structure */ |
239 | 239 |
}; |
240 | 240 |
|
... | ... |
@@ -1,19 +1,14 @@ |
1 | 1 |
/* |
2 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
3 | 3 |
* |
4 |
- * This file is part of ser, a free SIP server. |
|
4 |
+ * This file is part of Kamailio, a free SIP server. |
|
5 | 5 |
* |
6 |
- * ser is free software; you can redistribute it and/or modify |
|
6 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
7 | 7 |
* it under the terms of the GNU General Public License as published by |
8 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
9 | 9 |
* (at your option) any later version |
10 | 10 |
* |
11 |
- * For a license to use the ser software under conditions |
|
12 |
- * other than those described here, or to purchase support for this |
|
13 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
14 |
- * info@iptel.org |
|
15 |
- * |
|
16 |
- * ser is distributed in the hope that it will be useful, |
|
11 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
17 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | 14 |
* GNU General Public License for more details. |
... | ... |
@@ -23,32 +18,9 @@ |
23 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 | 19 |
*/ |
25 | 20 |
|
26 |
-/* |
|
27 |
- * History: |
|
28 |
- * -------- |
|
29 |
- * 2003-03-10 changed module exports interface: added struct cmd_export |
|
30 |
- * and param_export (andrei) |
|
31 |
- * 2003-03-16 Added flags field to cmd_export_ (janakj) |
|
32 |
- * 2003-04-05 s/reply_route/failure_route, onreply_route introduced (jiri) |
|
33 |
- * 2004-03-12 extra flag USE_FUNC_PARAM added to modparam type - |
|
34 |
- * instead of copying the param value, a func is called (bogdan) |
|
35 |
- * 2004-09-19 switched to version.h for the module versions checks (andrei) |
|
36 |
- * 2004-12-03 changed param_func_t to (modparam_t, void*), killed |
|
37 |
- * param_func_param_t (andrei) |
|
38 |
- * 2007-06-07 added PROC_INIT, called in the main process context |
|
39 |
- * (same as PROC_MAIN), buf guaranteed to be called before |
|
40 |
- * any other process is forked (andrei) |
|
41 |
- * 2008-11-17 sip-router version: includes some of the openser/kamailio |
|
42 |
- * changes: f(void) instead of f(), free_fixup_function() |
|
43 |
- * dual module interface support: ser & kamailio (andrei) |
|
44 |
- * 2008-11-18 prototypes for various fixed parameters numbers module |
|
45 |
- * functions (3, 4, 5 & 6) and variable parameters (andrei) |
|
46 |
- * 2008-11-26 added fparam_free_contents() and fix_param_types (andrei) |
|
47 |
- */ |
|
48 |
- |
|
49 | 21 |
/** |
50 | 22 |
* @file |
51 |
- * @brief SIP-Router core :: modules loading, structures declarations and utilities |
|
23 |
+ * @brief Kamailio core :: modules loading, structures declarations and utilities |
|
52 | 24 |
* @ingroup core |
53 | 25 |
* Module: \ref core |
54 | 26 |
*/ |
... | ... |
@@ -20,7 +20,7 @@ |
20 | 20 |
* |
21 | 21 |
* You should have received a copy of the GNU General Public License |
22 | 22 |
* along with this program; if not, write to the Free Software |
23 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
/* |
... | ... |
@@ -629,6 +629,17 @@ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param); |
629 | 629 |
*/ |
630 | 630 |
int get_int_fparam(int* dst, struct sip_msg* msg, fparam_t* param); |
631 | 631 |
|
632 |
+/** |
|
633 |
+ * @brief Get the function parameter value as integer/string |
|
634 |
+ * @param i_dst int destination |
|
635 |
+ * @param s_dst string destination |
|
636 |
+ * @param msg SIP message |
|
637 |
+ * @param param function parameters |
|
638 |
+ * @param flags flags to indicate destiantions |
|
639 |
+ * @return 0 on success, 1 on error, e.g. cannot get value |
|
640 |
+ */ |
|
641 |
+int get_is_fparam(int* i_dst, str* s_dst, struct sip_msg* msg, fparam_t* param, unsigned int *flags); |
|
642 |
+ |
|
632 | 643 |
/** |
633 | 644 |
* @brief Get the function parameter value as compiled regular expression |
634 | 645 |
* @param dst string destination |
- sepecify microseconds to sleep after initializing a module in order to
cope with systems having rate limits on new connections to db or other
servers
- existing function could convert single pv PVE in PVAR, which can cause
troubles as PVE value should be always zero terminated
... | ... |
@@ -542,6 +542,9 @@ int fixup_var_str_1(void** param, int param_no); |
542 | 542 |
/** Same as fixup_var_str_12 but applies to the 2nd parameter only */ |
543 | 543 |
int fixup_var_str_2(void** param, int param_no); |
544 | 544 |
|
545 |
+/** fixup variable-pve-only-string. */ |
|
546 |
+int fixup_var_pve_12(void** param, int param_no); |
|
547 |
+ |
|
545 | 548 |
/** fixup variable-pve-string. |
546 | 549 |
* The parameter can be a PVAR, AVP, SELECT, PVE (pv based format string) |
547 | 550 |
* or string. |
- PROC_SIPINIT 1 - some modules do specific processing in this child
only, like usrloc loading records from db
- PROC_SIPRPC 127 - special positive rank to use in RPC workers to init
the environment for processing SIP-specific commands. For example,
event_route[tm:local-request] can be executed due to MI/RPC command
and have insite SIP related functions from other modules which need db
connection, like acc_db_request()
... | ... |
@@ -204,6 +204,13 @@ typedef int (*param_func_t)( modparam_t type, void* val); |
204 | 204 |
#define PROC_NOCHLDINIT -128 /**< no child init functions will be called |
205 | 205 |
if this rank is used in fork_process() */ |
206 | 206 |
|
207 |
+#define PROC_SIPINIT 1 /**< First SIP worker - some modules do special |
|
208 |
+ processing in this child, like loading db data */ |
|
209 |
+#define PROC_SIPRPC 127 /**< Used to init RPC worker as SIP commands |
|
210 |
+ handler. Don't do any special processing in the |
|
211 |
+ child init with this rank - just bare child |
|
212 |
+ initialization */ |
|
213 |
+ |
|
207 | 214 |
#define PROC_MIN PROC_NOCHLDINIT /**< Minimum process rank */ |
208 | 215 |
|
209 | 216 |
|
- a sip child process can handle rpc (e.g., xmlops module) and a rpc
child process can handle sip commands (e.g., mi cmd to end dlg and
event_route[tm:local-request])
... | ... |
@@ -655,8 +655,9 @@ int fixup_free_fparam_2(void** param, int param_no); |
655 | 655 |
*/ |
656 | 656 |
free_fixup_function get_fixup_free(fixup_function f); |
657 | 657 |
|
658 |
-void set_sip_rpc_mode(int mode); |
|
659 |
-int get_sip_rpc_mode(void); |
|
658 |
+void set_child_sip_rpc_mode(void); |
|
659 |
+void set_child_rpc_sip_mode(void); |
|
660 |
+int is_sip_worker(int rank); |
|
660 | 661 |
int is_rpc_worker(int rank); |
661 | 662 |
|
662 | 663 |
#endif /* sr_module_h */ |
- for example when using xmlrpc module, the rpc commands are handled by
sip workers and may require special sip child initialization
... | ... |
@@ -655,4 +655,8 @@ int fixup_free_fparam_2(void** param, int param_no); |
655 | 655 |
*/ |
656 | 656 |
free_fixup_function get_fixup_free(fixup_function f); |
657 | 657 |
|
658 |
+void set_sip_rpc_mode(int mode); |
|
659 |
+int get_sip_rpc_mode(void); |
|
660 |
+int is_rpc_worker(int rank); |
|
661 |
+ |
|
658 | 662 |
#endif /* sr_module_h */ |
... | ... |
@@ -326,14 +326,6 @@ typedef struct kam_cmd_export_ kam_cmd_export_t; |
326 | 326 |
typedef struct cmd_export_common_ cmd_export_common_t; |
327 | 327 |
typedef struct sr31_cmd_export_ sr31_cmd_export_t; |
328 | 328 |
|
329 |
-#if 0 |
|
330 |
-union cmd_export_u{ |
|
331 |
- cmd_export_common_t c; /* common members for everybody */ |
|
332 |
- ser_cmd_export_t v0; |
|
333 |
- kam_cmd_export_t v1; |
|
334 |
-}; |
|
335 |
-#endif |
|
336 |
- |
|
337 | 329 |
|
338 | 330 |
/** ser module exports version */ |
339 | 331 |
struct ser_module_exports { |
... | ... |
@@ -1,8 +1,4 @@ |
1 |
-/* $Id$ |
|
2 |
- * |
|
3 |
- * modules/plug-in structures declarations |
|
4 |
- * |
|
5 |
- * |
|
1 |
+/* |
|
6 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
7 | 3 |
* |
8 | 4 |
* This file is part of ser, a free SIP server. |
... | ... |
@@ -26,6 +22,7 @@ |
26 | 22 |
* along with this program; if not, write to the Free Software |
27 | 23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 | 24 |
*/ |
25 |
+ |
|
29 | 26 |
/* |
30 | 27 |
* History: |
31 | 28 |
* -------- |
... | ... |
@@ -49,8 +46,11 @@ |
49 | 46 |
* 2008-11-26 added fparam_free_contents() and fix_param_types (andrei) |
50 | 47 |
*/ |
51 |