Author: rjung
Date: Sat May 23 08:37:51 2015
New Revision: 1681290

URL: http://svn.apache.org/r1681290
Log:
Sync trunk with 1.1 branch: Forward port

r1291760 | mturk | 2012-02-21 14:15:42 +0100 (Tue, 21 Feb 2012) | 1 line
Fix BZ52717 by allowing to have %scope_id as address suffix for local-link IPv6 
addresses

Modified:
    tomcat/native/trunk/native/src/address.c

Modified: tomcat/native/trunk/native/src/address.c
URL: 
http://svn.apache.org/viewvc/tomcat/native/trunk/native/src/address.c?rev=1681290&r1=1681289&r2=1681290&view=diff
==============================================================================
--- tomcat/native/trunk/native/src/address.c (original)
+++ tomcat/native/trunk/native/src/address.c Sat May 23 08:37:51 2015
@@ -29,6 +29,8 @@ TCN_IMPLEMENT_CALL(jlong, Address, info)
 {
     apr_pool_t *p = J2P(pool, apr_pool_t *);
     TCN_ALLOC_CSTRING(hostname);
+    char *sp = NULL;
+    int   scope_id = 0;
     apr_sockaddr_t *sa = NULL;
     apr_sockaddr_t *sl = NULL;
     apr_int32_t f;
@@ -36,6 +38,16 @@ TCN_IMPLEMENT_CALL(jlong, Address, info)
 
     UNREFERENCED(o);
     GET_S_FAMILY(f, family);
+#if APR_HAVE_IPV6
+    if (hostname) {
+        /* XXX: This only works for real scope_id's
+         */
+        if ((sp = strchr(J2S(hostname), '%'))) {
+            *sp++ = '\0';
+            scope_id = atoi(sp);
+        }
+    }
+#endif
     TCN_THROW_IF_ERR(apr_sockaddr_info_get(&sa,
             J2S(hostname), f, (apr_port_t)port,
             (apr_int32_t)flags, p), sa);
@@ -58,6 +70,13 @@ TCN_IMPLEMENT_CALL(jlong, Address, info)
             sl = sa;
         }
     }
+    if (sp) {
+        /* Set the provided scope id
+         * APR lack the api for setting this directly so lets presume
+         * the sin6_scope_id is present everywhere
+         */
+        sl->sa.sin6.sin6_scope_id = scope_id;
+    }
 #endif
 
 cleanup:



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to