]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
MdeModulePkg/Universal/Network/IScsiDxe/IScsiImpl.h:
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Main.h
CommitLineData
83cbd279 1/** @file\r
2\r
dfc1f033 3Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
83cbd279 4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
dfc1f033 7http://opensource.org/licenses/bsd-license.php<BR>\r
83cbd279 8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
83cbd279 12**/\r
13\r
14#ifndef _TCP4_MAIN_H_\r
15#define _TCP4_MAIN_H_\r
16\r
17#include "Socket.h"\r
18\r
19#include "Tcp4Proto.h"\r
20#include "Tcp4Driver.h"\r
21\r
22\r
23extern UINT16 mTcp4RandomPort;\r
dfc1f033 24extern CHAR16 *mTcpStateName[];\r
83cbd279 25\r
26//\r
27// Driver Produced Protocol Prototypes\r
28//\r
29\r
83cbd279 30//\r
31// Function prototype for the Tcp4 socket request handler\r
32//\r
dfc1f033 33/**\r
34 The procotol handler provided to the socket layer, used to\r
35 dispatch the socket level requests by calling the corresponding\r
36 TCP layer functions.\r
37\r
38 @param Sock Pointer to the socket of this TCP instance.\r
39 @param Request The code of this operation request.\r
40 @param Data Pointer to the operation specific data passed in\r
41 together with the operation request.\r
42\r
43 @retval EFI_SUCCESS The socket request is completed successfully.\r
44 @retval other The error status returned by the corresponding TCP\r
45 layer function.\r
46\r
47**/\r
83cbd279 48EFI_STATUS\r
49Tcp4Dispatcher (\r
50 IN SOCKET *Sock,\r
51 IN SOCK_REQUEST Request,\r
52 IN VOID *Data OPTIONAL\r
53 );\r
dfc1f033 54 \r
55///\r
56/// TCP mode data\r
57///\r
83cbd279 58typedef struct _TCP4_MODE_DATA {\r
59 EFI_TCP4_CONNECTION_STATE *Tcp4State;\r
60 EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;\r
61 EFI_IP4_MODE_DATA *Ip4ModeData;\r
62 EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;\r
63 EFI_SIMPLE_NETWORK_MODE *SnpModeData;\r
64} TCP4_MODE_DATA;\r
65\r
dfc1f033 66///\r
67/// TCP route infomation data\r
68///\r
83cbd279 69typedef struct _TCP4_ROUTE_INFO {\r
70 BOOLEAN DeleteRoute;\r
71 EFI_IPv4_ADDRESS *SubnetAddress;\r
72 EFI_IPv4_ADDRESS *SubnetMask;\r
73 EFI_IPv4_ADDRESS *GatewayAddress;\r
74} TCP4_ROUTE_INFO;\r
75\r
dfc1f033 76/**\r
77 Get the current operational status of a TCP instance.\r
78 \r
79 The GetModeData() function copies the current operational settings of this \r
80 EFI TCPv4 Protocol instance into user-supplied buffers. This function can \r
81 also be used to retrieve the operational setting of underlying drivers \r
82 such as IPv4, MNP, or SNP.\r
83\r
84 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
85 @param Tcp4State Pointer to the buffer to receive the current TCP\r
86 state.\r
87 @param Tcp4ConfigData Pointer to the buffer to receive the current TCP\r
88 configuration.\r
89 @param Ip4ModeData Pointer to the buffer to receive the current IPv4 \r
90 configuration data used by the TCPv4 instance.\r
91 @param MnpConfigData Pointer to the buffer to receive the current MNP\r
92 configuration data indirectly used by the TCPv4\r
93 Instance.\r
94 @param SnpModeData Pointer to the buffer to receive the current SNP\r
95 configuration data indirectly used by the TCPv4\r
96 Instance.\r
97\r
98 @retval EFI_SUCCESS The mode data was read.\r
99 @retval EFI_NOT_STARTED No configuration data is available because this\r
100 instance hasn't been started.\r
101 @retval EFI_INVALID_PARAMETER This is NULL.\r
102\r
103**/\r
83cbd279 104EFI_STATUS\r
105EFIAPI\r
106Tcp4GetModeData (\r
dfc1f033 107 IN CONST EFI_TCP4_PROTOCOL *This,\r
108 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,\r
109 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,\r
110 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r
111 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
112 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
83cbd279 113 );\r
114\r
dfc1f033 115\r
116/**\r
117 Initialize or brutally reset the operational parameters for\r
118 this EFI TCPv4 instance.\r
119 \r
120 The Configure() function does the following:\r
121 * Initialize this EFI TCPv4 instance, i.e., initialize the communication end \r
122 setting, specify active open or passive open for an instance.\r
123 * Reset this TCPv4 instance brutally, i.e., cancel all pending asynchronous \r
124 tokens, flush transmission and receiving buffer directly without informing \r
125 the communication peer.\r
126 No other TCPv4 Protocol operation can be executed by this instance \r
127 until it is configured properly. For an active TCP4 instance, after a proper \r
128 configuration it may call Connect() to initiates the three-way handshake. \r
129 For a passive TCP4 instance, its state will transit to Tcp4StateListen after \r
130 configuration, and Accept() may be called to listen the incoming TCP connection \r
131 request. If TcpConfigData is set to NULL, the instance is reset. Resetting \r
132 process will be done brutally, the state machine will be set to Tcp4StateClosed \r
133 directly, the receive queue and transmit queue will be flushed, and no traffic is \r
134 allowed through this instance.\r
135\r
136 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
137 @param TcpConfigData Pointer to the configure data to configure the\r
138 instance.\r
139\r
140 @retval EFI_SUCCESS The operational settings are set, changed, or\r
141 reset successfully.\r
142 @retval EFI_NO_MAPPING When using a default address, configuration\r
143 (through DHCP, BOOTP, RARP, etc.) is not\r
144 finished.\r
145 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
146 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already\r
147 configured.\r
148 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
149 @retval EFI_UNSUPPORTED One or more of the control options are not\r
150 supported in the implementation.\r
151 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.\r
152\r
153**/\r
83cbd279 154EFI_STATUS\r
155EFIAPI\r
156Tcp4Configure (\r
85511ddf 157 IN EFI_TCP4_PROTOCOL *This,\r
dfc1f033 158 IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL\r
83cbd279 159 );\r
160\r
dfc1f033 161/**\r
162 Add or delete routing entries.\r
163 \r
164 The Routes() function adds or deletes a route from the instance's routing table.\r
165 The most specific route is selected by comparing the SubnetAddress with the \r
166 destination IP address's arithmetical AND to the SubnetMask.\r
167 The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0. \r
168 The default route matches all destination IP addresses if there is no more specific route.\r
169 Direct route is added with GatewayAddress set to 0.0.0.0. Packets are sent to \r
170 the destination host if its address can be found in the Address Resolution Protocol (ARP) \r
171 cache or it is on the local subnet. If the instance is configured to use default \r
172 address, a direct route to the local network will be added automatically.\r
173 Each TCP instance has its own independent routing table. Instance that uses the \r
174 default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL's routing table. \r
175 The copy will be updated automatically whenever the IP driver reconfigures its \r
176 instance. As a result, the previous modification to the instance's local copy \r
177 will be lost. The priority of checking the route table is specific with IP \r
178 implementation and every IP implementation must comply with RFC 1122.\r
179\r
180 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
181 @param DeleteRoute If TRUE, delete the specified route from routing\r
182 table; if FALSE, add the specified route to\r
183 routing table.\r
184 DestinationAddress and SubnetMask are used as \r
185 the keywords to search route entry.\r
186 @param SubnetAddress The destination network.\r
187 @param SubnetMask The subnet mask for the destination network.\r
188 @param GatewayAddress The gateway address for this route. \r
189 It must be on the same subnet with the station \r
190 address unless a direct route is specified.\r
191 \r
192 @retval EFI_SUCCESS The operation completed successfully.\r
193 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been\r
194 configured.\r
195 @retval EFI_NO_MAPPING When using a default address, configuration\r
196 (through DHCP, BOOTP, RARP, etc.) is not\r
197 finished.\r
198 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
199 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the\r
200 entry to the routing table.\r
201 @retval EFI_NOT_FOUND This route is not in the routing table.\r
202 @retval EFI_ACCESS_DENIED This route is already in the routing table.\r
203 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.\r
204\r
205**/\r
83cbd279 206EFI_STATUS\r
207EFIAPI\r
208Tcp4Routes (\r
209 IN EFI_TCP4_PROTOCOL *This,\r
210 IN BOOLEAN DeleteRoute,\r
211 IN EFI_IPv4_ADDRESS *SubnetAddress,\r
212 IN EFI_IPv4_ADDRESS *SubnetMask,\r
213 IN EFI_IPv4_ADDRESS *GatewayAddress\r
214 );\r
215\r
dfc1f033 216/**\r
217 Initiate a nonblocking TCP connection request for an active TCP instance.\r
218\r
219 The Connect() function will initiate an active open to the remote peer configured \r
220 in current TCP instance if it is configured active. If the connection succeeds \r
221 or fails due to any error, the ConnectionToken->CompletionToken.Event will be \r
222 signaled and ConnectionToken->CompletionToken.Status will be updated accordingly. \r
223 This function can only be called for the TCP instance in Tcp4StateClosed state. \r
224 The instance will transfer into Tcp4StateSynSent if the function returns EFI_SUCCESS. \r
225 If TCP three way handshake succeeds, its state will become Tcp4StateEstablished, \r
226 otherwise, the state will return to Tcp4StateClosed.\r
227 \r
228 @param This Pointer to the EFI_TCP4_PROTOCOL instance\r
229 @param ConnectionToken Pointer to the connection token to return when\r
230 the TCP three way handshake finishes.\r
231\r
232 @retval EFI_SUCCESS The connection request is successfully initiated \r
233 and the state of this TCPv4 instance has \r
234 been changed to Tcp4StateSynSent.\r
235 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been\r
236 configured.\r
237 @retval EFI_ACCESS_DENIED The instance is not configured as an active one\r
238 or it is not in Tcp4StateClosed state.\r
239 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
240 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to\r
241 initiate the active open.\r
242 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
243\r
244**/\r
83cbd279 245EFI_STATUS\r
246EFIAPI\r
247Tcp4Connect (\r
248 IN EFI_TCP4_PROTOCOL *This,\r
249 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken\r
250 );\r
251\r
dfc1f033 252/**\r
253 Listen on the passive instance to accept an incoming connection request.\r
254\r
255 The Accept() function initiates an asynchronous accept request to wait for an \r
256 incoming connection on the passive TCP instance. If a remote peer successfully \r
257 establishes a connection with this instance, a new TCP instance will be created \r
258 and its handle will be returned in ListenToken->NewChildHandle. The newly created \r
259 instance is configured by inheriting the passive instance's configuration and is \r
260 ready for use upon return. The instance is in the Tcp4StateEstablished state.\r
261 The ListenToken->CompletionToken.Event will be signaled when a new connection \r
262 is accepted, user aborts the listen or connection is reset. This function only \r
263 can be called when current TCP instance is in Tcp4StateListen state.\r
264\r
265 @param This Pointer to the EFI_TCP4_PROTOCOL instance\r
266 @param ListenToken Pointer to the listen token to return when\r
267 operation finishes.\r
268\r
269 @retval EFI_SUCCESS The listen token has been queued successfully.\r
270 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
271 configured.\r
272 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not\r
273 in Tcp4StateListen state or a same listen token\r
274 has already existed in the listen token queue of\r
275 this TCP instance.\r
276 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
277 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish\r
278 the operation.\r
279 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.\r
280\r
281**/\r
83cbd279 282EFI_STATUS\r
283EFIAPI\r
284Tcp4Accept (\r
285 IN EFI_TCP4_PROTOCOL *This,\r
286 IN EFI_TCP4_LISTEN_TOKEN *ListenToken\r
287 );\r
288\r
dfc1f033 289/**\r
290 Queues outgoing data into the transmit queue.\r
291\r
292 The Transmit() function queues a sending request to this TCPv4 instance along \r
293 with the user data. The status of the token is updated and the event in the token \r
294 will be signaled once the data is sent out or some error occurs.\r
295\r
296 @param This Pointer to the EFI_TCP4_PROTOCOL instance\r
297 @param Token Pointer to the completion token to queue to the\r
298 transmit queue\r
299\r
300 @retval EFI_SUCCESS The data has been queued for transmission.\r
301 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
302 configured.\r
303 @retval EFI_NO_MAPPING When using a default address, configuration\r
304 (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
305 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
306 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
307 * A transmit completion token with the same\r
308 Token-> CompletionToken.Event was already in the\r
309 transmission queue. \r
310 * The current instance is in Tcp4StateClosed state \r
311 * The current instance is a passive one and \r
312 it is in Tcp4StateListen state. \r
313 * User has called Close() to disconnect this \r
314 connection.\r
315 @retval EFI_NOT_READY The completion token could not be queued because\r
316 the transmit queue is full.\r
317 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of\r
318 resource shortage.\r
319 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or\r
320 address.\r
321\r
322**/\r
83cbd279 323EFI_STATUS\r
324EFIAPI\r
325Tcp4Transmit (\r
326 IN EFI_TCP4_PROTOCOL *This,\r
327 IN EFI_TCP4_IO_TOKEN *Token\r
328 );\r
329\r
dfc1f033 330/**\r
331 Place an asynchronous receive request into the receiving queue.\r
332\r
333 The Receive() function places a completion token into the receive packet queue. \r
334 This function is always asynchronous. The caller must allocate the \r
335 Token->CompletionToken.Event and the FragmentBuffer used to receive data. He also \r
336 must fill the DataLength which represents the whole length of all FragmentBuffer. \r
337 When the receive operation completes, the EFI TCPv4 Protocol driver updates the \r
338 Token->CompletionToken.Status and Token->Packet.RxData fields and the \r
339 Token->CompletionToken.Event is signaled. If got data the data and its length \r
340 will be copy into the FragmentTable, in the same time the full length of received \r
341 data will be recorded in the DataLength fields. Providing a proper notification \r
342 function and context for the event will enable the user to receive the notification \r
343 and receiving status. That notification function is guaranteed to not be re-entered.\r
344\r
345 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
346 @param Token Pointer to a token that is associated with the\r
347 receive data descriptor.\r
348\r
349 @retval EFI_SUCCESS The receive completion token was cached.\r
350 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
351 configured.\r
352 @retval EFI_NO_MAPPING When using a default address, configuration\r
353 (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
354 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
355 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued\r
356 due to a lack of system resources.\r
357 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
358 The EFI TCPv4 Protocol instance has been reset \r
359 to startup defaults.\r
360 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
361 * A receive completion token with the same\r
362 Token->CompletionToken.Event was already in \r
363 the receive queue. \r
364 * The current instance is in Tcp4StateClosed state. \r
365 * The current instance is a passive one and it \r
366 is in Tcp4StateListen state. \r
367 * User has called Close() to disconnect this \r
368 connection.\r
369 @retval EFI_CONNECTION_FIN The communication peer has closed the connection\r
370 and there is no any buffered data in the receive\r
371 buffer of this instance.\r
372 @retval EFI_NOT_READY The receive request could not be queued because\r
373 the receive queue is full.\r
374\r
375**/\r
83cbd279 376EFI_STATUS\r
85511ddf 377EFIAPI\r
83cbd279 378Tcp4Receive (\r
379 IN EFI_TCP4_PROTOCOL *This,\r
380 IN EFI_TCP4_IO_TOKEN *Token\r
381 );\r
382\r
dfc1f033 383/**\r
384 Disconnecting a TCP connection gracefully or reset a TCP connection.\r
385\r
386 Initiate an asynchronous close token to TCP driver. After Close() is called, \r
387 any buffered transmission data will be sent by TCP driver and the current \r
388 instance will have a graceful close working flow described as RFC 793 if \r
389 AbortOnClose is set to FALSE, otherwise, a rest packet will be sent by TCP \r
390 driver to fast disconnect this connection. When the close operation completes \r
391 successfully the TCP instance is in Tcp4StateClosed state, all pending \r
392 asynchronous operation is signaled and any buffers used for TCP network traffic \r
393 is flushed.\r
394\r
395 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
396 @param CloseToken Pointer to the close token to return when\r
397 operation finishes.\r
398\r
399 @retval EFI_SUCCESS The operation completed successfully.\r
400 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
401 configured.\r
402 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: \r
403 * Configure() has been called with TcpConfigData\r
404 set to NULL and this function has not returned.\r
405 * Previous Close() call on this instance has not\r
406 finished.\r
407 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.\r
408 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the\r
409 operation.\r
410 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above\r
411 category error.\r
412\r
413**/\r
83cbd279 414EFI_STATUS\r
415EFIAPI\r
416Tcp4Close (\r
417 IN EFI_TCP4_PROTOCOL *This,\r
418 IN EFI_TCP4_CLOSE_TOKEN *CloseToken\r
419 );\r
420\r
dfc1f033 421/**\r
422 Abort an asynchronous connection, listen, transmission or receive request.\r
423\r
424 The Cancel() function aborts a pending connection, listen, transmit or receive \r
425 request. If Token is not NULL and the token is in the connection, listen, \r
426 transmission or receive queue when it is being cancelled, its Token->Status \r
427 will be set to EFI_ABORTED and then Token->Event will be signaled. If the token \r
428 is not in one of the queues, which usually means that the asynchronous operation \r
429 has completed, EFI_NOT_FOUND is returned. If Token is NULL all asynchronous token \r
430 issued by Connect(), Accept(), Transmit() and Receive()will be aborted.\r
431 NOTE: It has not been implemented currently.\r
432 \r
433 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
434 @param Token Pointer to a token that has been issued by\r
435 Connect(), Accept(), Transmit() or Receive(). If\r
436 NULL, all pending tokens issued by above four\r
437 functions will be aborted.\r
438 \r
439 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r
440 is signaled.\r
441 @retval EFI_INVALID_PARAMETER This is NULL.\r
442 @retval EFI_NOT_STARTED This instance hasn's been configured.\r
443 @retval EFI_NO_MAPPING When using the default address, configuration\r
444 (DHCP, BOOTP,RARP, etc.) hasn's finished yet.\r
445 @retval EFI_NOT_FOUND The asynchronous I/O request isn's found in the \r
446 transmission or receive queue. It has either \r
447 completed or wasn's issued by Transmit() and Receive().\r
448 @retval EFI_UNSUPPORTED The operation is not supported in current\r
449 implementation.\r
450 \r
451**/\r
83cbd279 452EFI_STATUS\r
453EFIAPI\r
454Tcp4Cancel (\r
85511ddf 455 IN EFI_TCP4_PROTOCOL *This,\r
dfc1f033 456 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL\r
83cbd279 457 );\r
458\r
dfc1f033 459/**\r
460 Poll to receive incoming data and transmit outgoing segments.\r
461\r
462 The Poll() function increases the rate that data is moved between the network \r
463 and application and can be called when the TCP instance is created successfully. \r
464 Its use is optional. In some implementations, the periodical timer in the MNP \r
465 driver may not poll the underlying communications device fast enough to avoid \r
466 drop packets. Drivers and applications that are experiencing packet loss should \r
467 try calling the Poll() function in a high frequency.\r
468\r
469 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
470\r
471 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
472 @retval EFI_INVALID_PARAMETER This is NULL.\r
473 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
474 @retval EFI_NOT_READY No incoming or outgoing data was processed.\r
475 @retval EFI_TIMEOUT Data was dropped out of the transmission or\r
476 receive queue. Consider increasing the polling\r
477 rate.\r
478\r
479**/\r
83cbd279 480EFI_STATUS\r
481EFIAPI\r
482Tcp4Poll (\r
483 IN EFI_TCP4_PROTOCOL *This\r
484 );\r
485\r
486#endif\r