Module: kamailio Branch: master Commit: 4503914030dd59e28df8c14bab070a0433d10482 URL: https://github.com/kamailio/kamailio/commit/4503914030dd59e28df8c14bab070a04...
Author: jaybeepee jason.penton@gmail.com Committer: jaybeepee jason.penton@gmail.com Date: 2016-05-18T15:17:15+02:00
modules/ims_dialog: support for dlg_vars in ims_dialog. taken from orig. dialog module
---
Modified: modules/ims_dialog/dlg_ng_stats.h Modified: modules/ims_dialog/ims_dialog.c
---
Diff: https://github.com/kamailio/kamailio/commit/4503914030dd59e28df8c14bab070a04... Patch: https://github.com/kamailio/kamailio/commit/4503914030dd59e28df8c14bab070a04...
---
diff --git a/modules/ims_dialog/dlg_ng_stats.h b/modules/ims_dialog/dlg_ng_stats.h index b9ed67f..978a223 100644 --- a/modules/ims_dialog/dlg_ng_stats.h +++ b/modules/ims_dialog/dlg_ng_stats.h @@ -11,6 +11,8 @@ struct dialog_ng_counters_h {
};
+struct dialog_ng_counters_h dialog_ng_cnts_h; + int dialog_ng_stats_init(); void dialog_ng_stats_destroy();
diff --git a/modules/ims_dialog/ims_dialog.c b/modules/ims_dialog/ims_dialog.c index 3562235..3074427 100644 --- a/modules/ims_dialog/ims_dialog.c +++ b/modules/ims_dialog/ims_dialog.c @@ -87,6 +87,8 @@ static int w_dlg_setflag(struct sip_msg *msg, char *flag, char *s2); static int w_dlg_terminate(struct sip_msg*, char*, char*); static int w_dlg_get(struct sip_msg*, char*, char*, char*); static int w_is_known_dlg(struct sip_msg *); +static int pv_get_dlg_count( struct sip_msg *msg, pv_param_t *param, + pv_value_t *res);
static cmd_export_t cmds[] = { {"set_dlg_profile", (cmd_function) w_set_dlg_profile, 1, fixup_profile, @@ -155,6 +157,22 @@ static mi_export_t mi_cmds[] = {
static rpc_export_t rpc_methods[];
+static pv_export_t mod_items[] = { + { {"DLG_count", sizeof("DLG_count")-1}, PVT_OTHER, pv_get_dlg_count, 0, + 0, 0, 0, 0 }, + { {"DLG_lifetime",sizeof("DLG_lifetime")-1}, PVT_OTHER, pv_get_dlg_lifetime, 0, + 0, 0, 0, 0 }, + { {"DLG_status", sizeof("DLG_status")-1}, PVT_OTHER, pv_get_dlg_status, 0, + 0, 0, 0, 0 }, + { {"dlg_ctx", sizeof("dlg_ctx")-1}, PVT_OTHER, pv_get_dlg_ctx, + pv_set_dlg_ctx, pv_parse_dlg_ctx_name, 0, 0, 0 }, + { {"dlg", sizeof("dlg")-1}, PVT_OTHER, pv_get_dlg, + 0, pv_parse_dlg_name, 0, 0, 0 }, + { {"dlg_var", sizeof("dlg_var")-1}, PVT_OTHER, pv_get_dlg_variable, + pv_set_dlg_variable, pv_parse_dialog_var_name, 0, 0, 0}, + { {0, 0}, 0, 0, 0, 0, 0, 0, 0 } +}; + struct module_exports exports = { "ims_dialog", /* module's name */ DEFAULT_DLFLAGS, /* dlopen flags */ @@ -162,7 +180,7 @@ struct module_exports exports = { mod_params, /* param exports */ 0, /* exported statistics */ mi_cmds, /* exported MI functions */ - 0, /* exported pseudo-variables */ + mod_items, /* exported pseudo-variables */ 0, /* extra processes */ mod_init, /* module initialization function */ 0, /* reply processing function */ @@ -346,6 +364,30 @@ int load_dlg(struct dlg_binds *dlgb) { return 1; }
+static int pv_get_dlg_count(struct sip_msg *msg, pv_param_t *param, + pv_value_t *res) +{ + int n; + int l; + char *ch; + + if(msg==NULL || res==NULL) + return -1; + + n = counter_get_val(dialog_ng_cnts_h.active); + l = 0; + ch = int2str( n, &l); + + res->rs.s = ch; + res->rs.len = l; + + res->ri = n; + res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT; + + return 0; +} + + static int mod_init(void) { unsigned int n;