1040N/A/*
3261N/A * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
1040N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1040N/A *
1040N/A * This code is free software; you can redistribute it and/or modify it
1040N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
1040N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
1040N/A *
1040N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1040N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1040N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1040N/A * version 2 for more details (a copy is included in the LICENSE file that
1040N/A * accompanied this code).
1040N/A *
1040N/A * You should have received a copy of the GNU General Public License version
1040N/A * 2 along with this work; if not, write to the Free Software Foundation,
1040N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1040N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1040N/A */
1040N/A
1040N/Apackage sun.net;
1040N/A
1040N/Aimport java.net.InetAddress;
1040N/Aimport java.io.FileDescriptor;
1040N/Aimport java.io.IOException;
1040N/Aimport java.security.AccessController;
1040N/Aimport java.security.PrivilegedAction;
1040N/Aimport sun.security.action.GetPropertyAction;
1040N/A
1040N/A/**
1040N/A * Defines static methods to be invoked prior to binding or connecting TCP sockets.
1040N/A */
1040N/A
1040N/Apublic final class NetHooks {
1040N/A
1040N/A /**
1040N/A * A provider with hooks to allow sockets be converted prior to binding or
1040N/A * connecting a TCP socket.
1040N/A *
1040N/A * <p> Concrete implementations of this class should define a zero-argument
1040N/A * constructor and implement the abstract methods specified below.
1040N/A */
1040N/A public static abstract class Provider {
1040N/A /**
1040N/A * Initializes a new instance of this class.
1040N/A */
1040N/A protected Provider() {}
1040N/A
1040N/A /**
1040N/A * Invoked prior to binding a TCP socket.
1040N/A */
1040N/A public abstract void implBeforeTcpBind(FileDescriptor fdObj,
1040N/A InetAddress address,
1040N/A int port)
1040N/A throws IOException;
1040N/A
1040N/A /**
1040N/A * Invoked prior to connecting an unbound TCP socket.
1040N/A */
1040N/A public abstract void implBeforeTcpConnect(FileDescriptor fdObj,
1040N/A InetAddress address,
1040N/A int port)
1040N/A throws IOException;
1040N/A }
1040N/A
1040N/A /**
1040N/A * For now, we load the SDP provider on Solaris. In the future this may
1040N/A * be changed to use the ServiceLoader facility to allow the deployment of
1040N/A * other providers.
1040N/A */
2736N/A private static final Provider provider = new sun.net.sdp.SdpProvider();
1040N/A
1040N/A /**
1040N/A * Invoke prior to binding a TCP socket.
1040N/A */
1040N/A public static void beforeTcpBind(FileDescriptor fdObj,
1040N/A InetAddress address,
1040N/A int port)
1040N/A throws IOException
1040N/A {
2736N/A provider.implBeforeTcpBind(fdObj, address, port);
1040N/A }
1040N/A
1040N/A /**
1040N/A * Invoke prior to connecting an unbound TCP socket.
1040N/A */
1040N/A public static void beforeTcpConnect(FileDescriptor fdObj,
1040N/A InetAddress address,
1040N/A int port)
1040N/A throws IOException
1040N/A {
2736N/A provider.implBeforeTcpConnect(fdObj, address, port);
1040N/A }
1040N/A}