]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Tcp4.h
04b8c92696d321f8a1353a101c5248f8d01ae688
[mirror_edk2.git] / MdePkg / Include / Protocol / Tcp4.h
1 /** @file
2 EFI TCPv4 Protocol Definition
3 The EFI TCPv4 Service Binding Protocol is used to locate EFI TCPv4 Protocol drivers to create
4 and destroy child of the driver to communicate with other host using TCP protocol.
5 The EFI TCPv4 Protocol provides services to send and receive data stream.
6
7 Copyright (c) 2006 - 2008, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __EFI_TCP4_PROTOCOL_H__
19 #define __EFI_TCP4_PROTOCOL_H__
20
21 #include <Protocol/Ip4.h>
22
23 #define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \
24 { \
25 0x00720665, 0x67EB, 0x4a99, {0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } \
26 }
27
28 #define EFI_TCP4_PROTOCOL_GUID \
29 { \
30 0x65530BC7, 0xA359, 0x410f, {0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } \
31 }
32
33 typedef struct _EFI_TCP4_PROTOCOL EFI_TCP4_PROTOCOL;
34
35 typedef struct {
36 EFI_HANDLE InstanceHandle;
37 EFI_IPv4_ADDRESS LocalAddress;
38 UINT16 LocalPort;
39 EFI_IPv4_ADDRESS RemoteAddress;
40 UINT16 RemotePort;
41 } EFI_TCP4_SERVICE_POINT;
42
43 typedef struct {
44 EFI_HANDLE DriverHandle;
45 UINT32 ServiceCount;
46 EFI_TCP4_SERVICE_POINT Services[1];
47 } EFI_TCP4_VARIABLE_DATA;
48
49 typedef struct {
50 BOOLEAN UseDefaultAddress;
51 EFI_IPv4_ADDRESS StationAddress;
52 EFI_IPv4_ADDRESS SubnetMask;
53 UINT16 StationPort;
54 EFI_IPv4_ADDRESS RemoteAddress;
55 UINT16 RemotePort;
56 BOOLEAN ActiveFlag;
57 } EFI_TCP4_ACCESS_POINT;
58
59 typedef struct {
60 UINT32 ReceiveBufferSize;
61 UINT32 SendBufferSize;
62 UINT32 MaxSynBackLog;
63 UINT32 ConnectionTimeout;
64 UINT32 DataRetries;
65 UINT32 FinTimeout;
66 UINT32 TimeWaitTimeout;
67 UINT32 KeepAliveProbes;
68 UINT32 KeepAliveTime;
69 UINT32 KeepAliveInterval;
70 BOOLEAN EnableNagle;
71 BOOLEAN EnableTimeStamp;
72 BOOLEAN EnableWindowScaling;
73 BOOLEAN EnableSelectiveAck;
74 BOOLEAN EnablePathMtuDiscovery;
75 } EFI_TCP4_OPTION;
76
77 typedef struct {
78 //
79 // I/O parameters
80 //
81 UINT8 TypeOfService;
82 UINT8 TimeToLive;
83
84 //
85 // Access Point
86 //
87 EFI_TCP4_ACCESS_POINT AccessPoint;
88
89 //
90 // TCP Control Options
91 //
92 EFI_TCP4_OPTION *ControlOption;
93 } EFI_TCP4_CONFIG_DATA;
94
95 typedef enum {
96 Tcp4StateClosed = 0,
97 Tcp4StateListen = 1,
98 Tcp4StateSynSent = 2,
99 Tcp4StateSynReceived = 3,
100 Tcp4StateEstablished = 4,
101 Tcp4StateFinWait1 = 5,
102 Tcp4StateFinWait2 = 6,
103 Tcp4StateClosing = 7,
104 Tcp4StateTimeWait = 8,
105 Tcp4StateCloseWait = 9,
106 Tcp4StateLastAck = 10
107 } EFI_TCP4_CONNECTION_STATE;
108
109 typedef struct {
110 EFI_EVENT Event;
111 EFI_STATUS Status;
112 } EFI_TCP4_COMPLETION_TOKEN;
113
114 typedef struct {
115 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
116 } EFI_TCP4_CONNECTION_TOKEN;
117
118 typedef struct {
119 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
120 EFI_HANDLE NewChildHandle;
121 } EFI_TCP4_LISTEN_TOKEN;
122
123 typedef struct {
124 UINT32 FragmentLength;
125 VOID *FragmentBuffer;
126 } EFI_TCP4_FRAGMENT_DATA;
127
128 typedef struct {
129 BOOLEAN UrgentFlag;
130 UINT32 DataLength;
131 UINT32 FragmentCount;
132 EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
133 } EFI_TCP4_RECEIVE_DATA;
134
135 typedef struct {
136 BOOLEAN Push;
137 BOOLEAN Urgent;
138 UINT32 DataLength;
139 UINT32 FragmentCount;
140 EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
141 } EFI_TCP4_TRANSMIT_DATA;
142
143 typedef struct {
144 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
145 union {
146 EFI_TCP4_RECEIVE_DATA *RxData;
147 EFI_TCP4_TRANSMIT_DATA *TxData;
148 } Packet;
149 } EFI_TCP4_IO_TOKEN;
150
151 typedef struct {
152 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
153 BOOLEAN AbortOnClose;
154 } EFI_TCP4_CLOSE_TOKEN;
155
156 //
157 // Interface definition for TCP4 protocol
158 //
159
160 /**
161 Get the current operational status.
162
163 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
164 @param Tcp4State Pointer to the buffer to receive the current TCP state.
165 @param Tcp4ConfigData Pointer to the buffer to receive the current TCP configuration.
166 @param Ip4ModeData Pointer to the buffer to receive the current IPv4 configuration
167 data used by the TCPv4 instance.
168 @param MnpConfigData Pointer to the buffer to receive the current MNP configuration
169 data used indirectly by the TCPv4 instance.
170 @param SnpModeData Pointer to the buffer to receive the current SNP configuration
171 data used indirectly by the TCPv4 instance.
172
173 @retval EFI_SUCCESS The mode data was read.
174 @retval EFI_INVALID_PARAMETER This is NULL.
175 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
176 been started.
177
178 **/
179 typedef
180 EFI_STATUS
181 (EFIAPI *EFI_TCP4_GET_MODE_DATA)(
182 IN CONST EFI_TCP4_PROTOCOL *This,
183 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
184 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
185 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
186 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
187 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
188 );
189
190 /**
191 Initialize or brutally reset the operational parameters for this EFI TCPv4 instance.
192
193 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
194 @param Tcp4ConfigData Pointer to the configure data to configure the instance.
195
196 @retval EFI_SUCCESS The operational settings are set, changed, or reset
197 successfully.
198 @retval EFI_INVALID_PARAMETER Some parameter is invalid.
199 @retval EFI_NO_MAPPING When using a default address, configuration (through
200 DHCP, BOOTP, RARP, etc.) is not finished yet.
201 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without
202 calling Configure() with NULL to reset it.
203 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
204 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
205 the implementation.
206 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
207 executing Configure().
208
209 **/
210 typedef
211 EFI_STATUS
212 (EFIAPI *EFI_TCP4_CONFIGURE)(
213 IN EFI_TCP4_PROTOCOL *This,
214 IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
215 );
216
217
218 /**
219 Add or delete a route entry to the route table
220
221 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
222 @param DeleteRoute Set it to TRUE to delete this route from the routing table. Set it to
223 FALSE to add this route to the routing table.
224 DestinationAddress and SubnetMask are used as the
225 keywords to search route entry.
226 @param SubnetAddress The destination network.
227 @param SubnetMask The subnet mask of the destination network.
228 @param GatewayAddress The gateway address for this route. It must be on the same
229 subnet with the station address unless a direct route is specified.
230
231 @retval EFI_SUCCESS The operation completed successfully.
232 @retval EFI_NOT_STARTED The EFI TCPv4 Protocol instance has not been configured.
233 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
234 RARP, etc.) is not finished yet.
235 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
236 - This is NULL.
237 - SubnetAddress is NULL.
238 - SubnetMask is NULL.
239 - GatewayAddress is NULL.
240 - *SubnetAddress is not NULL a valid subnet address.
241 - *SubnetMask is not a valid subnet mask.
242 - *GatewayAddress is not a valid unicast IP address or it
243 is not in the same subnet.
244 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the entry to the
245 routing table.
246 @retval EFI_NOT_FOUND This route is not in the routing table.
247 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.
248 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
249
250 **/
251 typedef
252 EFI_STATUS
253 (EFIAPI *EFI_TCP4_ROUTES)(
254 IN EFI_TCP4_PROTOCOL *This,
255 IN BOOLEAN DeleteRoute,
256 IN EFI_IPv4_ADDRESS *SubnetAddress,
257 IN EFI_IPv4_ADDRESS *SubnetMask,
258 IN EFI_IPv4_ADDRESS *GatewayAddress
259 );
260
261 /**
262 Initiate a nonblocking TCP connection request for an active TCP instance.
263
264 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
265 @param ConnectionToken Pointer to the connection token to return when the TCP three
266 way handshake finishes.
267
268 @retval EFI_SUCCESS The connection request is successfully initiated and the state
269 - of this TCPv4 instance has been changed to
270 - Tcp4StateSynSent.
271 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
272 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
273 - This instance is not configured as an active one.
274 - This instance is not in Tcp4StateClosed state.
275 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
276 - This is NULL.
277 - ConnectionToken is NULL.
278 - ConnectionToken->CompletionToken.Event is NULL.
279 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to initiate the activeopen.
280 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
281
282 **/
283 typedef
284 EFI_STATUS
285 (EFIAPI *EFI_TCP4_CONNECT)(
286 IN EFI_TCP4_PROTOCOL *This,
287 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
288 );
289
290
291 /**
292 Listen on the passive instance to accept an incoming connection request. This is a nonblocking operation.
293
294 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
295 @param ListenToken Pointer to the listen token to return when operation finishes.
296
297 @retval EFI_SUCCESS The listen token has been queued successfully.
298 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
299 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
300 - This instance is not a passive instance.
301 - This instance is not in Tcp4StateListen state.
302 - The same listen token has already existed in the listen
303 token queue of this TCP instance.
304 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
305 - This is NULL.
306 - ListenToken is NULL.
307 - ListentToken->CompletionToken.Event is NULL.
308 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
309 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.
310
311 **/
312 typedef
313 EFI_STATUS
314 (EFIAPI *EFI_TCP4_ACCEPT)(
315 IN EFI_TCP4_PROTOCOL *This,
316 IN EFI_TCP4_LISTEN_TOKEN *ListenToken
317 );
318
319 /**
320 Queues outgoing data into the transmit queue.
321
322 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
323 @param Token Pointer to the completion token to queue to the transmit queue.
324
325 @retval EFI_SUCCESS The data has been queued for transmission.
326 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
327 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
328 RARP, etc.) is not finished yet.
329 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
330 - This is NULL.
331 - Token is NULL.
332 - Token->CompletionToken.Event is NULL.
333 - Token->Packet.TxData is NULL L.
334 - Token->Packet.FragmentCount is zero.
335 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
336 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
337 - A transmit completion token with the same Token->CompletionToken.Event
338 was already in the transmission queue.
339 - The current instance is in Tcp4StateClosed state.
340 - The current instance is a passive one and it is in
341 Tcp4StateListen state.
342 - User has called Close() to disconnect this connection.
343 @retval EFI_NOT_READY The completion token could not be queued because the
344 transmit queue is full.
345 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
346 shortage.
347 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
348
349 **/
350 typedef
351 EFI_STATUS
352 (EFIAPI *EFI_TCP4_TRANSMIT)(
353 IN EFI_TCP4_PROTOCOL *This,
354 IN EFI_TCP4_IO_TOKEN *Token
355 );
356
357
358 /**
359 Places an asynchronous receive request into the receiving queue.
360
361 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
362 @param Token Pointer to a token that is associated with the receive data
363 descriptor.
364
365 @retval EFI_SUCCESS The receive completion token was cached.
366 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
367 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP,
368 etc.) is not finished yet.
369 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
370 - This is NULL.
371 - Token is NULL.
372 - Token->CompletionToken.Event is NULL.
373 - Token->Packet.RxData is NULL.
374 - Token->Packet.RxData->DataLength is 0.
375 - The Token->Packet.RxData->DataLength is not
376 the sum of all FragmentBuffer length in FragmentTable.
377 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
378 system resources (usually memory).
379 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
380 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
381 - A receive completion token with the same Token-
382 >CompletionToken.Event was already in the receive
383 queue.
384 - The current instance is in Tcp4StateClosed state.
385 - The current instance is a passive one and it is in
386 Tcp4StateListen state.
387 - User has called Close() to disconnect this connection.
388 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is
389 no any buffered data in the receive buffer of this instance.
390 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
391
392 **/
393 typedef
394 EFI_STATUS
395 (EFIAPI *EFI_TCP4_RECEIVE)(
396 IN EFI_TCP4_PROTOCOL *This,
397 IN EFI_TCP4_IO_TOKEN *Token
398 );
399
400 /**
401 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
402 nonblocking operation.
403
404 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
405 @param CloseToken Pointer to the close token to return when operation finishes.
406
407 @retval EFI_SUCCESS The Close() is called successfully.
408 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
409 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
410 - Configure() has been called with
411 TcpConfigData set to NULL and this function has
412 not returned.
413 - Previous Close() call on this instance has not
414 finished.
415 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
416 - This is NULL.
417 - CloseToken is NULL.
418 - CloseToken->CompletionToken.Event is NULL.
419 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
420 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.
421
422 **/
423 typedef
424 EFI_STATUS
425 (EFIAPI *EFI_TCP4_CLOSE)(
426 IN EFI_TCP4_PROTOCOL *This,
427 IN EFI_TCP4_CLOSE_TOKEN *CloseToken
428 );
429
430 /**
431 Abort an asynchronous connection, listen, transmission or receive request.
432
433 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
434 @param Token Pointer to a token that has been issued by
435 EFI_TCP4_PROTOCOL.Connect(),
436 EFI_TCP4_PROTOCOL.Accept(),
437 EFI_TCP4_PROTOCOL.Transmit() or
438 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
439 tokens issued by above four functions will be aborted. Type
440 EFI_TCP4_COMPLETION_TOKEN is defined in
441 EFI_TCP4_PROTOCOL.Connect().
442
443 @retval EFI_SUCCESS Incoming or outgoing data was processed.
444 @retval EFI_INVALID_PARAMETER This is NULL.
445 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
446 @retval EFI_NOT_READY No incoming or outgoing data is processed.
447 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
448 Consider increasing the polling rate.
449
450 **/
451 typedef
452 EFI_STATUS
453 (EFIAPI *EFI_TCP4_CANCEL)(
454 IN EFI_TCP4_PROTOCOL *This,
455 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
456 );
457
458
459 /**
460 Poll to receive incoming data and transmit outgoing segments.
461
462 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
463
464 @retval EFI_SUCCESS Incoming or outgoing data was processed.
465 @retval EFI_INVALID_PARAMETER This is NULL.
466 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
467 @retval EFI_NOT_READY No incoming or outgoing data is processed.
468 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
469 Consider increasing the polling rate.
470
471 **/
472 typedef
473 EFI_STATUS
474 (EFIAPI *EFI_TCP4_POLL)(
475 IN EFI_TCP4_PROTOCOL *This
476 );
477
478 /**
479 @par Protocol Description:
480 The EFI_TCP4_PROTOCOL defines the EFI TCPv4 Protocol child to be used by
481 any network drivers or applications to send or receive data stream.
482 It can either listen on a specified port as a service or actively connected
483 to remote peer as a client. Each instance has its own independent settings,
484 such as the routing table.
485 **/
486 struct _EFI_TCP4_PROTOCOL {
487 EFI_TCP4_GET_MODE_DATA GetModeData;
488 EFI_TCP4_CONFIGURE Configure;
489 EFI_TCP4_ROUTES Routes;
490 EFI_TCP4_CONNECT Connect;
491 EFI_TCP4_ACCEPT Accept;
492 EFI_TCP4_TRANSMIT Transmit;
493 EFI_TCP4_RECEIVE Receive;
494 EFI_TCP4_CLOSE Close;
495 EFI_TCP4_CANCEL Cancel;
496 EFI_TCP4_POLL Poll;
497 };
498
499 #define EFI_CONNECTION_FIN EFIERR (104)
500 #define EFI_CONNECTION_RESET EFIERR (105)
501 #define EFI_CONNECTION_REFUSED EFIERR (106)
502
503 extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid;
504 extern EFI_GUID gEfiTcp4ProtocolGuid;
505
506 #endif