comparison src/solaris/native/java/net/PlainDatagramSocketImpl.c @ 5398:979c364ea1f1

7191275: Cleanup OS specific blocks in PlainDatagramSocketImpl.c to support more unix-like platforms Reviewed-by: chegar
author dingxmin
date Fri, 17 Aug 2012 17:10:56 +0800
parents 99cc5c9ef200
children a48da818ed65
comparison
equal deleted inserted replaced
15:76aa3551fdf4 16:1ccdaff48d7c
1348 if (opt == java_net_SocketOptions_IP_MULTICAST_IF) { 1348 if (opt == java_net_SocketOptions_IP_MULTICAST_IF) {
1349 /* 1349 /*
1350 * value is an InetAddress. 1350 * value is an InetAddress.
1351 */ 1351 */
1352 #ifdef AF_INET6 1352 #ifdef AF_INET6
1353 #if defined(__solaris__) || defined(MACOSX) 1353 #ifdef __linux__
1354 mcast_set_if_by_addr_v4(env, this, fd, value);
1355 if (ipv6_available()) {
1356 mcast_set_if_by_addr_v6(env, this, fd, value);
1357 }
1358 #else /* __linux__ not defined */
1354 if (ipv6_available()) { 1359 if (ipv6_available()) {
1355 mcast_set_if_by_addr_v6(env, this, fd, value); 1360 mcast_set_if_by_addr_v6(env, this, fd, value);
1356 } else { 1361 } else {
1357 mcast_set_if_by_addr_v4(env, this, fd, value); 1362 mcast_set_if_by_addr_v4(env, this, fd, value);
1358 } 1363 }
1359 #endif 1364 #endif /* __linux__ */
1360 #ifdef __linux__
1361 mcast_set_if_by_addr_v4(env, this, fd, value);
1362 if (ipv6_available()) {
1363 mcast_set_if_by_addr_v6(env, this, fd, value);
1364 }
1365 #endif
1366 #else 1365 #else
1367 mcast_set_if_by_addr_v4(env, this, fd, value); 1366 mcast_set_if_by_addr_v4(env, this, fd, value);
1368 #endif /* AF_INET6 */ 1367 #endif /* AF_INET6 */
1369 } 1368 }
1370 1369
1371 if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) { 1370 if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) {
1372 /* 1371 /*
1373 * value is a NetworkInterface. 1372 * value is a NetworkInterface.
1374 */ 1373 */
1375 #ifdef AF_INET6 1374 #ifdef AF_INET6
1376 #if defined(__solaris__) || defined(MACOSX) 1375 #ifdef __linux__
1376 mcast_set_if_by_if_v4(env, this, fd, value);
1377 if (ipv6_available()) {
1378 mcast_set_if_by_if_v6(env, this, fd, value);
1379 }
1380 #else /* __linux__ not defined */
1377 if (ipv6_available()) { 1381 if (ipv6_available()) {
1378 mcast_set_if_by_if_v6(env, this, fd, value); 1382 mcast_set_if_by_if_v6(env, this, fd, value);
1379 } else { 1383 } else {
1380 mcast_set_if_by_if_v4(env, this, fd, value); 1384 mcast_set_if_by_if_v4(env, this, fd, value);
1381 } 1385 }
1382 #endif 1386 #endif /* __linux__ */
1383 #ifdef __linux__
1384 mcast_set_if_by_if_v4(env, this, fd, value);
1385 if (ipv6_available()) {
1386 mcast_set_if_by_if_v6(env, this, fd, value);
1387 }
1388 #endif
1389 #else 1387 #else
1390 mcast_set_if_by_if_v4(env, this, fd, value); 1388 mcast_set_if_by_if_v4(env, this, fd, value);
1391 #endif /* AF_INET6 */ 1389 #endif /* AF_INET6 */
1392 } 1390 }
1393 } 1391 }
1454 * Sets the multicast loopback mode. 1452 * Sets the multicast loopback mode.
1455 */ 1453 */
1456 static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, 1454 static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
1457 jint opt, jobject value) { 1455 jint opt, jobject value) {
1458 #ifdef AF_INET6 1456 #ifdef AF_INET6
1459 #if defined(__solaris__) || defined(MACOSX) 1457 #ifdef __linux__
1458 mcast_set_loop_v4(env, this, fd, value);
1459 if (ipv6_available()) {
1460 mcast_set_loop_v6(env, this, fd, value);
1461 }
1462 #else /* __linux__ not defined */
1460 if (ipv6_available()) { 1463 if (ipv6_available()) {
1461 mcast_set_loop_v6(env, this, fd, value); 1464 mcast_set_loop_v6(env, this, fd, value);
1462 } else { 1465 } else {
1463 mcast_set_loop_v4(env, this, fd, value); 1466 mcast_set_loop_v4(env, this, fd, value);
1464 } 1467 }
1465 #endif 1468 #endif /* __linux__ */
1466 #ifdef __linux__
1467 mcast_set_loop_v4(env, this, fd, value);
1468 if (ipv6_available()) {
1469 mcast_set_loop_v6(env, this, fd, value);
1470 }
1471 #endif
1472 #else 1469 #else
1473 mcast_set_loop_v4(env, this, fd, value); 1470 mcast_set_loop_v4(env, this, fd, value);
1474 #endif /* AF_INET6 */ 1471 #endif /* AF_INET6 */
1475 } 1472 }
1476 1473
2028 } else { 2025 } else {
2029 fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); 2026 fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
2030 } 2027 }
2031 /* setsockopt to be correct ttl */ 2028 /* setsockopt to be correct ttl */
2032 #ifdef AF_INET6 2029 #ifdef AF_INET6
2033 #if defined(__solaris__) || defined(MACOSX)
2034 if (ipv6_available()) {
2035 setHopLimit(env, fd, ttl);
2036 } else {
2037 setTTL(env, fd, ttl);
2038 }
2039 #endif
2040 #ifdef __linux__ 2030 #ifdef __linux__
2041 setTTL(env, fd, ttl); 2031 setTTL(env, fd, ttl);
2042 if (ipv6_available()) { 2032 if (ipv6_available()) {
2043 setHopLimit(env, fd, ttl); 2033 setHopLimit(env, fd, ttl);
2044 if (isOldKernel) { 2034 if (isOldKernel) {
2045 (*env)->SetIntField(env, this, pdsi_ttlID, ttl); 2035 (*env)->SetIntField(env, this, pdsi_ttlID, ttl);
2046 } 2036 }
2047 } 2037 }
2048 #endif // __linux__ 2038 #else /* __linux__ not defined */
2039 if (ipv6_available()) {
2040 setHopLimit(env, fd, ttl);
2041 } else {
2042 setTTL(env, fd, ttl);
2043 }
2044 #endif /* __linux__ */
2049 #else 2045 #else
2050 setTTL(env, fd, ttl); 2046 setTTL(env, fd, ttl);
2051 #endif /* AF_INET6 */ 2047 #endif /* AF_INET6 */
2052 } 2048 }
2053 2049