Module: kamailio
Branch: master
Commit: ffbef4181f6632401715a250af26cce4696c3c46
URL:
https://github.com/kamailio/kamailio/commit/ffbef4181f6632401715a250af26cce…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-09-22T16:33:40+02:00
tsilo: pass uri parameter to registrar lookup_to_dset()
- ts_append_to() can take uri 4th parameter
---
Modified: modules/tsilo/ts_append.c
Modified: modules/tsilo/ts_append.h
Modified: modules/tsilo/tsilo.c
---
Diff:
https://github.com/kamailio/kamailio/commit/ffbef4181f6632401715a250af26cce…
Patch:
https://github.com/kamailio/kamailio/commit/ffbef4181f6632401715a250af26cce…
---
diff --git a/modules/tsilo/ts_append.c b/modules/tsilo/ts_append.c
index 1295f03..ba4b4c4 100644
--- a/modules/tsilo/ts_append.c
+++ b/modules/tsilo/ts_append.c
@@ -59,7 +59,7 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
while(ptr) {
LM_DBG("transaction %u:%u found for %.*s, going to append
branches\n",ptr->tindex, ptr->tlabel, ruri->len, ruri->s);
- appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table);
+ appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, ruri);
if (appended > 0)
update_stat(added_branches, appended);
ptr = ptr->next;
@@ -70,7 +70,7 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
return 1;
}
-int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table) {
+int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri) {
struct cell *t;
struct sip_msg *orig_msg;
int ret;
@@ -84,7 +84,11 @@ int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char
*table) {
orig_msg = t->uas.request;
- ret = _regapi.lookup_to_dset(orig_msg, table, NULL);
+ if(uri==NULL || uri->s==NULL || uri->len<=0) {
+ ret = _regapi.lookup_to_dset(orig_msg, table, NULL);
+ } else {
+ ret = _regapi.lookup_to_dset(orig_msg, table, uri);
+ }
if(ret != 1) {
LM_DBG("transaction %u:%u: error updating dset (%d)\n", tindex, tlabel,
ret);
return -1;
diff --git a/modules/tsilo/ts_append.h b/modules/tsilo/ts_append.h
index 093449c..56f9120 100644
--- a/modules/tsilo/ts_append.h
+++ b/modules/tsilo/ts_append.h
@@ -23,6 +23,6 @@
#define _TS_APPEND_H
int ts_append(struct sip_msg* msg, str *ruri, char *table);
-int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table);
+int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri);
#endif
diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c
index f9bcfa9..fe475c6 100644
--- a/modules/tsilo/tsilo.c
+++ b/modules/tsilo/tsilo.c
@@ -61,6 +61,7 @@ static int mod_init(void);
static void destroy(void);
static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d);
+static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *d, char
*ruri);
static int fixup_ts_append_to(void** param, int param_no);
static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri);
static int fixup_ts_append(void** param, int param_no);
@@ -77,6 +78,8 @@ extern stat_var *added_branches;
static cmd_export_t cmds[]={
{"ts_append_to", (cmd_function)w_ts_append_to, 3,
fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+ {"ts_append_to", (cmd_function)w_ts_append_to, 4,
+ fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE },
{"ts_append", (cmd_function)w_ts_append, 2,
fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE },
{"ts_store", (cmd_function)w_ts_store, 0,
@@ -226,6 +229,10 @@ static int fixup_ts_append_to(void** param, int param_no)
return -1;
}
}
+
+ if (param_no==4) {
+ return fixup_spve_null(param, 1);
+ }
return 0;
}
@@ -276,7 +283,34 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl,
char *table
return -1;
}
- return ts_append_to(msg, tindex, tlabel, table);
+ return ts_append_to(msg, tindex, tlabel, table, 0);
+}
+
+/**
+ *
+ */
+static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *table, char
*ruri)
+{
+ unsigned int tindex;
+ unsigned int tlabel;
+ str suri;
+
+ if(fixup_get_ivalue(msg, (gparam_p)idx, (int*)&tindex)<0) {
+ LM_ERR("cannot get transaction index\n");
+ return -1;
+ }
+
+ if(fixup_get_ivalue(msg, (gparam_p)lbl, (int*)&tlabel)<0) {
+ LM_ERR("cannot get transaction label\n");
+ return -1;
+ }
+
+ if(fixup_get_svalue(msg, (gparam_t*)ruri, &suri)!=0) {
+ LM_ERR("failed to conert r-uri parameter\n");
+ return -1;
+ }
+
+ return ts_append_to(msg, tindex, tlabel, table, &suri);
}
/**