Module: sip-router
Branch: master
Commit: 6c7ae21a222fc56f623e7e49bcafc94167dab9d4
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6c7ae21…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Apr 10 12:20:58 2012 +0200
kex: new pv $sruid to return unique strings
- uses lib/srutils/sruid.{c,h} with prefix 'srid'
---
modules_k/kex/Makefile | 1 +
modules_k/kex/kex_mod.c | 31 ++++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/modules_k/kex/Makefile b/modules_k/kex/Makefile
index b06b35e..9b89954 100644
--- a/modules_k/kex/Makefile
+++ b/modules_k/kex/Makefile
@@ -15,4 +15,5 @@ DEFS+=-DOPENSER_MOD_INTERFACE
SERLIBPATH=../../lib
SER_LIBS+=$(SERLIBPATH)/kmi/kmi
SER_LIBS+=$(SERLIBPATH)/kcore/kcore
+SER_LIBS+=$(SERLIBPATH)/srutils/srutils
include ../../Makefile.modules
diff --git a/modules_k/kex/kex_mod.c b/modules_k/kex/kex_mod.c
index 60f859a..82165f5 100644
--- a/modules_k/kex/kex_mod.c
+++ b/modules_k/kex/kex_mod.c
@@ -33,6 +33,7 @@
#include "../../dset.h"
#include "../../mod_fix.h"
#include "../../parser/parse_uri.h"
+#include "../../lib/srutils/sruid.h"
#include "flags.h"
#include "km_core.h"
@@ -55,6 +56,18 @@ static int mod_init(void);
static int child_init(int rank);
static void destroy(void);
+
+static sruid_t _kex_sruid;
+
+static int pv_get_sruid_val(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
+static pv_export_t mod_pvs[] = {
+ { {"sruid", sizeof("sruid")-1}, PVT_OTHER, pv_get_sruid_val, 0,
+ 0, 0, 0, 0 },
+ { {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
+};
+
static cmd_export_t cmds[]={
{"setsflag", (cmd_function)w_setsflag, 1,fixup_igp_null,
0, ANY_ROUTE },
@@ -111,7 +124,7 @@ struct module_exports exports= {
params,
0, /* exported statistics */
0, /* exported MI functions */
- 0, /* exported pseudo-variables */
+ mod_pvs, /* exported pseudo-variables */
0, /* extra processes */
mod_init, /* module initialization function */
0,
@@ -124,6 +137,8 @@ struct module_exports exports= {
*/
static int mod_init(void)
{
+ if(sruid_init(&_kex_sruid, '-', NULL)<0)
+ return -1;
if(init_mi_core()<0)
return -1;
#ifdef STATISTICS
@@ -143,6 +158,8 @@ static int mod_init(void)
static int child_init(int rank)
{
LM_DBG("rank is (%d)\n", rank);
+ if(sruid_init(&_kex_sruid, '-', NULL)<0)
+ return -1;
if (rank==PROC_INIT)
return pkg_proc_stats_init();
return pkg_proc_stats_myinit(rank);
@@ -207,3 +224,15 @@ int w_resetdebug(struct sip_msg *msg, char *uri, str *s2)
reset_local_debug_level();
return 1;
}
+
+
+static int pv_get_sruid_val(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ if(res==NULL)
+ return -1;
+ if(sruid_next(&_kex_sruid)<0)
+ return pv_get_null(msg, param, res);
+ return pv_get_strval(msg, param, res, &_kex_sruid.uid);
+}
+