Browse Source

Merge branch 'sr_3.0' of ssh://[email protected]/sip-router into backport-tmp

* 'sr_3.0' of ssh://[email protected]/sip-router:
  - fix bug in encode_contact()
  - fix bug when RURI was changed before and newuri will be used
  - remove unused code
Henning Westerholt 15 years ago
parent
commit
e5f0ed558e
3 changed files with 277 additions and 212 deletions
  1. 222 170
      modules_k/siputils/README
  2. 28 27
      modules_k/siputils/contact_ops.c
  3. 27 15
      modules_k/siputils/doc/siputils_admin.xml

+ 222 - 170
modules_k/siputils/README

@@ -1,4 +1,3 @@
-
 siputils
 
 Hardy Kahl
@@ -40,45 +39,45 @@ Gabriel Vasile
    Copyright © 2008, 2005, 2003 1&1 Internet AG, FhG Fokus,
    voice-system.ro
    Revision History
-   Revision $Revision: 4872 $ $Date: 2008-09-09 17:39:38 +0200
-   (Di, 09 Sep 2008) $
-     _________________________________________________________
+   Revision $Revision: 4872 $ $Date: 2008-09-09 17:39:38 +0200 (Di, 09 Sep
+                              2008) $
+     __________________________________________________________________
 
    Table of Contents
 
    1. Admin Guide
 
-        1.1. Overview
-        1.2. Dependencies
-
-              1.2.1. Kamailio Modules
-              1.2.2. External Libraries or Applications
-
-        1.3. Exported Parameters
-
-              1.3.1. ring_timeout (int)
-              1.3.2. options_accept (string)
-              1.3.3. options_accept_encoding (string)
-              1.3.4. contact_flds_separator (string)
-              1.3.5. options_accept_language (string)
-              1.3.6. options_support (string)
-
-        1.4. Exported Functions
-
-              1.4.1. ring_insert_callid() 
-              1.4.2. options_reply() 
-              1.4.3. is_user(username) 
-              1.4.4. has_totag() 
-              1.4.5. uri_param(param) 
-              1.4.6. uri_param(param,value) 
-              1.4.7. add_uri_param(param) 
-              1.4.8. tel2sip() 
-              1.4.9. is_uri_user_e164(pseudo-variable) 
-              1.4.10. encode_contact(encoding_prefix) 
-              1.4.11. decode_contact() 
-              1.4.12. decode_contact_header() 
-              1.4.13. cmp_uri(str1, str2) 
-              1.4.14. cmp_aor(str1, str2) 
+        1. Overview
+        2. Dependencies
+
+              2.1. Kamailio Modules
+              2.2. External Libraries or Applications
+
+        3. Exported Parameters
+
+              3.1. ring_timeout (int)
+              3.2. options_accept (string)
+              3.3. options_accept_encoding (string)
+              3.4. contact_flds_separator (string)
+              3.5. options_accept_language (string)
+              3.6. options_support (string)
+
+        4. Exported Functions
+
+              4.1. ring_insert_callid()
+              4.2. options_reply()
+              4.3. is_user(username)
+              4.4. has_totag()
+              4.5. uri_param(param)
+              4.6. uri_param(param,value)
+              4.7. add_uri_param(param)
+              4.8. tel2sip()
+              4.9. is_uri_user_e164(pseudo-variable)
+              4.10. encode_contact(encoding_prefix,hostpart)
+              4.11. decode_contact()
+              4.12. decode_contact_header()
+              4.13. cmp_uri(str1, str2)
+              4.14. cmp_aor(str1, str2)
 
    List of Examples
 
@@ -105,96 +104,137 @@ Gabriel Vasile
 
 Chapter 1. Admin Guide
 
-1.1. Overview
+   Table of Contents
+
+   1. Overview
+   2. Dependencies
+
+        2.1. Kamailio Modules
+        2.2. External Libraries or Applications
+
+   3. Exported Parameters
+
+        3.1. ring_timeout (int)
+        3.2. options_accept (string)
+        3.3. options_accept_encoding (string)
+        3.4. contact_flds_separator (string)
+        3.5. options_accept_language (string)
+        3.6. options_support (string)
+
+   4. Exported Functions
+
+        4.1. ring_insert_callid()
+        4.2. options_reply()
+        4.3. is_user(username)
+        4.4. has_totag()
+        4.5. uri_param(param)
+        4.6. uri_param(param,value)
+        4.7. add_uri_param(param)
+        4.8. tel2sip()
+        4.9. is_uri_user_e164(pseudo-variable)
+        4.10. encode_contact(encoding_prefix,hostpart)
+        4.11. decode_contact()
+        4.12. decode_contact_header()
+        4.13. cmp_uri(str1, str2)
+        4.14. cmp_aor(str1, str2)
+
+1. Overview
 
-   This module implement various functions and checks related to
-   SIP message handling and URI handling.
+   This module implement various functions and checks related to SIP
+   message handling and URI handling.
 
-   It offers some functions related to handle ringing. In a
-   parallel forking scenario you get several 183s with SDP. You
-   don't want that your customers hear more than one ringtone or
-   answer machine in parallel on the phone. So its necessary to
-   drop the 183 in this cases and send a 180 instead.
+   It offers some functions related to handle ringing. In a parallel
+   forking scenario you get several 183s with SDP. You don't want that
+   your customers hear more than one ringtone or answer machine in
+   parallel on the phone. So its necessary to drop the 183 in this cases
+   and send a 180 instead.
 
-   This module provides a function to answer OPTIONS requests
-   which are directed to the server itself. This means an OPTIONS
-   request which has the address of the server in the request
-   URI, and no username in the URI. The request will be answered
-   with a 200 OK which the capabilities of the server.
+   This module provides a function to answer OPTIONS requests which are
+   directed to the server itself. This means an OPTIONS request which has
+   the address of the server in the request URI, and no username in the
+   URI. The request will be answered with a 200 OK which the capabilities
+   of the server.
 
-   To answer OPTIONS request directed to your server is the
-   easiest way for is-alive-tests on the SIP (application) layer
-   from remote (similar to ICMP echo requests, also known as
-   "ping", on the network layer).
+   To answer OPTIONS request directed to your server is the easiest way
+   for is-alive-tests on the SIP (application) layer from remote (similar
+   to ICMP echo requests, also known as "ping", on the network layer).
 
-1.2. Dependencies
+2. Dependencies
 
-1.2.1. Kamailio Modules
+   2.1. Kamailio Modules
+   2.2. External Libraries or Applications
+
+2.1. Kamailio Modules
 
    The following modules must be loaded before this module:
      * sl -- Stateless replies.
 
-1.2.2. External Libraries or Applications
+2.2. External Libraries or Applications
 
-   The following libraries or applications must be installed
-   before running Kamailio with this module loaded:
+   The following libraries or applications must be installed before
+   running Kamailio with this module loaded:
      * None.
 
-1.3. Exported Parameters
+3. Exported Parameters
+
+   3.1. ring_timeout (int)
+   3.2. options_accept (string)
+   3.3. options_accept_encoding (string)
+   3.4. contact_flds_separator (string)
+   3.5. options_accept_language (string)
+   3.6. options_support (string)
 
-1.3.1. ring_timeout (int)
+3.1. ring_timeout (int)
 
-   Timeout value in seconds, define how long the call-id is
-   stored in the internal list. A reasonable value is "30".
+   Timeout value in seconds, define how long the call-id is stored in the
+   internal list. A reasonable value is "30".
 
-   Default value is "0". 
+   Default value is "0".
 
    Example 1.1. Set ring_timeout parameter
 ...
 modparam("siputils", "ring_timeout", 30)
 ...
 
-1.3.2. options_accept (string)
+3.2. options_accept (string)
 
-   This parameter is the content of the Accept header field.
-   Note: it is not clearly written in RFC3261 if a proxy should
-   accept any content (the default "*/*") because it does not
-   care about content. Or if it does not accept any content,
-   which is "".
+   This parameter is the content of the Accept header field. Note: it is
+   not clearly written in RFC3261 if a proxy should accept any content
+   (the default "*/*") because it does not care about content. Or if it
+   does not accept any content, which is "".
 
-   Default value is "*/*". 
+   Default value is "*/*".
 
    Example 1.2. Set options_accept parameter
 ...
 modparam("siputils", "options_accept", "application/*")
 ...
 
-1.3.3. options_accept_encoding (string)
+3.3. options_accept_encoding (string)
 
-   This parameter is the content of the Accept-Encoding header
-   field. Please do not change the default value because Kamailio
-   does not support any encodings yet.
+   This parameter is the content of the Accept-Encoding header field.
+   Please do not change the default value because Kamailio does not
+   support any encodings yet.
 
-   Default value is "". 
+   Default value is "".
 
    Example 1.3. Set options_accept_encoding parameter
 ...
 modparam("siputils", "options_accept_encoding", "gzip")
 ...
 
-1.3.4. contact_flds_separator (string)
+3.4. contact_flds_separator (string)
 
-   First char of this parameter is used as separator for
-   encoding/decoding Contact header.
+   First char of this parameter is used as separator for encoding/decoding
+   Contact header.
 
 Warning
 
-   First char of this field must be set to a value which is not
-   used inside username,password or other fields of contact.
-   Otherwise it is possible for the decoding step to fail/produce
-   wrong results.
+   First char of this field must be set to a value which is not used
+   inside username,password or other fields of contact. Otherwise it is
+   possible for the decoding step to fail/produce wrong results.
 
-   Default value is "*". 
+   Default value is "*".
 
    Example 1.4. Set db_url parameter
 ...
@@ -204,73 +244,83 @@ modparam("siputils", "contact_flds_separator", "-")
    then an encoded uri might look
    sip:user-password-ip-port-protocol@PublicIP
 
-1.3.5. options_accept_language (string)
+3.5. options_accept_language (string)
 
-   This parameter is the content of the Accept-Language header
-   field. You can set any language code which you prefer for
-   error descriptions from other devices, but presumably there
-   are not much devices around which support other languages then
-   the default English.
+   This parameter is the content of the Accept-Language header field. You
+   can set any language code which you prefer for error descriptions from
+   other devices, but presumably there are not much devices around which
+   support other languages then the default English.
 
-   Default value is "en". 
+   Default value is "en".
 
    Example 1.5. Set options_accept_language parameter
 ...
 modparam("siputils", "options_accept_language", "de")
 ...
 
-1.3.6. options_support (string)
+3.6. options_support (string)
 
-   This parameter is the content of the Support header field.
-   Please do not change the default value, because Kamailio
-   currently does not support any of the SIP extensions
-   registered at the IANA.
+   This parameter is the content of the Support header field. Please do
+   not change the default value, because Kamailio currently does not
+   support any of the SIP extensions registered at the IANA.
 
-   Default value is "". 
+   Default value is "".
 
    Example 1.6. Set options_support parameter
 ...
 modparam("siputils", "options_support", "100rel")
 ...
 
-1.4. Exported Functions
+4. Exported Functions
+
+   4.1. ring_insert_callid()
+   4.2. options_reply()
+   4.3. is_user(username)
+   4.4. has_totag()
+   4.5. uri_param(param)
+   4.6. uri_param(param,value)
+   4.7. add_uri_param(param)
+   4.8. tel2sip()
+   4.9. is_uri_user_e164(pseudo-variable)
+   4.10. encode_contact(encoding_prefix,hostpart)
+   4.11. decode_contact()
+   4.12. decode_contact_header()
+   4.13. cmp_uri(str1, str2)
+   4.14. cmp_aor(str1, str2)
 
-1.4.1.  ring_insert_callid()
+4.1.  ring_insert_callid()
 
-   Inserting the call-id in the internal list, which is checked
-   when further replies arrive. Any 183 reply that is received
-   during the timeout value will be converted to a 180 message.
-   Please not that you need to set a positive timeout value in
-   order to use this function.
+   Inserting the call-id in the internal list, which is checked when
+   further replies arrive. Any 183 reply that is received during the
+   timeout value will be converted to a 180 message. Please not that you
+   need to set a positive timeout value in order to use this function.
 
-   The function returns TRUE on success, and FALSE during
-   processing failures.
+   The function returns TRUE on success, and FALSE during processing
+   failures.
 
-   This function can be used from REQUEST_ROUTE and
-   FAILURE_ROUTE.
+   This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
 
    Example 1.7. ring_insert_callid() usage
 ...
 ring_insert_callid();
 ...
 
-1.4.2.  options_reply()
+4.2.  options_reply()
 
-   This function checks if the request method is OPTIONS and if
-   the request URI does not contain an username. If both is true
-   the request will be answered stateless with "200 OK" and the
-   capabilities from the modules parameters.
+   This function checks if the request method is OPTIONS and if the
+   request URI does not contain an username. If both is true the request
+   will be answered stateless with "200 OK" and the capabilities from the
+   modules parameters.
 
-   It sends "500 Server Internal Error" for some errors and
-   returns false if it is called for a wrong request.
+   It sends "500 Server Internal Error" for some errors and returns false
+   if it is called for a wrong request.
 
-   The check for the request method and the missing username is
-   optional because it is also done by the function itself. But
-   you should not call this function outside the myself check
-   because in this case the function could answer OPTIONS
-   requests which are sent to you as outbound proxy but with an
-   other destination then your proxy (this check is currently
-   missing in the function).
+   The check for the request method and the missing username is optional
+   because it is also done by the function itself. But you should not call
+   this function outside the myself check because in this case the
+   function could answer OPTIONS requests which are sent to you as
+   outbound proxy but with an other destination then your proxy (this
+   check is currently missing in the function).
 
    This function can be used from REQUEST_ROUTE.
 
@@ -283,10 +333,9 @@ if (uri==myself) {
 }
 ...
 
-1.4.3.  is_user(username)
+4.3.  is_user(username)
 
-   Check if the username in credentials matches the given
-   username.
+   Check if the username in credentials matches the given username.
 
    Meaning of the parameters is as follows:
      * username - Username string.
@@ -300,7 +349,7 @@ if (is_user("john")) {
 };
 ...
 
-1.4.4.  has_totag()
+4.4.  has_totag()
 
    Check if To header field uri contains tag parameter.
 
@@ -313,7 +362,7 @@ if (has_totag()) {
 };
 ...
 
-1.4.5.  uri_param(param)
+4.5.  uri_param(param)
 
    Find if Request URI has a given parameter with no value
 
@@ -329,7 +378,7 @@ if (uri_param("param1")) {
 };
 ...
 
-1.4.6.  uri_param(param,value)
+4.6.  uri_param(param,value)
 
    Find if Request URI has a given parameter with matching value
 
@@ -346,7 +395,7 @@ if (uri_param("param1","value1")) {
 };
 ...
 
-1.4.7.  add_uri_param(param)
+4.7.  add_uri_param(param)
 
    Add to RURI a parameter (name=value);
 
@@ -360,17 +409,17 @@ if (uri_param("param1","value1")) {
 add_uri_param("nat=yes");
 ...
 
-1.4.8.  tel2sip()
+4.8.  tel2sip()
 
-   Converts RURI, if it is tel URI, to SIP URI. Returns true only
-   if conversion succeeded or if no conversion was needed (like
-   RURI was not tel URI).
+   Converts RURI, if it is tel URI, to SIP URI. Returns true only if
+   conversion succeeded or if no conversion was needed (like RURI was not
+   tel URI).
 
    The conversion follows the rules in RFC 3261 section 19.1.6:
-     * Visual separators ( "-", ".", "(", ")" ) are removed from
-       tel URI number before converting it to SIP URI userinfo.
-     * tel URI parameters are downcased before appending them to
-       SIP URI userinfo
+     * Visual separators ( "-", ".", "(", ")" ) are removed from tel URI
+       number before converting it to SIP URI userinfo.
+     * tel URI parameters are downcased before appending them to SIP URI
+       userinfo
 
    The SIP URI host is formed using the From URI host.
 
@@ -387,13 +436,11 @@ tel2sip();
 # RURI:  sip:+12345678;ext=200;[email protected];user=phone
 ...
 
-1.4.9.  is_uri_user_e164(pseudo-variable)
+4.9.  is_uri_user_e164(pseudo-variable)
 
-   Checks if userpart of URI stored in pseudo variable is E164
-   number.
+   Checks if userpart of URI stored in pseudo variable is E164 number.
 
-   This function can be used from REQUEST_ROUTE and
-   FAILURE_ROUTE.
+   This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
 
    Example 1.15. is_uri_user_e164 usage
 ...
@@ -406,35 +453,38 @@ if (is_uri_user_e164("$avp(i:705)") {
 };
 ...
 
-1.4.10.  encode_contact(encoding_prefix)
+4.10.  encode_contact(encoding_prefix,hostpart)
+
+   This function will encode uri-s inside Contact header in the following
+   manner sip:username:password@ip:port;transport=protocol goes
+   sip:encoding_prefix*username*ip*port*protocol@hostpart.
+
+   * is the default separator and can be changed by setting the
+   contact_flds_separator module parameter.
 
-   This function will encode uri-s inside Contact header in the
-   following manner
-   sip:username:password@ip:port;transport=protocol goes
-   sip:enc_pref*username*ip*port*protocol@public_ip * is the
-   default separator.
+   Note: This function discards all of the URI parameters. Thus, none of
+   the paramters (except the transport parameter which is encoded into the
+   userpart) can be restored.
 
    The function returns negative on error, 1 on success.
 
    Meaning of the parameters is as follows:
-     * encoding_prefix - Something to allow us to determine that
-       a contact is encoded publicip--a routable IP, most
-       probably you should put your external IP of your NAT box.
+     * encoding_prefix - Something to allow us to determine that a contact
+       is encoded.
+     * hostpart - An IP address or a hostname.
 
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE.
 
    Example 1.16. encode_contact usage
 ...
-if (src_ip == 10.0.0.0/8) encode_contact("enc_prefix","193.175.135.38")
-;
+if (src_ip == 10.0.0.0/8) encode_contact("natted_client","1.2.3.4");
 ...
 
-1.4.11.  decode_contact()
+4.11.  decode_contact()
 
-   This function will decode the URI in first line in packets
-   which come with encoded URI in the following manner
-   sip:enc_pref*username*ip*port*protocol@public_ip goes to
-   sip:username:password@ip:port;transport=protocol It uses the
+   This function will decode the request URI. If the RURI is in the format
+   sip:encoding_prefix*username*ip*port*protocol@hostpart it will be
+   decoded to sip:username:password@ip:port;transport=protocol It uses the
    default set parameter for contact encoding separator.
 
    The function returns negative on error, 1 on success.
@@ -445,16 +495,15 @@ if (src_ip == 10.0.0.0/8) encode_contact("enc_prefix","193.175.135.38")
 
    Example 1.17. decode_contact usage
 ...
-if (uri =~ "^enc*") { decode_contact(); }
+if (uri =~ "^sip:natted_client") { decode_contact(); }
 ...
 
-1.4.12.  decode_contact_header()
+4.12.  decode_contact_header()
 
-   This function will decode URIs inside Contact header in the
-   following manner
-   sip:enc_pref*username*ip*port*protocol@public_ip goes to
-   sip:username:password@ip:port;transport=protocol. It uses the
-   default set parameter for contact encoding separator.
+   This function will decode URIs inside Contact header. If the URI in the
+   format sip:encoding_prefix*username*ip*port*protocol@hostpart it will
+   be decoded to sip:username:password@ip:port;transport=protocol. It uses
+   the default set parameter for contact encoding separator.
 
    The function returns negative on error, 1 on success.
 
@@ -464,13 +513,16 @@ if (uri =~ "^enc*") { decode_contact(); }
 
    Example 1.18. decode_contact_header usage
 ...
-if (uri =~ "^enc*") { decode_contact_header(); }
+reply_route[2] {
+        ...
+        decode_contact_header();
+        ...
+}
 ...
 
-1.4.13.  cmp_uri(str1, str2)
+4.13.  cmp_uri(str1, str2)
 
-   The function returns true if the two parameters matches as SIP
-   URI.
+   The function returns true if the two parameters matches as SIP URI.
 
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
    FAILURE_ROUTE and BRANCH_ROUTE.
@@ -483,10 +535,10 @@ if(cmp_uri("$ru", "sip:[email protected]"))
 }
 ...
 
-1.4.14.  cmp_aor(str1, str2)
+4.14.  cmp_aor(str1, str2)
 
-   The function returns true if the two parameters matches as
-   AoR. The parameters have to be SIP URIs.
+   The function returns true if the two parameters matches as AoR. The
+   parameters have to be SIP URIs.
 
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
    FAILURE_ROUTE and BRANCH_ROUTE.

+ 28 - 27
modules_k/siputils/contact_ops.c

@@ -160,40 +160,40 @@ decode_contact (struct sip_msg *msg,char *unused1,char *unused2)
 			separator = contact_flds_separator[0];
 		
 	if ((msg->new_uri.s == NULL) || (msg->new_uri.len == 0))
-		{
+	{
 		uri = msg->first_line.u.request.uri;
-		if (uri.s == NULL) return -1;
-		}
+		if (uri.s == NULL) 
+			return -1;
+	}
+	else
+	{
+		uri = msg->new_uri;
+	}
 	
-		res = decode_uri (uri, separator, &newUri);
+	res = decode_uri (uri, separator, &newUri);
 	
 #ifdef DEBUG
-		if (res == 0) fprintf (stdout, "newuri.s=[%.*s]\n", newUri.len, newUri.s);
+	if (res == 0) 
+		fprintf (stdout, "newuri.s=[%.*s]\n", newUri.len, newUri.s);
 #endif
-		if (res != 0)
-		{
-			LM_ERR("failed decoding contact.Code %d\n", res);
+	if (res != 0)
+	{
+		LM_ERR("failed decoding contact.Code %d\n", res);
 #ifdef STRICT_CHECK
-				return res;
+		return res;
 #endif
-		}
+	}
+	else
+	{
+		/* we do not modify the original first line */
+		if ((msg->new_uri.s == NULL) || (msg->new_uri.len == 0)) 
+			msg->new_uri = newUri;
 		else
-			/* we do not modify the original first line */
-			if ((msg->new_uri.s == NULL) || (msg->new_uri.len == 0)) msg->new_uri = newUri;
-				else
-					{
-						pkg_free(msg->new_uri.s);
-						msg->new_uri = newUri;
-					}
-			
-			
-		/*
-		if (patch (msg, uri.s, uri.len, newUri.s, newUri.len) < 0)
 		{
-			LM_ERR("lumping failed in mangling port \n");
-			return -2;
-		}
-		*/
+			pkg_free(msg->new_uri.s);
+			msg->new_uri = newUri;
+		}		
+	}
 	return 1;
 }
 
@@ -313,10 +313,10 @@ encode2format (str uri, struct uri_format *format)
 		return -1;
 	string = uri.s;
 
-
 	pos = memchr (string, '<', uri.len);
 	if (pos != NULL)	/* we are only interested of chars inside <> */
 	{
+		/* KD: I think this can be removed as the parsed contact removed <> already */
 		start = memchr (string, ':', uri.len);
 		if (start == NULL)	return -2;
 		if (start - pos < 4) return -3;
@@ -330,8 +330,9 @@ encode2format (str uri, struct uri_format *format)
 		start = memchr (string, ':', uri.len);
 		if (start == NULL)
 			return -5;
-		if (start - pos < 3)
+		if (start - string < 3)
 			return -6;
+		/* KD: FIXME: Looks like this code can not handle 'sips' URIs and discards all other URI parameters! */
 		start = start - 3;
 		end = string + uri.len;
 	}

+ 27 - 15
modules_k/siputils/doc/siputils_admin.xml

@@ -490,14 +490,21 @@ if (is_uri_user_e164("$avp(i:705)") {
 
 	<section>
 		<title>
-		<function moreinfo="none">encode_contact(encoding_prefix)</function>
+		<function moreinfo="none">encode_contact(encoding_prefix,hostpart)</function>
 		</title>
 		<para>
 		This function will encode uri-s inside Contact header in the following 
 		manner
 		sip:username:password@ip:port;transport=protocol goes
-		sip:enc_pref*username*ip*port*protocol@public_ip * is the default 
-		separator.
+		sip:encoding_prefix*username*ip*port*protocol@hostpart.
+		</para>
+		<para>
+		* is the default separator and can be changed by setting the contact_flds_separator 
+		module parameter.
+		</para>
+		<para>
+		Note: This function discards all of the URI parameters. Thus, none of the paramters
+		(except the transport parameter which is encoded into the userpart) can be restored.
 		</para>
 		<para>
 		The function returns negative on error, 1 on success.
@@ -506,9 +513,11 @@ if (is_uri_user_e164("$avp(i:705)") {
 		<itemizedlist>
 		<listitem>
 			<para><emphasis>encoding_prefix</emphasis> - Something to allow us 
-			to determine that a contact is encoded publicip--a routable &ip;, 
-			most probably you should
-			put your external &ip; of your &nat; box.
+			to determine that a contact is encoded.
+			</para>
+		</listitem>
+		<listitem>
+			<para><emphasis>hostpart</emphasis> - An IP address or a hostname.
 			</para>
 		</listitem>
 		</itemizedlist>
@@ -519,7 +528,7 @@ if (is_uri_user_e164("$avp(i:705)") {
 		<title><function>encode_contact</function> usage</title>
 		<programlisting format="linespecific">
 ...
-if (src_ip == 10.0.0.0/8) encode_contact("enc_prefix","193.175.135.38"); 
+if (src_ip == 10.0.0.0/8) encode_contact("natted_client","1.2.3.4"); 
 ...
 </programlisting>
 		</example>
@@ -530,9 +539,8 @@ if (src_ip == 10.0.0.0/8) encode_contact("enc_prefix","193.175.135.38");
 		<function moreinfo="none">decode_contact()</function>
 		</title>
 		<para>
-		This function will decode the &uri; in first line in packets which 
-		come with encoded &uri; in the following manner 
-		sip:enc_pref*username*ip*port*protocol@public_ip goes to
+		This function will decode the request URI. If the RURI is in the format
+		sip:encoding_prefix*username*ip*port*protocol@hostpart it will be decoded to
 		sip:username:password@ip:port;transport=protocol It uses the default 
 		set parameter for contact encoding separator.
 		</para>
@@ -547,7 +555,7 @@ if (src_ip == 10.0.0.0/8) encode_contact("enc_prefix","193.175.135.38");
 		<title><function>decode_contact</function> usage</title>
 		<programlisting format="linespecific">
 ...
-if (uri =~ "^enc*") { decode_contact(); }
+if (uri =~ "^sip:natted_client") { decode_contact(); }
 ...
 </programlisting>
 		</example>
@@ -558,9 +566,9 @@ if (uri =~ "^enc*") { decode_contact(); }
 		<function moreinfo="none">decode_contact_header()</function>
 		</title>
 		<para>
-		This function will decode &uri;s inside Contact header in the 
-		following manner sip:enc_pref*username*ip*port*protocol@public_ip goes 
-		to sip:username:password@ip:port;transport=protocol. It uses the 
+		This function will decode &uri;s inside Contact header. If the URI in the format 
+		sip:encoding_prefix*username*ip*port*protocol@hostpart it will be decoded to
+		sip:username:password@ip:port;transport=protocol. It uses the 
 		default set parameter for contact encoding separator.
 		</para>
 		<para>
@@ -574,7 +582,11 @@ if (uri =~ "^enc*") { decode_contact(); }
 		<title><function>decode_contact_header</function> usage</title>
 		<programlisting format="linespecific">
 ...
-if (uri =~ "^enc*") { decode_contact_header(); }
+reply_route[2] {
+	...
+	decode_contact_header();
+	...
+}
 ...
 </programlisting>
 		</example>