浏览代码

tsilot: t_store(...) accepts uri as parameter

- uri can be explicitely given as parameter instead of taking it from
  r-uri
- can help avoiding: backup r-uri, set it to another uri and then restore
  r-uri from backup
Daniel-Constantin Mierla 10 年之前
父节点
当前提交
19e608f803
共有 3 个文件被更改,包括 32 次插入10 次删除
  1. 10 6
      modules/tsilo/ts_store.c
  2. 1 1
      modules/tsilo/ts_store.h
  3. 21 3
      modules/tsilo/tsilo.c

+ 10 - 6
modules/tsilo/ts_store.c

@@ -39,7 +39,7 @@
 
 extern int use_domain;
 
-int ts_store(struct sip_msg* msg) {
+int ts_store(struct sip_msg* msg, str *puri) {
 	struct cell		*t;
 	str aor;
 	struct sip_uri ruri;
@@ -48,12 +48,16 @@ int ts_store(struct sip_msg* msg) {
 	ts_urecord_t* r;
 	int res;
 
-	if (msg->new_uri.s!=NULL) {
-		/* incoming r-uri was chaged by cfg or other component */
-		suri = msg->new_uri;
+	if(puri && puri->s && puri->len>0) {
+		suri = *puri;
 	} else {
-		/* no changes to incoming r-uri */
-		suri = msg->first_line.u.request.uri;
+		if (msg->new_uri.s!=NULL) {
+			/* incoming r-uri was chaged by cfg or other component */
+			suri = msg->new_uri;
+		} else {
+			/* no changes to incoming r-uri */
+			suri = msg->first_line.u.request.uri;
+		}
 	}
 
 	if (use_domain) {

+ 1 - 1
modules/tsilo/ts_store.h

@@ -22,6 +22,6 @@
 #ifndef _TS_STORE_H
 #define _TS_STORE_H
 
-int ts_store(struct sip_msg* msg);
+int ts_store(struct sip_msg* msg, str *puri);
 
 #endif

+ 21 - 3
modules/tsilo/tsilo.c

@@ -65,7 +65,8 @@ 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);
 
-static int w_ts_store(struct sip_msg* msg);
+static int w_ts_store(struct sip_msg* msg, char *p1, char *p2);
+static int w_ts_store1(struct sip_msg* msg, char *_ruri, char *p2);
 
 extern stat_var *stored_ruris;
 extern stat_var *stored_transactions;
@@ -80,6 +81,8 @@ static cmd_export_t cmds[]={
 		fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE },
 	{"ts_store", (cmd_function)w_ts_store,  0,
 		0 , 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{"ts_store", (cmd_function)w_ts_store1,  1,
+		fixup_spve_null , 0, REQUEST_ROUTE | FAILURE_ROUTE },
 	{0,0,0,0,0,0}
 };
 
@@ -279,7 +282,22 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table
 /**
  *
  */
-static int w_ts_store(struct sip_msg* msg)
+static int w_ts_store(struct sip_msg* msg, char *p1, char *p2)
 {
-	return ts_store(msg);
+	return ts_store(msg, 0);
+}
+
+
+/**
+ *
+ */
+static int w_ts_store1(struct sip_msg* msg, char *_ruri, char *p2)
+{
+	str suri;
+
+	if(fixup_get_svalue(msg, (gparam_t*)_ruri, &suri)!=0) {
+		LM_ERR("failed to conert r-uri parameter\n");
+		return -1;
+	}
+	return ts_store(msg, &suri);
 }