jdk/src/solaris/classes/sun/nio/ch/sctp/SctpNet.java
changeset 18212 22f8c33b0690
parent 14342 8435a30053c1
child 23010 6dadb192ad81
equal deleted inserted replaced
18211:74aeb4741e3d 18212:22f8c33b0690
    92                 IPv4MappedAddresses());
    92                 IPv4MappedAddresses());
    93     }
    93     }
    94 
    94 
    95     static Set<SocketAddress> getLocalAddresses(int fd)
    95     static Set<SocketAddress> getLocalAddresses(int fd)
    96             throws IOException {
    96             throws IOException {
    97         HashSet<SocketAddress> set = null;
    97         Set<SocketAddress> set = null;
    98         SocketAddress[] saa = getLocalAddresses0(fd);
    98         SocketAddress[] saa = getLocalAddresses0(fd);
    99 
    99 
   100         if (saa != null) {
   100         if (saa != null) {
   101             set = new HashSet<SocketAddress>(saa.length);
   101             set = getRevealedLocalAddressSet(saa);
   102             for (SocketAddress sa : saa)
       
   103                 set.add(sa);
       
   104         }
   102         }
   105 
   103 
   106         return set;
   104         return set;
       
   105     }
       
   106 
       
   107     private static Set<SocketAddress> getRevealedLocalAddressSet(
       
   108             SocketAddress[] saa)
       
   109     {
       
   110          SecurityManager sm = System.getSecurityManager();
       
   111          Set<SocketAddress> set = new HashSet<>(saa.length);
       
   112          for (SocketAddress sa : saa) {
       
   113              set.add(getRevealedLocalAddress(sa, sm));
       
   114          }
       
   115          return set;
       
   116     }
       
   117 
       
   118     private static SocketAddress getRevealedLocalAddress(SocketAddress sa,
       
   119                                                          SecurityManager sm)
       
   120     {
       
   121         if (sm == null || sa == null)
       
   122             return sa;
       
   123         InetSocketAddress ia = (InetSocketAddress)sa;
       
   124         try{
       
   125             sm.checkConnect(ia.getAddress().getHostAddress(), -1);
       
   126             // Security check passed
       
   127         } catch (SecurityException e) {
       
   128             // Return loopback address
       
   129             return new InetSocketAddress(InetAddress.getLoopbackAddress(),
       
   130                                          ia.getPort());
       
   131         }
       
   132         return sa;
   107     }
   133     }
   108 
   134 
   109     static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
   135     static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
   110             throws IOException {
   136             throws IOException {
   111         HashSet<SocketAddress> set = null;
   137         HashSet<SocketAddress> set = null;