Author: mturk
Date: Tue Feb 21 13:15:42 2012
New Revision: 1291760

URL: http://svn.apache.org/viewvc?rev=1291760&view=rev
Log:
Fix BZ52717 by allowing to have %scope_id as address suffix for local-link IPv6 
addresses

Modified:
    tomcat/native/branches/1.1.x/native/src/address.c
    tomcat/native/branches/1.1.x/xdocs/miscellaneous/changelog.xml

Modified: tomcat/native/branches/1.1.x/native/src/address.c
URL: 
http://svn.apache.org/viewvc/tomcat/native/branches/1.1.x/native/src/address.c?rev=1291760&r1=1291759&r2=1291760&view=diff
==============================================================================
--- tomcat/native/branches/1.1.x/native/src/address.c (original)
+++ tomcat/native/branches/1.1.x/native/src/address.c Tue Feb 21 13:15:42 2012
@@ -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:

Modified: tomcat/native/branches/1.1.x/xdocs/miscellaneous/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/native/branches/1.1.x/xdocs/miscellaneous/changelog.xml?rev=1291760&r1=1291759&r2=1291760&view=diff
==============================================================================
--- tomcat/native/branches/1.1.x/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/native/branches/1.1.x/xdocs/miscellaneous/changelog.xml Tue Feb 21 
13:15:42 2012
@@ -38,6 +38,9 @@
 </section>
 <section name="Changes between 1.1.22 and 1.1.23">
   <changelog>
+    <fix>
+      <bug>52717</bug>: Set scope_id for IPv6 addresses if provided. (mturk)
+    </fix>
     <update>
       <bug>50570</bug>: Allow explicit use of FIPS mode in APR lifecycle 
listener (native support only in this update; Java support to follow). Based 
upon a patch from Chris Beckey. (schultz)
     </update>



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

Reply via email to