1 /* 2 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.net; 27 28 import java.net.InetAddress; 29 import java.io.FileDescriptor; 30 import java.io.IOException; 31 import java.security.AccessController; 32 import java.security.PrivilegedAction; 33 import sun.security.action.GetPropertyAction; 34 35 /** 36 * Defines static methods to be invoked prior to binding or connecting TCP sockets. 37 */ 38 39 public final class NetHooks { 40 41 // Android-removed: No SDP support. 42 // /** 43 // * A provider with hooks to allow sockets be converted prior to binding or 44 // * connecting a TCP socket. 45 // * 46 // * <p> Concrete implementations of this class should define a zero-argument 47 // * constructor and implement the abstract methods specified below. 48 // */ 49 // public static abstract class Provider { 50 // /** 51 // * Initializes a new instance of this class. 52 // */ 53 // protected Provider() {} 54 // 55 // /** 56 // * Invoked prior to binding a TCP socket. 57 // */ 58 // public abstract void implBeforeTcpBind(FileDescriptor fdObj, 59 // InetAddress address, 60 // int port) 61 // throws IOException; 62 // 63 // /** 64 // * Invoked prior to connecting an unbound TCP socket. 65 // */ 66 // public abstract void implBeforeTcpConnect(FileDescriptor fdObj, 67 // InetAddress address, 68 // int port) 69 // throws IOException; 70 // } 71 72 /** 73 * For now, we load the SDP provider on Solaris. In the future this may 74 * be changed to use the ServiceLoader facility to allow the deployment of 75 * other providers. 76 */ 77 // Android-removed: No SDP support 78 // private static final Provider provider = new sun.net.sdp.SdpProvider(); 79 80 /** 81 * Invoke prior to binding a TCP socket. 82 */ beforeTcpBind(FileDescriptor fdObj, InetAddress address, int port)83 public static void beforeTcpBind(FileDescriptor fdObj, 84 InetAddress address, 85 int port) 86 throws IOException 87 { 88 // Android-removed: No SDP support 89 // provider.implBeforeTcpBind(fdObj, address, port); 90 } 91 92 /** 93 * Invoke prior to connecting an unbound TCP socket. 94 */ beforeTcpConnect(FileDescriptor fdObj, InetAddress address, int port)95 public static void beforeTcpConnect(FileDescriptor fdObj, 96 InetAddress address, 97 int port) 98 throws IOException 99 { 100 // Android-removed: No SDP support 101 // provider.implBeforeTcpConnect(fdObj, address, port); 102 } 103 } 104