7 * ***************************************************
8 * * Jiri's Source Memorial *
10 * * Welcome, pilgrim ! This is the greatest place *
11 * * where dramatic changes happend. There are not *
12 * * many places with a history like this, as there *
13 * * are not so many people like Jiri, one of the *
14 * * ser's fathers, who brought everywhere the wind *
15 * * of change, the flood of clean-up. We all felt *
16 * * his fatherly eye watching over us day and night.*
18 * * Please, preserve this codework heritage, as *
19 * * it's unlikely for fresh, juicy pieces of code to *
20 * * arise to give him the again the chance to *
21 * * demonstrate his clean-up and improvement skills.*
23 * * Hereby, we solicit you to adopt this historical *
24 * * piece of code. For $100, your name will be *
25 * * be printed in this banner and we will use *
26 * * collected funds to create and display an ASCII *
27 * * statue of Jiri . *
28 * ***************************************************
31 * Copyright (C) 2001-2003 FhG Fokus
33 * This file is part of ser, a free SIP server.
35 * ser is free software; you can redistribute it and/or modify
36 * it under the terms of the GNU General Public License as published by
37 * the Free Software Foundation; either version 2 of the License, or
38 * (at your option) any later version
40 * For a license to use the ser software under conditions
41 * other than those described here, or to purchase support for this
42 * software, please contact iptel.org by e-mail at the following addresses:
45 * ser is distributed in the hope that it will be useful,
46 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 * GNU General Public License for more details.
50 * You should have received a copy of the GNU General Public License
51 * along with this program; if not, write to the Free Software
52 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
57 * 2003-02-18 added t_forward_nonack_{udp, tcp}, t_relay_to_{udp,tcp},
58 * t_replicate_{udp, tcp} (andrei)
59 * 2003-02-19 added t_rely_{udp, tcp} (andrei)
60 * 2003-03-06 voicemail changes accepted (jiri)
61 * 2003-03-10 module export interface updated to the new format (andrei)
62 * 2003-03-16 flags export parameter added (janakj)
63 * 2003-03-19 replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
64 * 2003-03-30 set_kr for requests only (jiri)
65 * 2003-04-05 s/reply_route/failure_route, onreply_route introduced (jiri)
66 * 2003-04-14 use protocol from uri (jiri)
67 * 2003-07-07 added t_relay_to_tls, t_replicate_tls, t_forward_nonack_tls
68 * added #ifdef USE_TCP, USE_TLS
69 * removed t_relay_{udp,tcp,tls} (andrei)
70 * 2003-09-26 added t_forward_nonack_uri() - same as t_forward_nonack() but
71 * takes no parameters -> forwards to uri (bogdan)
72 * 2004-02-11 FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
73 * 2004-02-18 t_reply exported via FIFO - imported from VM (bogdan)
74 * 2004-10-01 added a new param.: restart_fr_on_each_reply (andrei)
75 * 2005-11-14 new timer support, changed timer related module params (andrei)
76 * 2005-12-09 fixup_hostport2proxy uses route_struct to access param #1
77 * when fixing param #2
78 * 2005-12-09 added t_set_fr() (andrei)
79 * 2006-02-07 named routes support (andrei)
80 * 2006-09-28 added t_branch_replied, t_branch_timeout, t_any_replied,
81 * t_any_timeout, t_is_canceled (andrei)
82 * 2006-10-16 added a new param.: aggregate challenges (andrei)
83 * 2007-05-28 two new params: reparse_invite, ac_extra_hdrs
84 * added w_t_relay_cancel() (Miklos)
85 * 2007-06-05 added t_set_auto_inv_100() and auto_inv_100 (param);
86 * t_set_max_lifetime(), max_{non}inv_lifetime (andrei)
87 * 2008-02-05 module config parameters use the configuration framework (Miklos)
88 * 2008-02-29 added t_grep_status(code) (andrei)
99 #include "../../sr_module.h"
100 #include "../../dprint.h"
101 #include "../../error.h"
102 #include "../../ut.h"
103 #include "../../script_cb.h"
104 #include "../../usr_avp.h"
105 #include "../../mem/mem.h"
106 #include "../../route_struct.h"
107 #include "../../route.h"
108 #include "../../cfg/cfg.h"
119 #include "t_lookup.h"
122 #include "t_cancel.h"
125 #include "t_msgbuilder.h"
130 /* fixup functions */
131 static int fixup_hostport2proxy(void** param, int param_no);
132 static int fixup_proto_hostport2proxy(void** param, int param_no);
133 static int fixup_on_failure(void** param, int param_no);
134 static int fixup_on_reply(void** param, int param_no);
135 static int fixup_on_branch(void** param, int param_no);
136 static int fixup_t_reply(void** param, int param_no);
140 static int mod_init(void);
141 static int child_init(int rank);
144 /* exported functions */
145 inline static int w_t_check(struct sip_msg* msg, char* str, char* str2);
146 inline static int w_t_lookup_cancel(struct sip_msg* msg, char* str, char* str2);
147 inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2);
148 inline static int w_t_release(struct sip_msg* msg, char* str, char* str2);
149 inline static int w_t_retransmit_reply(struct sip_msg* p_msg, char* foo,
151 inline static int w_t_newtran(struct sip_msg* p_msg, char* foo, char* bar );
152 inline static int w_t_relay( struct sip_msg *p_msg , char *_foo, char *_bar);
153 inline static int w_t_relay_to_udp( struct sip_msg *p_msg , char *proxy,
156 inline static int w_t_relay_to_tcp( struct sip_msg *p_msg , char *proxy,
160 inline static int w_t_relay_to_tls( struct sip_msg *p_msg , char *proxy,
163 inline static int w_t_relay_to(struct sip_msg* msg, char* str,char*);
164 inline static int w_t_replicate( struct sip_msg *p_msg ,
165 char *proxy, /* struct proxy_l *proxy expected */
166 char *_foo /* nothing expected */ );
167 inline static int w_t_replicate_udp( struct sip_msg *p_msg ,
168 char *proxy, /* struct proxy_l *proxy expected */
169 char *_foo /* nothing expected */ );
171 inline static int w_t_replicate_tcp( struct sip_msg *p_msg ,
172 char *proxy, /* struct proxy_l *proxy expected */
173 char *_foo /* nothing expected */ );
176 inline static int w_t_replicate_tls( struct sip_msg *p_msg ,
177 char *proxy, /* struct proxy_l *proxy expected */
178 char *_foo /* nothing expected */ );
180 inline static int w_t_replicate_to(struct sip_msg* msg, char* str,char*);
181 inline static int w_t_forward_nonack(struct sip_msg* msg, char* str, char* );
182 inline static int w_t_forward_nonack_uri(struct sip_msg* msg, char* str,char*);
183 inline static int w_t_forward_nonack_udp(struct sip_msg* msg, char* str,char*);
185 inline static int w_t_forward_nonack_tcp(struct sip_msg* msg, char* str,char*);
188 inline static int w_t_forward_nonack_tls(struct sip_msg* msg, char* str,char*);
190 inline static int w_t_forward_nonack_to(struct sip_msg* msg, char* str,char*);
191 inline static int w_t_relay_cancel(struct sip_msg *p_msg, char *_foo, char *_bar);
192 inline static int w_t_on_negative(struct sip_msg* msg, char *go_to, char *foo);
193 inline static int w_t_on_branch(struct sip_msg* msg, char *go_to, char *foo);
194 inline static int w_t_on_reply(struct sip_msg* msg, char *go_to, char *foo );
195 inline static int t_check_status(struct sip_msg* msg, char *match, char *foo);
196 static int t_set_fr_inv(struct sip_msg* msg, char* fr_inv, char* foo);
197 static int t_set_fr_all(struct sip_msg* msg, char* fr_inv, char* fr);
198 static int w_t_reset_fr(struct sip_msg* msg, char* foo, char* bar);
199 static int w_t_set_retr(struct sip_msg* msg, char* retr_t1, char* retr_t2);
200 static int w_t_reset_retr(struct sip_msg* msg, char* foo, char* bar);
201 static int w_t_set_max_lifetime(struct sip_msg* msg, char* inv, char* noninv);
202 static int w_t_reset_max_lifetime(struct sip_msg* msg, char* foo, char* bar);
203 static int t_set_auto_inv_100(struct sip_msg* msg, char* on_off, char* foo);
204 static int t_branch_timeout(struct sip_msg* msg, char*, char*);
205 static int t_branch_replied(struct sip_msg* msg, char*, char*);
206 static int t_any_timeout(struct sip_msg* msg, char*, char*);
207 static int t_any_replied(struct sip_msg* msg, char*, char*);
208 static int t_is_canceled(struct sip_msg* msg, char*, char*);
209 static int t_grep_status(struct sip_msg* msg, char*, char*);
212 /* by default the fr timers avps are not set, so that the avps won't be
213 * searched for nothing each time a new transaction is created */
214 static char *fr_timer_param = 0 /*FR_TIMER_AVP*/;
215 static char *fr_inv_timer_param = 0 /*FR_INV_TIMER_AVP*/;
217 static rpc_export_t tm_rpc[];
219 static int fixup_t_check_status(void** param, int param_no);
221 static cmd_export_t cmds[]={
222 {"t_newtran", w_t_newtran, 0, 0,
224 {"t_lookup_request", w_t_check, 0, 0,
226 {"t_lookup_cancel", w_t_lookup_cancel, 0, 0,
228 {T_REPLY, w_t_reply, 2, fixup_t_reply,
229 REQUEST_ROUTE | FAILURE_ROUTE },
230 {"t_retransmit_reply", w_t_retransmit_reply, 0, 0,
232 {"t_release", w_t_release, 0, 0,
234 {T_RELAY_TO_UDP, w_t_relay_to_udp, 2, fixup_hostport2proxy,
235 REQUEST_ROUTE|FAILURE_ROUTE},
237 {T_RELAY_TO_TCP, w_t_relay_to_tcp, 2, fixup_hostport2proxy,
238 REQUEST_ROUTE|FAILURE_ROUTE},
241 {T_RELAY_TO_TLS, w_t_relay_to_tls, 2, fixup_hostport2proxy,
242 REQUEST_ROUTE|FAILURE_ROUTE},
244 {"t_replicate", w_t_replicate, 2, fixup_hostport2proxy,
246 {"t_replicate_udp", w_t_replicate_udp, 2, fixup_hostport2proxy,
249 {"t_replicate_tcp", w_t_replicate_tcp, 2, fixup_hostport2proxy,
253 {"t_replicate_tls", w_t_replicate_tls, 2, fixup_hostport2proxy,
256 {"t_replicate_to", w_t_replicate_to, 2, fixup_proto_hostport2proxy,
258 {T_RELAY, w_t_relay, 0, 0,
259 REQUEST_ROUTE | FAILURE_ROUTE },
260 {"t_relay_to", w_t_relay_to, 2, fixup_proto_hostport2proxy,
262 {T_FORWARD_NONACK, w_t_forward_nonack, 2, fixup_hostport2proxy,
264 {T_FORWARD_NONACK_URI, w_t_forward_nonack_uri, 0, 0,
266 {T_FORWARD_NONACK_UDP, w_t_forward_nonack_udp, 2, fixup_hostport2proxy,
269 {T_FORWARD_NONACK_TCP, w_t_forward_nonack_tcp, 2, fixup_hostport2proxy,
273 {T_FORWARD_NONACK_TLS, w_t_forward_nonack_tls, 2, fixup_hostport2proxy,
276 {"t_forward_nonack_to", w_t_forward_nonack_to, 2, fixup_proto_hostport2proxy,
278 {"t_relay_cancel", w_t_relay_cancel, 0, 0,
280 {"t_on_failure", w_t_on_negative, 1, fixup_on_failure,
281 REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE },
282 {"t_on_reply", w_t_on_reply, 1, fixup_on_reply,
283 REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE },
284 {"t_on_branch", w_t_on_branch, 1, fixup_on_branch,
285 REQUEST_ROUTE | FAILURE_ROUTE },
286 {"t_check_status", t_check_status, 1, fixup_t_check_status,
287 REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE },
288 {"t_write_req", t_write_req, 2, fixup_t_write,
289 REQUEST_ROUTE | FAILURE_ROUTE },
290 {"t_write_unix", t_write_unix, 2, fixup_t_write,
291 REQUEST_ROUTE | FAILURE_ROUTE },
292 {"t_set_fr", t_set_fr_inv, 1, fixup_var_int_1,
293 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
294 {"t_set_fr", t_set_fr_all, 2, fixup_var_int_12,
295 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
296 {"t_reset_fr", w_t_reset_fr, 0, 0,
297 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
298 {"t_set_retr", w_t_set_retr, 2, fixup_var_int_12,
299 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
300 {"t_reset_retr", w_t_reset_retr, 0, 0,
301 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
302 {"t_set_max_lifetime", w_t_set_max_lifetime, 2, fixup_var_int_12,
303 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
304 {"t_reset_max_lifetime", w_t_reset_max_lifetime, 0, 0,
305 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
306 {"t_set_auto_inv_100", t_set_auto_inv_100, 1, fixup_var_int_1,
308 {"t_branch_timeout", t_branch_timeout, 0, 0, FAILURE_ROUTE},
309 {"t_branch_replied", t_branch_replied, 0, 0, FAILURE_ROUTE},
310 {"t_any_timeout", t_any_timeout, 0, 0,
311 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
312 {"t_any_replied", t_any_replied, 0, 0,
313 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
314 {"t_is_canceled", t_is_canceled, 0, 0,
315 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
316 {"t_grep_status", t_grep_status, 1, fixup_var_int_1,
317 REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
319 /* not applicable from the script */
320 {"register_tmcb", (cmd_function)register_tmcb, NO_SCRIPT, 0, 0},
321 {"load_tm", (cmd_function)load_tm, NO_SCRIPT, 0, 0},
322 {T_REPLY_WB, (cmd_function)t_reply_with_body, NO_SCRIPT, 0, 0},
323 {T_IS_LOCAL, (cmd_function)t_is_local, NO_SCRIPT, 0, 0},
324 {T_GET_TI, (cmd_function)t_get_trans_ident, NO_SCRIPT, 0, 0},
325 {T_LOOKUP_IDENT, (cmd_function)t_lookup_ident, NO_SCRIPT, 0, 0},
326 {T_ADDBLIND, (cmd_function)add_blind_uac, NO_SCRIPT, 0, 0},
327 {"t_request_within", (cmd_function)req_within, NO_SCRIPT, 0, 0},
328 {"t_request_outside", (cmd_function)req_outside, NO_SCRIPT, 0, 0},
329 {"t_request", (cmd_function)request, NO_SCRIPT, 0, 0},
330 {"new_dlg_uac", (cmd_function)new_dlg_uac, NO_SCRIPT, 0, 0},
331 {"dlg_response_uac", (cmd_function)dlg_response_uac, NO_SCRIPT, 0, 0},
332 {"new_dlg_uas", (cmd_function)new_dlg_uas, NO_SCRIPT, 0, 0},
333 {"update_dlg_uas", (cmd_function)update_dlg_uas, NO_SCRIPT, 0, 0},
334 {"dlg_request_uas", (cmd_function)dlg_request_uas, NO_SCRIPT, 0, 0},
335 {"set_dlg_target", (cmd_function)set_dlg_target, NO_SCRIPT, 0, 0},
336 {"free_dlg", (cmd_function)free_dlg, NO_SCRIPT, 0, 0},
337 {"print_dlg", (cmd_function)print_dlg, NO_SCRIPT, 0, 0},
338 {T_GETT, (cmd_function)get_t, NO_SCRIPT, 0, 0},
339 {"calculate_hooks", (cmd_function)w_calculate_hooks, NO_SCRIPT, 0, 0},
340 {"t_uac", (cmd_function)t_uac, NO_SCRIPT, 0, 0},
341 {"t_uac_with_ids", (cmd_function)t_uac_with_ids, NO_SCRIPT, 0, 0},
342 {"t_unref", (cmd_function)t_unref, NO_SCRIPT, 0, 0},
343 {"run_failure_handlers", (cmd_function)run_failure_handlers, NO_SCRIPT, 0, 0},
344 {"cancel_uacs", (cmd_function)cancel_uacs, NO_SCRIPT, 0, 0},
349 static param_export_t params[]={
350 {"ruri_matching", PARAM_INT, &default_tm_cfg.ruri_matching },
351 {"via1_matching", PARAM_INT, &default_tm_cfg.via1_matching },
352 {"fr_timer", PARAM_INT, &default_tm_cfg.fr_timeout },
353 {"fr_inv_timer", PARAM_INT, &default_tm_cfg.fr_inv_timeout },
354 {"wt_timer", PARAM_INT, &default_tm_cfg.wait_timeout },
355 {"delete_timer", PARAM_INT, &default_tm_cfg.delete_timeout },
356 {"retr_timer1", PARAM_INT, &default_tm_cfg.rt_t1_timeout },
357 {"retr_timer2" , PARAM_INT, &default_tm_cfg.rt_t2_timeout },
358 {"max_inv_lifetime", PARAM_INT, &default_tm_cfg.tm_max_inv_lifetime },
359 {"max_noninv_lifetime", PARAM_INT, &default_tm_cfg.tm_max_noninv_lifetime},
360 {"noisy_ctimer", PARAM_INT, &default_tm_cfg.noisy_ctimer },
361 {"auto_inv_100", PARAM_INT, &default_tm_cfg.tm_auto_inv_100 },
362 {"unix_tx_timeout", PARAM_INT, &default_tm_cfg.tm_unix_tx_timeout },
363 {"restart_fr_on_each_reply", PARAM_INT,
364 &default_tm_cfg.restart_fr_on_each_reply},
365 {"fr_timer_avp", PARAM_STRING, &fr_timer_param },
366 {"fr_inv_timer_avp", PARAM_STRING, &fr_inv_timer_param },
367 {"tw_append", PARAM_STRING|PARAM_USE_FUNC,
368 (void*)parse_tw_append },
369 {"pass_provisional_replies", PARAM_INT,
370 &default_tm_cfg.pass_provisional_replies },
371 {"aggregate_challenges", PARAM_INT, &default_tm_cfg.tm_aggregate_auth },
372 {"unmatched_cancel", PARAM_INT, &default_tm_cfg.unmatched_cancel },
373 {"default_code", PARAM_INT, &default_tm_cfg.default_code },
374 {"default_reason", PARAM_STRING, &default_tm_cfg.default_reason },
375 {"reparse_invite", PARAM_INT, &default_tm_cfg.reparse_invite },
376 {"ac_extra_hdrs", PARAM_STR, &default_tm_cfg.ac_extra_hdrs },
377 {"blst_503", PARAM_INT, &default_tm_cfg.tm_blst_503 },
378 {"blst_503_def_timeout",PARAM_INT, &default_tm_cfg.tm_blst_503_default },
379 {"blst_503_min_timeout",PARAM_INT, &default_tm_cfg.tm_blst_503_min },
380 {"blst_503_max_timeout",PARAM_INT, &default_tm_cfg.tm_blst_503_max },
381 {"blst_methods_add", PARAM_INT, &default_tm_cfg.tm_blst_methods_add },
382 {"blst_methods_lookup", PARAM_INT, &default_tm_cfg.tm_blst_methods_lookup},
383 {"cancel_b_method", PARAM_INT, &default_tm_cfg.cancel_b_flags},
388 struct module_exports tm_exports = {
390 struct module_exports exports= {
393 /* -------- exported functions ----------- */
395 tm_rpc, /* RPC methods */
396 /* ------------ exported variables ---------- */
399 mod_init, /* module initialization function */
400 (response_function) reply_received,
401 (destroy_function) tm_shutdown,
403 child_init /* per-child init function */
408 /* helper for fixup_on_* */
409 static int fixup_routes(char* r_type, struct route_list* rt, void** param)
413 i=route_get(rt, (char*)*param);
415 LOG(L_ERR, "ERROR: tm: fixup_routes: route_get failed\n");
418 if (rt->rlist[i]==0){
419 LOG(L_WARN, "WARNING: %s(\"%s\"): empty/non existing route\n",
420 r_type, (char*)*param);
422 *param=(void*)(long)i;
426 static int fixup_t_reply(void** param, int param_no)
431 ret = fix_param(FPARAM_AVP, param);
432 if (ret <= 0) return ret;
433 if (fix_param(FPARAM_INT, param) != 0) return -1;
434 } else if (param_no == 2) {
435 return fixup_var_str_12(param, 2);
440 static int fixup_on_failure(void** param, int param_no)
443 return fixup_routes("t_on_failure", &failure_rt, param);
450 static int fixup_on_reply(void** param, int param_no)
453 return fixup_routes("t_on_reply", &onreply_rt, param);
460 static int fixup_on_branch(void** param, int param_no)
463 return fixup_routes("t_on_branch", &branch_rt, param);
470 /* (char *hostname, char *port_nr) ==> (struct proxy_l *, -) */
471 static int fixup_hostport2proxy(void** param, int param_no)
476 struct proxy_l *proxy;
480 DBG("TM module: fixup_hostport2proxy(%s, %d)\n", (char*)*param, param_no);
483 } else if (param_no==2) {
484 a = fixup_get_param(param, param_no, 1);
486 port=str2s(*param, strlen(*param), &err);
488 LOG(L_ERR, "TM module:fixup_hostport2proxy: bad port number <%s>\n",
493 s.len = strlen(host);
494 proxy=mk_proxy(&s, port, 0); /* FIXME: udp or tcp? */
496 LOG(L_ERR, "ERROR: fixup_hostport2proxy: bad host name in URI <%s>\n",
498 return E_BAD_ADDRESS;
500 /* success -- fix the first parameter to proxy now ! */
505 LOG(L_ERR,"ERROR: fixup_hostport2proxy called with parameter #<>{1,2}\n");
510 /* (char *$proto, char *$host:port) ==> (fparam, fparam) */
511 static int fixup_proto_hostport2proxy(void** param, int param_no) {
514 ret = fix_param(FPARAM_AVP, param);
515 if (ret <= 0) return ret;
516 /* if (param_no = 1) { FIXME: param_str currently does not offer INT/STR overloading
517 ret = fix_param(FPARAM_INT, param);
518 if (ret <= 0) return ret;
520 if (fix_param(FPARAM_STRING, param) != 0) return -1;
525 static int fixup_t_check_status(void** param, int param_no)
529 ret = fix_param(FPARAM_AVP, param);
530 if (ret <= 0) return ret;
532 ret = fix_param(FPARAM_SELECT, param);
533 if (ret <= 0) return ret;
535 if (fix_param(FPARAM_REGEX, param) != 0) return -1;
540 /***************************** init functions *****************************/
541 static int w_t_unref( struct sip_msg *foo, void *bar)
547 static int script_init( struct sip_msg *foo, void *bar)
549 /* we primarily reset all private memory here to make sure
550 * private values left over from previous message will
551 * not be used again */
553 /* make sure the new message will not inherit previous
554 message's t_on_negative value
559 /* reset the kr status */
561 /* set request mode so that multiple-mode actions know
568 static int mod_init(void)
570 DBG( "TM - (sizeof cell=%ld, sip_msg=%ld) initializing...\n",
571 (long)sizeof(struct cell), (long)sizeof(struct sip_msg));
573 /* checking if we have sufficient bitmap capacity for given
574 maximum number of branches */
575 if (MAX_BRANCHES+1>31) {
576 LOG(L_CRIT, "Too many max UACs for UAC branch_bm_t bitmap: %d\n",
581 if (init_callid() < 0) {
582 LOG(L_CRIT, "Error while initializing Call-ID generator\n");
586 /* building the hash table*/
587 if (!init_hash_table()) {
588 LOG(L_ERR, "ERROR: mod_init: initializing hash_table failed\n");
592 /* init static hidden values */
595 if (tm_init_selects()==-1) {
596 LOG(L_ERR, "ERROR: mod_init: select init failed\n");
600 /* the default timer values must be fixed-up before
601 * declaring the configuration (Miklos) */
602 if (tm_init_timers()==-1) {
603 LOG(L_ERR, "ERROR: mod_init: timer init failed\n");
607 /* the cancel branch flags must be fixed before declaring the
609 if (cancel_b_flags_get(&default_tm_cfg.cancel_b_flags,
610 default_tm_cfg.cancel_b_flags)<0){
611 LOG(L_ERR, "ERROR: mod_init: bad cancel branch method\n");
615 /* declare the configuration */
616 if (cfg_declare("tm", tm_cfg_def, &default_tm_cfg, cfg_size(tm),
618 LOG(L_ERR, "ERROR: mod_init: failed to declare the configuration\n");
622 /* First tm_stat initialization function only allocates the top level stat
623 * structure in shared memory, the initialization will complete in child
624 * init with init_tm_stats_child when the final value of estimated_process_count is
627 if (init_tm_stats() < 0) {
628 LOG(L_CRIT, "ERROR: mod_init: failed to init stats\n");
632 if (uac_init()==-1) {
633 LOG(L_ERR, "ERROR: mod_init: uac_init failed\n");
637 if (init_tmcb_lists()!=1) {
638 LOG(L_CRIT, "ERROR:tm:mod_init: failed to init tmcb lists\n");
644 if (init_twrite_sock() < 0) {
645 LOG(L_ERR, "ERROR:tm:mod_init: Unable to create socket\n");
649 /* register post-script clean-up function */
650 if (register_script_cb( w_t_unref, POST_SCRIPT_CB|REQ_TYPE_CB, 0)<0 ) {
651 LOG(L_ERR,"ERROR:tm:mod_init: failed to register POST request "
655 if (register_script_cb( script_init, PRE_SCRIPT_CB|REQ_TYPE_CB , 0)<0 ) {
656 LOG(L_ERR,"ERROR:tm:mod_init: failed to register PRE request "
661 if (init_avp_params( fr_timer_param, fr_inv_timer_param)<0 ){
662 LOG(L_ERR,"ERROR:tm:mod_init: failed to process timer AVPs\n");
669 static int child_init(int rank)
671 if (rank == PROC_INIT) {
672 /* we must init stats when rank==PROC_INIT: after mod_init we know
673 * the exact number of processes and we must init the shared structure
674 * before any other process is starting (or else some new process
675 * might try to use the stats before the stats array is allocated) */
676 if (init_tm_stats_child() < 0) {
677 ERR("Error while initializing tm statistics structures\n");
680 }else if (child_init_callid(rank) < 0) {
681 /* don't init callid for PROC_INIT*/
682 LOG(L_ERR, "ERROR: child_init: Error while initializing Call-ID"
693 /**************************** wrapper functions ***************************/
694 static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
698 char *status, *s = NULL;
700 int lowest_status, n;
707 /* first get the transaction */
708 if (t_check(msg, 0 ) == -1) return -1;
709 if ((t = get_t()) == 0) {
710 LOG(L_ERR, "ERROR: t_check_status: cannot check status for a reply "
711 "which has no T-state established\n");
722 /* AVP or select, get the value and compile the regex */
723 if (get_str_fparam(&tmp, msg, fp) < 0) goto error;
724 s = pkg_malloc(tmp.len + 1);
726 ERR("Out of memory\n");
729 memcpy(s, tmp.s, tmp.len);
732 if ((re = pkg_malloc(sizeof(regex_t))) == 0) {
733 ERR("No memory left\n");
737 if (regcomp(re, s, REG_EXTENDED|REG_ICASE|REG_NEWLINE)) {
738 ERR("Bad regular expression '%s'\n", s);
746 /* use the status of the last sent reply */
747 status = int2str( t->uas.status, 0);
751 /* use the status of the current reply */
752 status = msg->first_line.u.reply.status.s;
753 backup = status[msg->first_line.u.reply.status.len];
754 status[msg->first_line.u.reply.status.len] = 0;
758 /* use the status of the winning reply */
759 if (t_pick_branch( -1, 0, t, &lowest_status)<0 ) {
760 LOG(L_CRIT,"BUG:t_check_status: t_pick_branch failed to get "
761 " a final response in MODE_ONFAILURE\n");
764 status = int2str( lowest_status , 0);
768 LOG(L_ERR,"ERROR:t_check_status: unsupported mode %d\n",rmode);
772 DBG("DEBUG:t_check_status: checked status is <%s>\n",status);
773 /* do the checking */
774 n = regexec(re, status, 1, &pmatch, 0);
776 if (backup) status[msg->first_line.u.reply.status.len] = backup;
778 if ((fp->type != FPARAM_REGEX) && re) {
788 if ((fp->type != FPARAM_REGEX) && re) {
796 inline static int w_t_check(struct sip_msg* msg, char* str, char* str2)
798 return t_check( msg , 0 ) ? 1 : -1;
801 inline static int w_t_lookup_cancel(struct sip_msg* msg, char* str, char* str2)
804 if (msg->REQ_METHOD==METHOD_CANCEL) {
805 ret = t_lookupOriginalT( msg );
806 DBG("lookup_original: t_lookupOriginalT returned: %p\n", ret);
807 if (ret != T_NULL_CELL) {
808 /* The cell is reffed by t_lookupOriginalT, but T is not set.
809 So we must unref it before returning. */
816 LOG(L_WARN, "WARNING: script error t_lookup_cancel() called for non-CANCEL request\n");
821 inline static int str2proto(char *s, int len) {
822 if (len == 3 && !strncasecmp(s, "udp", 3))
824 else if (len == 3 && !strncasecmp(s, "tcp", 3)) /* tcp&tls checks will be passed in getproto() */
826 else if (len == 3 && !strncasecmp(s, "tls", 3))
832 inline static struct proxy_l* t_protoaddr2proxy(char *proto_par, char *addr_par) {
833 struct proxy_l *proxy = 0;
836 int proto, port, err;
840 switch(((fparam_t *)proto_par)->type) {
842 if (!(avp = search_first_avp(((fparam_t *)proto_par)->v.avp.flags, ((fparam_t *)proto_par)->v.avp.name, &val, 0))) {
845 if (avp->flags & AVP_VAL_STR) {
846 proto = str2proto(val.s.s, val.s.len);
855 proto = ((fparam_t *)proto_par)->v.i;
858 proto = str2proto( ((fparam_t *)proto_par)->v.asciiz, strlen(((fparam_t *)proto_par)->v.asciiz));
861 ERR("BUG: Invalid proto parameter value in t_protoaddr2proxy\n");
866 switch(((fparam_t *)addr_par)->type) {
868 if (!(avp = search_first_avp(((fparam_t *)addr_par)->v.avp.flags, ((fparam_t *)addr_par)->v.avp.name, &val, 0))) {
871 if ((avp->flags & AVP_VAL_STR) == 0) {
872 LOG(L_ERR, "tm:t_protoaddr2proxy: avp <%.*s> value is not string\n",
873 ((fparam_t *)addr_par)->v.avp.name.s.len, ((fparam_t *)addr_par)->v.avp.name.s.s);
881 s.s = ((fparam_t *) addr_par)->v.asciiz;
886 ERR("BUG: Invalid addr parameter value in t_protoaddr2proxy\n");
892 c = memchr(s.s, ':', s.len);
894 port = str2s(c+1, s.len-(c-s.s+1), &err);
896 LOG(L_ERR, "tm:t_protoaddr2proxy: bad port number <%.*s>\n",
904 LOG(L_ERR, "tm: protoaddr2proxy: host name is empty\n");
907 proxy=mk_proxy(&s, port, proto);
909 LOG(L_ERR, "tm: protoaddr2proxy: bad host name in URI <%.*s>\n",
916 inline static int _w_t_forward_nonack(struct sip_msg* msg, struct proxy_l* proxy,
920 if (t_check( msg , 0 )==-1) {
921 LOG(L_ERR, "ERROR: forward_nonack: "
922 "can't forward when no transaction was set up\n");
926 if ( t && t!=T_UNDEFINED ) {
927 if (msg->REQ_METHOD==METHOD_ACK) {
928 LOG(L_WARN,"WARNING: you don't really want to fwd hbh ACK\n");
931 return t_forward_nonack(t, msg, proxy, proto );
933 DBG("DEBUG: forward_nonack: no transaction found\n");
939 inline static int w_t_forward_nonack( struct sip_msg* msg, char* proxy,
942 return _w_t_forward_nonack(msg, ( struct proxy_l *) proxy, PROTO_NONE);
946 inline static int w_t_forward_nonack_uri(struct sip_msg* msg, char *foo,
949 return _w_t_forward_nonack(msg, 0, PROTO_NONE);
953 inline static int w_t_forward_nonack_udp( struct sip_msg* msg, char* proxy,
956 return _w_t_forward_nonack(msg, ( struct proxy_l *) proxy, PROTO_UDP);
961 inline static int w_t_forward_nonack_tcp( struct sip_msg* msg, char* proxy,
964 return _w_t_forward_nonack(msg, ( struct proxy_l *) proxy, PROTO_TCP);
970 inline static int w_t_forward_nonack_tls( struct sip_msg* msg, char* proxy,
973 return _w_t_forward_nonack(msg, ( struct proxy_l *) proxy, PROTO_TLS);
977 inline static int w_t_forward_nonack_to( struct sip_msg *p_msg ,
981 struct proxy_l *proxy;
983 proxy = t_protoaddr2proxy(proto_par, addr_par);
985 r = _w_t_forward_nonack(p_msg, proxy, proxy->proto);
992 inline static int w_t_reply(struct sip_msg* msg, char* p1, char* p2)
999 if (msg->REQ_METHOD==METHOD_ACK) {
1000 LOG(L_WARN, "WARNING: t_reply: ACKs are not replied\n");
1003 if (t_check( msg , 0 )==-1) return -1;
1006 LOG(L_ERR, "ERROR: t_reply: cannot send a t_reply to a message "
1007 "for which no T-state has been established\n");
1011 if (get_int_fparam(&code, msg, (fparam_t*)p1) < 0) {
1012 code = cfg_get(tm, tm_cfg, default_code);
1015 if (get_str_fparam(&reason, msg, (fparam_t*)p2) < 0) {
1016 r = cfg_get(tm, tm_cfg, default_reason);
1018 r = as_asciiz(&reason);
1019 if (r == NULL) r = cfg_get(tm, tm_cfg, default_reason);
1022 /* if called from reply_route, make sure that unsafe version
1023 * is called; we are already in a mutex and another mutex in
1024 * the safe version would lead to a deadlock
1027 if (rmode==MODE_ONFAILURE) {
1028 DBG("DEBUG: t_reply_unsafe called from w_t_reply\n");
1029 ret = t_reply_unsafe(t, msg, code, r);
1030 } else if (rmode==MODE_REQUEST) {
1031 ret = t_reply( t, msg, code, r);
1033 LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
1037 if (r && (r != cfg_get(tm, tm_cfg, default_reason))) pkg_free(r);
1042 inline static int w_t_release(struct sip_msg* msg, char* str, char* str2)
1047 if (t_check( msg , 0 )==-1) return -1;
1049 if ( t && t!=T_UNDEFINED ) {
1050 ret = t_release_transaction( t );
1058 inline static int w_t_retransmit_reply( struct sip_msg* p_msg, char* foo, char* bar)
1063 if (t_check( p_msg , 0 )==-1)
1067 if (p_msg->REQ_METHOD==METHOD_ACK) {
1068 LOG(L_WARN, "WARNING: : ACKs transmit_replies not replied\n");
1071 return t_retransmit_reply( t );
1077 inline static int w_t_newtran( struct sip_msg* p_msg, char* foo, char* bar )
1079 /* t_newtran returns 0 on error (negative value means
1080 'transaction exists' */
1082 ret = t_newtran( p_msg );
1083 if (ret==E_SCRIPT) {
1084 LOG(L_ERR, "ERROR: t_newtran: "
1085 "transaction already in process %p\n", get_t() );
1091 inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo)
1093 t_on_negative( (unsigned int )(long) go_to );
1097 inline static int w_t_on_branch( struct sip_msg* msg, char *go_to, char *foo)
1099 t_on_branch( (unsigned int )(long) go_to );
1104 inline static int w_t_on_reply( struct sip_msg* msg, char *go_to, char *foo )
1106 t_on_reply( (unsigned int )(long) go_to );
1112 inline static int _w_t_relay_to( struct sip_msg *p_msg ,
1113 struct proxy_l *proxy )
1117 if (rmode==MODE_ONFAILURE) {
1119 if (!t || t==T_UNDEFINED) {
1120 LOG(L_CRIT, "BUG: w_t_relay_to: undefined T\n");
1123 if (t_forward_nonack(t, p_msg, proxy, PROTO_NONE)<=0 ) {
1124 LOG(L_ERR, "ERROR: w_t_relay_to: t_relay_to failed\n");
1129 if (rmode==MODE_REQUEST)
1130 return t_relay_to( p_msg, proxy, PROTO_NONE,
1131 0 /* no replication */ );
1132 LOG(L_CRIT, "ERROR: w_t_relay_to: unsupported mode: %d\n", rmode);
1137 inline static int w_t_relay_to_udp( struct sip_msg *p_msg ,
1138 char *proxy, /* struct proxy_l *proxy expected */
1139 char *_foo /* nothing expected */ )
1141 ((struct proxy_l *)proxy)->proto=PROTO_UDP;
1142 return _w_t_relay_to( p_msg, ( struct proxy_l *) proxy);
1147 inline static int w_t_relay_to_tcp( struct sip_msg *p_msg ,
1148 char *proxy, /* struct proxy_l *proxy expected */
1149 char *_foo /* nothing expected */ )
1151 ((struct proxy_l *)proxy)->proto=PROTO_TCP;
1152 return _w_t_relay_to( p_msg, ( struct proxy_l *) proxy);
1158 inline static int w_t_relay_to_tls( struct sip_msg *p_msg ,
1159 char *proxy, /* struct proxy_l *proxy expected */
1160 char *_foo /* nothing expected */ )
1162 ((struct proxy_l *)proxy)->proto=PROTO_TLS;
1163 return _w_t_relay_to( p_msg, ( struct proxy_l *) proxy);
1167 inline static int w_t_relay_to( struct sip_msg *p_msg ,
1171 struct proxy_l *proxy;
1173 proxy = t_protoaddr2proxy(proto_par, addr_par);
1175 r = _w_t_relay_to(p_msg, proxy);
1182 inline static int w_t_replicate( struct sip_msg *p_msg ,
1183 char *proxy, /* struct proxy_l *proxy expected */
1184 char *_foo /* nothing expected */ )
1186 return t_replicate(p_msg, ( struct proxy_l *) proxy, p_msg->rcv.proto );
1189 inline static int w_t_replicate_udp( struct sip_msg *p_msg ,
1190 char *proxy, /* struct proxy_l *proxy expected */
1191 char *_foo /* nothing expected */ )
1193 return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_UDP );
1198 inline static int w_t_replicate_tcp( struct sip_msg *p_msg ,
1199 char *proxy, /* struct proxy_l *proxy expected */
1200 char *_foo /* nothing expected */ )
1202 return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_TCP );
1208 inline static int w_t_replicate_tls( struct sip_msg *p_msg ,
1209 char *proxy, /* struct proxy_l *proxy expected */
1210 char *_foo /* nothing expected */ )
1212 return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_TLS );
1216 inline static int w_t_replicate_to( struct sip_msg *p_msg ,
1220 struct proxy_l *proxy;
1222 proxy = t_protoaddr2proxy(proto_par, addr_par);
1224 r = t_replicate(p_msg, proxy, proxy->proto);
1230 inline static int w_t_relay( struct sip_msg *p_msg ,
1231 char *_foo, char *_bar)
1235 if (rmode==MODE_ONFAILURE) {
1237 if (!t || t==T_UNDEFINED) {
1238 LOG(L_CRIT, "BUG: w_t_relay: undefined T\n");
1241 if (t_forward_nonack(t, p_msg, ( struct proxy_l *) 0, PROTO_NONE)<=0) {
1242 LOG(L_ERR, "ERROR: w_t_relay (failure mode): forwarding failed\n");
1247 if (rmode==MODE_REQUEST)
1248 return t_relay_to( p_msg,
1249 (struct proxy_l *) 0 /* no proxy */, PROTO_NONE,
1250 0 /* no replication */ );
1251 LOG(L_CRIT, "ERROR: w_t_relay_to: unsupported mode: %d\n", rmode);
1255 /* relays CANCEL at the beginning of the script */
1256 inline static int w_t_relay_cancel( struct sip_msg *p_msg ,
1257 char *_foo, char *_bar)
1259 if (p_msg->REQ_METHOD!=METHOD_CANCEL)
1262 /* it makes no sense to use this function without reparse_invite=1 */
1263 if (!cfg_get(tm, tm_cfg, reparse_invite))
1264 LOG(L_WARN, "WARNING: t_relay_cancel is probably used with "
1265 "wrong configuration, check the readme for details\n");
1267 return t_relay_cancel(p_msg);
1270 /* set fr_inv_timeout & or fr_timeout; 0 means: use the default value */
1271 static int t_set_fr_all(struct sip_msg* msg, char* p1, char* p2)
1275 if (get_int_fparam(&fr_inv, msg, (fparam_t*)p1) < 0) return -1;
1277 if (get_int_fparam(&fr, msg, (fparam_t*)p2) < 0) return -1;
1282 return t_set_fr(msg, fr_inv, fr);
1285 static int t_set_fr_inv(struct sip_msg* msg, char* fr_inv, char* foo)
1287 return t_set_fr_all(msg, fr_inv, (char*)0);
1290 /* reset fr_timer and fr_inv_timer to the default values */
1291 static int w_t_reset_fr(struct sip_msg* msg, char* foo, char* bar)
1293 return t_reset_fr();
1296 /* set retr. intervals per transaction; 0 means: use the default value */
1297 static int w_t_set_retr(struct sip_msg* msg, char* p1, char* p2)
1301 if (get_int_fparam(&t1, msg, (fparam_t*)p1) < 0) return -1;
1303 if (get_int_fparam(&t2, msg, (fparam_t*)p2) < 0) return -1;
1307 #ifdef TM_DIFF_RT_TIMEOUT
1308 return t_set_retr(msg, t1, t2);
1310 ERR("w_t_set_retr: support for changing retransmission intervals on "
1311 "the fly not compiled in (re-compile tm with"
1312 " -DTM_DIFF_RT_TIMEOUT)\n");
1317 /* reset retr. t1 and t2 to the default values */
1318 int w_t_reset_retr(struct sip_msg* msg, char* foo, char* bar)
1320 #ifdef TM_DIFF_RT_TIMEOUT
1321 return t_reset_retr();
1323 ERR("w_t_reset_retr: support for changing retransmission intervals on "
1324 "the fly not compiled in (re-compile tm with"
1325 " -DTM_DIFF_RT_TIMEOUT)\n");
1330 /* set maximum transaction lifetime for inv & noninv */
1331 static int w_t_set_max_lifetime(struct sip_msg* msg, char* p1, char* p2)
1335 if (get_int_fparam(&t1, msg, (fparam_t*)p1) < 0) return -1;
1337 if (get_int_fparam(&t2, msg, (fparam_t*)p2) < 0) return -1;
1341 return t_set_max_lifetime(msg, t1, t2);
1344 /* reset maximum invite/non-invite lifetime to the default value */
1345 int w_t_reset_max_lifetime(struct sip_msg* msg, char* foo, char* bar)
1347 return t_reset_max_lifetime();
1350 /* set automatically sending 100 replies on/off for the current or
1351 * next to be created transaction */
1352 static int t_set_auto_inv_100(struct sip_msg* msg, char* p1, char* p2)
1357 if (get_int_fparam(&state, msg, (fparam_t*)p1) < 0) return -1;
1359 /* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
1360 * in MODE_REQUEST T will be set only if the transaction was already
1361 * created; if not -> use the static variables */
1362 if (!t || t==T_UNDEFINED ){
1364 set_msgid_val(user_auto_inv_100, msg->id, int, 1); /* set */
1366 set_msgid_val(user_auto_inv_100, msg->id, int, -1); /* reset */
1369 t->flags|=T_AUTO_INV_100;
1371 t->flags&=~T_AUTO_INV_100;
1378 /* script function, FAILURE_ROUTE only, returns true if the
1379 * choosed "failure" branch failed because of a timeout,
1381 int t_branch_timeout(struct sip_msg* msg, char* foo, char* bar)
1383 return (msg->msg_flags & FL_TIMEOUT)?1:-1;
1388 /* script function, FAILURE_ROUTE only, returns true if the
1389 * choosed "failure" branch ever received a reply, -1 otherwise */
1390 int t_branch_replied(struct sip_msg* msg, char* foo, char* bar)
1392 return (msg->msg_flags & FL_REPLIED)?1:-1;
1397 /* script function, returns: 1 if the transaction was canceled, -1 if not */
1398 int t_is_canceled(struct sip_msg* msg, char* foo, char* bar)
1404 if (t_check( msg , 0 )==-1) return -1;
1406 if ((t==0) || (t==T_UNDEFINED)){
1407 LOG(L_ERR, "ERROR: t_is_canceled: cannot check a message "
1408 "for which no T-state has been established\n");
1411 ret=(t->flags & T_CANCELED)?1:-1;
1418 /* script function, returns: 1 if any of the branches did timeout, -1 if not */
1419 int t_any_timeout(struct sip_msg* msg, char* foo, char* bar)
1424 if (t_check( msg , 0 )==-1) return -1;
1426 if ((t==0) || (t==T_UNDEFINED)){
1427 LOG(L_ERR, "ERROR: t_any_timeout: cannot check a message "
1428 "for which no T-state has been established\n");
1431 for (r=0; r<t->nr_of_outgoings; r++){
1432 if (t->uac[r].request.flags & F_RB_TIMEOUT)
1441 /* script function, returns: 1 if any of the branches received at leat one
1442 * reply, -1 if not */
1443 int t_any_replied(struct sip_msg* msg, char* foo, char* bar)
1448 if (t_check( msg , 0 )==-1) return -1;
1450 if ((t==0) || (t==T_UNDEFINED)){
1451 LOG(L_ERR, "ERROR: t_any_replied: cannot check a message "
1452 "for which no T-state has been established\n");
1455 for (r=0; r<t->nr_of_outgoings; r++){
1456 if (t->uac[r].request.flags & F_RB_REPLIED)
1465 /* script function, returns: 1 if any of the branches received the
1466 * reply code "status" */
1467 int t_grep_status(struct sip_msg* msg, char* status, char* bar)
1473 if (get_int_fparam(&code, msg, (fparam_t*)status) < 0) return -1;
1474 if (t_check( msg , 0 )==-1) return -1;
1476 if ((t==0) || (t==T_UNDEFINED)){
1477 LOG(L_ERR, "ERROR: t_any_replied: cannot check a message "
1478 "for which no T-state has been established\n");
1481 for (r=0; r<t->nr_of_outgoings; r++){
1482 if ((t->uac[r].last_received==code) &&
1483 (t->uac[r].request.flags & F_RB_REPLIED))
1492 static rpc_export_t tm_rpc[] = {
1493 {"tm.cancel", rpc_cancel, rpc_cancel_doc, 0},
1494 {"tm.reply", rpc_reply, rpc_reply_doc, 0},
1495 {"tm.stats", tm_rpc_stats, tm_rpc_stats_doc, 0},
1496 {"tm.hash_stats", tm_rpc_hash_stats, tm_rpc_hash_stats_doc, 0},
1500 /* wrapper function needed after changes in w_t_reply */
1501 int w_t_reply_wrp(struct sip_msg *m, unsigned int code, char *txt)
1506 c.type = FPARAM_INT;
1507 c.orig = NULL; /* ? */
1510 r.type = FPARAM_STRING;
1511 r.orig = NULL; /* ? */
1514 return w_t_reply(m, (char *)&c, (char*)&r);