jdk/src/solaris/native/java/net/net_util_md.c
changeset 22605 dba3d6b22818
parent 22597 7515a991bb37
child 22607 ba232b417248
equal deleted inserted replaced
22604:9b394795e216 22605:dba3d6b22818
   994         { java_net_SocketOptions_SO_OOBINLINE,          SOL_SOCKET,     SO_OOBINLINE },
   994         { java_net_SocketOptions_SO_OOBINLINE,          SOL_SOCKET,     SO_OOBINLINE },
   995         { java_net_SocketOptions_SO_LINGER,             SOL_SOCKET,     SO_LINGER },
   995         { java_net_SocketOptions_SO_LINGER,             SOL_SOCKET,     SO_LINGER },
   996         { java_net_SocketOptions_SO_SNDBUF,             SOL_SOCKET,     SO_SNDBUF },
   996         { java_net_SocketOptions_SO_SNDBUF,             SOL_SOCKET,     SO_SNDBUF },
   997         { java_net_SocketOptions_SO_RCVBUF,             SOL_SOCKET,     SO_RCVBUF },
   997         { java_net_SocketOptions_SO_RCVBUF,             SOL_SOCKET,     SO_RCVBUF },
   998         { java_net_SocketOptions_SO_KEEPALIVE,          SOL_SOCKET,     SO_KEEPALIVE },
   998         { java_net_SocketOptions_SO_KEEPALIVE,          SOL_SOCKET,     SO_KEEPALIVE },
   999 #if defined(_AIX)
       
  1000         { java_net_SocketOptions_SO_REUSEADDR,          SOL_SOCKET,     SO_REUSEPORT },
       
  1001 #else
       
  1002         { java_net_SocketOptions_SO_REUSEADDR,          SOL_SOCKET,     SO_REUSEADDR },
   999         { java_net_SocketOptions_SO_REUSEADDR,          SOL_SOCKET,     SO_REUSEADDR },
  1003 #endif
       
  1004         { java_net_SocketOptions_SO_BROADCAST,          SOL_SOCKET,     SO_BROADCAST },
  1000         { java_net_SocketOptions_SO_BROADCAST,          SOL_SOCKET,     SO_BROADCAST },
  1005         { java_net_SocketOptions_IP_TOS,                IPPROTO_IP,     IP_TOS },
  1001         { java_net_SocketOptions_IP_TOS,                IPPROTO_IP,     IP_TOS },
  1006         { java_net_SocketOptions_IP_MULTICAST_IF,       IPPROTO_IP,     IP_MULTICAST_IF },
  1002         { java_net_SocketOptions_IP_MULTICAST_IF,       IPPROTO_IP,     IP_MULTICAST_IF },
  1007         { java_net_SocketOptions_IP_MULTICAST_IF2,      IPPROTO_IP,     IP_MULTICAST_IF },
  1003         { java_net_SocketOptions_IP_MULTICAST_IF2,      IPPROTO_IP,     IP_MULTICAST_IF },
  1008         { java_net_SocketOptions_IP_MULTICAST_LOOP,     IPPROTO_IP,     IP_MULTICAST_LOOP },
  1004         { java_net_SocketOptions_IP_MULTICAST_LOOP,     IPPROTO_IP,     IP_MULTICAST_LOOP },
  1283  */
  1279  */
  1284 int
  1280 int
  1285 NET_SetSockOpt(int fd, int level, int  opt, const void *arg,
  1281 NET_SetSockOpt(int fd, int level, int  opt, const void *arg,
  1286                int len)
  1282                int len)
  1287 {
  1283 {
       
  1284 
  1288 #ifndef IPTOS_TOS_MASK
  1285 #ifndef IPTOS_TOS_MASK
  1289 #define IPTOS_TOS_MASK 0x1e
  1286 #define IPTOS_TOS_MASK 0x1e
  1290 #endif
  1287 #endif
  1291 #ifndef IPTOS_PREC_MASK
  1288 #ifndef IPTOS_PREC_MASK
  1292 #define IPTOS_PREC_MASK 0xe0
  1289 #define IPTOS_PREC_MASK 0xe0
  1303 #ifdef __APPLE__
  1300 #ifdef __APPLE__
  1304     static int maxsockbuf = -1;
  1301     static int maxsockbuf = -1;
  1305 #else
  1302 #else
  1306     static long maxsockbuf = -1;
  1303     static long maxsockbuf = -1;
  1307 #endif
  1304 #endif
  1308 
       
  1309     int addopt;
       
  1310     struct linger *ling;
       
  1311 #endif
  1305 #endif
  1312 
  1306 
  1313     /*
  1307     /*
  1314      * IPPROTO/IP_TOS :-
  1308      * IPPROTO/IP_TOS :-
  1315      * 1. IPv6 on Solaris/Mac OS: NOOP and will be set
  1309      * 1. IPv6 on Solaris/Mac OS: NOOP and will be set
  1477                 *bufsize = 1024;
  1471                 *bufsize = 1024;
  1478            }
  1472            }
  1479 
  1473 
  1480         }
  1474         }
  1481     }
  1475     }
  1482 
  1476 #endif
       
  1477 
       
  1478 #if defined(_ALLBSD_SOURCE) || defined(_AIX)
  1483     /*
  1479     /*
  1484      * On Solaris, SO_REUSEADDR will allow multiple datagram
  1480      * On Solaris, SO_REUSEADDR will allow multiple datagram
  1485      * sockets to bind to the same port.  The network jck tests
  1481      * sockets to bind to the same port. The network jck tests check
  1486      * for this "feature", so we need to emulate it by turning on
  1482      * for this "feature", so we need to emulate it by turning on
  1487      * SO_REUSEPORT as well for that combination.
  1483      * SO_REUSEPORT as well for that combination.
  1488      */
  1484      */
  1489     if (level == SOL_SOCKET && opt == SO_REUSEADDR) {
  1485     if (level == SOL_SOCKET && opt == SO_REUSEADDR) {
  1490         int sotype;
  1486         int sotype;
  1494         if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) < 0) {
  1490         if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) < 0) {
  1495             return -1;
  1491             return -1;
  1496         }
  1492         }
  1497 
  1493 
  1498         if (sotype == SOCK_DGRAM) {
  1494         if (sotype == SOCK_DGRAM) {
  1499             addopt = SO_REUSEPORT;
  1495             setsockopt(fd, level, SO_REUSEPORT, arg, len);
  1500             setsockopt(fd, level, addopt, arg, len);
  1496         }
  1501         }
  1497     }
  1502     }
       
  1503 
       
  1504 #endif
  1498 #endif
  1505 
  1499 
  1506     return setsockopt(fd, level, opt, arg, len);
  1500     return setsockopt(fd, level, opt, arg, len);
  1507 }
  1501 }
  1508 
  1502 
  1668         newTime = JVM_CurrentTimeMillis(env, 0);
  1662         newTime = JVM_CurrentTimeMillis(env, 0);
  1669         timeout -= (newTime - prevTime);
  1663         timeout -= (newTime - prevTime);
  1670         if (timeout <= 0) {
  1664         if (timeout <= 0) {
  1671           return read_rv > 0 ? 0 : -1;
  1665           return read_rv > 0 ? 0 : -1;
  1672         }
  1666         }
  1673         newTime = prevTime;
  1667         prevTime = newTime;
  1674 
  1668 
  1675         if (read_rv > 0) {
  1669         if (read_rv > 0) {
  1676           break;
  1670           break;
  1677         }
  1671         }
  1678 
  1672