[svn-commits] simon.perreault: branch 1.8 r281687 - in /branches/1.8: channels/sip/ configs...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 11 08:31:05 CDT 2010


Author: simon.perreault
Date: Wed Aug 11 08:30:59 2010
New Revision: 281687

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=281687
Log:
Fix parsing of IPv6 address literals in outboundproxy

(closes issue #17757)
Reported by: oej
Patches:
      17757.diff uploaded by sperreault (license 252)
      sip.conf.diff uploaded by sperreault (license 252)
Tested by: oej

Modified:
    branches/1.8/channels/sip/config_parser.c
    branches/1.8/configs/sip.conf.sample
    branches/1.8/include/asterisk/netsock2.h
    branches/1.8/main/netsock2.c

Modified: branches/1.8/channels/sip/config_parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/sip/config_parser.c?view=diff&rev=281687&r1=281686&r2=281687
==============================================================================
--- branches/1.8/channels/sip/config_parser.c (original)
+++ branches/1.8/channels/sip/config_parser.c Wed Aug 11 08:30:59 2010
@@ -661,16 +661,18 @@
 	else
 		line = *hostname;
 
-	if ((port = strrchr(line, ':'))) {
-		*port++ = '\0';
-
+	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);
+		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);
 			port = NULL;
 		}
-	}
-
-	if (!port) {
+	} else {
 		if (*transport & SIP_TRANSPORT_TLS) {
 			*portnum = STANDARD_TLS_PORT;
 		} else {

Modified: branches/1.8/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/configs/sip.conf.sample?view=diff&rev=281687&r1=281686&r2=281687
==============================================================================
--- branches/1.8/configs/sip.conf.sample (original)
+++ branches/1.8/configs/sip.conf.sample Wed Aug 11 08:30:59 2010
@@ -367,6 +367,10 @@
 ;outboundproxy=proxy.provider.domain:8080       ; send outbound signaling to this proxy, not directly to the devices
 ;outboundproxy=proxy.provider.domain,force      ; Send ALL outbound signalling to proxy, ignoring route: headers
 ;outboundproxy=tls://proxy.provider.domain      ; same as '=proxy.provider.domain' except we try to connect with tls
+;outboundproxy=192.0.2.1                        ; IPv4 address literal (default port is 5060)
+;outboundproxy=2001:db8::1                      ; IPv6 address literal (default port is 5060)
+;outboundproxy=192.168.0.2.1:5062               ; IPv4 address literal with explicit port
+;outboundproxy=[2001:db8::1]:5062               ; IPv6 address literal with explicit port
 ;                                               ; (could also be tcp,udp) - defining transports on the proxy line only
 ;                                               ; applies for the global proxy, otherwise use the transport= option
 ;matchexternaddrlocally = yes     ; Only substitute the externaddr or externhost setting if it matches

Modified: branches/1.8/include/asterisk/netsock2.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/netsock2.h?view=diff&rev=281687&r1=281686&r2=281687
==============================================================================
--- branches/1.8/include/asterisk/netsock2.h (original)
+++ branches/1.8/include/asterisk/netsock2.h Wed Aug 11 08:30:59 2010
@@ -233,6 +233,26 @@
  * \since 1.8
  *
  * \brief
+ * Splits a string into its host and port components
+ *
+ * \param str[in]   The string to parse. May be modified by writing a NUL at the end of
+ *                  the host part.
+ * \param host[out] Pointer to the host component within \a str.
+ * \param port[out] Pointer to the port component within \a str.
+ * \param flags     If set to zero, a port MAY be present. If set to PARSE_PORT_IGNORE, a
+ *                  port MAY be present but will be ignored. If set to PARSE_PORT_REQUIRE,
+ *                  a port MUST be present. If set to PARSE_PORT_FORBID, a port MUST NOT
+ *                  be present.
+ *
+ * \retval 1 Success
+ * \retval 0 Failure
+ */
+int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags);
+
+/*!
+ * \since 1.8
+ *
+ * \brief
  * Parse an IPv4 or IPv6 address string.
  *
  * \details

Modified: branches/1.8/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/netsock2.c?view=diff&rev=281687&r1=281686&r2=281687
==============================================================================
--- branches/1.8/main/netsock2.c (original)
+++ branches/1.8/main/netsock2.c Wed Aug 11 08:30:59 2010
@@ -118,7 +118,7 @@
 	return ast_str_buffer(str);
 }
 
-int static _ast_sockaddr_parse(char *str, char **host, char **port, int flags)
+int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
 {
 	char *s = str;
 
@@ -187,7 +187,7 @@
 	int	e;
 
 	s = ast_strdupa(str);
-	if (!_ast_sockaddr_parse(s, &host, &port, flags)) {
+	if (!ast_sockaddr_split_hostport(s, &host, &port, flags)) {
 		return 0;
 	}
 
@@ -233,7 +233,7 @@
 	int	e, i, res_cnt;
 
 	s = ast_strdupa(str);
-	if (!_ast_sockaddr_parse(s, &host, &port, flags)) {
+	if (!ast_sockaddr_split_hostport(s, &host, &port, flags)) {
 		return 0;
 	}
 




More information about the svn-commits mailing list