Module: kamailio Branch: master Commit: 0421bf53c6ec193238b15907cf4a7c83bbae4401 URL: https://github.com/kamailio/kamailio/commit/0421bf53c6ec193238b15907cf4a7c83...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2016-07-08T10:27:55+02:00
pv: return 5061 for port variables (e.g., $dp) when transport is tls
- reported by Colin Morelli, GH #700
---
Modified: modules/pv/pv_core.c
---
Diff: https://github.com/kamailio/kamailio/commit/0421bf53c6ec193238b15907cf4a7c83... Patch: https://github.com/kamailio/kamailio/commit/0421bf53c6ec193238b15907cf4a7c83...
---
diff --git a/modules/pv/pv_core.c b/modules/pv/pv_core.c index 6c1ec41..abaa2ec 100644 --- a/modules/pv/pv_core.c +++ b/modules/pv/pv_core.c @@ -53,6 +53,7 @@
static str str_udp = { "UDP", 3 }; static str str_5060 = { "5060", 4 }; +static str str_5061 = { "5061", 4 }; static str pv_str_1 = { "1", 1 }; static str pv_uri_scheme[] = { { "none", 4 }, @@ -97,6 +98,11 @@ int pv_get_5060(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) return pv_get_strintval(msg, param, res, &str_5060, 5060); }
+int pv_get_5061(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) +{ + return pv_get_strintval(msg, param, res, &str_5061, 5061); +} + int pv_get_true(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) { @@ -279,8 +285,13 @@ int pv_get_xuri_attr(struct sip_msg *msg, struct sip_uri *parsed_uri, return pv_get_null(msg, param, res); return pv_get_strval(msg, param, res, &parsed_uri->host); } else if(param->pvn.u.isname.name.n==3) /* port */ { - if(parsed_uri->port.s==NULL) - return pv_get_5060(msg, param, res); + if(parsed_uri->port.s==NULL) { + if(parsed_uri->proto==PROTO_TLS) { + return pv_get_5061(msg, param, res); + } else { + return pv_get_5060(msg, param, res); + } + } return pv_get_strintval(msg, param, res, &parsed_uri->port, (int)parsed_uri->port_no); } else if(param->pvn.u.isname.name.n==4) /* protocol */ { @@ -1140,8 +1151,13 @@ int pv_get_dsturi_attr(struct sip_msg *msg, pv_param_t *param, return pv_get_null(msg, param, res); return pv_get_strval(msg, param, res, &uri.host); } else if(param->pvn.u.isname.name.n==2) /* port */ { - if(uri.port.s==NULL) - return pv_get_5060(msg, param, res); + if(uri.port.s==NULL || uri.port.len<=0) { + if(uri.proto==PROTO_TLS) { + return pv_get_5061(msg, param, res); + } else { + return pv_get_5060(msg, param, res); + } + } return pv_get_strintval(msg, param, res, &uri.port, (int)uri.port_no); } else if(param->pvn.u.isname.name.n==3) /* proto */ { if(uri.transport_val.s==NULL)