src/share/classes/sun/nio/ch/Net.java

Print this page
rev 7398 : 8032808: Support Solaris SO_FLOW_SLA socket option
Reviewed-by: michaelm
rev 7400 : 8029607: Type of Service (TOS) cannot be set in IPv6 header
Reviewed-by: alanb

*** 25,39 **** --- 25,41 ---- package sun.nio.ch; import java.io.*; import java.net.*; + import jdk.net.*; import java.nio.channels.*; import java.util.*; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; + import sun.net.ExtendedOptionsImpl; class Net { // package-private private Net() { }
*** 325,334 **** --- 327,346 ---- if (value == null) throw new IllegalArgumentException("Invalid option value"); // only simple values supported by this method Class<?> type = name.type(); + + if (type == SocketFlow.class) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new NetworkPermission("setOption.SO_FLOW_SLA")); + } + ExtendedOptionsImpl.setFlowOption(fd, (SocketFlow)value); + return; + } + if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); // special handling if (name == StandardSocketOptions.SO_RCVBUF ||
*** 368,386 **** boolean b = ((Boolean)value).booleanValue(); arg = (b) ? 1 : 0; } boolean mayNeedConversion = (family == UNSPEC); ! setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg); } static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, SocketOption<?> name) throws IOException { Class<?> type = name.type(); // only simple values supported by this method if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); // map option name to platform level/name --- 380,409 ---- boolean b = ((Boolean)value).booleanValue(); arg = (b) ? 1 : 0; } boolean mayNeedConversion = (family == UNSPEC); ! boolean isIPv6 = (family == StandardProtocolFamily.INET6); ! setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg, isIPv6); } static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, SocketOption<?> name) throws IOException { Class<?> type = name.type(); + if (type == SocketFlow.class) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA")); + } + SocketFlow flow = SocketFlow.create(); + ExtendedOptionsImpl.getFlowOption(fd, flow); + return flow; + } + // only simple values supported by this method if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); // map option name to platform level/name
*** 505,515 **** private static native int getIntOption0(FileDescriptor fd, boolean mayNeedConversion, int level, int opt) throws IOException; private static native void setIntOption0(FileDescriptor fd, boolean mayNeedConversion, ! int level, int opt, int arg) throws IOException; // -- Multicast support -- --- 528,538 ---- private static native int getIntOption0(FileDescriptor fd, boolean mayNeedConversion, int level, int opt) throws IOException; private static native void setIntOption0(FileDescriptor fd, boolean mayNeedConversion, ! int level, int opt, int arg, boolean isIPv6) throws IOException; // -- Multicast support --