Browse code

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

Victor Seva authored on 02/05/2013 16:30:50
Showing 4 changed files
... ...
@@ -814,7 +814,7 @@ modparam("usrloc", "db_ops_ruid", 1)
814 814
      * contact - contact string to be added
815 815
      * expires - expires value of the contact
816 816
      * Q - Q value of the contact
817
-     * unused - unused attribute (kept for backword compatibility)
817
+     * path value of the contact
818 818
      * flags - internal USRLOC flags of the contact
819 819
      * cflags - per branch flags of the contact
820 820
      * methods - mask with supported requests of the contact
... ...
@@ -887,7 +887,7 @@ modparam("usrloc", "db_ops_ruid", 1)
887 887
      * contact - contact string to be added
888 888
      * expires - expires value of the contact
889 889
      * Q - Q value of the contact
890
-     * unused - unused attribute (kept for backword compatibility)
890
+     * path value of the contact
891 891
      * flags - internal USRLOC flags of the contact
892 892
      * cflags - per branch flags of the contact
893 893
      * methods - mask with supported requests of the contact
... ...
@@ -986,8 +986,7 @@ modparam("usrloc", "db_ops_ruid", 1)
986 986
 				<emphasis>Q</emphasis> - Q value of the contact
987 987
 			</para></listitem>
988 988
 			<listitem><para>
989
-				<emphasis>unused</emphasis> - unused attribute (kept for
990
-				backword compatibility)
989
+				<emphasis>path</emphasis> value of the contact
991 990
 			</para></listitem>
992 991
 			<listitem><para>
993 992
 				<emphasis>flags</emphasis> - internal USRLOC flags of the 
... ...
@@ -1142,8 +1141,7 @@ modparam("usrloc", "db_ops_ruid", 1)
1142 1142
 				<emphasis>Q</emphasis> - Q value of the contact
1143 1143
 			</para></listitem>
1144 1144
 			<listitem><para>
1145
-				<emphasis>unused</emphasis> - unused attribute (kept for
1146
-				backword compatibility)
1145
+				<emphasis>path</emphasis> value of the contact
1147 1146
 			</para></listitem>
1148 1147
 			<listitem><para>
1149 1148
 				<emphasis>flags</emphasis> - internal USRLOC flags of the
... ...
@@ -491,8 +491,8 @@ struct mi_root* mi_usrloc_flush(struct mi_root *cmd, void *param)
491 491
  * \brief Add a new contact for an address of record
492 492
  * \param cmd mi_root containing the parameter
493 493
  * \param param not used
494
- * \note Expects 7 nodes: table name, AOR, contact, expires, Q,
495
- * useless - backward compatible, flags, cflags, methods
494
+ * \note Expects 9 nodes: table name, AOR, contact, expires, Q,
495
+ * path, flags, cflags, methods
496 496
  * \return mi_root with the result
497 497
  */
498 498
 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)
540 540
 	if (str2q( &ci.q, node->value.s, node->value.len) < 0)
541 541
 		goto bad_syntax;
542 542
 
543
-	/* unused value (param 6) FIXME */
543
+	/* path value (param 6) */
544 544
 	node = node->next;
545
+	if(strncmp(node->value.s, "0", 1) != 0 && node->value.len > 1)
546
+		ci.path = &node->value;
545 547
 
546 548
 	/* flags value (param 7) */
547 549
 	node = node->next;
... ...
@@ -524,14 +524,15 @@ static const char* ul_rpc_flush_doc[2] = {
524 524
 /*!
525 525
  * \brief Add a new contact for an address of record
526 526
  * \note Expects 9 parameters: table name, AOR, contact, expires, Q,
527
- * useless - backward compatible, flags, cflags, methods
527
+ * path, flags, cflags, methods
528 528
  */
529 529
 static void ul_rpc_add(rpc_t* rpc, void* ctx)
530 530
 {
531 531
 	str table = {0, 0};
532 532
 	str aor = {0, 0};
533 533
 	str contact = {0, 0};
534
-	str useless = {0, 0};
534
+	str path = {0, 0};
535
+	str temp = {0, 0};
535 536
 	double dtemp;
536 537
 	ucontact_info_t ci;
537 538
 	urecord_t* r;
... ...
@@ -541,18 +542,24 @@ static void ul_rpc_add(rpc_t* rpc, void* ctx)
541 541
 
542 542
 	memset( &ci, 0, sizeof(ucontact_info_t));
543 543
 
544
-	ret = rpc->scan(ctx, "SSSdf.Sddd", &table, &aor, &contact, &ci.expires,
545
-		&dtemp, &useless, &ci.flags, &ci.cflags, &ci.methods);
546
-	LM_DBG("ret: %d table:%.*s aor:%.*s contact:%.*s expires:%d dtemp:%f useless:%.*s flags:%d bflags:%d methods:%d\n",
544
+	ret = rpc->scan(ctx, "SSSdfSddd", &table, &aor, &contact, &ci.expires,
545
+		&dtemp, &path, &ci.flags, &ci.cflags, &ci.methods);
546
+	if(path.len==1 && (strncmp(temp.s, "0", 1)==0))	{
547
+		LM_DBG("path == 0 -> unset\n");
548
+	}
549
+	else {
550
+		ci.path = &path;
551
+	}
552
+	LM_DBG("ret: %d table:%.*s aor:%.*s contact:%.*s expires:%d dtemp:%f path:%.*s flags:%d bflags:%d methods:%d\n",
547 553
 		ret, table.len, table.s, aor.len, aor.s, contact.len, contact.s,
548
-		(int) ci.expires, dtemp, useless.len, useless.s, ci.flags, ci.cflags, (int) ci.methods);
554
+		(int) ci.expires, dtemp, ci.path->len, ci.path->s, ci.flags, ci.cflags, (int) ci.methods);
549 555
 	if ( ret != 9) {
550 556
 		rpc->fault(ctx, 500, "Not enough parameters or wrong format");
551 557
 		return;
552 558
 	}
553 559
 	ci.q = double2q(dtemp);
554
-	useless.s = q2str(ci.q, (unsigned int*)&useless.len);
555
-	LM_DBG("q:%.*s\n", useless.len, useless.s);
560
+	temp.s = q2str(ci.q, (unsigned int*)&temp.len);
561
+	LM_DBG("q:%.*s\n", temp.len, temp.s);
556 562
 	/* look for table */
557 563
 	dom = rpc_find_domain( &table );
558 564
 	if (dom == NULL) {