mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-01 07:12:26 +00:00
Issue #8524, support multiple via header values (tardieu)
Thanks! git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@49983 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -5327,21 +5327,25 @@ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, const st
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (!copied) { /* Only check for empty rport in topmost via header */
|
if (!copied) { /* Only check for empty rport in topmost via header */
|
||||||
char *rport;
|
char leftmost[256], *others, *rport;
|
||||||
|
|
||||||
|
/* Only work on leftmost value */
|
||||||
|
ast_copy_string(leftmost, oh, sizeof(leftmost));
|
||||||
|
others = strchr(leftmost, ',');
|
||||||
|
if (others)
|
||||||
|
*others++ = '\0';
|
||||||
|
|
||||||
/* Find ;rport; (empty request) */
|
/* Find ;rport; (empty request) */
|
||||||
rport = strstr(oh, ";rport");
|
rport = strstr(leftmost, ";rport");
|
||||||
if (rport && *(rport+6) == '=')
|
if (rport && *(rport+6) == '=')
|
||||||
rport = NULL; /* We already have a parameter to rport */
|
rport = NULL; /* We already have a parameter to rport */
|
||||||
|
|
||||||
/* Check rport if NAT=yes or NAT=rfc3581 (which is the default setting) */
|
/* Check rport if NAT=yes or NAT=rfc3581 (which is the default setting) */
|
||||||
if (rport && ((ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_ALWAYS) || (ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_RFC3581))) {
|
if (rport && ((ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_ALWAYS) || (ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_RFC3581))) {
|
||||||
/* We need to add received port - rport */
|
/* We need to add received port - rport */
|
||||||
char tmp[256], *end;
|
char *end;
|
||||||
|
|
||||||
ast_copy_string(tmp, oh, sizeof(tmp));
|
rport = strstr(leftmost, ";rport");
|
||||||
|
|
||||||
rport = strstr(tmp, ";rport");
|
|
||||||
|
|
||||||
if (rport) {
|
if (rport) {
|
||||||
end = strchr(rport + 1, ';');
|
end = strchr(rport + 1, ';');
|
||||||
@@ -5352,13 +5356,15 @@ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, const st
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add rport to first VIA header if requested */
|
/* Add rport to first VIA header if requested */
|
||||||
snprintf(new, sizeof(new), "%s;received=%s;rport=%d",
|
snprintf(new, sizeof(new), "%s;received=%s;rport=%d%s%s",
|
||||||
tmp, ast_inet_ntoa(p->recv.sin_addr),
|
leftmost, ast_inet_ntoa(p->recv.sin_addr),
|
||||||
ntohs(p->recv.sin_port));
|
ntohs(p->recv.sin_port),
|
||||||
|
others ? "," : "", others ? others : "");
|
||||||
} else {
|
} else {
|
||||||
/* We should *always* add a received to the topmost via */
|
/* We should *always* add a received to the topmost via */
|
||||||
snprintf(new, sizeof(new), "%s;received=%s",
|
snprintf(new, sizeof(new), "%s;received=%s%s%s",
|
||||||
oh, ast_inet_ntoa(p->recv.sin_addr));
|
leftmost, ast_inet_ntoa(p->recv.sin_addr),
|
||||||
|
others ? "," : "", others ? others : "");
|
||||||
}
|
}
|
||||||
oh = new; /* the header to copy */
|
oh = new; /* the header to copy */
|
||||||
} /* else add the following via headers untouched */
|
} /* else add the following via headers untouched */
|
||||||
@@ -8741,6 +8747,11 @@ static void check_via(struct sip_pvt *p, struct sip_request *req)
|
|||||||
|
|
||||||
ast_copy_string(via, get_header(req, "Via"), sizeof(via));
|
ast_copy_string(via, get_header(req, "Via"), sizeof(via));
|
||||||
|
|
||||||
|
/* Work on the leftmost value of the topmost Via header */
|
||||||
|
c = strchr(via, ',');
|
||||||
|
if (c)
|
||||||
|
*c = '\0';
|
||||||
|
|
||||||
/* Check for rport */
|
/* Check for rport */
|
||||||
c = strstr(via, ";rport");
|
c = strstr(via, ";rport");
|
||||||
if (c && (c[6] != '=')) /* rport query, not answer */
|
if (c && (c[6] != '=')) /* rport query, not answer */
|
||||||
|
Reference in New Issue
Block a user