Module: sip-router
Branch: master
Commit: ee37a2ce17c8b8c43c67cd5876fa985e3c1482e8
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ee37a2c…
Author: Juha Heinanen <jh(a)tutpro.com>
Committer: Juha Heinanen <jh(a)tutpro.com>
Date: Wed Aug 25 22:30:00 2010 +0300
modules_k/nathelper: replaced offending contact alias character
- Changed character ':' in contact alias paramater value to '~',
because ':' is not allowed in value field of generic contact
parameter.
---
modules_k/nathelper/nathelper.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/modules_k/nathelper/nathelper.c b/modules_k/nathelper/nathelper.c
index 6a728e0..a437786 100644
--- a/modules_k/nathelper/nathelper.c
+++ b/modules_k/nathelper/nathelper.c
@@ -818,7 +818,7 @@ add_contact_alias_f(struct sip_msg* msg, char* str1, char* str2)
LM_ERR("you can't call alias_contact twice, check your config!\n");
return -1;
}
- param_len = SALIAS_LEN + IP6_MAX_STR_SIZE + 1 /* : */ + 5 /* port */ +
+ param_len = SALIAS_LEN + IP6_MAX_STR_SIZE + 1 /* ~ */ + 5 /* port */ +
1 /* t */ + 1 /* proto */;
param = (char*)pkg_malloc(param_len);
if (!param) {
@@ -834,7 +834,7 @@ add_contact_alias_f(struct sip_msg* msg, char* str1, char* str2)
return -1;
}
at = at + ip_len;
- append_chr(at, ':');
+ append_chr(at, '~');
port = int2str(msg->rcv.src_port, &len);
append_str(at, port, len);
append_chr(at, 't');
@@ -877,7 +877,8 @@ static int
handle_ruri_alias_f(struct sip_msg* msg, char* str1, char* str2)
{
str uri, proto;
- char buf[MAX_URI_SIZE], *val, *sep, *trans, *at, *next, *cur_uri, *rest;
+ char buf[MAX_URI_SIZE], *val, *sep, *trans, *at, *next, *cur_uri, *rest,
+ *col;
unsigned int len, rest_len, val_len, alias_len, proto_type, cur_uri_len,
ip_port_len;
@@ -920,6 +921,13 @@ handle_ruri_alias_f(struct sip_msg* msg, char* str1, char* str2)
append_str(at, "sip:", 4);
ip_port_len = sep - val;
alias_len = SALIAS_LEN + ip_port_len + 2 /* tn */;
+ /* replace ~ with : */
+ col = memchr(val, 126 /* ~ */, ip_port_len);
+ if (col == NULL) {
+ LM_ERR("no '~' in alias param value\n");
+ return -1;
+ }
+ *(col) = ':';
memcpy(at, val, ip_port_len);
at = at + ip_port_len;
trans = sep + 1;