OSDN Git Service

Integrate luni module (but not tests) to Harmony r772995.
[android-x86/dalvik.git] / libcore / luni / src / main / java / org / apache / harmony / luni / platform / INetworkSystem.java
1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17
18 // BEGIN android-note
19 // address length was changed from long to int for performance reasons.
20 // END android-note
21
22 package org.apache.harmony.luni.platform;
23
24 import java.io.FileDescriptor;
25 import java.io.IOException;
26 import java.net.DatagramPacket;
27 import java.net.InetAddress;
28 import java.net.SocketException;
29 import java.net.SocketImpl;
30 import java.net.UnknownHostException;
31 import java.nio.channels.Channel;
32
33 /*
34  * The interface for network methods.
35  */
36 public interface INetworkSystem {
37
38     /*
39      * Socket connect Step start
40      */
41     public final int SOCKET_CONNECT_STEP_START = 0;
42
43     /*
44      * Socket connect Step check
45      */
46     public final int SOCKET_CONNECT_STEP_CHECK = 1;
47
48     /*
49      * socket accept
50      */
51     public void accept(FileDescriptor fdServer, SocketImpl newSocket,
52             FileDescriptor fdnewSocket, int timeout) throws IOException;
53
54     public void bind(FileDescriptor aFD, InetAddress inetAddress, int port)
55             throws SocketException;
56
57     public int read(FileDescriptor aFD, byte[] data, int offset, int count,
58             int timeout) throws IOException;
59
60     public int readDirect(FileDescriptor aFD, int address, int offset, int count,
61             int timeout) throws IOException;
62
63     public int write(FileDescriptor fd, byte[] data, int offset, int count)
64             throws IOException;
65
66     public int writeDirect(FileDescriptor fd, int address, int offset, int count)
67             throws IOException;
68
69     public void setNonBlocking(FileDescriptor aFD, boolean block)
70             throws IOException;
71
72     public int connect(FileDescriptor aFD, int trafficClass,
73             InetAddress inetAddress, int port) throws IOException;
74
75     // BEGIN android-changed
76     public int connectWithTimeout(FileDescriptor aFD, int timeout,
77             int trafficClass, InetAddress hostname, int port, int step,
78             byte[] context) throws IOException;
79     // END android-changed
80
81     public int sendDatagram(FileDescriptor fd, byte[] data, int offset,
82             int length, int port, boolean bindToDevice, int trafficClass,
83             InetAddress inetAddress) throws IOException;
84
85     public int sendDatagramDirect(FileDescriptor fd, int address, int offset,
86             int length, int port, boolean bindToDevice, int trafficClass,
87             InetAddress inetAddress) throws IOException;
88
89     public int receiveDatagram(FileDescriptor aFD, DatagramPacket packet,
90             byte[] data, int offset, int length, int receiveTimeout,
91             boolean peek) throws IOException;
92
93     public int receiveDatagramDirect(FileDescriptor aFD, DatagramPacket packet,
94             int address, int offset, int length, int receiveTimeout,
95             boolean peek) throws IOException;
96
97     public int recvConnectedDatagram(FileDescriptor aFD, DatagramPacket packet,
98             byte[] data, int offset, int length, int receiveTimeout,
99             boolean peek) throws IOException;
100
101     public int recvConnectedDatagramDirect(FileDescriptor aFD,
102             DatagramPacket packet, int address, int offset, int length,
103             int receiveTimeout, boolean peek) throws IOException;
104
105     public int peekDatagram(FileDescriptor aFD, InetAddress sender,
106             int receiveTimeout) throws IOException;
107
108     public int sendConnectedDatagram(FileDescriptor fd, byte[] data,
109             int offset, int length, boolean bindToDevice) throws IOException;
110
111     public int sendConnectedDatagramDirect(FileDescriptor fd, int address,
112             int offset, int length, boolean bindToDevice) throws IOException;
113
114     public void disconnectDatagram(FileDescriptor aFD) throws SocketException;
115
116     public void createDatagramSocket(FileDescriptor aFD, boolean preferIPv4Stack)
117             throws SocketException;
118
119     public void connectDatagram(FileDescriptor aFD, int port, int trafficClass,
120             InetAddress inetAddress) throws SocketException;
121
122     /**
123      * @deprecated Use {@link #read(FileDescriptor, byte[], int, int, int)}
124      */
125     @Deprecated
126     public int receiveStream(FileDescriptor aFD, byte[] data, int offset,
127             int count, int timeout) throws IOException;
128
129     // BEGIN android-added
130     public int sendStream(FileDescriptor fd, byte[] data, int offset, int count)
131             throws IOException;
132     // END android-added
133
134     public void shutdownInput(FileDescriptor descriptor) throws IOException;
135
136     public void shutdownOutput(FileDescriptor descriptor) throws IOException;
137
138     public boolean supportsUrgentData(FileDescriptor fd);
139
140     public void sendUrgentData(FileDescriptor fd, byte value);
141
142     public int availableStream(FileDescriptor aFD) throws SocketException;
143
144     // BEGIN android-removed
145     // public void acceptStreamSocket(FileDescriptor fdServer,
146     //         SocketImpl newSocket, FileDescriptor fdnewSocket, int timeout)
147     //         throws IOException;
148     // END android-removed
149
150     public void createServerStreamSocket(FileDescriptor aFD, boolean preferIPv4Stack)
151             throws SocketException;
152
153     public void createStreamSocket(FileDescriptor aFD, boolean preferIPv4Stack)
154             throws SocketException;
155
156     public void listenStreamSocket(FileDescriptor aFD, int backlog)
157             throws SocketException;
158
159     public void connectStreamWithTimeoutSocket(FileDescriptor aFD, int aport,
160             int timeout, int trafficClass, InetAddress inetAddress)
161             throws IOException;
162
163     public int sendDatagram2(FileDescriptor fd, byte[] data, int offset,
164             int length, int port, InetAddress inetAddress) throws IOException;
165
166     public InetAddress getSocketLocalAddress(FileDescriptor aFD,
167             boolean preferIPv6Addresses);
168
169     public int[] select(FileDescriptor[] readFDs,
170             FileDescriptor[] writeFDs, long timeout)
171             throws SocketException;
172
173     /*
174      * Query the IP stack for the local port to which this socket is bound.
175      *
176      * @param aFD the socket descriptor @param preferIPv6Addresses address
177      * preference for nodes that support both IPv4 and IPv6 @return int the
178      * local port to which the socket is bound
179      */
180     public int getSocketLocalPort(FileDescriptor aFD,
181             boolean preferIPv6Addresses);
182
183     /*
184      * Query the IP stack for the nominated socket option.
185      *
186      * @param aFD the socket descriptor @param opt the socket option type
187      * @return the nominated socket option value
188      *
189      * @throws SocketException if the option is invalid
190      */
191     public Object getSocketOption(FileDescriptor aFD, int opt)
192             throws SocketException;
193
194     /*
195      * Set the nominated socket option in the IP stack.
196      *
197      * @param aFD the socket descriptor @param opt the option selector @param
198      * optVal the nominated option value
199      *
200      * @throws SocketException if the option is invalid or cannot be set
201      */
202     public void setSocketOption(FileDescriptor aFD, int opt, Object optVal)
203             throws SocketException;
204
205     public int getSocketFlags();
206
207     /*
208      * Close the socket in the IP stack.
209      *
210      * @param aFD the socket descriptor
211      */
212     public void socketClose(FileDescriptor aFD) throws IOException;
213
214     public InetAddress getHostByAddr(byte[] addr) throws UnknownHostException;
215
216     public InetAddress getHostByName(String addr, boolean preferIPv6Addresses)
217             throws UnknownHostException;
218
219     public void setInetAddress(InetAddress sender, byte[] address);
220     
221     // BEGIN android-removed
222     // public boolean isReachableByICMP(InetAddress dest,InetAddress source,int ttl,int timeout);
223     // END android-removed
224
225     public Channel inheritedChannel();
226
227     public void oneTimeInitialization(boolean jcl_supports_ipv6);
228 }