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 |
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 |