Module: kamailio
Branch: master
Commit: de3386e4a303adecc3eee809c05e0654b7a05065
URL:
https://github.com/kamailio/kamailio/commit/de3386e4a303adecc3eee809c05e065…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-06-25T09:48:26+02:00
topoh: option to disable uri prefix checks
- some devices do not copy the exact URI as received in headers
(Contact, Record-Route) - they can add default port or mix parameters
- reported by GH #1165
---
Modified: src/modules/topoh/th_msg.c
Modified: src/modules/topoh/topoh_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/de3386e4a303adecc3eee809c05e065…
Patch:
https://github.com/kamailio/kamailio/commit/de3386e4a303adecc3eee809c05e065…
---
diff --git a/src/modules/topoh/th_msg.c b/src/modules/topoh/th_msg.c
index a1f117e316..24bb32e185 100644
--- a/src/modules/topoh/th_msg.c
+++ b/src/modules/topoh/th_msg.c
@@ -57,6 +57,7 @@ extern str th_vparam_prefix;
extern int th_param_mask_callid;
extern int th_mask_addr_myself;
+extern int th_uri_prefix_checks;
int th_skip_rw(char *s, int len)
{
@@ -391,8 +392,8 @@ int th_unmask_via(sip_msg_t *msg, str *cookie)
if(i!=1)
{
/* Skip if via is not encoded */
- if (via->host.len!=th_ip.len
- || strncasecmp(via->host.s, th_ip.s, th_ip.len)!=0)
+ if (th_uri_prefix_checks && (via->host.len!=th_ip.len
+ || strncasecmp(via->host.s, th_ip.s, th_ip.len)!=0))
{
LM_DBG("via %d is not encoded",i);
continue;
@@ -687,10 +688,13 @@ int th_unmask_route(sip_msg_t *msg)
if(i!=1)
{
/* Skip if route is not encoded */
- if ((rr->nameaddr.uri.len<th_uri_prefix.len) ||
- (strncasecmp(rr->nameaddr.uri.s,th_uri_prefix.s,th_uri_prefix.len)!=0))
+ if (th_uri_prefix_checks
+ && ((rr->nameaddr.uri.len<th_uri_prefix.len) ||
+ (strncasecmp(rr->nameaddr.uri.s,th_uri_prefix.s,
+ th_uri_prefix.len)!=0)))
{
- LM_DBG("rr %d is not encoded:
[%.*s]",i,rr->nameaddr.uri.len,rr->nameaddr.uri.s);
+ LM_DBG("rr %d is not encoded: [%.*s]", i,
+ rr->nameaddr.uri.len, rr->nameaddr.uri.s);
rr = rr->next;
continue;
}
@@ -736,8 +740,9 @@ int th_unmask_ruri(sip_msg_t *msg)
str out;
/* Do nothing if ruri is not encoded */
- if ((REQ_LINE(msg).uri.len<th_uri_prefix.len) ||
- (strncasecmp(REQ_LINE(msg).uri.s,th_uri_prefix.s,th_uri_prefix.len)!=0))
+ if (th_uri_prefix_checks && ((REQ_LINE(msg).uri.len<th_uri_prefix.len) ||
+ (strncasecmp(REQ_LINE(msg).uri.s, th_uri_prefix.s,
+ th_uri_prefix.len)!=0)))
{
LM_DBG("ruri [%.*s] is not
encoded",REQ_LINE(msg).uri.len,REQ_LINE(msg).uri.s);
return 0;
@@ -798,8 +803,8 @@ int th_unmask_refer_to(sip_msg_t *msg)
uri = &(get_refer_to(msg)->uri);
/* Do nothing if refer_to is not encoded */
- if ((uri->len<th_uri_prefix.len)
- || (strncasecmp(uri->s, th_uri_prefix.s, th_uri_prefix.len)!=0))
+ if (th_uri_prefix_checks && ((uri->len<th_uri_prefix.len)
+ || (strncasecmp(uri->s, th_uri_prefix.s, th_uri_prefix.len)!=0)))
{
LM_DBG("refer-to [%.*s] is not encoded",uri->len,uri->s);
return 0;
diff --git a/src/modules/topoh/topoh_mod.c b/src/modules/topoh/topoh_mod.c
index 91a1b7f29c..164087592a 100644
--- a/src/modules/topoh/topoh_mod.c
+++ b/src/modules/topoh/topoh_mod.c
@@ -77,9 +77,11 @@ str th_uri_prefix = {0, 0};
int th_param_mask_callid = 0;
int th_sanity_checks = 0;
-sanity_api_t scb;
+int th_uri_prefix_checks = 0;
int th_mask_addr_myself = 0;
+sanity_api_t scb;
+
int th_msg_received(sr_event_param_t *evp);
int th_msg_sent(sr_event_param_t *evp);
int th_execute_event_route(sip_msg_t *msg, sr_event_param_t *evp);
@@ -101,6 +103,7 @@ static param_export_t params[]={
{"vparam_prefix", PARAM_STR, &th_vparam_prefix},
{"callid_prefix", PARAM_STR, &th_callid_prefix},
{"sanity_checks", PARAM_INT, &th_sanity_checks},
+ {"uri_prefix_checks", PARAM_INT, &th_uri_prefix_checks},
{"event_callback", PARAM_STR, &_th_eventrt_callback},
{0,0,0}
};