gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, ipv6, created. release_0_8_9_final-14


From: Rob Savoye
Subject: [Gnash-commit] [SCM] Gnash branch, ipv6, created. release_0_8_9_final-1447-gf1467a7
Date: Tue, 13 Mar 2012 21:48:24 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, ipv6 has been created
        at  f1467a702088abc3bbfacaffc2aa588f32261e65 (commit)

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=f1467a702088abc3bbfacaffc2aa588f32261e65


commit f1467a702088abc3bbfacaffc2aa588f32261e65
Author: Rob Savoye <address@hidden>
Date:   Tue Mar 13 15:47:49 2012 -0600

    parse IPV6 addresses correctly

diff --git a/libbase/URL.cpp b/libbase/URL.cpp
index 497fe27..290b48d 100644
--- a/libbase/URL.cpp
+++ b/libbase/URL.cpp
@@ -17,6 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "URL.h"
+#include "log.h"
 
 #include <iostream>
 #include <string>
@@ -44,6 +45,8 @@ namespace gnash {
 
 URL::URL(const std::string& relative_url, const URL& baseurl)
 {
+    GNASH_REPORT_FUNCTION;
+
     init_relative(relative_url, baseurl);
 }
 
@@ -51,6 +54,7 @@ URL::URL(const std::string& relative_url, const URL& baseurl)
 void
 URL::normalize_path(std::string& path)
 {
+    GNASH_REPORT_FUNCTION;
 
 #if defined(_WIN32) || defined(WIN32) || defined(__OS2__) || 
defined(__amigaos4__)
     return;
@@ -92,6 +96,8 @@ URL::normalize_path(std::string& path)
 void
 URL::init_absolute(const std::string& in)
 {
+    GNASH_REPORT_FUNCTION;
+
     // Find protocol
     std::string::size_type pos = in.find("://");
     if ( pos != std::string::npos ) {
@@ -142,7 +148,9 @@ URL::init_absolute(const std::string& in)
 
 URL::URL(const std::string& absolute_url)
 {
-    //cerr << "URL(" << absolute_url << ")" << endl;
+    GNASH_REPORT_FUNCTION;
+    
+    std::cerr << "URL(" << absolute_url << ")" << std::endl;
     if ( ( absolute_url.size() && absolute_url[0] == '/' )
          || absolute_url.find("://") != std::string::npos 
          || ( absolute_url.size() > 1 && absolute_url[1] == ':' )        //for 
win32
@@ -185,6 +193,7 @@ URL::URL(const std::string& absolute_url)
 void
 URL::init_relative(const std::string& relative_url, const URL& baseurl)
 {
+    GNASH_REPORT_FUNCTION;
     
     // If relative url starts with an hash, it's just
     // an anchor change
@@ -274,6 +283,8 @@ URL::init_relative(const std::string& relative_url, const 
URL& baseurl)
 std::string
 URL::str() const
 {
+    GNASH_REPORT_FUNCTION;
+
     std::string ret = _proto + "://" + _host;
 
     if (!_port.empty()) {
@@ -295,6 +306,8 @@ URL::str() const
 void
 URL::split_anchor_from_path()
 {
+    GNASH_REPORT_FUNCTION;
+
     assert(_anchor == "");
 
     // Extract anchor from path, if any
@@ -308,19 +321,38 @@ URL::split_anchor_from_path()
 void
 URL::split_port_from_host()
 {
+    GNASH_REPORT_FUNCTION;
+
     assert(_port == "");
 
     // Extract anchor from path, if any
-    std::string::size_type hashpos = _host.find(':');
-    if ( hashpos != std::string::npos ) {
-        _port = _host.substr(hashpos+1);
-        _host.erase(hashpos);
+
+    // IPV4 addresses have square brackets around the adress like this:
+    // http://[2a00:1450:4001:c01::88]/
+    
+    std::string::size_type ipv6 = _host.find(']');
+    if (ipv6 == std::string::npos) {
+        // IPV6 address
+        std::string::size_type hashpos = _host.find(':');
+        if ( hashpos != std::string::npos ) {
+            _port = _host.substr(hashpos+1);
+            _host.erase(hashpos);
+        }
+    } else {
+        // IPV4 address
+        std::string::size_type hashpos = _host.find(':', ipv6);
+        if ( hashpos != std::string::npos ) {
+            _port = _host.substr(hashpos+1);
+            _host.erase(hashpos);
+        }        
     }
 }
 
 void
 URL::split_querystring_from_path()
 {
+    GNASH_REPORT_FUNCTION;
+
     assert(_querystring == "");
 
     // extract the parameters from the URL
@@ -342,6 +374,7 @@ void
 URL::parse_querystring(const std::string& query_string,
                        std::map<std::string, std::string>& target_map)
 {
+    GNASH_REPORT_FUNCTION;
 
     if ( query_string.empty() ) return; // nothing to do
 

http://git.savannah.gnu.org/cgit//commit/?id=5cc647f4f8fa683e0b9edae58973e6a9943f34c2


commit 5cc647f4f8fa683e0b9edae58973e6a9943f34c2
Author: Rob Savoye <address@hidden>
Date:   Tue Mar 13 15:47:28 2012 -0600

    add tests for IPV6 addresses

diff --git a/testsuite/libbase.all/URLTest.cpp 
b/testsuite/libbase.all/URLTest.cpp
index 4383712..105bb34 100644
--- a/testsuite/libbase.all/URLTest.cpp
+++ b/testsuite/libbase.all/URLTest.cpp
@@ -321,6 +321,24 @@ main(int /*argc*/, char** /*argv*/)
         check_equals(u2.path(), "/home/toto/Téléchargement/testfile.xml");
     }
 
+    // IPV6 paths
+    // http://[2a00:1450:4001:c01::88]/
+    URL v6("http://[2a00:1450:4001:c01::88]/";);
+    check_equals (v6.protocol(), "http");
+    check_equals (v6.hostname(), "[2a00:1450:4001:c01::88]");
+    check_equals (v6.port(), "");
+    check_equals (v6.path(), "/");
+    check_equals (v6.querystring(), "");
+    check_equals (v6.anchor(), "");
+
+    URL v66("https://[2a00:1450:4001:c01::88]:8080/";);
+    check_equals (v66.protocol(), "https");
+    check_equals (v66.hostname(), "[2a00:1450:4001:c01::88]");
+    check_equals (v66.port(), "8080");
+    check_equals (v66.path(), "/");
+    check_equals (v66.querystring(), "");
+    check_equals (v66.anchor(), "");
+    
        // TODO: Samba paths
 }
 

http://git.savannah.gnu.org/cgit//commit/?id=1fa1c4057e7911ae39e0637b8903b3bfce7a48c6


commit 1fa1c4057e7911ae39e0637b8903b3bfce7a48c6
Author: Rob Savoye <address@hidden>
Date:   Mon Mar 12 20:08:08 2012 -0600

    use log_error instead of std::cerr

diff --git a/libbase/Socket.cpp b/libbase/Socket.cpp
index 9e3a9e6..34cc1db 100644
--- a/libbase/Socket.cpp
+++ b/libbase/Socket.cpp
@@ -49,8 +49,7 @@ Socket::Socket()
     _socket(0),
     _size(0),
     _pos(0),
-    _error(false),
-    _ipv6(false)
+    _error(false)
 { }
 
 bool
@@ -188,8 +187,7 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
         std::memset(&straddr, 0, INET6_ADDRSTRLEN);
         ::inet_ntop(AF_INET6, it->ai_addr, straddr,
                     sizeof(straddr));
-        std::cerr << "IPV6 address for host " << clienthost
-                  << " is: " << straddr << std::endl;
+        log_debug("IPV6 address for host %s is %s", clienthost, straddr);
 
         addr6.sin6_family = AF_INET6;
         addr6.sin6_port = htons(port);

http://git.savannah.gnu.org/cgit//commit/?id=30e43ac2b2765451d778766bf6d8e407a491531c


commit 30e43ac2b2765451d778766bf6d8e407a491531c
Author: Rob Savoye <address@hidden>
Date:   Mon Mar 12 18:50:08 2012 -0600

    use IPV6 for client connections if supported

diff --git a/libbase/Socket.cpp b/libbase/Socket.cpp
index d4eb914..9e3a9e6 100644
--- a/libbase/Socket.cpp
+++ b/libbase/Socket.cpp
@@ -147,13 +147,15 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
     // If _socket is 0, either there has been no connection, or close() has
     // been called. There must not be an error in either case.
     assert(!_error);
-
+    
     if (hostname.empty()) {
         return false;
     }
 
+    struct sockaddr saddr;
+    
 #ifdef HAVE_IPV6
-    // struct sockaddr_in6 addr6;
+    struct sockaddr_in6 addr6;
     // std::memset(&addr6, 0, sizeof(addr6));
     // addr.sin6_family = AF_INET6;
     // addr.sin6_port = htons(port);
@@ -163,7 +165,7 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
     req.ai_family = AF_UNSPEC;  // Allow IPv4 or IPv6
     req.ai_socktype = SOCK_STREAM;
 
-    if ((code = getaddrinfo("www.youtube.com", "http", &req, &ans)) != 0) {
+    if ((code = getaddrinfo(hostname.c_str(), "login", &req, &ans)) != 0) {
         log_error(_("getaddrinfo() failed with code: #%d - %s\n"),
                   code, gai_strerror(code));
         return false;
@@ -188,8 +190,25 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
                     sizeof(straddr));
         std::cerr << "IPV6 address for host " << clienthost
                   << " is: " << straddr << std::endl;
-        it = it->ai_next;
+
+        addr6.sin6_family = AF_INET6;
+        addr6.sin6_port = htons(port);
+        _socket = ::socket(it->ai_family, it->ai_socktype, it->ai_protocol);
+        
+        if (_socket < 0) {
+            const int err = errno;
+            log_error(_("Socket creation failed: %s"), std::strerror(err));
+            _socket = 0;
+            it = 0;
+        } else {
+            it = it->ai_next;
+        }
     }
+
+    // cache the data we need later
+    std::memcpy(&saddr, ans->ai_addr, ans->ai_addrlen);
+    const int addrlen = ans->ai_addrlen;    
+
     freeaddrinfo(ans);          // free the response data
 #else
     struct sockaddr_in addr;
@@ -204,26 +223,27 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
             return false;
         }
         addr.sin_addr = *reinterpret_cast<in_addr*>(host->h_addr);
-        
-    }
-    _socket = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-    
-    if (_socket < 0) {
-        const int err = errno;
-        log_error(_("Socket creation failed: %s"), std::strerror(err));
-        _socket = 0;
-        return false;
+        _socket = ::socket(addr.sin_family, SOCK_STREAM, IPPROTO_TCP);        
+
+        if (_socket < 0) {
+            const int err = errno;
+            log_error(_("Socket creation failed: %s"), std::strerror(err));
+            _socket = 0;
+            return false;
+        }
     }
+    std::memcpy(&saddr, &addr, sizeof(struct sockaddr));
+    const int addrlen = sizeof(struct sockaddr);
+#endif
+
 #ifndef _WIN32
     // Set non-blocking.
     const int flag = ::fcntl(_socket, F_GETFL, 0);
     ::fcntl(_socket, F_SETFL, flag | O_NONBLOCK);
 #endif
 
-    const struct sockaddr* a = reinterpret_cast<struct sockaddr*>(&addr);
-
     // Attempt connection
-    if (::connect(_socket, a, sizeof(struct sockaddr)) < 0) {
+    if (::connect(_socket, &saddr, addrlen) < 0) {
         const int err = errno;
 #ifndef _WIN32
         if (err != EINPROGRESS) {
@@ -235,24 +255,23 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
         return false;
 #endif
     }
-#endif
 
     // Magic timeout number. Use rcfile ?
     const struct timeval tv = { 120, 0 };
-
+    
     // NB: the cast to const char* is needed for windows and is harmless
     // for POSIX.
     if (::setsockopt(_socket, SOL_SOCKET, SO_RCVTIMEO,
-                reinterpret_cast<const char*>(&tv), sizeof(tv))) {
+                     reinterpret_cast<const char*>(&tv), sizeof(tv))) {
         log_error(_("Setting socket timeout failed"));
     }
-
+    
     const int on = 1;
     // NB: the cast to const char* is needed for windows and is harmless
     // for POSIX.
     ::setsockopt(_socket, IPPROTO_TCP, TCP_NODELAY,
-            reinterpret_cast<const char*>(&on), sizeof(on));
-
+                 reinterpret_cast<const char*>(&on), sizeof(on));
+    
     assert(_socket);
     return true;
 }

http://git.savannah.gnu.org/cgit//commit/?id=6d821004d8d1ef7f286bf1e4a50123000ee9caa4


commit 6d821004d8d1ef7f286bf1e4a50123000ee9caa4
Author: Rob Savoye <address@hidden>
Date:   Mon Mar 12 17:22:14 2012 -0600

    use getaddrifo() rather than gethostbyname(). which is being depreciated.

diff --git a/libbase/Socket.cpp b/libbase/Socket.cpp
index 575fcfc..d4eb914 100644
--- a/libbase/Socket.cpp
+++ b/libbase/Socket.cpp
@@ -18,6 +18,10 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
+#ifdef HAVE_CONFIG_H
+# include "gnashconfig.h"
+#endif
+
 #include "Socket.h"
 
 #include <cstring>
@@ -33,6 +37,10 @@
 #include "utility.h"
 #include "GnashAlgorithm.h"
 
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
 namespace gnash {
 
 Socket::Socket()
@@ -41,14 +49,21 @@ Socket::Socket()
     _socket(0),
     _size(0),
     _pos(0),
-    _error(false)
-{}
+    _error(false),
+    _ipv6(false)
+{ }
 
 bool
 Socket::connected() const
 {
-    if (_connected) return true;
-    if (!_socket) return false;
+    GNASH_REPORT_FUNCTION;
+
+    if (_connected) {
+        return true;
+    }
+    if (!_socket) {
+        return false;
+    }
 
     size_t retries = 10;
     fd_set fdset;
@@ -107,6 +122,8 @@ Socket::connected() const
 void
 Socket::close()
 {
+    GNASH_REPORT_FUNCTION;
+
     if (_socket) ::close(_socket);
     _socket = 0;
     _size = 0;
@@ -118,7 +135,8 @@ Socket::close()
 bool
 Socket::connect(const std::string& hostname, boost::uint16_t port)
 {
-
+    GNASH_REPORT_FUNCTION;
+    
     // We use _socket here because connected() or _connected might not
     // be true if a connection attempt is underway but not completed.
     if (_socket) {
@@ -130,11 +148,54 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
     // been called. There must not be an error in either case.
     assert(!_error);
 
-    if (hostname.empty()) return false;
+    if (hostname.empty()) {
+        return false;
+    }
 
+#ifdef HAVE_IPV6
+    // struct sockaddr_in6 addr6;
+    // std::memset(&addr6, 0, sizeof(addr6));
+    // addr.sin6_family = AF_INET6;
+    // addr.sin6_port = htons(port);
+    int code = 0;
+    struct addrinfo req, *ans;
+    std::memset(&req, 0, sizeof(struct addrinfo));
+    req.ai_family = AF_UNSPEC;  // Allow IPv4 or IPv6
+    req.ai_socktype = SOCK_STREAM;
+
+    if ((code = getaddrinfo("www.youtube.com", "http", &req, &ans)) != 0) {
+        log_error(_("getaddrinfo() failed with code: #%d - %s\n"),
+                  code, gai_strerror(code));
+        return false;
+    }
+
+    // Multiple IPV$ and IPV6 numbers may bve returned, so we try them all if
+    // required
+    struct addrinfo *it = ans;
+    while (it) {    
+        char clienthost   [NI_MAXHOST];
+        std::memset(&clienthost, 0, NI_MAXHOST);
+        char clientservice[NI_MAXSERV];
+        std::memset(&clientservice, 0, NI_MAXSERV);
+        getnameinfo(it->ai_addr, it->ai_addrlen,
+                    clienthost, sizeof(clienthost),
+                    clientservice, sizeof(clientservice),
+                    NI_NUMERICHOST);
+
+        char straddr[INET6_ADDRSTRLEN];
+        std::memset(&straddr, 0, INET6_ADDRSTRLEN);
+        ::inet_ntop(AF_INET6, it->ai_addr, straddr,
+                    sizeof(straddr));
+        std::cerr << "IPV6 address for host " << clienthost
+                  << " is: " << straddr << std::endl;
+        it = it->ai_next;
+    }
+    freeaddrinfo(ans);          // free the response data
+#else
     struct sockaddr_in addr;
     std::memset(&addr, 0, sizeof(addr));
     addr.sin_family = AF_INET;
+    addr.sin_port = htons(port);
 
     addr.sin_addr.s_addr = ::inet_addr(hostname.c_str());
     if (addr.sin_addr.s_addr == INADDR_NONE) {
@@ -143,10 +204,8 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
             return false;
         }
         addr.sin_addr = *reinterpret_cast<in_addr*>(host->h_addr);
+        
     }
-
-    addr.sin_port = htons(port);
-
     _socket = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
     
     if (_socket < 0) {
@@ -176,6 +235,7 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
         return false;
 #endif
     }
+#endif
 
     // Magic timeout number. Use rcfile ?
     const struct timeval tv = { 120, 0 };

http://git.savannah.gnu.org/cgit//commit/?id=cefc09e1088323d61d80fd1b0a8da17a92d6567c


commit cefc09e1088323d61d80fd1b0a8da17a92d6567c
Author: Rob Savoye <address@hidden>
Date:   Mon Mar 12 17:21:38 2012 -0600

    add test for getaddrinfo(), which is needed for IPV6 dual stack

diff --git a/configure.ac b/configure.ac
index f29eed7..a2df5d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1547,6 +1547,11 @@ AC_SEARCH_LIBS([mallinfo], [c malloc],
 AM_CONDITIONAL([HAVE_MALLINFO], test x$mallinfo = xyes)
 AM_CONDITIONAL(JEMALLOC, test x$jemalloc = xyes)
 
+AC_SEARCH_LIBS([getaddrinfo], [c],
+               AC_DEFINE(HAVE_IPV6, [1], [Has IPV6 support])
+               ipv6=yes
+               )
+
 AC_ARG_ENABLE(fps-debug,
   AC_HELP_STRING([--enable-fps-debug],[Enable FPS debugging code]),
 [case "${enableval}" in

http://git.savannah.gnu.org/cgit//commit/?id=61d41972a8542f813641f65bebc92b7096344b5b


commit 61d41972a8542f813641f65bebc92b7096344b5b
Author: Rob Savoye <address@hidden>
Date:   Mon Mar 12 17:20:36 2012 -0600

    use localhost.localdomain rather than just localhost so it resolves 
correctly for IPV6

diff --git a/testsuite/misc-ming.all/XMLSocketTest.as 
b/testsuite/misc-ming.all/XMLSocketTest.as
index a90106c..cc29152 100644
--- a/testsuite/misc-ming.all/XMLSocketTest.as
+++ b/testsuite/misc-ming.all/XMLSocketTest.as
@@ -77,7 +77,7 @@ myXML.onData = handleData;
 myXML.onClose = handleDisconnect;
 receivedArray = new Array();
 
- ret = myXML.connect("localhost", 2229);
+ ret = myXML.connect("localhost.localdomain", 2229);
  check_equals(ret, true);
  stop();
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]