2
0

dialog.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705
  1. /*
  2. * $Id$
  3. *
  4. * dialog module - basic support for dialog tracking
  5. *
  6. * Copyright (C) 2006 Voice Sistem SRL
  7. * Copyright (C) 2011 Carsten Bock, [email protected]
  8. *
  9. * This file is part of Kamailio, a free SIP server.
  10. *
  11. * Kamailio is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version
  15. *
  16. * Kamailio is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  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
  24. *
  25. * History:
  26. * --------
  27. * 2006-04-14 initial version (bogdan)
  28. * 2006-11-28 Added statistic support for the number of early and failed
  29. * dialogs. (Jeffrey Magder - SOMA Networks)
  30. * 2007-04-30 added dialog matching without DID (dialog ID), but based only
  31. * on RFC3261 elements - based on an original patch submitted
  32. * by Michel Bensoussan <[email protected]> (bogdan)
  33. * 2007-05-15 added saving dialogs' information to database (ancuta)
  34. * 2007-07-04 added saving dialog cseq, contact, record route
  35. * and bind_addresses(sock_info) for caller and callee (ancuta)
  36. * 2008-04-14 added new type of callback to be triggered when dialogs are
  37. * loaded from DB (bogdan)
  38. * 2010-06-16 added sip-router rpc interface (osas)
  39. */
  40. /**
  41. * @defgroup dialog dialog :: Kamailio dialog module
  42. * @brief Kamailio dialog module
  43. *
  44. * The dialog module provides dialog awareness to the Kamailio proxy. Its
  45. * functionality is to keep track of the current dialogs, to offer
  46. * information about them (like how many dialogs are active) or to manage
  47. * them. The module exports several functions that could be used directly
  48. * from scripts.
  49. * The module, via an internal API, also provide the foundation to build
  50. * on top of it more complex dialog-based functionalities via other
  51. * Kamailio modules.
  52. */
  53. #include <stdio.h>
  54. #include <string.h>
  55. #include <stdlib.h>
  56. #include <sys/time.h>
  57. #include "../../sr_module.h"
  58. #include "../../lib/srdb1/db.h"
  59. #include "../../dprint.h"
  60. #include "../../error.h"
  61. #include "../../ut.h"
  62. #include "../../pvar.h"
  63. #include "../../mod_fix.h"
  64. #include "../../script_cb.h"
  65. #include "../../lib/kcore/faked_msg.h"
  66. #include "../../hashes.h"
  67. #include "../../lib/kcore/kstats_wrapper.h"
  68. #include "../../mem/mem.h"
  69. #include "../../lib/kmi/mi.h"
  70. #include "../../timer_proc.h"
  71. #include "../../lvalue.h"
  72. #include "../../parser/parse_to.h"
  73. #include "../../modules/tm/tm_load.h"
  74. #include "../../rpc_lookup.h"
  75. #include "../rr/api.h"
  76. #include "dlg_hash.h"
  77. #include "dlg_timer.h"
  78. #include "dlg_handlers.h"
  79. #include "dlg_load.h"
  80. #include "dlg_cb.h"
  81. #include "dlg_db_handler.h"
  82. #include "dlg_req_within.h"
  83. #include "dlg_profile.h"
  84. #include "dlg_var.h"
  85. #include "dlg_transfer.h"
  86. MODULE_VERSION
  87. static int mod_init(void);
  88. static int child_init(int rank);
  89. static void mod_destroy(void);
  90. /* module parameter */
  91. static int dlg_hash_size = 4096;
  92. static char* rr_param = "did";
  93. static int dlg_flag = -1;
  94. static str timeout_spec = {NULL, 0};
  95. static int default_timeout = 60 * 60 * 12; /* 12 hours */
  96. static int seq_match_mode = SEQ_MATCH_STRICT_ID;
  97. static char* profiles_wv_s = NULL;
  98. static char* profiles_nv_s = NULL;
  99. str dlg_extra_hdrs = {NULL,0};
  100. static int db_fetch_rows = 200;
  101. int initial_cbs_inscript = 1;
  102. int dlg_wait_ack = 1;
  103. int dlg_event_rt[DLG_EVENTRT_MAX];
  104. str dlg_bridge_controller = {"sip:[email protected]", 27};
  105. str dlg_bridge_contact = {"sip:[email protected]:5060", 32};
  106. str ruri_pvar_param = {"$ru", 3};
  107. pv_elem_t * ruri_param_model = NULL;
  108. /* statistic variables */
  109. int dlg_enable_stats = 1;
  110. int active_dlgs_cnt = 0;
  111. int early_dlgs_cnt = 0;
  112. int detect_spirals = 1;
  113. int dlg_send_bye = 0;
  114. stat_var *active_dlgs = 0;
  115. stat_var *processed_dlgs = 0;
  116. stat_var *expired_dlgs = 0;
  117. stat_var *failed_dlgs = 0;
  118. stat_var *early_dlgs = 0;
  119. struct tm_binds d_tmb;
  120. struct rr_binds d_rrb;
  121. pv_spec_t timeout_avp;
  122. int dlg_db_mode_param = DB_MODE_NONE;
  123. str dlg_xavp_cfg = {0};
  124. int dlg_ka_timer = 0;
  125. int dlg_ka_interval = 0;
  126. /* db stuff */
  127. static str db_url = str_init(DEFAULT_DB_URL);
  128. static unsigned int db_update_period = DB_DEFAULT_UPDATE_PERIOD;
  129. static int pv_get_dlg_count( struct sip_msg *msg, pv_param_t *param,
  130. pv_value_t *res);
  131. void dlg_ka_timer_exec(unsigned int ticks, void* param);
  132. /* commands wrappers and fixups */
  133. static int fixup_profile(void** param, int param_no);
  134. static int fixup_get_profile2(void** param, int param_no);
  135. static int fixup_get_profile3(void** param, int param_no);
  136. static int w_set_dlg_profile(struct sip_msg*, char*, char*);
  137. static int w_unset_dlg_profile(struct sip_msg*, char*, char*);
  138. static int w_is_in_profile(struct sip_msg*, char*, char*);
  139. static int w_get_profile_size2(struct sip_msg*, char*, char*);
  140. static int w_get_profile_size3(struct sip_msg*, char*, char*, char*);
  141. static int w_dlg_isflagset(struct sip_msg *msg, char *flag, str *s2);
  142. static int w_dlg_resetflag(struct sip_msg *msg, char *flag, str *s2);
  143. static int w_dlg_setflag(struct sip_msg *msg, char *flag, char *s2);
  144. static int w_dlg_set_property(struct sip_msg *msg, char *prop, char *s2);
  145. static int w_dlg_manage(struct sip_msg*, char*, char*);
  146. static int w_dlg_bye(struct sip_msg*, char*, char*);
  147. static int w_dlg_refer(struct sip_msg*, char*, char*);
  148. static int w_dlg_bridge(struct sip_msg*, char*, char*, char*);
  149. static int w_dlg_set_timeout(struct sip_msg*, char*, char*, char*);
  150. static int w_dlg_set_timeout_by_profile2(struct sip_msg *, char *, char *);
  151. static int w_dlg_set_timeout_by_profile3(struct sip_msg *, char *, char *,
  152. char *);
  153. static int fixup_dlg_bye(void** param, int param_no);
  154. static int fixup_dlg_refer(void** param, int param_no);
  155. static int fixup_dlg_bridge(void** param, int param_no);
  156. static int w_dlg_get(struct sip_msg*, char*, char*, char*);
  157. static int w_is_known_dlg(struct sip_msg *);
  158. static cmd_export_t cmds[]={
  159. {"dlg_manage", (cmd_function)w_dlg_manage, 0,0,
  160. 0, REQUEST_ROUTE },
  161. {"set_dlg_profile", (cmd_function)w_set_dlg_profile, 1,fixup_profile,
  162. 0, ANY_ROUTE },
  163. {"set_dlg_profile", (cmd_function)w_set_dlg_profile, 2,fixup_profile,
  164. 0, ANY_ROUTE },
  165. {"unset_dlg_profile", (cmd_function)w_unset_dlg_profile, 1,fixup_profile,
  166. 0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
  167. {"unset_dlg_profile", (cmd_function)w_unset_dlg_profile, 2,fixup_profile,
  168. 0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
  169. {"is_in_profile", (cmd_function)w_is_in_profile, 1,fixup_profile,
  170. 0, ANY_ROUTE },
  171. {"is_in_profile", (cmd_function)w_is_in_profile, 2,fixup_profile,
  172. 0, ANY_ROUTE },
  173. {"get_profile_size",(cmd_function)w_get_profile_size2, 2,fixup_get_profile2,
  174. 0, ANY_ROUTE },
  175. {"get_profile_size",(cmd_function)w_get_profile_size3, 3,fixup_get_profile3,
  176. 0, ANY_ROUTE },
  177. {"dlg_setflag", (cmd_function)w_dlg_setflag, 1,fixup_igp_null,
  178. 0, ANY_ROUTE },
  179. {"dlg_resetflag", (cmd_function)w_dlg_resetflag, 1,fixup_igp_null,
  180. 0, ANY_ROUTE },
  181. {"dlg_isflagset", (cmd_function)w_dlg_isflagset, 1,fixup_igp_null,
  182. 0, ANY_ROUTE },
  183. {"dlg_bye",(cmd_function)w_dlg_bye, 1,fixup_dlg_bye,
  184. 0, ANY_ROUTE },
  185. {"dlg_refer",(cmd_function)w_dlg_refer, 2,fixup_dlg_refer,
  186. 0, ANY_ROUTE },
  187. {"dlg_bridge",(cmd_function)w_dlg_bridge, 3,fixup_dlg_bridge,
  188. 0, ANY_ROUTE },
  189. {"dlg_get",(cmd_function)w_dlg_get, 3,fixup_dlg_bridge,
  190. 0, ANY_ROUTE },
  191. {"is_known_dlg", (cmd_function)w_is_known_dlg, 0, NULL,
  192. 0, ANY_ROUTE },
  193. {"dlg_set_timeout", (cmd_function)w_dlg_set_timeout, 1,fixup_igp_null,
  194. 0, ANY_ROUTE },
  195. {"dlg_set_timeout", (cmd_function)w_dlg_set_timeout, 3,fixup_igp_all,
  196. 0, ANY_ROUTE },
  197. {"dlg_set_timeout_by_profile",
  198. (cmd_function) w_dlg_set_timeout_by_profile2, 2, fixup_profile,
  199. 0, ANY_ROUTE },
  200. {"dlg_set_timeout_by_profile",
  201. (cmd_function) w_dlg_set_timeout_by_profile3, 3, fixup_profile,
  202. 0, ANY_ROUTE },
  203. {"dlg_set_property", (cmd_function)w_dlg_set_property,1,fixup_spve_null,
  204. 0, ANY_ROUTE },
  205. {"load_dlg", (cmd_function)load_dlg, 0, 0, 0, 0},
  206. {0,0,0,0,0,0}
  207. };
  208. static param_export_t mod_params[]={
  209. { "enable_stats", INT_PARAM, &dlg_enable_stats },
  210. { "hash_size", INT_PARAM, &dlg_hash_size },
  211. { "rr_param", STR_PARAM, &rr_param },
  212. { "dlg_flag", INT_PARAM, &dlg_flag },
  213. { "timeout_avp", STR_PARAM, &timeout_spec.s },
  214. { "default_timeout", INT_PARAM, &default_timeout },
  215. { "dlg_extra_hdrs", STR_PARAM, &dlg_extra_hdrs.s },
  216. { "dlg_match_mode", INT_PARAM, &seq_match_mode },
  217. { "detect_spirals", INT_PARAM, &detect_spirals, },
  218. { "db_url", STR_PARAM, &db_url.s },
  219. { "db_mode", INT_PARAM, &dlg_db_mode_param },
  220. { "table_name", STR_PARAM, &dialog_table_name },
  221. { "call_id_column", STR_PARAM, &call_id_column.s },
  222. { "from_uri_column", STR_PARAM, &from_uri_column.s },
  223. { "from_tag_column", STR_PARAM, &from_tag_column.s },
  224. { "to_uri_column", STR_PARAM, &to_uri_column.s },
  225. { "to_tag_column", STR_PARAM, &to_tag_column.s },
  226. { "h_id_column", STR_PARAM, &h_id_column.s },
  227. { "h_entry_column", STR_PARAM, &h_entry_column.s },
  228. { "state_column", STR_PARAM, &state_column.s },
  229. { "start_time_column", STR_PARAM, &start_time_column.s },
  230. { "timeout_column", STR_PARAM, &timeout_column.s },
  231. { "to_cseq_column", STR_PARAM, &to_cseq_column.s },
  232. { "from_cseq_column", STR_PARAM, &from_cseq_column.s },
  233. { "to_route_column", STR_PARAM, &to_route_column.s },
  234. { "from_route_column", STR_PARAM, &from_route_column.s },
  235. { "to_contact_column", STR_PARAM, &to_contact_column.s },
  236. { "from_contact_column", STR_PARAM, &from_contact_column.s },
  237. { "to_sock_column", STR_PARAM, &to_sock_column.s },
  238. { "from_sock_column", STR_PARAM, &from_sock_column.s },
  239. { "sflags_column", STR_PARAM, &sflags_column.s },
  240. { "toroute_name_column", STR_PARAM, &toroute_name_column.s },
  241. { "vars_table_name", STR_PARAM, &dialog_vars_table_name },
  242. { "vars_h_id_column", STR_PARAM, &vars_h_id_column.s },
  243. { "vars_h_entry_column", STR_PARAM, &vars_h_entry_column.s },
  244. { "vars_key_column", STR_PARAM, &vars_key_column.s },
  245. { "vars_value_column", STR_PARAM, &vars_value_column.s },
  246. { "db_update_period", INT_PARAM, &db_update_period },
  247. { "db_fetch_rows", INT_PARAM, &db_fetch_rows },
  248. { "profiles_with_value", STR_PARAM, &profiles_wv_s },
  249. { "profiles_no_value", STR_PARAM, &profiles_nv_s },
  250. { "bridge_controller", STR_PARAM, &dlg_bridge_controller.s },
  251. { "bridge_contact", PARAM_STR, &dlg_bridge_contact },
  252. { "ruri_pvar", STR_PARAM, &ruri_pvar_param.s },
  253. { "initial_cbs_inscript", INT_PARAM, &initial_cbs_inscript },
  254. { "send_bye", INT_PARAM, &dlg_send_bye },
  255. { "wait_ack", INT_PARAM, &dlg_wait_ack },
  256. { "xavp_cfg", STR_PARAM, &dlg_xavp_cfg.s },
  257. { "ka_timer", INT_PARAM, &dlg_ka_timer },
  258. { "ka_interval", INT_PARAM, &dlg_ka_interval },
  259. { 0,0,0 }
  260. };
  261. static stat_export_t mod_stats[] = {
  262. {"active_dialogs" , STAT_NO_RESET, &active_dlgs },
  263. {"early_dialogs", STAT_NO_RESET, &early_dlgs },
  264. {"processed_dialogs" , 0, &processed_dlgs },
  265. {"expired_dialogs" , 0, &expired_dlgs },
  266. {"failed_dialogs", 0, &failed_dlgs },
  267. {0,0,0}
  268. };
  269. struct mi_root * mi_dlg_bridge(struct mi_root *cmd_tree, void *param);
  270. static mi_export_t mi_cmds[] = {
  271. { "dlg_list", mi_print_dlgs, 0, 0, 0},
  272. { "dlg_list_ctx", mi_print_dlgs_ctx, 0, 0, 0},
  273. { "dlg_end_dlg", mi_terminate_dlg, 0, 0, 0},
  274. { "dlg_terminate_dlg", mi_terminate_dlgs, 0, 0, 0},
  275. { "profile_get_size", mi_get_profile, 0, 0, 0},
  276. { "profile_list_dlgs", mi_profile_list, 0, 0, 0},
  277. { "dlg_bridge", mi_dlg_bridge, 0, 0, 0},
  278. { 0, 0, 0, 0, 0}
  279. };
  280. static rpc_export_t rpc_methods[];
  281. static pv_export_t mod_items[] = {
  282. { {"DLG_count", sizeof("DLG_count")-1}, PVT_OTHER, pv_get_dlg_count, 0,
  283. 0, 0, 0, 0 },
  284. { {"DLG_lifetime",sizeof("DLG_lifetime")-1}, PVT_OTHER, pv_get_dlg_lifetime, 0,
  285. 0, 0, 0, 0 },
  286. { {"DLG_status", sizeof("DLG_status")-1}, PVT_OTHER, pv_get_dlg_status, 0,
  287. 0, 0, 0, 0 },
  288. { {"dlg_ctx", sizeof("dlg_ctx")-1}, PVT_OTHER, pv_get_dlg_ctx,
  289. pv_set_dlg_ctx, pv_parse_dlg_ctx_name, 0, 0, 0 },
  290. { {"dlg", sizeof("dlg")-1}, PVT_OTHER, pv_get_dlg,
  291. 0, pv_parse_dlg_name, 0, 0, 0 },
  292. { {"dlg_var", sizeof("dlg_var")-1}, PVT_OTHER, pv_get_dlg_variable,
  293. pv_set_dlg_variable, pv_parse_dialog_var_name, 0, 0, 0},
  294. { {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
  295. };
  296. struct module_exports exports= {
  297. "dialog", /* module's name */
  298. DEFAULT_DLFLAGS, /* dlopen flags */
  299. cmds, /* exported functions */
  300. mod_params, /* param exports */
  301. mod_stats, /* exported statistics */
  302. mi_cmds, /* exported MI functions */
  303. mod_items, /* exported pseudo-variables */
  304. 0, /* extra processes */
  305. mod_init, /* module initialization function */
  306. 0, /* reply processing function */
  307. mod_destroy,
  308. child_init /* per-child init function */
  309. };
  310. static int fixup_profile(void** param, int param_no)
  311. {
  312. struct dlg_profile_table *profile;
  313. pv_elem_t *model=NULL;
  314. str s;
  315. s.s = (char*)(*param);
  316. s.len = strlen(s.s);
  317. if(s.len==0) {
  318. LM_ERR("param %d is empty string!\n", param_no);
  319. return E_CFG;
  320. }
  321. if (param_no==1) {
  322. profile = search_dlg_profile( &s );
  323. if (profile==NULL) {
  324. LM_CRIT("profile <%s> not definited\n",s.s);
  325. return E_CFG;
  326. }
  327. pkg_free(*param);
  328. *param = (void*)profile;
  329. return 0;
  330. } else if (param_no==2) {
  331. if(pv_parse_format(&s ,&model) || model==NULL) {
  332. LM_ERR("wrong format [%s] for value param!\n", s.s);
  333. return E_CFG;
  334. }
  335. *param = (void*)model;
  336. }
  337. return 0;
  338. }
  339. static int fixup_get_profile2(void** param, int param_no)
  340. {
  341. pv_spec_t *sp;
  342. int ret;
  343. if (param_no==1) {
  344. return fixup_profile(param, 1);
  345. } else if (param_no==2) {
  346. ret = fixup_pvar_null(param, 1);
  347. if (ret<0) return ret;
  348. sp = (pv_spec_t*)(*param);
  349. if (sp->type!=PVT_AVP && sp->type!=PVT_SCRIPTVAR) {
  350. LM_ERR("return must be an AVP or SCRIPT VAR!\n");
  351. return E_SCRIPT;
  352. }
  353. }
  354. return 0;
  355. }
  356. static int fixup_get_profile3(void** param, int param_no)
  357. {
  358. if (param_no==1) {
  359. return fixup_profile(param, 1);
  360. } else if (param_no==2) {
  361. return fixup_profile(param, 2);
  362. } else if (param_no==3) {
  363. return fixup_get_profile2( param, 2);
  364. }
  365. return 0;
  366. }
  367. int load_dlg( struct dlg_binds *dlgb )
  368. {
  369. dlgb->register_dlgcb = register_dlgcb;
  370. dlgb->terminate_dlg = dlg_bye_all;
  371. dlgb->set_dlg_var = set_dlg_variable;
  372. dlgb->get_dlg_var = get_dlg_variable;
  373. dlgb->get_dlg = dlg_get_msg_dialog;
  374. dlgb->release_dlg = dlg_release;
  375. return 1;
  376. }
  377. static int pv_get_dlg_count(struct sip_msg *msg, pv_param_t *param,
  378. pv_value_t *res)
  379. {
  380. int n;
  381. int l;
  382. char *ch;
  383. if(msg==NULL || res==NULL)
  384. return -1;
  385. n = active_dlgs ? get_stat_val(active_dlgs) : 0;
  386. l = 0;
  387. ch = int2str( n, &l);
  388. res->rs.s = ch;
  389. res->rs.len = l;
  390. res->ri = n;
  391. res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT;
  392. return 0;
  393. }
  394. static int mod_init(void)
  395. {
  396. unsigned int n;
  397. dlg_event_rt[DLG_EVENTRT_START] = route_lookup(&event_rt, "dialog:start");
  398. dlg_event_rt[DLG_EVENTRT_END] = route_lookup(&event_rt, "dialog:end");
  399. dlg_event_rt[DLG_EVENTRT_FAILED] = route_lookup(&event_rt, "dialog:failed");
  400. #ifdef STATISTICS
  401. /* register statistics */
  402. if (register_module_stats( exports.name, mod_stats)!=0 ) {
  403. LM_ERR("failed to register core statistics\n");
  404. return -1;
  405. }
  406. #endif
  407. if(register_mi_mod(exports.name, mi_cmds)!=0)
  408. {
  409. LM_ERR("failed to register MI commands\n");
  410. return -1;
  411. }
  412. if (rpc_register_array(rpc_methods)!=0) {
  413. LM_ERR("failed to register RPC commands\n");
  414. return -1;
  415. }
  416. if(faked_msg_init()<0)
  417. return -1;
  418. if(dlg_bridge_init_hdrs()<0)
  419. return -1;
  420. if (timeout_spec.s)
  421. timeout_spec.len = strlen(timeout_spec.s);
  422. dlg_bridge_controller.len = strlen(dlg_bridge_controller.s);
  423. db_url.len = strlen(db_url.s);
  424. call_id_column.len = strlen(call_id_column.s);
  425. from_uri_column.len = strlen(from_uri_column.s);
  426. from_tag_column.len = strlen(from_tag_column.s);
  427. to_uri_column.len = strlen(to_uri_column.s);
  428. to_tag_column.len = strlen(to_tag_column.s);
  429. h_id_column.len = strlen(h_id_column.s);
  430. h_entry_column.len = strlen(h_entry_column.s);
  431. state_column.len = strlen(state_column.s);
  432. start_time_column.len = strlen(start_time_column.s);
  433. timeout_column.len = strlen(timeout_column.s);
  434. to_cseq_column.len = strlen(to_cseq_column.s);
  435. from_cseq_column.len = strlen(from_cseq_column.s);
  436. to_route_column.len = strlen(to_route_column.s);
  437. from_route_column.len = strlen(from_route_column.s);
  438. to_contact_column.len = strlen(to_contact_column.s);
  439. from_contact_column.len = strlen(from_contact_column.s);
  440. to_sock_column.len = strlen(to_sock_column.s);
  441. from_sock_column.len = strlen(from_sock_column.s);
  442. sflags_column.len = strlen(sflags_column.s);
  443. toroute_name_column.len = strlen(toroute_name_column.s);
  444. dialog_table_name.len = strlen(dialog_table_name.s);
  445. dialog_vars_table_name.len = strlen(dialog_vars_table_name.s);
  446. vars_h_id_column.len = strlen(vars_h_id_column.s);
  447. vars_h_entry_column.len = strlen(vars_h_entry_column.s);
  448. vars_key_column.len = strlen(vars_key_column.s);
  449. vars_value_column.len = strlen(vars_value_column.s);
  450. if(dlg_xavp_cfg.s!=NULL)
  451. dlg_xavp_cfg.len = strlen(dlg_xavp_cfg.s);
  452. /* param checkings */
  453. if (dlg_flag==-1) {
  454. LM_ERR("no dlg flag set!!\n");
  455. return -1;
  456. } else if (dlg_flag>MAX_FLAG) {
  457. LM_ERR("invalid dlg flag %d!!\n",dlg_flag);
  458. return -1;
  459. }
  460. if (rr_param==0 || rr_param[0]==0) {
  461. LM_ERR("empty rr_param!!\n");
  462. return -1;
  463. } else if (strlen(rr_param)>MAX_DLG_RR_PARAM_NAME) {
  464. LM_ERR("rr_param too long (max=%d)!!\n", MAX_DLG_RR_PARAM_NAME);
  465. return -1;
  466. }
  467. if (timeout_spec.s) {
  468. if ( pv_parse_spec(&timeout_spec, &timeout_avp)==0
  469. && (timeout_avp.type!=PVT_AVP)){
  470. LM_ERR("malformed or non AVP timeout "
  471. "AVP definition in '%.*s'\n", timeout_spec.len,timeout_spec.s);
  472. return -1;
  473. }
  474. }
  475. if (default_timeout<=0) {
  476. LM_ERR("0 default_timeout not accepted!!\n");
  477. return -1;
  478. }
  479. if (ruri_pvar_param.s==NULL || *ruri_pvar_param.s=='\0') {
  480. LM_ERR("invalid r-uri PV string\n");
  481. return -1;
  482. }
  483. ruri_pvar_param.len = strlen(ruri_pvar_param.s);
  484. if(pv_parse_format(&ruri_pvar_param, &ruri_param_model) < 0
  485. || ruri_param_model==NULL) {
  486. LM_ERR("malformed r-uri PV string: %s\n", ruri_pvar_param.s);
  487. return -1;
  488. }
  489. if (initial_cbs_inscript != 0 && initial_cbs_inscript != 1) {
  490. LM_ERR("invalid parameter for running initial callbacks in-script"
  491. " (must be either 0 or 1)\n");
  492. return -1;
  493. }
  494. /* update the len of the extra headers */
  495. if (dlg_extra_hdrs.s)
  496. dlg_extra_hdrs.len = strlen(dlg_extra_hdrs.s);
  497. if (seq_match_mode!=SEQ_MATCH_NO_ID &&
  498. seq_match_mode!=SEQ_MATCH_FALLBACK &&
  499. seq_match_mode!=SEQ_MATCH_STRICT_ID ) {
  500. LM_ERR("invalid value %d for seq_match_mode param!!\n",seq_match_mode);
  501. return -1;
  502. }
  503. if (detect_spirals != 0 && detect_spirals != 1) {
  504. LM_ERR("invalid value %d for detect_spirals param!!\n",detect_spirals);
  505. return -1;
  506. }
  507. /* if statistics are disabled, prevent their registration to core */
  508. if (dlg_enable_stats==0)
  509. exports.stats = 0;
  510. /* create profile hashes */
  511. if (add_profile_definitions( profiles_nv_s, 0)!=0 ) {
  512. LM_ERR("failed to add profiles without value\n");
  513. return -1;
  514. }
  515. if (add_profile_definitions( profiles_wv_s, 1)!=0 ) {
  516. LM_ERR("failed to add profiles with value\n");
  517. return -1;
  518. }
  519. /* load the TM API */
  520. if (load_tm_api(&d_tmb)!=0) {
  521. LM_ERR("can't load TM API\n");
  522. return -1;
  523. }
  524. /* load RR API also */
  525. if (load_rr_api(&d_rrb)!=0) {
  526. LM_ERR("can't load RR API\n");
  527. return -1;
  528. }
  529. /* register callbacks*/
  530. /* listen for all incoming requests */
  531. if ( d_tmb.register_tmcb( 0, 0, TMCB_REQUEST_IN, dlg_onreq, 0, 0 ) <=0 ) {
  532. LM_ERR("cannot register TMCB_REQUEST_IN callback\n");
  533. return -1;
  534. }
  535. /* listen for all routed requests */
  536. if ( d_rrb.register_rrcb( dlg_onroute, 0 ) <0 ) {
  537. LM_ERR("cannot register RR callback\n");
  538. return -1;
  539. }
  540. if (register_script_cb( profile_cleanup, POST_SCRIPT_CB|REQUEST_CB,0)<0) {
  541. LM_ERR("cannot register script callback");
  542. return -1;
  543. }
  544. if (register_script_cb(dlg_cfg_cb,
  545. PRE_SCRIPT_CB|REQUEST_CB,0)<0)
  546. {
  547. LM_ERR("cannot register pre-script ctx callback\n");
  548. return -1;
  549. }
  550. if (register_script_cb(dlg_cfg_cb,
  551. POST_SCRIPT_CB|REQUEST_CB,0)<0)
  552. {
  553. LM_ERR("cannot register post-script ctx callback\n");
  554. return -1;
  555. }
  556. if (register_script_cb( spiral_detect_reset, POST_SCRIPT_CB|REQUEST_CB,0)<0) {
  557. LM_ERR("cannot register req pre-script spiral detection reset callback\n");
  558. return -1;
  559. }
  560. if ( register_timer( dlg_timer_routine, 0, 1)<0 ) {
  561. LM_ERR("failed to register timer \n");
  562. return -1;
  563. }
  564. /* init handlers */
  565. init_dlg_handlers( rr_param, dlg_flag,
  566. timeout_spec.s?&timeout_avp:0, default_timeout, seq_match_mode);
  567. /* init timer */
  568. if (init_dlg_timer(dlg_ontimeout)!=0) {
  569. LM_ERR("cannot init timer list\n");
  570. return -1;
  571. }
  572. /* sanitize dlg_hash_zie */
  573. if (dlg_hash_size < 1){
  574. LM_WARN("hash_size is smaller "
  575. "then 1 -> rounding from %d to 1\n",
  576. dlg_hash_size);
  577. dlg_hash_size = 1;
  578. }
  579. /* initialized the hash table */
  580. for( n=0 ; n<(8*sizeof(n)) ; n++) {
  581. if (dlg_hash_size==(1<<n))
  582. break;
  583. if (n && dlg_hash_size<(1<<n)) {
  584. LM_WARN("hash_size is not a power "
  585. "of 2 as it should be -> rounding from %d to %d\n",
  586. dlg_hash_size, 1<<(n-1));
  587. dlg_hash_size = 1<<(n-1);
  588. }
  589. }
  590. if ( init_dlg_table(dlg_hash_size)<0 ) {
  591. LM_ERR("failed to create hash table\n");
  592. return -1;
  593. }
  594. /* if a database should be used to store the dialogs' information */
  595. dlg_db_mode = dlg_db_mode_param;
  596. if (dlg_db_mode==DB_MODE_NONE) {
  597. db_url.s = 0; db_url.len = 0;
  598. } else {
  599. if (dlg_db_mode!=DB_MODE_REALTIME &&
  600. dlg_db_mode!=DB_MODE_DELAYED && dlg_db_mode!=DB_MODE_SHUTDOWN ) {
  601. LM_ERR("unsupported db_mode %d\n", dlg_db_mode);
  602. return -1;
  603. }
  604. if ( !db_url.s || db_url.len==0 ) {
  605. LM_ERR("db_url not configured for db_mode %d\n", dlg_db_mode);
  606. return -1;
  607. }
  608. if (init_dlg_db(&db_url, dlg_hash_size, db_update_period,db_fetch_rows)!=0) {
  609. LM_ERR("failed to initialize the DB support\n");
  610. return -1;
  611. }
  612. run_load_callbacks();
  613. }
  614. destroy_dlg_callbacks( DLGCB_LOADED );
  615. if(dlg_ka_timer>0 && dlg_ka_interval>0)
  616. register_sync_timers(1);
  617. return 0;
  618. }
  619. static int child_init(int rank)
  620. {
  621. dlg_db_mode = dlg_db_mode_param;
  622. if(rank==PROC_MAIN && dlg_ka_timer>0 && dlg_ka_interval>0)
  623. {
  624. if(fork_sync_timer(PROC_TIMER, "Dialog KA Timer", 1 /*socks flag*/,
  625. dlg_ka_timer_exec, NULL, dlg_ka_timer /*sec*/)<0) {
  626. LM_ERR("failed to start ka timer routine as process\n");
  627. return -1; /* error */
  628. }
  629. }
  630. if (rank==1) {
  631. if_update_stat(dlg_enable_stats, active_dlgs, active_dlgs_cnt);
  632. if_update_stat(dlg_enable_stats, early_dlgs, early_dlgs_cnt);
  633. }
  634. if ( ((dlg_db_mode==DB_MODE_REALTIME || dlg_db_mode==DB_MODE_DELAYED) &&
  635. (rank>0 || rank==PROC_TIMER)) ||
  636. (dlg_db_mode==DB_MODE_SHUTDOWN && (rank==PROC_MAIN)) ) {
  637. if ( dlg_connect_db(&db_url) ) {
  638. LM_ERR("failed to connect to database (rank=%d)\n",rank);
  639. return -1;
  640. }
  641. }
  642. /* in DB_MODE_SHUTDOWN only PROC_MAIN will do a DB dump at the end, so
  643. * for the rest of the processes will be the same as DB_MODE_NONE */
  644. if (dlg_db_mode==DB_MODE_SHUTDOWN && rank!=PROC_MAIN)
  645. dlg_db_mode = DB_MODE_NONE;
  646. /* in DB_MODE_REALTIME and DB_MODE_DELAYED the PROC_MAIN have no DB handle */
  647. if ( (dlg_db_mode==DB_MODE_REALTIME || dlg_db_mode==DB_MODE_DELAYED) &&
  648. rank==PROC_MAIN)
  649. dlg_db_mode = DB_MODE_NONE;
  650. return 0;
  651. }
  652. static void mod_destroy(void)
  653. {
  654. if(dlg_db_mode == DB_MODE_DELAYED || dlg_db_mode == DB_MODE_SHUTDOWN) {
  655. dialog_update_db(0, 0);
  656. destroy_dlg_db();
  657. }
  658. dlg_bridge_destroy_hdrs();
  659. /* no DB interaction from now on */
  660. dlg_db_mode = DB_MODE_NONE;
  661. destroy_dlg_table();
  662. destroy_dlg_timer();
  663. destroy_dlg_callbacks( DLGCB_CREATED|DLGCB_LOADED );
  664. destroy_dlg_handlers();
  665. destroy_dlg_profiles();
  666. }
  667. static int w_set_dlg_profile(struct sip_msg *msg, char *profile, char *value)
  668. {
  669. pv_elem_t *pve;
  670. str val_s;
  671. pve = (pv_elem_t *)value;
  672. if (((struct dlg_profile_table*)profile)->has_value) {
  673. if ( pve==NULL || pv_printf_s(msg, pve, &val_s)!=0 ||
  674. val_s.len == 0 || val_s.s == NULL) {
  675. LM_WARN("cannot get string for value\n");
  676. return -1;
  677. }
  678. if ( set_dlg_profile( msg, &val_s,
  679. (struct dlg_profile_table*)profile) < 0 ) {
  680. LM_ERR("failed to set profile");
  681. return -1;
  682. }
  683. } else {
  684. if ( set_dlg_profile( msg, NULL,
  685. (struct dlg_profile_table*)profile) < 0 ) {
  686. LM_ERR("failed to set profile");
  687. return -1;
  688. }
  689. }
  690. return 1;
  691. }
  692. static int w_unset_dlg_profile(struct sip_msg *msg, char *profile, char *value)
  693. {
  694. pv_elem_t *pve;
  695. str val_s;
  696. pve = (pv_elem_t *)value;
  697. if (((struct dlg_profile_table*)profile)->has_value) {
  698. if ( pve==NULL || pv_printf_s(msg, pve, &val_s)!=0 ||
  699. val_s.len == 0 || val_s.s == NULL) {
  700. LM_WARN("cannot get string for value\n");
  701. return -1;
  702. }
  703. if ( unset_dlg_profile( msg, &val_s,
  704. (struct dlg_profile_table*)profile) < 0 ) {
  705. LM_ERR("failed to unset profile");
  706. return -1;
  707. }
  708. } else {
  709. if ( unset_dlg_profile( msg, NULL,
  710. (struct dlg_profile_table*)profile) < 0 ) {
  711. LM_ERR("failed to unset profile");
  712. return -1;
  713. }
  714. }
  715. return 1;
  716. }
  717. static int w_is_in_profile(struct sip_msg *msg, char *profile, char *value)
  718. {
  719. pv_elem_t *pve;
  720. str val_s;
  721. pve = (pv_elem_t *)value;
  722. if ( pve!=NULL && ((struct dlg_profile_table*)profile)->has_value) {
  723. if ( pv_printf_s(msg, pve, &val_s)!=0 ||
  724. val_s.len == 0 || val_s.s == NULL) {
  725. LM_WARN("cannot get string for value\n");
  726. return -1;
  727. }
  728. return is_dlg_in_profile( msg, (struct dlg_profile_table*)profile,
  729. &val_s);
  730. } else {
  731. return is_dlg_in_profile( msg, (struct dlg_profile_table*)profile,
  732. NULL);
  733. }
  734. }
  735. /**
  736. * get dynamic name profile size
  737. */
  738. static int w_get_profile_size3(struct sip_msg *msg, char *profile,
  739. char *value, char *result)
  740. {
  741. pv_elem_t *pve;
  742. str val_s;
  743. pv_spec_t *sp_dest;
  744. unsigned int size;
  745. pv_value_t val;
  746. if(result!=NULL)
  747. {
  748. pve = (pv_elem_t *)value;
  749. sp_dest = (pv_spec_t *)result;
  750. } else {
  751. pve = NULL;
  752. sp_dest = (pv_spec_t *)value;
  753. }
  754. if ( pve!=NULL && ((struct dlg_profile_table*)profile)->has_value) {
  755. if ( pv_printf_s(msg, pve, &val_s)!=0 ||
  756. val_s.len == 0 || val_s.s == NULL) {
  757. LM_WARN("cannot get string for value\n");
  758. return -1;
  759. }
  760. size = get_profile_size( (struct dlg_profile_table*)profile, &val_s );
  761. } else {
  762. size = get_profile_size( (struct dlg_profile_table*)profile, NULL );
  763. }
  764. memset(&val, 0, sizeof(pv_value_t));
  765. val.flags = PV_VAL_INT|PV_TYPE_INT;
  766. val.ri = (int)size;
  767. if(sp_dest->setf(msg, &sp_dest->pvp, (int)EQ_T, &val)<0)
  768. {
  769. LM_ERR("setting profile PV failed\n");
  770. return -1;
  771. }
  772. return 1;
  773. }
  774. /**
  775. * get static name profile size
  776. */
  777. static int w_get_profile_size2(struct sip_msg *msg, char *profile, char *result)
  778. {
  779. return w_get_profile_size3(msg, profile, result, NULL);
  780. }
  781. static int w_dlg_setflag(struct sip_msg *msg, char *flag, char *s2)
  782. {
  783. dlg_ctx_t *dctx;
  784. dlg_cell_t *d;
  785. int val;
  786. if(fixup_get_ivalue(msg, (gparam_p)flag, &val)!=0)
  787. {
  788. LM_ERR("no flag value\n");
  789. return -1;
  790. }
  791. if(val<0 || val>31)
  792. return -1;
  793. if ( (dctx=dlg_get_dlg_ctx())==NULL )
  794. return -1;
  795. dctx->flags |= 1<<val;
  796. d = dlg_get_by_iuid(&dctx->iuid);
  797. if(d!=NULL) {
  798. d->sflags |= 1<<val;
  799. dlg_release(d);
  800. }
  801. return 1;
  802. }
  803. static int w_dlg_resetflag(struct sip_msg *msg, char *flag, str *s2)
  804. {
  805. dlg_ctx_t *dctx;
  806. dlg_cell_t *d;
  807. int val;
  808. if(fixup_get_ivalue(msg, (gparam_p)flag, &val)!=0)
  809. {
  810. LM_ERR("no flag value\n");
  811. return -1;
  812. }
  813. if(val<0 || val>31)
  814. return -1;
  815. if ( (dctx=dlg_get_dlg_ctx())==NULL )
  816. return -1;
  817. dctx->flags &= ~(1<<val);
  818. d = dlg_get_by_iuid(&dctx->iuid);
  819. if(d!=NULL) {
  820. d->sflags &= ~(1<<val);
  821. dlg_release(d);
  822. }
  823. return 1;
  824. }
  825. static int w_dlg_isflagset(struct sip_msg *msg, char *flag, str *s2)
  826. {
  827. dlg_ctx_t *dctx;
  828. dlg_cell_t *d;
  829. int val;
  830. int ret;
  831. if(fixup_get_ivalue(msg, (gparam_p)flag, &val)!=0)
  832. {
  833. LM_ERR("no flag value\n");
  834. return -1;
  835. }
  836. if(val<0 || val>31)
  837. return -1;
  838. if ( (dctx=dlg_get_dlg_ctx())==NULL )
  839. return -1;
  840. d = dlg_get_by_iuid(&dctx->iuid);
  841. if(d!=NULL) {
  842. ret = (d->sflags&(1<<val))?1:-1;
  843. dlg_release(d);
  844. return ret;
  845. }
  846. return (dctx->flags&(1<<val))?1:-1;
  847. }
  848. /**
  849. *
  850. */
  851. static int w_dlg_manage(struct sip_msg *msg, char *s1, char *s2)
  852. {
  853. return dlg_manage(msg);
  854. }
  855. static int w_dlg_bye(struct sip_msg *msg, char *side, char *s2)
  856. {
  857. dlg_cell_t *dlg = NULL;
  858. int n;
  859. dlg = dlg_get_ctx_dialog();
  860. if(dlg==NULL)
  861. return -1;
  862. n = (int)(long)side;
  863. if(n==1)
  864. {
  865. if(dlg_bye(dlg, NULL, DLG_CALLER_LEG)!=0)
  866. goto error;
  867. goto done;
  868. } else if(n==2) {
  869. if(dlg_bye(dlg, NULL, DLG_CALLEE_LEG)!=0)
  870. goto error;
  871. goto done;
  872. } else {
  873. if(dlg_bye_all(dlg, NULL)!=0)
  874. goto error;
  875. goto done;
  876. }
  877. done:
  878. dlg_release(dlg);
  879. return 1;
  880. error:
  881. dlg_release(dlg);
  882. return -1;
  883. }
  884. static int w_dlg_refer(struct sip_msg *msg, char *side, char *to)
  885. {
  886. dlg_cell_t *dlg;
  887. int n;
  888. str st = {0,0};
  889. dlg = dlg_get_ctx_dialog();
  890. if(dlg==NULL)
  891. return -1;
  892. n = (int)(long)side;
  893. if(fixup_get_svalue(msg, (gparam_p)to, &st)!=0)
  894. {
  895. LM_ERR("unable to get To\n");
  896. goto error;
  897. }
  898. if(st.s==NULL || st.len == 0)
  899. {
  900. LM_ERR("invalid To parameter\n");
  901. goto error;
  902. }
  903. if(n==1)
  904. {
  905. if(dlg_transfer(dlg, &st, DLG_CALLER_LEG)!=0)
  906. goto error;
  907. } else {
  908. if(dlg_transfer(dlg, &st, DLG_CALLEE_LEG)!=0)
  909. goto error;
  910. }
  911. dlg_release(dlg);
  912. return 1;
  913. error:
  914. dlg_release(dlg);
  915. return -1;
  916. }
  917. static int w_dlg_bridge(struct sip_msg *msg, char *from, char *to, char *op)
  918. {
  919. str sf = {0,0};
  920. str st = {0,0};
  921. str so = {0,0};
  922. if(from==0 || to==0 || op==0)
  923. {
  924. LM_ERR("invalid parameters\n");
  925. return -1;
  926. }
  927. if(fixup_get_svalue(msg, (gparam_p)from, &sf)!=0)
  928. {
  929. LM_ERR("unable to get From\n");
  930. return -1;
  931. }
  932. if(sf.s==NULL || sf.len == 0)
  933. {
  934. LM_ERR("invalid From parameter\n");
  935. return -1;
  936. }
  937. if(fixup_get_svalue(msg, (gparam_p)to, &st)!=0)
  938. {
  939. LM_ERR("unable to get To\n");
  940. return -1;
  941. }
  942. if(st.s==NULL || st.len == 0)
  943. {
  944. LM_ERR("invalid To parameter\n");
  945. return -1;
  946. }
  947. if(fixup_get_svalue(msg, (gparam_p)op, &so)!=0)
  948. {
  949. LM_ERR("unable to get OP\n");
  950. return -1;
  951. }
  952. if(dlg_bridge(&sf, &st, &so)!=0)
  953. return -1;
  954. return 1;
  955. }
  956. /**
  957. *
  958. */
  959. static int w_dlg_set_timeout(struct sip_msg *msg, char *pto, char *phe, char *phi)
  960. {
  961. int to = 0;
  962. unsigned int he = 0;
  963. unsigned int hi = 0;
  964. dlg_cell_t *dlg = NULL;
  965. if(fixup_get_ivalue(msg, (gparam_p)pto, &to)!=0)
  966. {
  967. LM_ERR("no timeout value\n");
  968. return -1;
  969. }
  970. if(phe!=NULL)
  971. {
  972. if(fixup_get_ivalue(msg, (gparam_p)phe, (int*)&he)!=0)
  973. {
  974. LM_ERR("no hash entry value value\n");
  975. return -1;
  976. }
  977. if(fixup_get_ivalue(msg, (gparam_p)phi, (int*)&hi)!=0)
  978. {
  979. LM_ERR("no hash id value value\n");
  980. return -1;
  981. }
  982. dlg = dlg_lookup(he, hi);
  983. } else {
  984. dlg = dlg_get_msg_dialog(msg);
  985. }
  986. if(dlg==NULL)
  987. {
  988. LM_DBG("no dialog found\n");
  989. return -1;
  990. }
  991. if(update_dlg_timeout(dlg, to) != 0)
  992. return -1;
  993. return 1;
  994. }
  995. static int w_dlg_set_property(struct sip_msg *msg, char *prop, char *s2)
  996. {
  997. dlg_ctx_t *dctx;
  998. dlg_cell_t *d;
  999. str val;
  1000. if(fixup_get_svalue(msg, (gparam_t*)prop, &val)!=0)
  1001. {
  1002. LM_ERR("no property value\n");
  1003. return -1;
  1004. }
  1005. if(val.len<=0)
  1006. {
  1007. LM_ERR("empty property value\n");
  1008. return -1;
  1009. }
  1010. if ( (dctx=dlg_get_dlg_ctx())==NULL )
  1011. return -1;
  1012. if(val.len==6 && strncmp(val.s, "ka-src", 6)==0) {
  1013. dctx->iflags |= DLG_IFLAG_KA_SRC;
  1014. d = dlg_get_by_iuid(&dctx->iuid);
  1015. if(d!=NULL) {
  1016. d->iflags |= DLG_IFLAG_KA_SRC;
  1017. dlg_release(d);
  1018. }
  1019. } else if(val.len==6 && strncmp(val.s, "ka-dst", 6)==0) {
  1020. dctx->iflags |= DLG_IFLAG_KA_DST;
  1021. d = dlg_get_by_iuid(&dctx->iuid);
  1022. if(d!=NULL) {
  1023. d->iflags |= DLG_IFLAG_KA_DST;
  1024. dlg_release(d);
  1025. }
  1026. } else {
  1027. LM_ERR("unknown property value [%.*s]\n", val.len, val.s);
  1028. return -1;
  1029. }
  1030. return 1;
  1031. }
  1032. static int w_dlg_set_timeout_by_profile3(struct sip_msg *msg, char *profile,
  1033. char *value, char *timeout_str)
  1034. {
  1035. pv_elem_t *pve = NULL;
  1036. str val_s;
  1037. pve = (pv_elem_t *) value;
  1038. if(pve != NULL && ((struct dlg_profile_table *) profile)->has_value) {
  1039. if(pv_printf_s(msg,pve, &val_s) != 0 ||
  1040. !val_s.s || val_s.len == 0) {
  1041. LM_WARN("cannot get string for value\n");
  1042. return -1;
  1043. }
  1044. }
  1045. if(dlg_set_timeout_by_profile((struct dlg_profile_table *) profile,
  1046. &val_s, atoi(timeout_str)) != 0)
  1047. return -1;
  1048. return 1;
  1049. }
  1050. static int w_dlg_set_timeout_by_profile2(struct sip_msg *msg,
  1051. char *profile, char *timeout_str)
  1052. {
  1053. return w_dlg_set_timeout_by_profile3(msg, profile, NULL, timeout_str);
  1054. }
  1055. void dlg_ka_timer_exec(unsigned int ticks, void* param)
  1056. {
  1057. dlg_ka_run(ticks);
  1058. }
  1059. static int fixup_dlg_bye(void** param, int param_no)
  1060. {
  1061. char *val;
  1062. int n = 0;
  1063. if (param_no==1) {
  1064. val = (char*)*param;
  1065. if (strcasecmp(val,"all")==0) {
  1066. n = 0;
  1067. } else if (strcasecmp(val,"caller")==0) {
  1068. n = 1;
  1069. } else if (strcasecmp(val,"callee")==0) {
  1070. n = 2;
  1071. } else {
  1072. LM_ERR("invalid param \"%s\"\n", val);
  1073. return E_CFG;
  1074. }
  1075. pkg_free(*param);
  1076. *param=(void*)(long)n;
  1077. } else {
  1078. LM_ERR("called with parameter != 1\n");
  1079. return E_BUG;
  1080. }
  1081. return 0;
  1082. }
  1083. static int fixup_dlg_refer(void** param, int param_no)
  1084. {
  1085. char *val;
  1086. int n = 0;
  1087. if (param_no==1) {
  1088. val = (char*)*param;
  1089. if (strcasecmp(val,"caller")==0) {
  1090. n = 1;
  1091. } else if (strcasecmp(val,"callee")==0) {
  1092. n = 2;
  1093. } else {
  1094. LM_ERR("invalid param \"%s\"\n", val);
  1095. return E_CFG;
  1096. }
  1097. pkg_free(*param);
  1098. *param=(void*)(long)n;
  1099. } else if (param_no==2) {
  1100. return fixup_spve_null(param, 1);
  1101. } else {
  1102. LM_ERR("called with parameter idx %d\n", param_no);
  1103. return E_BUG;
  1104. }
  1105. return 0;
  1106. }
  1107. static int fixup_dlg_bridge(void** param, int param_no)
  1108. {
  1109. if (param_no>=1 && param_no<=3) {
  1110. return fixup_spve_null(param, 1);
  1111. } else {
  1112. LM_ERR("called with parameter idx %d\n", param_no);
  1113. return E_BUG;
  1114. }
  1115. return 0;
  1116. }
  1117. static int w_dlg_get(struct sip_msg *msg, char *ci, char *ft, char *tt)
  1118. {
  1119. dlg_cell_t *dlg = NULL;
  1120. str sc = {0,0};
  1121. str sf = {0,0};
  1122. str st = {0,0};
  1123. unsigned int dir = 0;
  1124. if(ci==0 || ft==0 || tt==0)
  1125. {
  1126. LM_ERR("invalid parameters\n");
  1127. return -1;
  1128. }
  1129. if(fixup_get_svalue(msg, (gparam_p)ci, &sc)!=0)
  1130. {
  1131. LM_ERR("unable to get Call-ID\n");
  1132. return -1;
  1133. }
  1134. if(sc.s==NULL || sc.len == 0)
  1135. {
  1136. LM_ERR("invalid Call-ID parameter\n");
  1137. return -1;
  1138. }
  1139. if(fixup_get_svalue(msg, (gparam_p)ft, &sf)!=0)
  1140. {
  1141. LM_ERR("unable to get From tag\n");
  1142. return -1;
  1143. }
  1144. if(sf.s==NULL || sf.len == 0)
  1145. {
  1146. LM_ERR("invalid From tag parameter\n");
  1147. return -1;
  1148. }
  1149. if(fixup_get_svalue(msg, (gparam_p)tt, &st)!=0)
  1150. {
  1151. LM_ERR("unable to get To Tag\n");
  1152. return -1;
  1153. }
  1154. if(st.s==NULL || st.len == 0)
  1155. {
  1156. LM_ERR("invalid To tag parameter\n");
  1157. return -1;
  1158. }
  1159. dlg = get_dlg(&sc, &sf, &st, &dir);
  1160. if(dlg==NULL)
  1161. return -1;
  1162. /* set shorcut to dialog internal unique id */
  1163. _dlg_ctx.iuid.h_entry = dlg->h_entry;
  1164. _dlg_ctx.iuid.h_id = dlg->h_id;
  1165. _dlg_ctx.dir = dir;
  1166. dlg_release(dlg);
  1167. return 1;
  1168. }
  1169. struct mi_root * mi_dlg_bridge(struct mi_root *cmd_tree, void *param)
  1170. {
  1171. str from = {0,0};
  1172. str to = {0,0};
  1173. str op = {0,0};
  1174. struct mi_node* node;
  1175. node = cmd_tree->node.kids;
  1176. if(node == NULL)
  1177. return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
  1178. from = node->value;
  1179. if(from.len<=0 || from.s==NULL)
  1180. {
  1181. LM_ERR("bad From value\n");
  1182. return init_mi_tree( 500, "Bad From value", 14);
  1183. }
  1184. node = node->next;
  1185. if(node == NULL)
  1186. return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
  1187. to = node->value;
  1188. if(to.len<=0 || to.s == NULL)
  1189. {
  1190. return init_mi_tree(500, "Bad To value", 12);
  1191. }
  1192. node= node->next;
  1193. if(node != NULL)
  1194. {
  1195. op = node->value;
  1196. if(op.len<=0 || op.s==NULL)
  1197. {
  1198. return init_mi_tree(500, "Bad OP value", 12);
  1199. }
  1200. }
  1201. if(dlg_bridge(&from, &to, &op)!=0)
  1202. return init_mi_tree(500, MI_INTERNAL_ERR_S, MI_INTERNAL_ERR_LEN);
  1203. return init_mi_tree(200, MI_OK_S, MI_OK_LEN);
  1204. }
  1205. /**************************** RPC functions ******************************/
  1206. /*!
  1207. * \brief Helper method that outputs a dialog via the RPC interface
  1208. * \see rpc_print_dlg
  1209. * \param rpc RPC node that should be filled
  1210. * \param c RPC void pointer
  1211. * \param dlg printed dialog
  1212. * \param with_context if 1 then the dialog context will be also printed
  1213. * \return 0 on success, -1 on failure
  1214. */
  1215. static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c, dlg_cell_t *dlg,
  1216. int with_context)
  1217. {
  1218. rpc_cb_ctx_t rpc_cb;
  1219. rpc->printf(c, "hash:%u:%u state:%u ref_count:%u timestart:%u timeout:%u",
  1220. dlg->h_entry, dlg->h_id, dlg->state, dlg->ref, dlg->start_ts, dlg->tl.timeout);
  1221. rpc->printf(c, "\tcallid:%.*s from_tag:%.*s to_tag:%.*s",
  1222. dlg->callid.len, dlg->callid.s,
  1223. dlg->tag[DLG_CALLER_LEG].len, dlg->tag[DLG_CALLER_LEG].s,
  1224. dlg->tag[DLG_CALLEE_LEG].len, dlg->tag[DLG_CALLEE_LEG].s);
  1225. rpc->printf(c, "\tfrom_uri:%.*s to_uri:%.*s",
  1226. dlg->from_uri.len, dlg->from_uri.s, dlg->to_uri.len, dlg->to_uri.s);
  1227. rpc->printf(c, "\tcaller_contact:%.*s caller_cseq:%.*s",
  1228. dlg->contact[DLG_CALLER_LEG].len, dlg->contact[DLG_CALLER_LEG].s,
  1229. dlg->cseq[DLG_CALLER_LEG].len, dlg->cseq[DLG_CALLER_LEG].s);
  1230. rpc->printf(c, "\tcaller_route_set: %.*s",
  1231. dlg->route_set[DLG_CALLER_LEG].len, dlg->route_set[DLG_CALLER_LEG].s);
  1232. rpc->printf(c, "\tcallee_contact:%.*s callee_cseq:%.*s",
  1233. dlg->contact[DLG_CALLEE_LEG].len, dlg->contact[DLG_CALLEE_LEG].s,
  1234. dlg->cseq[DLG_CALLEE_LEG].len, dlg->cseq[DLG_CALLEE_LEG].s);
  1235. rpc->printf(c, "\tcallee_route_set: %.*s",
  1236. dlg->route_set[DLG_CALLEE_LEG].len, dlg->route_set[DLG_CALLEE_LEG].s);
  1237. if (dlg->bind_addr[DLG_CALLEE_LEG]) {
  1238. rpc->printf(c, "\tcaller_bind_addr:%.*s callee_bind_addr:%.*s",
  1239. dlg->bind_addr[DLG_CALLER_LEG]->sock_str.len, dlg->bind_addr[DLG_CALLER_LEG]->sock_str.s,
  1240. dlg->bind_addr[DLG_CALLEE_LEG]->sock_str.len, dlg->bind_addr[DLG_CALLEE_LEG]->sock_str.s);
  1241. } else {
  1242. rpc->printf(c, "\tcaller_bind_addr:%.*s callee_bind_addr:",
  1243. dlg->bind_addr[DLG_CALLER_LEG]->sock_str.len, dlg->bind_addr[DLG_CALLER_LEG]->sock_str.s);
  1244. }
  1245. if (with_context) {
  1246. rpc_cb.rpc = rpc;
  1247. rpc_cb.c = c;
  1248. run_dlg_callbacks( DLGCB_RPC_CONTEXT, dlg, NULL, NULL, DLG_DIR_NONE, (void *)&rpc_cb);
  1249. }
  1250. }
  1251. /*!
  1252. * \brief Helper function that outputs all dialogs via the RPC interface
  1253. * \see rpc_print_dlgs
  1254. * \param rpc RPC node that should be filled
  1255. * \param c RPC void pointer
  1256. * \param with_context if 1 then the dialog context will be also printed
  1257. */
  1258. static void internal_rpc_print_dlgs(rpc_t *rpc, void *c, int with_context)
  1259. {
  1260. dlg_cell_t *dlg;
  1261. unsigned int i;
  1262. for( i=0 ; i<d_table->size ; i++ ) {
  1263. dlg_lock( d_table, &(d_table->entries[i]) );
  1264. for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) {
  1265. internal_rpc_print_dlg(rpc, c, dlg, with_context);
  1266. }
  1267. dlg_unlock( d_table, &(d_table->entries[i]) );
  1268. }
  1269. }
  1270. /*!
  1271. * \brief Helper function that outputs a dialog via the RPC interface
  1272. * \see rpc_print_dlgs
  1273. * \param rpc RPC node that should be filled
  1274. * \param c RPC void pointer
  1275. * \param with_context if 1 then the dialog context will be also printed
  1276. */
  1277. static void internal_rpc_print_single_dlg(rpc_t *rpc, void *c, int with_context) {
  1278. str callid, from_tag;
  1279. dlg_entry_t *d_entry;
  1280. dlg_cell_t *dlg;
  1281. unsigned int h_entry;
  1282. if (rpc->scan(c, ".S.S", &callid, &from_tag) < 2) return;
  1283. h_entry = core_hash( &callid, 0, d_table->size);
  1284. d_entry = &(d_table->entries[h_entry]);
  1285. dlg_lock( d_table, d_entry);
  1286. for( dlg = d_entry->first ; dlg ; dlg = dlg->next ) {
  1287. if (match_downstream_dialog( dlg, &callid, &from_tag)==1) {
  1288. internal_rpc_print_dlg(rpc, c, dlg, with_context);
  1289. }
  1290. }
  1291. dlg_unlock( d_table, d_entry);
  1292. }
  1293. /*!
  1294. * \brief Helper function that outputs the size of a given profile via the RPC interface
  1295. * \see rpc_profile_get_size
  1296. * \see rpc_profile_w_value_get_size
  1297. * \param rpc RPC node that should be filled
  1298. * \param c RPC void pointer
  1299. * \param profile_name the given profile
  1300. * \param value the given profile value
  1301. */
  1302. static void internal_rpc_profile_get_size(rpc_t *rpc, void *c, str *profile_name,
  1303. str *value) {
  1304. unsigned int size;
  1305. dlg_profile_table_t *profile;
  1306. profile = search_dlg_profile( profile_name );
  1307. if (!profile) {
  1308. rpc->printf(c, "Non existing profile:%.*s",
  1309. profile_name->len, profile_name->s);
  1310. return;
  1311. }
  1312. size = get_profile_size(profile, value);
  1313. if (value) {
  1314. rpc->printf(c, "Profile:%.*s => profile:%.*s value:%.*s count:%u",
  1315. profile_name->len, profile_name->s,
  1316. profile->name.len, profile->name.s,
  1317. value->len, value->s, size);
  1318. return;
  1319. } else {
  1320. rpc->printf(c, "Profile:%.*s => profile:%.*s value: count:%u",
  1321. profile_name->len, profile_name->s,
  1322. profile->name.len, profile->name.s, size);
  1323. return;
  1324. }
  1325. return;
  1326. }
  1327. /*!
  1328. * \brief Helper function that outputs the dialogs belonging to a given profile via the RPC interface
  1329. * \see rpc_profile_print_dlgs
  1330. * \see rpc_profile_w_value_print_dlgs
  1331. * \param rpc RPC node that should be filled
  1332. * \param c RPC void pointer
  1333. * \param profile_name the given profile
  1334. * \param value the given profile value
  1335. * \param with_context if 1 then the dialog context will be also printed
  1336. */
  1337. static void internal_rpc_profile_print_dlgs(rpc_t *rpc, void *c, str *profile_name,
  1338. str *value) {
  1339. dlg_profile_table_t *profile;
  1340. dlg_profile_hash_t *ph;
  1341. unsigned int i;
  1342. profile = search_dlg_profile( profile_name );
  1343. if (!profile) {
  1344. rpc->printf(c, "Non existing profile:%.*s",
  1345. profile_name->len, profile_name->s);
  1346. return;
  1347. }
  1348. /* go through the hash and print the dialogs */
  1349. if (profile->has_value==0 || value==NULL) {
  1350. /* no value */
  1351. lock_get( &profile->lock );
  1352. for ( i=0 ; i< profile->size ; i++ ) {
  1353. ph = profile->entries[i].first;
  1354. if(ph) {
  1355. do {
  1356. /* print dialog */
  1357. internal_rpc_print_dlg(rpc, c, ph->dlg, 0);
  1358. /* next */
  1359. ph=ph->next;
  1360. }while(ph!=profile->entries[i].first);
  1361. }
  1362. lock_release(&profile->lock);
  1363. }
  1364. } else {
  1365. /* check for value also */
  1366. lock_get( &profile->lock );
  1367. for ( i=0 ; i< profile->size ; i++ ) {
  1368. ph = profile->entries[i].first;
  1369. if(ph) {
  1370. do {
  1371. if ( value->len==ph->value.len &&
  1372. memcmp(value->s,ph->value.s,value->len)==0 ) {
  1373. /* print dialog */
  1374. internal_rpc_print_dlg(rpc, c, ph->dlg, 0);
  1375. }
  1376. /* next */
  1377. ph=ph->next;
  1378. }while(ph!=profile->entries[i].first);
  1379. }
  1380. lock_release(&profile->lock);
  1381. }
  1382. }
  1383. }
  1384. /*
  1385. * Wrapper around is_known_dlg().
  1386. */
  1387. static int w_is_known_dlg(sip_msg_t *msg) {
  1388. return is_known_dlg(msg);
  1389. }
  1390. static const char *rpc_print_dlgs_doc[2] = {
  1391. "Print all dialogs", 0
  1392. };
  1393. static const char *rpc_print_dlgs_ctx_doc[2] = {
  1394. "Print all dialogs with associated context", 0
  1395. };
  1396. static const char *rpc_print_dlg_doc[2] = {
  1397. "Print dialog based on callid and fromtag", 0
  1398. };
  1399. static const char *rpc_print_dlg_ctx_doc[2] = {
  1400. "Print dialog with associated context based on callid and fromtag", 0
  1401. };
  1402. static const char *rpc_end_dlg_entry_id_doc[2] = {
  1403. "End a given dialog based on [h_entry] [h_id]", 0
  1404. };
  1405. static const char *rpc_profile_get_size_doc[2] = {
  1406. "Returns the number of dialogs belonging to a profile", 0
  1407. };
  1408. static const char *rpc_profile_print_dlgs_doc[2] = {
  1409. "Lists all the dialogs belonging to a profile", 0
  1410. };
  1411. static const char *rpc_dlg_bridge_doc[2] = {
  1412. "Bridge two SIP addresses in a call using INVITE(hold)-REFER-BYE mechanism:\
  1413. to, from, [outbound SIP proxy]", 0
  1414. };
  1415. static void rpc_print_dlgs(rpc_t *rpc, void *c) {
  1416. internal_rpc_print_dlgs(rpc, c, 0);
  1417. }
  1418. static void rpc_print_dlgs_ctx(rpc_t *rpc, void *c) {
  1419. internal_rpc_print_dlgs(rpc, c, 1);
  1420. }
  1421. static void rpc_print_dlg(rpc_t *rpc, void *c) {
  1422. internal_rpc_print_single_dlg(rpc, c, 0);
  1423. }
  1424. static void rpc_print_dlg_ctx(rpc_t *rpc, void *c) {
  1425. internal_rpc_print_single_dlg(rpc, c, 1);
  1426. }
  1427. static void rpc_end_dlg_entry_id(rpc_t *rpc, void *c) {
  1428. unsigned int h_entry, h_id;
  1429. dlg_cell_t * dlg = NULL;
  1430. str rpc_extra_hdrs = {NULL,0};
  1431. int n;
  1432. n = rpc->scan(c, "dd", &h_entry, &h_id);
  1433. if (n < 2) {
  1434. LM_ERR("unable to read the parameters (%d)\n", n);
  1435. rpc->fault(c, 500, "Invalid parameters");
  1436. return;
  1437. }
  1438. if(rpc->scan(c, "*S", &rpc_extra_hdrs)<1)
  1439. {
  1440. rpc_extra_hdrs.s = NULL;
  1441. rpc_extra_hdrs.len = 0;
  1442. }
  1443. dlg = dlg_lookup(h_entry, h_id);
  1444. if(dlg==NULL) {
  1445. rpc->fault(c, 404, "Dialog not found");
  1446. return;
  1447. }
  1448. dlg_bye_all(dlg, (rpc_extra_hdrs.len>0)?&rpc_extra_hdrs:NULL);
  1449. dlg_release(dlg);
  1450. }
  1451. static void rpc_profile_get_size(rpc_t *rpc, void *c) {
  1452. str profile_name = {NULL,0};
  1453. str value = {NULL,0};
  1454. if (rpc->scan(c, ".S", &profile_name) < 1) return;
  1455. if (rpc->scan(c, "*.S", &value) > 0) {
  1456. internal_rpc_profile_get_size(rpc, c, &profile_name, &value);
  1457. } else {
  1458. internal_rpc_profile_get_size(rpc, c, &profile_name, NULL);
  1459. }
  1460. return;
  1461. }
  1462. static void rpc_profile_print_dlgs(rpc_t *rpc, void *c) {
  1463. str profile_name = {NULL,0};
  1464. str value = {NULL,0};
  1465. if (rpc->scan(c, ".S", &profile_name) < 1) return;
  1466. if (rpc->scan(c, "*.S", &value) > 0) {
  1467. internal_rpc_profile_print_dlgs(rpc, c, &profile_name, &value);
  1468. } else {
  1469. internal_rpc_profile_print_dlgs(rpc, c, &profile_name, NULL);
  1470. }
  1471. return;
  1472. }
  1473. static void rpc_dlg_bridge(rpc_t *rpc, void *c) {
  1474. str from = {NULL,0};
  1475. str to = {NULL,0};
  1476. str op = {NULL,0};
  1477. int n;
  1478. n = rpc->scan(c, "SS", &from, &to);
  1479. if (n< 2) {
  1480. LM_ERR("unable to read the parameters (%d)\n", n);
  1481. rpc->fault(c, 500, "Invalid parameters");
  1482. return;
  1483. }
  1484. if(rpc->scan(c, "*S", &op)<1) {
  1485. op.s = NULL;
  1486. op.len = 0;
  1487. }
  1488. dlg_bridge(&from, &to, &op);
  1489. }
  1490. static rpc_export_t rpc_methods[] = {
  1491. {"dlg.list", rpc_print_dlgs, rpc_print_dlgs_doc, 0},
  1492. {"dlg.list_ctx", rpc_print_dlgs_ctx, rpc_print_dlgs_ctx_doc, 0},
  1493. {"dlg.dlg_list", rpc_print_dlg, rpc_print_dlg_doc, 0},
  1494. {"dlg.dlg_list_ctx", rpc_print_dlg_ctx, rpc_print_dlg_ctx_doc, 0},
  1495. {"dlg.end_dlg", rpc_end_dlg_entry_id, rpc_end_dlg_entry_id_doc, 0},
  1496. {"dlg.profile_get_size", rpc_profile_get_size, rpc_profile_get_size_doc, 0},
  1497. {"dlg.profile_list", rpc_profile_print_dlgs, rpc_profile_print_dlgs_doc, 0},
  1498. {"dlg.bridge_dlg", rpc_dlg_bridge, rpc_dlg_bridge_doc, 0},
  1499. {0, 0, 0, 0}
  1500. };