- 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,1877 +0,0 @@ |
1 |
-/* |
|
2 |
- * dialog module - basic support for dialog tracking |
|
3 |
- * |
|
4 |
- * Copyright (C) 2006 Voice Sistem SRL |
|
5 |
- * Copyright (C) 2011 Carsten Bock, carsten@ng-voice.com |
|
6 |
- * |
|
7 |
- * This file is part of Kamailio, a free SIP server. |
|
8 |
- * |
|
9 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
10 |
- * it under the terms of the GNU General Public License as published by |
|
11 |
- * the Free Software Foundation; either version 2 of the License, or |
|
12 |
- * (at your option) any later version |
|
13 |
- * |
|
14 |
- * Kamailio is distributed in the hope that it will be useful, |
|
15 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
- * GNU General Public License for more details. |
|
18 |
- * |
|
19 |
- * You should have received a copy of the GNU General Public License |
|
20 |
- * along with this program; if not, write to the Free Software |
|
21 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
22 |
- * |
|
23 |
- */ |
|
24 |
- |
|
25 |
-/*! |
|
26 |
- * \file |
|
27 |
- * \brief Module interface |
|
28 |
- * \ingroup dialog |
|
29 |
- * Module: \ref dialog |
|
30 |
- */ |
|
31 |
- |
|
32 |
-/** |
|
33 |
- * @defgroup dialog dialog :: Kamailio dialog module |
|
34 |
- * @brief Kamailio dialog module |
|
35 |
- * |
|
36 |
- * The dialog module provides dialog awareness to the Kamailio proxy. Its |
|
37 |
- * functionality is to keep track of the current dialogs, to offer |
|
38 |
- * information about them (like how many dialogs are active) or to manage |
|
39 |
- * them. The module exports several functions that could be used directly |
|
40 |
- * from scripts. |
|
41 |
- * The module, via an internal API, also provide the foundation to build |
|
42 |
- * on top of it more complex dialog-based functionalities via other |
|
43 |
- * Kamailio modules. |
|
44 |
- */ |
|
45 |
- |
|
46 |
-#include <stdio.h> |
|
47 |
-#include <string.h> |
|
48 |
-#include <stdlib.h> |
|
49 |
-#include <sys/time.h> |
|
50 |
- |
|
51 |
-#include "../../sr_module.h" |
|
52 |
-#include "../../lib/srdb1/db.h" |
|
53 |
-#include "../../dprint.h" |
|
54 |
-#include "../../error.h" |
|
55 |
-#include "../../ut.h" |
|
56 |
-#include "../../pvar.h" |
|
57 |
-#include "../../mod_fix.h" |
|
58 |
-#include "../../script_cb.h" |
|
59 |
-#include "../../fmsg.h" |
|
60 |
-#include "../../hashes.h" |
|
61 |
-#include "../../counters.h" |
|
62 |
-#include "../../mem/mem.h" |
|
63 |
-#include "../../lib/kmi/mi.h" |
|
64 |
-#include "../../timer_proc.h" |
|
65 |
-#include "../../lvalue.h" |
|
66 |
-#include "../../parser/parse_to.h" |
|
67 |
-#include "../../modules/tm/tm_load.h" |
|
68 |
-#include "../../rpc_lookup.h" |
|
69 |
-#include "../../srapi.h" |
|
70 |
-#include "../rr/api.h" |
|
71 |
-#include "dlg_hash.h" |
|
72 |
-#include "dlg_timer.h" |
|
73 |
-#include "dlg_handlers.h" |
|
74 |
-#include "dlg_load.h" |
|
75 |
-#include "dlg_cb.h" |
|
76 |
-#include "dlg_db_handler.h" |
|
77 |
-#include "dlg_req_within.h" |
|
78 |
-#include "dlg_profile.h" |
|
79 |
-#include "dlg_var.h" |
|
80 |
-#include "dlg_transfer.h" |
|
81 |
-#include "dlg_cseq.h" |
|
82 |
-#include "dlg_dmq.h" |
|
83 |
- |
|
84 |
-MODULE_VERSION |
|
85 |
- |
|
86 |
- |
|
87 |
-#define RPC_DATE_BUF_LEN 21 |
|
88 |
- |
|
89 |
-static int mod_init(void); |
|
90 |
-static int child_init(int rank); |
|
91 |
-static void mod_destroy(void); |
|
92 |
- |
|
93 |
-/* module parameter */ |
|
94 |
-static int dlg_hash_size = 4096; |
|
95 |
-static char* rr_param = "did"; |
|
96 |
-static int dlg_flag = -1; |
|
97 |
-static str timeout_spec = {NULL, 0}; |
|
98 |
-static int default_timeout = 60 * 60 * 12; /* 12 hours */ |
|
99 |
-static int seq_match_mode = SEQ_MATCH_STRICT_ID; |
|
100 |
-static char* profiles_wv_s = NULL; |
|
101 |
-static char* profiles_nv_s = NULL; |
|
102 |
-str dlg_extra_hdrs = {NULL,0}; |
|
103 |
-static int db_fetch_rows = 200; |
|
104 |
-static int db_skip_load = 0; |
|
105 |
-int initial_cbs_inscript = 1; |
|
106 |
-int dlg_wait_ack = 1; |
|
107 |
-static int dlg_timer_procs = 0; |
|
108 |
-static int _dlg_track_cseq_updates = 0; |
|
109 |
-int dlg_ka_failed_limit = 1; |
|
110 |
- |
|
111 |
-int dlg_enable_dmq = 0; |
|
112 |
- |
|
113 |
-int dlg_event_rt[DLG_EVENTRT_MAX]; |
|
114 |
- |
|
115 |
-str dlg_bridge_controller = str_init("sip:controller@kamailio.org"); |
|
116 |
- |
|
117 |
-str dlg_bridge_contact = str_init("sip:controller@kamailio.org:5060"); |
|
118 |
- |
|
119 |
-str ruri_pvar_param = str_init("$ru"); |
|
120 |
-pv_elem_t * ruri_param_model = NULL; |
|
121 |
-str empty_str = STR_NULL; |
|
122 |
- |
|
123 |
-/* statistic variables */ |
|
124 |
-int dlg_enable_stats = 1; |
|
125 |
-int active_dlgs_cnt = 0; |
|
126 |
-int early_dlgs_cnt = 0; |
|
127 |
-int detect_spirals = 1; |
|
128 |
-int dlg_send_bye = 0; |
|
129 |
-int dlg_timeout_noreset = 0; |
|
130 |
-stat_var *active_dlgs = 0; |
|
131 |
-stat_var *processed_dlgs = 0; |
|
132 |
-stat_var *expired_dlgs = 0; |
|
133 |
-stat_var *failed_dlgs = 0; |
|
134 |
-stat_var *early_dlgs = 0; |
|
135 |
- |
|
136 |
-struct tm_binds d_tmb; |
|
137 |
-struct rr_binds d_rrb; |
|
138 |
-pv_spec_t timeout_avp; |
|
139 |
- |
|
140 |
-int dlg_db_mode_param = DB_MODE_NONE; |
|
141 |
- |
|
142 |
-str dlg_xavp_cfg = {0}; |
|
143 |
-int dlg_ka_timer = 0; |
|
144 |
-int dlg_ka_interval = 0; |
|
145 |
-int dlg_clean_timer = 90; |
|
146 |
- |
|
147 |
-str dlg_lreq_callee_headers = {0}; |
|
148 |
- |
|
149 |
-/* db stuff */ |
|
150 |
-static str db_url = str_init(DEFAULT_DB_URL); |
|
151 |
-static unsigned int db_update_period = DB_DEFAULT_UPDATE_PERIOD; |
|
152 |
- |
|
153 |
-static int pv_get_dlg_count( struct sip_msg *msg, pv_param_t *param, |
|
154 |
- pv_value_t *res); |
|
155 |
- |
|
156 |
-void dlg_ka_timer_exec(unsigned int ticks, void* param); |
|
157 |
-void dlg_clean_timer_exec(unsigned int ticks, void* param); |
|
158 |
- |
|
159 |
-/* commands wrappers and fixups */ |
|
160 |
-static int fixup_profile(void** param, int param_no); |
|
161 |
-static int fixup_get_profile2(void** param, int param_no); |
|
162 |
-static int fixup_get_profile3(void** param, int param_no); |
|
163 |
-static int w_set_dlg_profile(struct sip_msg*, char*, char*); |
|
164 |
-static int w_unset_dlg_profile(struct sip_msg*, char*, char*); |
|
165 |
-static int w_is_in_profile(struct sip_msg*, char*, char*); |
|
166 |
-static int w_get_profile_size2(struct sip_msg*, char*, char*); |
|
167 |
-static int w_get_profile_size3(struct sip_msg*, char*, char*, char*); |
|
168 |
-static int w_dlg_isflagset(struct sip_msg *msg, char *flag, str *s2); |
|
169 |
-static int w_dlg_resetflag(struct sip_msg *msg, char *flag, str *s2); |
|
170 |
-static int w_dlg_setflag(struct sip_msg *msg, char *flag, char *s2); |
|
171 |
-static int w_dlg_set_property(struct sip_msg *msg, char *prop, char *s2); |
|
172 |
-static int w_dlg_manage(struct sip_msg*, char*, char*); |
|
173 |
-static int w_dlg_bye(struct sip_msg*, char*, char*); |
|
174 |
-static int w_dlg_refer(struct sip_msg*, char*, char*); |
|
175 |
-static int w_dlg_bridge(struct sip_msg*, char*, char*, char*); |
|
176 |
-static int w_dlg_set_timeout(struct sip_msg*, char*, char*, char*); |
|
177 |
-static int w_dlg_set_timeout_by_profile2(struct sip_msg *, char *, char *); |
|
178 |
-static int w_dlg_set_timeout_by_profile3(struct sip_msg *, char *, char *, |
|
179 |
- char *); |
|
180 |
-static int fixup_dlg_bye(void** param, int param_no); |
|
181 |
-static int fixup_dlg_refer(void** param, int param_no); |
|
182 |
-static int fixup_dlg_bridge(void** param, int param_no); |
|
183 |
-static int w_dlg_get(struct sip_msg*, char*, char*, char*); |
|
184 |
-static int w_is_known_dlg(struct sip_msg *); |
|
185 |
- |
|
186 |
-static int w_dlg_remote_profile(sip_msg_t *msg, char *cmd, char *pname, |
|
187 |
- char *pval, char *puid, char *expires); |
|
188 |
-static int fixup_dlg_remote_profile(void** param, int param_no); |
|
189 |
- |
|
190 |
-static cmd_export_t cmds[]={ |
|
191 |
- {"dlg_manage", (cmd_function)w_dlg_manage, 0,0, |
|
192 |
- 0, REQUEST_ROUTE }, |
|
193 |
- {"set_dlg_profile", (cmd_function)w_set_dlg_profile, 1,fixup_profile, |
|
194 |
- 0, ANY_ROUTE }, |
|
195 |
- {"set_dlg_profile", (cmd_function)w_set_dlg_profile, 2,fixup_profile, |
|
196 |
- 0, ANY_ROUTE }, |
|
197 |
- {"unset_dlg_profile", (cmd_function)w_unset_dlg_profile, 1,fixup_profile, |
|
198 |
- 0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE }, |
|
199 |
- {"unset_dlg_profile", (cmd_function)w_unset_dlg_profile, 2,fixup_profile, |
|
200 |
- 0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE }, |
|
201 |
- {"is_in_profile", (cmd_function)w_is_in_profile, 1,fixup_profile, |
|
202 |
- 0, ANY_ROUTE }, |
|
203 |
- {"is_in_profile", (cmd_function)w_is_in_profile, 2,fixup_profile, |
|
204 |
- 0, ANY_ROUTE }, |
|
205 |
- {"get_profile_size",(cmd_function)w_get_profile_size2, 2,fixup_get_profile2, |
|
206 |
- 0, ANY_ROUTE }, |
|
207 |
- {"get_profile_size",(cmd_function)w_get_profile_size3, 3,fixup_get_profile3, |
|
208 |
- 0, ANY_ROUTE }, |
|
209 |
- {"dlg_setflag", (cmd_function)w_dlg_setflag, 1,fixup_igp_null, |
|
210 |
- 0, ANY_ROUTE }, |
|
211 |
- {"dlg_resetflag", (cmd_function)w_dlg_resetflag, 1,fixup_igp_null, |
|
212 |
- 0, ANY_ROUTE }, |
|
213 |
- {"dlg_isflagset", (cmd_function)w_dlg_isflagset, 1,fixup_igp_null, |
|
214 |
- 0, ANY_ROUTE }, |
|
215 |
- {"dlg_bye",(cmd_function)w_dlg_bye, 1,fixup_dlg_bye, |
|
216 |
- 0, ANY_ROUTE }, |
|
217 |
- {"dlg_refer",(cmd_function)w_dlg_refer, 2,fixup_dlg_refer, |
|
218 |
- 0, ANY_ROUTE }, |
|
219 |
- {"dlg_bridge",(cmd_function)w_dlg_bridge, 3,fixup_dlg_bridge, |
|
220 |
- 0, ANY_ROUTE }, |
|
221 |
- {"dlg_get",(cmd_function)w_dlg_get, 3,fixup_dlg_bridge, |
|
222 |
- 0, ANY_ROUTE }, |
|
223 |
- {"is_known_dlg", (cmd_function)w_is_known_dlg, 0, NULL, |
|
224 |
- 0, ANY_ROUTE }, |
|
225 |
- {"dlg_set_timeout", (cmd_function)w_dlg_set_timeout, 1,fixup_igp_null, |
|
226 |
- 0, ANY_ROUTE }, |
|
227 |
- {"dlg_set_timeout", (cmd_function)w_dlg_set_timeout, 3,fixup_igp_all, |
|
228 |
- 0, ANY_ROUTE }, |
|
229 |
- {"dlg_set_timeout_by_profile", |
|
230 |
- (cmd_function) w_dlg_set_timeout_by_profile2, 2, fixup_profile, |
|
231 |
- 0, ANY_ROUTE }, |
|
232 |
- {"dlg_set_timeout_by_profile", |
|
233 |
- (cmd_function) w_dlg_set_timeout_by_profile3, 3, fixup_profile, |
|
234 |
- 0, ANY_ROUTE }, |
|
235 |
- {"dlg_set_property", (cmd_function)w_dlg_set_property,1,fixup_spve_null, |
|
236 |
- 0, ANY_ROUTE }, |
|
237 |
- {"dlg_remote_profile", (cmd_function)w_dlg_remote_profile, 5, fixup_dlg_remote_profile, |
|
238 |
- 0, ANY_ROUTE }, |
|
239 |
- {"load_dlg", (cmd_function)load_dlg, 0, 0, 0, 0}, |
|
240 |
- {0,0,0,0,0,0} |
|
241 |
-}; |
|
242 |
- |
|
243 |
-static param_export_t mod_params[]={ |
|
244 |
- { "enable_stats", INT_PARAM, &dlg_enable_stats }, |
|
245 |
- { "hash_size", INT_PARAM, &dlg_hash_size }, |
|
246 |
- { "rr_param", PARAM_STRING, &rr_param }, |
|
247 |
- { "dlg_flag", INT_PARAM, &dlg_flag }, |
|
248 |
- { "timeout_avp", PARAM_STR, &timeout_spec }, |
|
249 |
- { "default_timeout", INT_PARAM, &default_timeout }, |
|
250 |
- { "dlg_extra_hdrs", PARAM_STR, &dlg_extra_hdrs }, |
|
251 |
- { "dlg_match_mode", INT_PARAM, &seq_match_mode }, |
|
252 |
- { "detect_spirals", INT_PARAM, &detect_spirals, }, |
|
253 |
- { "db_url", PARAM_STR, &db_url }, |
|
254 |
- { "db_mode", INT_PARAM, &dlg_db_mode_param }, |
|
255 |
- { "table_name", PARAM_STR, &dialog_table_name }, |
|
256 |
- { "call_id_column", PARAM_STR, &call_id_column }, |
|
257 |
- { "from_uri_column", PARAM_STR, &from_uri_column }, |
|
258 |
- { "from_tag_column", PARAM_STR, &from_tag_column }, |
|
259 |
- { "to_uri_column", PARAM_STR, &to_uri_column }, |
|
260 |
- { "to_tag_column", PARAM_STR, &to_tag_column }, |
|
261 |
- { "h_id_column", PARAM_STR, &h_id_column }, |
|
262 |
- { "h_entry_column", PARAM_STR, &h_entry_column }, |
|
263 |
- { "state_column", PARAM_STR, &state_column }, |
|
264 |
- { "start_time_column", PARAM_STR, &start_time_column }, |
|
265 |
- { "timeout_column", PARAM_STR, &timeout_column }, |
|
266 |
- { "to_cseq_column", PARAM_STR, &to_cseq_column }, |
|
267 |
- { "from_cseq_column", PARAM_STR, &from_cseq_column }, |
|
268 |
- { "to_route_column", PARAM_STR, &to_route_column }, |
|
269 |
- { "from_route_column", PARAM_STR, &from_route_column }, |
|
270 |
- { "to_contact_column", PARAM_STR, &to_contact_column }, |
|
271 |
- { "from_contact_column", PARAM_STR, &from_contact_column }, |
|
272 |
- { "to_sock_column", PARAM_STR, &to_sock_column }, |
|
273 |
- { "from_sock_column", PARAM_STR, &from_sock_column }, |
|
274 |
- { "sflags_column", PARAM_STR, &sflags_column }, |
|
275 |
- { "toroute_name_column", PARAM_STR, &toroute_name_column }, |
|
276 |
- |
|
277 |
- { "vars_table_name", PARAM_STR, &dialog_vars_table_name }, |
|
278 |
- { "vars_h_id_column", PARAM_STR, &vars_h_id_column }, |
|
279 |
- { "vars_h_entry_column", PARAM_STR, &vars_h_entry_column }, |
|
280 |
- { "vars_key_column", PARAM_STR, &vars_key_column }, |
|
281 |
- { "vars_value_column", PARAM_STR, &vars_value_column }, |
|
282 |
- |
|
283 |
- { "db_update_period", INT_PARAM, &db_update_period }, |
|
284 |
- { "db_fetch_rows", INT_PARAM, &db_fetch_rows }, |
|
285 |
- { "profiles_with_value", PARAM_STRING, &profiles_wv_s }, |
|
286 |
- { "profiles_no_value", PARAM_STRING, &profiles_nv_s }, |
|
287 |
- { "bridge_controller", PARAM_STR, &dlg_bridge_controller }, |
|
288 |
- { "bridge_contact", PARAM_STR, &dlg_bridge_contact }, |
|
289 |
- { "ruri_pvar", PARAM_STR, &ruri_pvar_param }, |
|
290 |
- { "initial_cbs_inscript", INT_PARAM, &initial_cbs_inscript }, |
|
291 |
- { "send_bye", INT_PARAM, &dlg_send_bye }, |
|
292 |
- { "wait_ack", INT_PARAM, &dlg_wait_ack }, |
|
293 |
- { "xavp_cfg", PARAM_STR, &dlg_xavp_cfg }, |
|
294 |
- { "ka_timer", INT_PARAM, &dlg_ka_timer }, |
|
295 |
- { "ka_interval", INT_PARAM, &dlg_ka_interval }, |
|
296 |
- { "timeout_noreset", INT_PARAM, &dlg_timeout_noreset }, |
|
297 |
- { "timer_procs", PARAM_INT, &dlg_timer_procs }, |
|
298 |
- { "track_cseq_updates", PARAM_INT, &_dlg_track_cseq_updates }, |
|
299 |
- { "lreq_callee_headers", PARAM_STR, &dlg_lreq_callee_headers }, |
|
300 |
- { "db_skip_load", INT_PARAM, &db_skip_load }, |
|
301 |
- { "ka_failed_limit", INT_PARAM, &dlg_ka_failed_limit }, |
|
302 |
- { "enable_dmq", INT_PARAM, &dlg_enable_dmq }, |
|
303 |
- { 0,0,0 } |
|
304 |
-}; |
|
305 |
- |
|
306 |
- |
|
307 |
-static stat_export_t mod_stats[] = { |
|
308 |
- {"active_dialogs" , STAT_NO_RESET, &active_dlgs }, |
|
309 |
- {"early_dialogs", STAT_NO_RESET, &early_dlgs }, |
|
310 |
- {"processed_dialogs" , 0, &processed_dlgs }, |
|
311 |
- {"expired_dialogs" , 0, &expired_dlgs }, |
|
312 |
- {"failed_dialogs", 0, &failed_dlgs }, |
|
313 |
- {0,0,0} |
|
314 |
-}; |
|
315 |
- |
|
316 |
-struct mi_root * mi_dlg_bridge(struct mi_root *cmd_tree, void *param); |
|
317 |
- |
|
318 |
-static mi_export_t mi_cmds[] = { |
|
319 |
- { "dlg_list", mi_print_dlgs, 0, 0, 0}, |
|
320 |
- { "dlg_list_ctx", mi_print_dlgs_ctx, 0, 0, 0}, |
|
321 |
- { "dlg_end_dlg", mi_terminate_dlg, 0, 0, 0}, |
|
322 |
- { "dlg_terminate_dlg", mi_terminate_dlgs, 0, 0, 0}, |
|
323 |
- { "profile_get_size", mi_get_profile, 0, 0, 0}, |
|
324 |
- { "profile_list_dlgs", mi_profile_list, 0, 0, 0}, |
|
325 |
- { "dlg_bridge", mi_dlg_bridge, 0, 0, 0}, |
|
326 |
- { 0, 0, 0, 0, 0} |
|
327 |
-}; |
|
328 |
- |
|
329 |
-static rpc_export_t rpc_methods[]; |
|
330 |
- |
|
331 |
-static pv_export_t mod_items[] = { |
|
332 |
- { {"DLG_count", sizeof("DLG_count")-1}, PVT_OTHER, pv_get_dlg_count, 0, |
|
333 |
- 0, 0, 0, 0 }, |
|
334 |
- { {"DLG_lifetime",sizeof("DLG_lifetime")-1}, PVT_OTHER, pv_get_dlg_lifetime, 0, |
|
335 |
- 0, 0, 0, 0 }, |
|
336 |
- { {"DLG_status", sizeof("DLG_status")-1}, PVT_OTHER, pv_get_dlg_status, 0, |
|
337 |
- 0, 0, 0, 0 }, |
|
338 |
- { {"dlg_ctx", sizeof("dlg_ctx")-1}, PVT_OTHER, pv_get_dlg_ctx, |
|
339 |
- pv_set_dlg_ctx, pv_parse_dlg_ctx_name, 0, 0, 0 }, |
|
340 |
- { {"dlg", sizeof("dlg")-1}, PVT_OTHER, pv_get_dlg, |
|
341 |
- 0, pv_parse_dlg_name, 0, 0, 0 }, |
|
342 |
- { {"dlg_var", sizeof("dlg_var")-1}, PVT_OTHER, pv_get_dlg_variable, |
|
343 |
- pv_set_dlg_variable, pv_parse_dialog_var_name, 0, 0, 0}, |
|
344 |
- { {0, 0}, 0, 0, 0, 0, 0, 0, 0 } |
|
345 |
-}; |
|
346 |
- |
|
347 |
-struct module_exports exports= { |
|
348 |
- "dialog", /* module's name */ |
|
349 |
- DEFAULT_DLFLAGS, /* dlopen flags */ |
|
350 |
- cmds, /* exported functions */ |
|
351 |
- mod_params, /* param exports */ |
|
352 |
- mod_stats, /* exported statistics */ |
|
353 |
- mi_cmds, /* exported MI functions */ |
|
354 |
- mod_items, /* exported pseudo-variables */ |
|
355 |
- 0, /* extra processes */ |
|
356 |
- mod_init, /* module initialization function */ |
|
357 |
- 0, /* reply processing function */ |
|
358 |
- mod_destroy, |
|
359 |
- child_init /* per-child init function */ |
|
360 |
-}; |
|
361 |
- |
|
362 |
- |
|
363 |
-static int fixup_profile(void** param, int param_no) |
|
364 |
-{ |
|
365 |
- struct dlg_profile_table *profile; |
|
366 |
- pv_elem_t *model=NULL; |
|
367 |
- str s; |
|
368 |
- |
|
369 |
- s.s = (char*)(*param); |
|
370 |
- s.len = strlen(s.s); |
|
371 |
- if(s.len==0) { |
|
372 |
- LM_ERR("param %d is empty string!\n", param_no); |
|
373 |
- return E_CFG; |
|
374 |
- } |
|
375 |
- |
|
376 |
- if (param_no==1) { |
|
377 |
- profile = search_dlg_profile( &s ); |
|
378 |
- if (profile==NULL) { |
|
379 |
- LM_CRIT("profile <%s> not defined\n",s.s); |
|
380 |
- return E_CFG; |
|
381 |
- } |
|
382 |
- pkg_free(*param); |
|
383 |
- *param = (void*)profile; |
|
384 |
- return 0; |
|
385 |
- } else if (param_no==2) { |
|
386 |
- if(pv_parse_format(&s ,&model) || model==NULL) { |
|
387 |
- LM_ERR("wrong format [%s] for value param!\n", s.s); |
|
388 |
- return E_CFG; |
|
389 |
- } |
|
390 |
- *param = (void*)model; |
|
391 |
- } |
|
392 |
- return 0; |
|
393 |
-} |
|
394 |
- |
|
395 |
- |
|
396 |
-static int fixup_get_profile2(void** param, int param_no) |
|
397 |
-{ |
|
398 |
- pv_spec_t *sp; |
|
399 |
- int ret; |
|
400 |
- |
|
401 |
- if (param_no==1) { |
|
402 |
- return fixup_profile(param, 1); |
|
403 |
- } else if (param_no==2) { |
|
404 |
- ret = fixup_pvar_null(param, 1); |
|
405 |
- if (ret<0) return ret; |
|
406 |
- sp = (pv_spec_t*)(*param); |
|
407 |
- if (sp->type!=PVT_AVP && sp->type!=PVT_SCRIPTVAR) { |
|
408 |
- LM_ERR("return must be an AVP or SCRIPT VAR!\n"); |
|
409 |
- return E_SCRIPT; |
|
410 |
- } |
|
411 |
- } |
|
412 |
- return 0; |
|
413 |
-} |
|
414 |
- |
|
415 |
- |
|
416 |
-static int fixup_get_profile3(void** param, int param_no) |
|
417 |
-{ |
|
418 |
- if (param_no==1) { |
|
419 |
- return fixup_profile(param, 1); |
|
420 |
- } else if (param_no==2) { |
|
421 |
- return fixup_profile(param, 2); |
|
422 |
- } else if (param_no==3) { |
|
423 |
- return fixup_get_profile2( param, 2); |
|
424 |
- } |
|
425 |
- return 0; |
|
426 |
-} |
|
427 |
- |
|
428 |
- |
|
429 |
- |
|
430 |
-int load_dlg( struct dlg_binds *dlgb ) |
|
431 |
-{ |
|
432 |
- dlgb->register_dlgcb = register_dlgcb; |
|
433 |
- dlgb->terminate_dlg = dlg_bye_all; |
|
434 |
- dlgb->set_dlg_var = set_dlg_variable; |
|
435 |
- dlgb->get_dlg_var = get_dlg_variable; |
|
436 |
- dlgb->get_dlg = dlg_get_msg_dialog; |
|
437 |
- dlgb->release_dlg = dlg_release; |
|
438 |
- return 1; |
|
439 |
-} |
|
440 |
- |
|
441 |
- |
|
442 |
-static int pv_get_dlg_count(struct sip_msg *msg, pv_param_t *param, |
|
443 |
- pv_value_t *res) |
|
444 |
-{ |
|
445 |
- int n; |
|
446 |
- int l; |
|
447 |
- char *ch; |
|
448 |
- |
|
449 |
- if(msg==NULL || res==NULL) |
|
450 |
- return -1; |
|
451 |
- |
|
452 |
- n = active_dlgs ? get_stat_val(active_dlgs) : 0; |
|
453 |
- l = 0; |
|
454 |
- ch = int2str( n, &l); |
|
455 |
- |
|
456 |
- res->rs.s = ch; |
|
457 |
- res->rs.len = l; |
|
458 |
- |
|
459 |
- res->ri = n; |
|
460 |
- res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT; |
|
461 |
- |
|
462 |
- return 0; |
|
463 |
-} |
|
464 |
- |
|
465 |
- |
|
466 |
-static int mod_init(void) |
|
467 |
-{ |
|
468 |
- unsigned int n; |
|
469 |
- sr_cfgenv_t *cenv = NULL; |
|
470 |
- |
|
471 |
- if(dlg_ka_interval!=0 && dlg_ka_interval<30) { |
|
472 |
- LM_ERR("ka interval too low (%d), has to be at least 30\n", |
|
473 |
- dlg_ka_interval); |
|
474 |
- return -1; |
|
475 |
- } |
|
476 |
- |
|
477 |
- dlg_event_rt[DLG_EVENTRT_START] = route_lookup(&event_rt, "dialog:start"); |
|
478 |
- dlg_event_rt[DLG_EVENTRT_END] = route_lookup(&event_rt, "dialog:end"); |
|
479 |
- dlg_event_rt[DLG_EVENTRT_FAILED] = route_lookup(&event_rt, "dialog:failed"); |
|
480 |
- |
|
481 |
-#ifdef STATISTICS |
|
482 |
- /* register statistics */ |
|
483 |
- if (register_module_stats( exports.name, mod_stats)!=0 ) { |
|
484 |
- LM_ERR("failed to register %s statistics\n", exports.name); |
|
485 |
- return -1; |
|
486 |
- } |
|
487 |
-#endif |
|
488 |
- |
|
489 |
- if(register_mi_mod(exports.name, mi_cmds)!=0) |
|
490 |
- { |
|
491 |
- LM_ERR("failed to register MI commands\n"); |
|
492 |
- return -1; |
|
493 |
- } |
|
494 |
- |
|
495 |
- if (rpc_register_array(rpc_methods)!=0) { |
|
496 |
- LM_ERR("failed to register RPC commands\n"); |
|
497 |
- return -1; |
|
498 |
- } |
|
499 |
- |
|
500 |
- if(faked_msg_init()<0) |
|
501 |
- return -1; |
|
502 |
- |
|
503 |
- if(dlg_bridge_init_hdrs()<0) |
|
504 |
- return -1; |
|
505 |
- |
|
506 |
- /* param checkings */ |
|
507 |
- if (dlg_flag>MAX_FLAG) { |
|
508 |
- LM_ERR("invalid dlg flag %d!!\n",dlg_flag); |
|
509 |
- return -1; |
|
510 |
- } |
|
511 |
- |
|
512 |
- if (rr_param==0 || rr_param[0]==0) { |
|
513 |
- LM_ERR("empty rr_param!!\n"); |
|
514 |
- return -1; |
|
515 |
- } else if (strlen(rr_param)>MAX_DLG_RR_PARAM_NAME) { |
|
516 |
- LM_ERR("rr_param too long (max=%d)!!\n", MAX_DLG_RR_PARAM_NAME); |
|
517 |
- return -1; |
|
518 |
- } |
|
519 |
- |
|
520 |
- if (timeout_spec.s) { |
|
521 |
- if ( pv_parse_spec(&timeout_spec, &timeout_avp)==0 |
|
522 |
- && (timeout_avp.type!=PVT_AVP)){ |
|
523 |
- LM_ERR("malformed or non AVP timeout " |
|
524 |
- "AVP definition in '%.*s'\n", timeout_spec.len,timeout_spec.s); |
|
525 |
- return -1; |
|
526 |
- } |
|
527 |
- } |
|
528 |
- |
|
529 |
- if (default_timeout<=0) { |
|
530 |
- LM_ERR("0 default_timeout not accepted!!\n"); |
|
531 |
- return -1; |
|
532 |
- } |
|
533 |
- |
|
534 |
- if (ruri_pvar_param.s==NULL || ruri_pvar_param.len<=0) { |
|
535 |
- LM_ERR("invalid r-uri PV string\n"); |
|
536 |
- return -1; |
|
537 |
- } |
|
538 |
- |
|
539 |
- if(pv_parse_format(&ruri_pvar_param, &ruri_param_model) < 0 |
|
540 |
- || ruri_param_model==NULL) { |
|
541 |
- LM_ERR("malformed r-uri PV string: %s\n", ruri_pvar_param.s); |
|
542 |
- return -1; |
|
543 |
- } |
|
544 |
- |
|
545 |
- if (initial_cbs_inscript != 0 && initial_cbs_inscript != 1) { |
|
546 |
- LM_ERR("invalid parameter for running initial callbacks in-script" |
|
547 |
- " (must be either 0 or 1)\n"); |
|
548 |
- return -1; |
|
549 |
- } |
|
550 |
- |
|
551 |
- if (seq_match_mode!=SEQ_MATCH_NO_ID && |
|
552 |
- seq_match_mode!=SEQ_MATCH_FALLBACK && |
|
553 |
- seq_match_mode!=SEQ_MATCH_STRICT_ID ) { |
|
554 |
- LM_ERR("invalid value %d for seq_match_mode param!!\n",seq_match_mode); |
|
555 |
- return -1; |
|
556 |
- } |
|
557 |
- |
|
558 |
- if (detect_spirals != 0 && detect_spirals != 1) { |
|
559 |
- LM_ERR("invalid value %d for detect_spirals param!!\n",detect_spirals); |
|
560 |
- return -1; |
|
561 |
- } |
|
562 |
- |
|
563 |
- if (dlg_timeout_noreset != 0 && dlg_timeout_noreset != 1) { |
|
564 |
- LM_ERR("invalid value %d for timeout_noreset param!!\n", |
|
565 |
- dlg_timeout_noreset); |
|
566 |
- return -1; |
|
567 |
- } |
|
568 |
- |
|
569 |
- /* if statistics are disabled, prevent their registration to core */ |
|
570 |
- if (dlg_enable_stats==0) |
|
571 |
- exports.stats = 0; |
|
572 |
- |
|
573 |
- /* create profile hashes */ |
|
574 |
- if (add_profile_definitions( profiles_nv_s, 0)!=0 ) { |
|
575 |
- LM_ERR("failed to add profiles without value\n"); |
|
576 |
- return -1; |
|
577 |
- } |
|
578 |
- if (add_profile_definitions( profiles_wv_s, 1)!=0 ) { |
|
579 |
- LM_ERR("failed to add profiles with value\n"); |
|
580 |
- return -1; |
|
581 |
- } |
|
582 |
- |
|
583 |
- /* load the TM API */ |
|
584 |
- if (load_tm_api(&d_tmb)!=0) { |
|
585 |
- LM_ERR("can't load TM API\n"); |
|
586 |
- return -1; |
|
587 |
- } |
|
588 |
- |
|
589 |
- /* load RR API also */ |
|
590 |
- if (load_rr_api(&d_rrb)!=0) { |
|
591 |
- LM_ERR("can't load RR API\n"); |
|
592 |
- return -1; |
|
593 |
- } |
|
594 |
- |
|
595 |
- /* register callbacks*/ |
|
596 |
- /* listen for all incoming requests */ |
|
597 |
- if ( d_tmb.register_tmcb( 0, 0, TMCB_REQUEST_IN, dlg_onreq, 0, 0 ) <=0 ) { |
|
598 |
- LM_ERR("cannot register TMCB_REQUEST_IN callback\n"); |
|
599 |
- return -1; |
|
600 |
- } |
|
601 |
- |
|
602 |
- /* listen for all routed requests */ |
|
603 |
- if ( d_rrb.register_rrcb( dlg_onroute, 0 ) <0 ) { |
|
604 |
- LM_ERR("cannot register RR callback\n"); |
|
605 |
- return -1; |
|
606 |
- } |
|
607 |
- |
|
608 |
- if (register_script_cb( profile_cleanup, POST_SCRIPT_CB|REQUEST_CB,0)<0) { |
|
609 |
- LM_ERR("cannot register script callback"); |
|
610 |
- return -1; |
|
611 |
- } |
|
612 |
- if (register_script_cb(dlg_cfg_cb, |
|
613 |
- PRE_SCRIPT_CB|REQUEST_CB,0)<0) |
|
614 |
- { |
|
615 |
- LM_ERR("cannot register pre-script ctx callback\n"); |
|
616 |
- return -1; |
|
617 |
- } |
|
618 |
- if (register_script_cb(dlg_cfg_cb, |
|
619 |
- POST_SCRIPT_CB|REQUEST_CB,0)<0) |
|
620 |
- { |
|
621 |
- LM_ERR("cannot register post-script ctx callback\n"); |
|
622 |
- return -1; |
|
623 |
- } |
|
624 |
- |
|
625 |
- if (register_script_cb(spiral_detect_reset,POST_SCRIPT_CB|REQUEST_CB,0)<0) { |
|
626 |
- LM_ERR("cannot register req pre-script spiral detection reset callback\n"); |
|
627 |
- return -1; |
|
628 |
- } |
|
629 |
- |
|
630 |
- if (register_script_cb(cb_dlg_locals_reset,POST_SCRIPT_CB|ONREPLY_CB,0)<0) { |
|
631 |
- LM_ERR("cannot register reply post-script dlg locals reset callback\n"); |
|
632 |
- return -1; |
|
633 |
- } |
|
634 |
- |
|
635 |
- if (register_script_cb(cb_dlg_locals_reset,POST_SCRIPT_CB|FAILURE_CB,0)<0) { |
|
636 |
- LM_ERR("cannot register failure post-script dlg locals reset callback\n"); |
|
637 |
- return -1; |
|
638 |
- } |
|
639 |
- |
|
640 |
- if(dlg_timer_procs<=0) { |
|
641 |
- if ( register_timer( dlg_timer_routine, 0, 1)<0 ) { |
|
642 |
- LM_ERR("failed to register timer \n"); |
|
643 |
- return -1; |
|
644 |
- } |
|
645 |
- } else { |
|
646 |
- register_sync_timers(1); |
|
647 |
- } |
|
648 |
- |
|
649 |
- /* init handlers */ |
|
650 |
- init_dlg_handlers( rr_param, dlg_flag, |
|
651 |
- timeout_spec.s?&timeout_avp:0, default_timeout, seq_match_mode); |
|
652 |
- |
|
653 |
- /* init timer */ |
|
654 |
- if (init_dlg_timer(dlg_ontimeout)!=0) { |
|
655 |
- LM_ERR("cannot init timer list\n"); |
|
656 |
- return -1; |
|
657 |
- } |
|
658 |
- |
|
659 |
- /* sanitize dlg_hash_zie */ |
|
660 |
- if (dlg_hash_size < 1){ |
|
661 |
- LM_WARN("hash_size is smaller " |
|
662 |
- "then 1 -> rounding from %d to 1\n", |
|
663 |
- dlg_hash_size); |
|
664 |
- dlg_hash_size = 1; |
|
665 |
- } |
|
666 |
- /* initialized the hash table */ |
|
667 |
- for( n=0 ; n<(8*sizeof(n)) ; n++) { |
|
668 |
- if (dlg_hash_size==(1<<n)) |
|
669 |
- break; |
|
670 |
- if (n && dlg_hash_size<(1<<n)) { |
|
671 |
- LM_WARN("hash_size is not a power " |
|
672 |
- "of 2 as it should be -> rounding from %d to %d\n", |
|
673 |
- dlg_hash_size, 1<<(n-1)); |
|
674 |
- dlg_hash_size = 1<<(n-1); |
|
675 |
- } |
|
676 |
- } |
|
677 |
- |
|
678 |
- if ( init_dlg_table(dlg_hash_size)<0 ) { |
|
679 |
- LM_ERR("failed to create hash table\n"); |
|
680 |
- return -1; |
|
681 |
- } |
|
682 |
- |
|
683 |
- /* if a database should be used to store the dialogs' information */ |
|
684 |
- dlg_db_mode = dlg_db_mode_param; |
|
685 |
- if (dlg_db_mode==DB_MODE_NONE) { |
|
686 |
- db_url.s = 0; db_url.len = 0; |
|
687 |
- } else { |
|
688 |
- if (dlg_db_mode!=DB_MODE_REALTIME && |
|
689 |
- dlg_db_mode!=DB_MODE_DELAYED && dlg_db_mode!=DB_MODE_SHUTDOWN ) { |
|
690 |
- LM_ERR("unsupported db_mode %d\n", dlg_db_mode); |
|
691 |
- return -1; |
|
692 |
- } |
|
693 |
- if ( !db_url.s || db_url.len==0 ) { |
|
694 |
- LM_ERR("db_url not configured for db_mode %d\n", dlg_db_mode); |
|
695 |
- return -1; |
|
696 |
- } |
|
697 |
- if (init_dlg_db(&db_url, dlg_hash_size, db_update_period, db_fetch_rows, db_skip_load)!=0) { |
|
698 |
- LM_ERR("failed to initialize the DB support\n"); |
|
699 |
- return -1; |
|
700 |
- } |
|
701 |
- run_load_callbacks(); |
|
702 |
- } |
|
703 |
- |
|
704 |
- destroy_dlg_callbacks( DLGCB_LOADED ); |
|
705 |
- |
|
706 |
- /* timer process to send keep alive requests */ |
|
707 |
- if(dlg_ka_timer>0 && dlg_ka_interval>0) |
|
708 |
- register_sync_timers(1); |
|
709 |
- |
|
710 |
- /* timer process to clean old unconfirmed dialogs */ |
|
711 |
- register_sync_timers(1); |
|
712 |
- |
|
713 |
- if(_dlg_track_cseq_updates!=0) { |
|
714 |
- cenv = sr_cfgenv_get(); |
|
715 |
- cenv->cb_cseq_update = dlg_cseq_update; |
|
716 |
- dlg_register_cseq_callbacks(); |
|
717 |
- } |
|
718 |
- |
|
719 |
- if (dlg_enable_dmq>0 && dlg_dmq_initialize()!=0) { |
|
720 |
- LM_ERR("failed to initialize dmq integration\n"); |
|
721 |
- return -1; |
|
722 |
- } |
|
723 |
- |
|
724 |
- return 0; |
|
725 |
-} |
|
726 |
- |
|
727 |
- |
|
728 |
-static int child_init(int rank) |
|
729 |
-{ |
|
730 |
- dlg_db_mode = dlg_db_mode_param; |
|
731 |
- |
|
732 |
- if(rank==PROC_MAIN) { |
|
733 |
- if(dlg_timer_procs>0) { |
|
734 |
- if(fork_sync_timer(PROC_TIMER, "Dialog Main Timer", 1 /*socks flag*/, |
|
735 |
- dlg_timer_routine, NULL, 1 /*every sec*/)<0) { |
|
736 |
- LM_ERR("failed to start main timer routine as process\n"); |
|
737 |
- return -1; /* error */ |
|
738 |
- } |
|
739 |
- } |
|
740 |
- |
|
741 |
- if(dlg_ka_timer>0 && dlg_ka_interval>0) { |
|
742 |
- if(fork_sync_timer(PROC_TIMER, "Dialog KA Timer", 1 /*socks flag*/, |
|
743 |
- dlg_ka_timer_exec, NULL, dlg_ka_timer /*sec*/)<0) { |
|
744 |
- LM_ERR("failed to start ka timer routine as process\n"); |
|
745 |
- return -1; /* error */ |
|
746 |
- } |
|
747 |
- } |
|
748 |
- |
|
749 |
- if(fork_sync_timer(PROC_TIMER, "Dialog Clean Timer", 1 /*socks flag*/, |
|
750 |
- dlg_clean_timer_exec, NULL, dlg_clean_timer /*sec*/)<0) { |
|
751 |
- LM_ERR("failed to start clean timer routine as process\n"); |
|
752 |
- return -1; /* error */ |
|
753 |
- } |
|
754 |
- } |
|
755 |
- |
|
756 |
- if (rank==1) { |
|
757 |
- if_update_stat(dlg_enable_stats, active_dlgs, active_dlgs_cnt); |
|
758 |
- if_update_stat(dlg_enable_stats, early_dlgs, early_dlgs_cnt); |
|
759 |
- } |
|
760 |
- |
|
761 |
- if ( ((dlg_db_mode==DB_MODE_REALTIME || dlg_db_mode==DB_MODE_DELAYED) && |
|
762 |
- (rank>0 || rank==PROC_TIMER || rank==PROC_RPC)) || |
|
763 |
- (dlg_db_mode==DB_MODE_SHUTDOWN && (rank==PROC_MAIN)) ) { |
|
764 |
- if ( dlg_connect_db(&db_url) ) { |
|
765 |
- LM_ERR("failed to connect to database (rank=%d)\n",rank); |
|
766 |
- return -1; |
|
767 |
- } |
|
768 |
- } |
|
769 |
- |
|
770 |
- /* in DB_MODE_SHUTDOWN only PROC_MAIN will do a DB dump at the end, so |
|
771 |
- * for the rest of the processes will be the same as DB_MODE_NONE */ |
|
772 |
- if (dlg_db_mode==DB_MODE_SHUTDOWN && rank!=PROC_MAIN) |
|
773 |
- dlg_db_mode = DB_MODE_NONE; |
|
774 |
- /* in DB_MODE_REALTIME and DB_MODE_DELAYED the PROC_MAIN have no DB handle */ |
|
775 |
- if ( (dlg_db_mode==DB_MODE_REALTIME || dlg_db_mode==DB_MODE_DELAYED) && |
|
776 |
- rank==PROC_MAIN) |
|
777 |
- dlg_db_mode = DB_MODE_NONE; |
|
778 |
- |
|
779 |
- return 0; |
|
780 |
-} |
|
781 |
- |
|
782 |
- |
|
783 |
-static void mod_destroy(void) |
|
784 |
-{ |
|
785 |
- if(dlg_db_mode == DB_MODE_DELAYED || dlg_db_mode == DB_MODE_SHUTDOWN) { |
|
786 |
- dialog_update_db(0, 0); |
|
787 |
- destroy_dlg_db(); |
|
788 |
- } |
|
789 |
- dlg_bridge_destroy_hdrs(); |
|
790 |
- /* no DB interaction from now on */ |
|
791 |
- dlg_db_mode = DB_MODE_NONE; |
|
792 |
- destroy_dlg_table(); |
|
793 |
- destroy_dlg_timer(); |
|
794 |
- destroy_dlg_callbacks( DLGCB_CREATED|DLGCB_LOADED ); |
|
795 |
- destroy_dlg_handlers(); |
|
796 |
- destroy_dlg_profiles(); |
|
797 |
-} |
|
798 |
- |
|
799 |
- |
|
800 |
- |
|
801 |
-static int w_set_dlg_profile(struct sip_msg *msg, char *profile, char *value) |
|
802 |
-{ |
|
803 |
- pv_elem_t *pve; |
|
804 |
- str val_s; |
|
805 |
- |
|
806 |
- pve = (pv_elem_t *)value; |
|
807 |
- |
|
808 |
- if (((struct dlg_profile_table*)profile)->has_value) { |
|
809 |
- if ( pve==NULL || pv_printf_s(msg, pve, &val_s)!=0 || |
|
810 |
- val_s.len == 0 || val_s.s == NULL) { |
|
811 |
- LM_WARN("cannot get string for value\n"); |
|
812 |
- return -1; |
|
813 |
- } |
|
814 |
- if ( set_dlg_profile( msg, &val_s, |
|
815 |
- (struct dlg_profile_table*)profile) < 0 ) { |
|
816 |
- LM_ERR("failed to set profile"); |
|
817 |
- return -1; |
|
818 |
- } |
|
819 |
- } else { |
|
820 |
- if ( set_dlg_profile( msg, NULL, |
|
821 |
- (struct dlg_profile_table*)profile) < 0 ) { |
|
822 |
- LM_ERR("failed to set profile"); |
|
823 |
- return -1; |
|
824 |
- } |
|
825 |
- } |
|
826 |
- return 1; |
|
827 |
-} |
|
828 |
- |
|
829 |
- |
|
830 |
- |
|
831 |
-static int w_unset_dlg_profile(struct sip_msg *msg, char *profile, char *value) |
|
832 |
-{ |
|
833 |
- pv_elem_t *pve; |
|
834 |
- str val_s; |
|
835 |
- |
|
836 |
- pve = (pv_elem_t *)value; |
|
837 |
- |
|
838 |
- if (((struct dlg_profile_table*)profile)->has_value) { |
|
839 |
- if ( pve==NULL || pv_printf_s(msg, pve, &val_s)!=0 || |
|
840 |
- val_s.len == 0 || val_s.s == NULL) { |
|
841 |
- LM_WARN("cannot get string for value\n"); |
|
842 |
- return -1; |
|
843 |
- } |
|
844 |
- if ( unset_dlg_profile( msg, &val_s, |
|
845 |
- (struct dlg_profile_table*)profile) < 0 ) { |
|
846 |
- LM_ERR("failed to unset profile"); |
|
847 |
- return -1; |
|
848 |
- } |
|
849 |
- } else { |
|
850 |
- if ( unset_dlg_profile( msg, NULL, |
|
851 |
- (struct dlg_profile_table*)profile) < 0 ) { |
|
852 |
- LM_ERR("failed to unset profile"); |
|
853 |
- return -1; |
|
854 |
- } |
|
855 |
- } |
|
856 |
- return 1; |
|
857 |
-} |
|
858 |
- |
|
859 |
- |
|
860 |
- |
|
861 |
-static int w_is_in_profile(struct sip_msg *msg, char *profile, char *value) |
|
862 |
-{ |
|
863 |
- pv_elem_t *pve; |
|
864 |
- str val_s; |
|
865 |
- |
|
866 |
- pve = (pv_elem_t *)value; |
|
867 |
- |
|
868 |
- if ( pve!=NULL && ((struct dlg_profile_table*)profile)->has_value) { |
|
869 |
- if ( pv_printf_s(msg, pve, &val_s)!=0 || |
|
870 |
- val_s.len == 0 || val_s.s == NULL) { |
|
871 |
- LM_WARN("cannot get string for value\n"); |
|
872 |
- return -1; |
|
873 |
- } |
|
874 |
- return is_dlg_in_profile( msg, (struct dlg_profile_table*)profile, |
|
875 |
- &val_s); |
|
876 |
- } else { |
|
877 |
- return is_dlg_in_profile( msg, (struct dlg_profile_table*)profile, |
|
878 |
- NULL); |
|
879 |
- } |
|
880 |
-} |
|
881 |
- |
|
882 |
- |
|
883 |
-/** |
|
884 |
- * get dynamic name profile size |
|
885 |
- */ |
|
886 |
-static int w_get_profile_size3(struct sip_msg *msg, char *profile, |
|
887 |
- char *value, char *result) |
|
888 |
-{ |
|
889 |
- pv_elem_t *pve; |
|
890 |
- str val_s; |
|
891 |
- pv_spec_t *sp_dest; |
|
892 |
- unsigned int size; |
|
893 |
- pv_value_t val; |
|
894 |
- |
|
895 |
- if(result!=NULL) |
|
896 |
- { |
|
897 |
- pve = (pv_elem_t *)value; |
|
898 |
- sp_dest = (pv_spec_t *)result; |
|
899 |
- } else { |
|
900 |