Fix error in the "IPorHost" section of a SIP dialstring.

This is based on the review request posted by Walter Doekes
(referenced lower in the commit message)

The main fix here is to treat the IPorHost portion of the dial
string as a temporary outbound proxy. This ensures requests
get sent to the proper location.

Due to the age of the request, some parts were no longer relevant.
For instance, the request moved outbound proxy parsing code into
a single method. This is done in a previous commit, so it was not
necessary to do again.

Also, the review request fixed some errors with regards to request
routing for CANCEL and ACK requests. This has also been fixed in
more recent commits.

(closes issue ASTERISK-19677)
reported by Walter Doekes

Review https://reviewboard.asterisk.org/r/1859
........

Merged revisions 370769 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@370843 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2012-08-07 15:40:46 +00:00
parent 948a5a2a9b
commit 7b0ada11d4
3 changed files with 103 additions and 82 deletions

View File

@@ -643,14 +643,17 @@ int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum s
if ((*hostname = strstr(line, "://"))) {
*hostname += 3;
if (!strncasecmp(line, "tcp", 3))
if (!strncasecmp(line, "tcp", 3)) {
*transport = SIP_TRANSPORT_TCP;
else if (!strncasecmp(line, "tls", 3))
} else if (!strncasecmp(line, "tls", 3)) {
*transport = SIP_TRANSPORT_TLS;
else if (!strncasecmp(line, "udp", 3))
} else if (!strncasecmp(line, "udp", 3)) {
*transport = SIP_TRANSPORT_UDP;
else
} else if (lineno) {
ast_log(LOG_NOTICE, "'%.3s' is not a valid transport type on line %d of sip.conf. defaulting to udp.\n", line, lineno);
} else {
ast_log(LOG_NOTICE, "'%.3s' is not a valid transport type in sip config. defaulting to udp.\n", line);
}
} else {
*hostname = line;
*transport = SIP_TRANSPORT_UDP;
@@ -662,14 +665,22 @@ int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum s
line = *hostname;
if (ast_sockaddr_split_hostport(line, hostname, &port, 0) == 0) {
ast_log(LOG_WARNING, "Cannot parse host '%s' on line %d of sip.conf.\n",
line, lineno);
if (lineno) {
ast_log(LOG_WARNING, "Cannot parse host '%s' on line %d of sip.conf.\n",
line, lineno);
} else {
ast_log(LOG_WARNING, "Cannot parse host '%s' in sip config.\n", line);
}
return -1;
}
if (port) {
if (!sscanf(port, "%5u", portnum)) {
ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", port, lineno);
if (lineno) {
ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", port, lineno);
} else {
ast_log(LOG_NOTICE, "'%s' is not a valid port number in sip config. using default.\n", port);
}
port = NULL;
}
}

View File

@@ -798,6 +798,7 @@ struct sip_invite_param {
enum sip_auth_type auth_type; /*!< Authentication type */
const char *replaces; /*!< Replaces header for call transfers */
int transfer; /*!< Flag - is this Invite part of a SIP transfer? (invite/replaces) */
struct sip_proxy *outboundproxy; /*!< Outbound proxy URI */
};
/*! \brief Structure to save routing information for a SIP session */