[sr-dev] git:master:8e037f62: modules/siputils: made tel2sip to return 2 if no conversion was needed

Juha Heinanen jh at tutpro.com
Sat Apr 8 09:32:24 CEST 2017


Module: kamailio
Branch: master
Commit: 8e037f623ae6daf58e092d8a41430fd13d1d38ec
URL: https://github.com/kamailio/kamailio/commit/8e037f623ae6daf58e092d8a41430fd13d1d38ec

Author: Juha Heinanen <jh at tutpro.com>
Committer: Juha Heinanen <jh at tutpro.com>
Date: 2017-04-08T10:31:23+03:00

modules/siputils: made tel2sip to return 2 if no conversion was needed

---

Modified: src/modules/siputils/README
Modified: src/modules/siputils/checks.c
Modified: src/modules/siputils/doc/siputils_admin.xml

---

Diff:  https://github.com/kamailio/kamailio/commit/8e037f623ae6daf58e092d8a41430fd13d1d38ec.diff
Patch: https://github.com/kamailio/kamailio/commit/8e037f623ae6daf58e092d8a41430fd13d1d38ec.patch

---

diff --git a/src/modules/siputils/README b/src/modules/siputils/README
index e7e5b79..8815baa 100644
--- a/src/modules/siputils/README
+++ b/src/modules/siputils/README
@@ -561,8 +561,8 @@ get_uri_param("nat", "$var(nat)");
 
    Converts URI in first param (pseudo variable or string) to SIP URI, if
    it is a tel URI. If conversion was done, writes resulting SIP URI to
-   third param (pseudo variable). Returns 1 if conversion succeeded or if
-   no conversion was needed.
+   third param (pseudo variable). Returns 1 if conversion succeeded, 2 if
+   no conversion was needed, and -1 in case of error.
 
    The conversion follows the rules in RFC 3261 section 19.1.6:
      * Visual separators ( "-", ".", "(", ")" ) are removed from tel URI
diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index ca6991f..0a33bdd 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -349,7 +349,7 @@ int add_uri_param(struct sip_msg* _msg, char* _param, char* _s2)
 
 /*
  * Converts URI, if it is tel URI, to SIP URI.  Returns 1, if
- * conversion succeeded or if no conversion was needed, i.e., URI was not
+ * conversion succeeded and 2 if no conversion was needed, i.e., URI was not
  * tel URI.  Returns -1, if conversion failed.  Takes SIP URI hostpart from
  * second parameter and (if needed) writes the result to third paramater.
  */
@@ -364,15 +364,17 @@ int tel2sip(struct sip_msg* _msg, char* _uri, char* _hostpart, char* _res)
 	/* get parameters */
 	if (get_str_fparam(&uri, _msg, (fparam_t*)_uri) < 0) {
 		LM_ERR("failed to get uri value\n");
+		return -1;
 	}
 	if (get_str_fparam(&hostpart, _msg, (fparam_t*)_hostpart) < 0) {
 		LM_ERR("failed to get hostpart value\n");
+		return -1;
 	}
 	res = (pv_spec_t *)_res;
 
 	/* check if anything needs to be done */
-	if (uri.len < 4) return 1;
-	if (strncasecmp(uri.s, "tel:", 4) != 0) return 1;
+	if (uri.len < 4) return 2;
+	if (strncasecmp(uri.s, "tel:", 4) != 0) return 2;
 
 	/* reserve memory for clean tel uri */
 	tel_uri.s = pkg_malloc(uri.len+1);
diff --git a/src/modules/siputils/doc/siputils_admin.xml b/src/modules/siputils/doc/siputils_admin.xml
index e28f7a2..2031ad2 100644
--- a/src/modules/siputils/doc/siputils_admin.xml
+++ b/src/modules/siputils/doc/siputils_admin.xml
@@ -513,8 +513,8 @@ get_uri_param("nat", "$var(nat)");
 		Converts URI in first param (pseudo variable or string) to
 		SIP URI, if it is a tel URI.  If conversion was done,
 		writes resulting SIP URI to third param (pseudo variable).
-		Returns 1 if conversion succeeded or if no conversion
-		was needed.
+		Returns 1 if conversion succeeded, 2 if no conversion
+		was needed, and -1 in case of error.
 		</para>
 		<para>
 		The conversion follows the rules in RFC 3261 section 19.1.6:




More information about the sr-dev mailing list