• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: Android doesn't support Session Description Protocol (SDP).
42     /*
43     /**
44      * A provider with hooks to allow sockets be converted prior to binding or
45      * connecting a TCP socket.
46      *
47      * <p> Concrete implementations of this class should define a zero-argument
48      * constructor and implement the abstract methods specified below.
49      *
50     public static abstract class Provider {
51         /**
52          * Initializes a new instance of this class.
53          *
54         protected Provider() {}
55 
56         /**
57          * Invoked prior to binding a TCP socket.
58          *
59         public abstract void implBeforeTcpBind(FileDescriptor fdObj,
60                                                InetAddress address,
61                                                int port)
62             throws IOException;
63 
64         /**
65          * Invoked prior to connecting an unbound TCP socket.
66          *
67         public abstract void implBeforeTcpConnect(FileDescriptor fdObj,
68                                                  InetAddress address,
69                                                  int port)
70             throws IOException;
71     }
72     */
73 
74     /**
75      * For now, we load the SDP provider on Solaris. In the future this may
76      * be changed to use the ServiceLoader facility to allow the deployment of
77      * other providers.
78      */
79     // Android-removed: Android doesn't support Session Description Protocol (SDP).
80     // private static final Provider provider = new sun.net.sdp.SdpProvider();
81 
82     /**
83      * Invoke prior to binding a TCP socket.
84      */
beforeTcpBind(FileDescriptor fdObj, InetAddress address, int port)85     public static void beforeTcpBind(FileDescriptor fdObj,
86                                      InetAddress address,
87                                      int port)
88         throws IOException
89     {
90         // Android-removed: Android doesn't support Session Description Protocol (SDP).
91         // provider.implBeforeTcpBind(fdObj, address, port);
92     }
93 
94     /**
95      * Invoke prior to connecting an unbound TCP socket.
96      */
beforeTcpConnect(FileDescriptor fdObj, InetAddress address, int port)97     public static void beforeTcpConnect(FileDescriptor fdObj,
98                                         InetAddress address,
99                                         int port)
100         throws IOException
101     {
102         // Android-removed: No SDP support
103         // provider.implBeforeTcpConnect(fdObj, address, port);
104     }
105 }
106