aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-03 11:58:10 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-03 11:58:10 +0000
commit6d4467d2ca51886476b93f80c99770340f816840 (patch)
treec62015bed6363b715ed1bc5f972ff6ffd863ae6f /channels
parent7c8d0e9b4ee1009298a6749f1e76bf92774efd28 (diff)
Bug #6071: Broken rport match in check_via(). (rizzo)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7733 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 67a2156d7..e52cbd7bf 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -6800,7 +6800,7 @@ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
return -1;
}
-/*! \brief check_via: check Via: headers ---*/
+/*! \brief check Via: header for hostname, port and rport request/answer */
static int check_via(struct sip_pvt *p, struct sip_request *req)
{
char via[256];
@@ -6810,9 +6810,16 @@ static int check_via(struct sip_pvt *p, struct sip_request *req)
struct ast_hostent ahp;
ast_copy_string(via, get_header(req, "Via"), sizeof(via));
+
+ /* Check for rport */
+ c = strstr(via, ";rport");
+ if (c && (c[6] != '=')) /* rport query, not answer */
+ ast_set_flag(p, SIP_NAT_ROUTE);
+
c = strchr(via, ';');
if (c)
*c = '\0';
+
c = strchr(via, ' ');
if (c) {
*c = '\0';
@@ -6833,9 +6840,7 @@ static int check_via(struct sip_pvt *p, struct sip_request *req)
p->sa.sin_family = AF_INET;
memcpy(&p->sa.sin_addr, hp->h_addr, sizeof(p->sa.sin_addr));
p->sa.sin_port = htons(pt ? atoi(pt) : DEFAULT_SIP_PORT);
- c = strstr(via, ";rport");
- if (c && (c[6] != '=')) /* rport query, not answer */
- ast_set_flag(p, SIP_NAT_ROUTE);
+
if (sip_debug_test_pvt(p)) {
c = (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE) ? "NAT" : "non-NAT";
ast_verbose("Sending to %s : %d (%s)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port), c);