[sr-dev] git:master: modules/usrloc: use 6th param to set the contact path

Daniel-Constantin Mierla miconda at gmail.com
Thu May 16 23:03:17 CEST 2013


Module: sip-router
Branch: master
Commit: ad0e5daa8865024440ea37a9e978eeeb7577602f
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ad0e5daa8865024440ea37a9e978eeeb7577602f

Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu May  2 18:30:50 2013 +0200

modules/usrloc: use 6th param to set the contact path

---

 modules/usrloc/README               |    4 ++--
 modules/usrloc/doc/usrloc_admin.xml |    6 ++----
 modules/usrloc/ul_mi.c              |    8 +++++---
 modules/usrloc/ul_rpc.c             |   23 +++++++++++++++--------
 4 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/modules/usrloc/README b/modules/usrloc/README
index 4b8daeb..05b8535 100644
--- a/modules/usrloc/README
+++ b/modules/usrloc/README
@@ -814,7 +814,7 @@ modparam("usrloc", "db_ops_ruid", 1)
      * contact - contact string to be added
      * expires - expires value of the contact
      * Q - Q value of the contact
-     * unused - unused attribute (kept for backword compatibility)
+     * path value of the contact
      * flags - internal USRLOC flags of the contact
      * cflags - per branch flags of the contact
      * methods - mask with supported requests of the contact
@@ -887,7 +887,7 @@ modparam("usrloc", "db_ops_ruid", 1)
      * contact - contact string to be added
      * expires - expires value of the contact
      * Q - Q value of the contact
-     * unused - unused attribute (kept for backword compatibility)
+     * path value of the contact
      * flags - internal USRLOC flags of the contact
      * cflags - per branch flags of the contact
      * methods - mask with supported requests of the contact
diff --git a/modules/usrloc/doc/usrloc_admin.xml b/modules/usrloc/doc/usrloc_admin.xml
index 0a8b15f..78be5e8 100644
--- a/modules/usrloc/doc/usrloc_admin.xml
+++ b/modules/usrloc/doc/usrloc_admin.xml
@@ -986,8 +986,7 @@ modparam("usrloc", "db_ops_ruid", 1)
 				<emphasis>Q</emphasis> - Q value of the contact
 			</para></listitem>
 			<listitem><para>
-				<emphasis>unused</emphasis> - unused attribute (kept for
-				backword compatibility)
+				<emphasis>path</emphasis> value of the contact
 			</para></listitem>
 			<listitem><para>
 				<emphasis>flags</emphasis> - internal USRLOC flags of the 
@@ -1142,8 +1141,7 @@ modparam("usrloc", "db_ops_ruid", 1)
 				<emphasis>Q</emphasis> - Q value of the contact
 			</para></listitem>
 			<listitem><para>
-				<emphasis>unused</emphasis> - unused attribute (kept for
-				backword compatibility)
+				<emphasis>path</emphasis> value of the contact
 			</para></listitem>
 			<listitem><para>
 				<emphasis>flags</emphasis> - internal USRLOC flags of the
diff --git a/modules/usrloc/ul_mi.c b/modules/usrloc/ul_mi.c
index 3f88a71..3e12bf1 100644
--- a/modules/usrloc/ul_mi.c
+++ b/modules/usrloc/ul_mi.c
@@ -491,8 +491,8 @@ struct mi_root* mi_usrloc_flush(struct mi_root *cmd, void *param)
  * \brief Add a new contact for an address of record
  * \param cmd mi_root containing the parameter
  * \param param not used
- * \note Expects 7 nodes: table name, AOR, contact, expires, Q,
- * useless - backward compatible, flags, cflags, methods
+ * \note Expects 9 nodes: table name, AOR, contact, expires, Q,
+ * path, flags, cflags, methods
  * \return mi_root with the result
  */
 struct mi_root* mi_usrloc_add(struct mi_root *cmd, void *param)
@@ -540,8 +540,10 @@ struct mi_root* mi_usrloc_add(struct mi_root *cmd, void *param)
 	if (str2q( &ci.q, node->value.s, node->value.len) < 0)
 		goto bad_syntax;
 
-	/* unused value (param 6) FIXME */
+	/* path value (param 6) */
 	node = node->next;
+	if(strncmp(node->value.s, "0", 1) != 0 && node->value.len > 1)
+		ci.path = &node->value;
 
 	/* flags value (param 7) */
 	node = node->next;
diff --git a/modules/usrloc/ul_rpc.c b/modules/usrloc/ul_rpc.c
index f21bbbf..7c10584 100644
--- a/modules/usrloc/ul_rpc.c
+++ b/modules/usrloc/ul_rpc.c
@@ -524,14 +524,15 @@ static const char* ul_rpc_flush_doc[2] = {
 /*!
  * \brief Add a new contact for an address of record
  * \note Expects 9 parameters: table name, AOR, contact, expires, Q,
- * useless - backward compatible, flags, cflags, methods
+ * path, flags, cflags, methods
  */
 static void ul_rpc_add(rpc_t* rpc, void* ctx)
 {
 	str table = {0, 0};
 	str aor = {0, 0};
 	str contact = {0, 0};
-	str useless = {0, 0};
+	str path = {0, 0};
+	str temp = {0, 0};
 	double dtemp;
 	ucontact_info_t ci;
 	urecord_t* r;
@@ -541,18 +542,24 @@ static void ul_rpc_add(rpc_t* rpc, void* ctx)
 
 	memset( &ci, 0, sizeof(ucontact_info_t));
 
-	ret = rpc->scan(ctx, "SSSdf.Sddd", &table, &aor, &contact, &ci.expires,
-		&dtemp, &useless, &ci.flags, &ci.cflags, &ci.methods);
-	LM_DBG("ret: %d table:%.*s aor:%.*s contact:%.*s expires:%d dtemp:%f useless:%.*s flags:%d bflags:%d methods:%d\n",
+	ret = rpc->scan(ctx, "SSSdfSddd", &table, &aor, &contact, &ci.expires,
+		&dtemp, &path, &ci.flags, &ci.cflags, &ci.methods);
+	if(path.len==1 && (strncmp(temp.s, "0", 1)==0))	{
+		LM_DBG("path == 0 -> unset\n");
+	}
+	else {
+		ci.path = &path;
+	}
+	LM_DBG("ret: %d table:%.*s aor:%.*s contact:%.*s expires:%d dtemp:%f path:%.*s flags:%d bflags:%d methods:%d\n",
 		ret, table.len, table.s, aor.len, aor.s, contact.len, contact.s,
-		(int) ci.expires, dtemp, useless.len, useless.s, ci.flags, ci.cflags, (int) ci.methods);
+		(int) ci.expires, dtemp, ci.path->len, ci.path->s, ci.flags, ci.cflags, (int) ci.methods);
 	if ( ret != 9) {
 		rpc->fault(ctx, 500, "Not enough parameters or wrong format");
 		return;
 	}
 	ci.q = double2q(dtemp);
-	useless.s = q2str(ci.q, (unsigned int*)&useless.len);
-	LM_DBG("q:%.*s\n", useless.len, useless.s);
+	temp.s = q2str(ci.q, (unsigned int*)&temp.len);
+	LM_DBG("q:%.*s\n", temp.len, temp.s);
 	/* look for table */
 	dom = rpc_find_domain( &table );
 	if (dom == NULL) {




More information about the sr-dev mailing list