[svn-commits] pabelanger: trunk r291760 - in /trunk: ./ channels/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Oct 14 10:21:49 CDT 2010


Author: pabelanger
Date: Thu Oct 14 10:21:42 2010
New Revision: 291760

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=291760
Log:
Merged revisions 291758 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r291758 | pabelanger | 2010-10-14 11:15:12 -0400 (Thu, 14 Oct 2010) | 11 lines
  
  Add the ability for ast_find_ourip to return IPv4, IPv6 or both.
  
  While testing chan_gtalk I noticed jabber was using my IPv6 address
  and not IPv4. When using bindaddr=0.0.0.0 it is possible for ast_find_ourip()
  to return both IPv6 and IPv4 results.  Adding a family parameter gives you
  the ablility to choose.
  
  Since jabber/gtalk/h323 do not support IPv6, we should only return IPv4 results.
  
  Review: https://reviewboard.asterisk.org/r/973/
........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_gtalk.c
    trunk/channels/chan_h323.c
    trunk/channels/chan_jingle.c
    trunk/channels/chan_sip.c
    trunk/include/asterisk/acl.h
    trunk/main/acl.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=291760&r1=291759&r2=291760
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Thu Oct 14 10:21:42 2010
@@ -859,7 +859,7 @@
 	ast_rtp_instance_get_local_address(p->rtp, &sin_tmp);
 	ast_sockaddr_to_sin(&sin_tmp, &sin);
 	ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr);
-	ast_find_ourip(&us, &bindaddr_tmp);
+	ast_find_ourip(&us, &bindaddr_tmp, AF_INET);
 	if (!strcmp(ast_sockaddr_stringify_addr(&us), "127.0.0.1")) {
 		ast_log(LOG_WARNING, "Found a loopback IP on the system, check your network configuration or set the bindaddr attribute.");
 	}
@@ -2217,7 +2217,7 @@
 	}
 
 	ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr);
-	if (ast_find_ourip(&ourip_tmp, &bindaddr_tmp)) {
+	if (ast_find_ourip(&ourip_tmp, &bindaddr_tmp, AF_INET)) {
 		ast_log(LOG_WARNING, "Unable to get own IP address, Gtalk disabled\n");
 		return 0;
 	}

Modified: trunk/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_h323.c?view=diff&rev=291760&r1=291759&r2=291760
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Thu Oct 14 10:21:42 2010
@@ -965,7 +965,7 @@
 		struct ast_sockaddr tmp;
 
 		ast_sockaddr_from_sin(&tmp, &bindaddr);
-		if (ast_find_ourip(&our_addr, &tmp)) {
+		if (ast_find_ourip(&our_addr, &tmp, AF_INET)) {
 			ast_mutex_unlock(&pvt->lock);
 			ast_log(LOG_ERROR, "Unable to locate local IP address for RTP stream\n");
 			return -1;

Modified: trunk/channels/chan_jingle.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_jingle.c?view=diff&rev=291760&r1=291759&r2=291760
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Thu Oct 14 10:21:42 2010
@@ -623,7 +623,7 @@
 	ast_rtp_instance_get_local_address(p->rtp, &sin_tmp);
 	ast_sockaddr_to_sin(&sin_tmp, &sin);
 	ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr);
-	ast_find_ourip(&us_tmp, &bindaddr_tmp);
+	ast_find_ourip(&us_tmp, &bindaddr_tmp, AF_INET);
 	us.s_addr = htonl(ast_sockaddr_ipv4(&us_tmp));
 
 	/* Setup our first jingle candidate */
@@ -1904,15 +1904,17 @@
 	}
 
 	sched = sched_context_create();
-	if (!sched) 
+	if (!sched) {
 		ast_log(LOG_WARNING, "Unable to create schedule context\n");
+	}
 
 	io = io_context_create();
-	if (!io) 
+	if (!io) {
 		ast_log(LOG_WARNING, "Unable to create I/O context\n");
+	}
 
 	ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr);
-	if (ast_find_ourip(&ourip_tmp, &bindaddr_tmp)) {
+	if (ast_find_ourip(&ourip_tmp, &bindaddr_tmp, AF_INET)) {
 		ast_log(LOG_WARNING, "Unable to get own IP address, Jingle disabled\n");
 		return 0;
 	}

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=291760&r1=291759&r2=291760
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Oct 14 10:21:42 2010
@@ -27216,7 +27216,7 @@
 
 	/* Set UDP address and open socket */
 	ast_sockaddr_copy(&internip, &bindaddr);
-	if (ast_find_ourip(&internip, &bindaddr)) {
+	if (ast_find_ourip(&internip, &bindaddr, 0)) {
 		ast_log(LOG_WARNING, "Unable to get own IP address, SIP disabled\n");
 		ast_config_destroy(cfg);
 		return 0;

Modified: trunk/include/asterisk/acl.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/acl.h?view=diff&rev=291760&r1=291759&r2=291760
==============================================================================
--- trunk/include/asterisk/acl.h (original)
+++ trunk/include/asterisk/acl.h Thu Oct 14 10:21:42 2010
@@ -220,10 +220,12 @@
  * \param[out] ourip Our IP address is written here when it is found
  * \param bindaddr A hint used for finding our IP. See the steps above for
  * more details
- * \retval 0 Success
- * \retval -1 Failure
- */
-int ast_find_ourip(struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr);
+ * \param family Only addresses of the given family will be returned. Use 0
+ * or AST_SOCKADDR_UNSPEC to get addresses of all families.
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_find_ourip(struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr, int family);
 
 /*!
  * \brief Convert a string to the appropriate COS value

Modified: trunk/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/acl.c?view=diff&rev=291760&r1=291759&r2=291760
==============================================================================
--- trunk/main/acl.c (original)
+++ trunk/main/acl.c Thu Oct 14 10:21:42 2010
@@ -720,7 +720,7 @@
 	return 0;
 }
 
-int ast_find_ourip(struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr)
+int ast_find_ourip(struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr, int family)
 {
 	char ourhost[MAXHOSTNAMELEN] = "";
 	struct ast_sockaddr root;
@@ -735,7 +735,7 @@
 	if (gethostname(ourhost, sizeof(ourhost) - 1)) {
 		ast_log(LOG_WARNING, "Unable to get hostname\n");
 	} else {
-		if (resolve_first(ourip, ourhost, PARSE_PORT_FORBID, 0) == 0) {
+		if (resolve_first(ourip, ourhost, PARSE_PORT_FORBID, family) == 0) {
 			return 0;
 		}
 	}




More information about the svn-commits mailing list