]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Tcp6.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / Tcp6.h
1 /** @file
2 EFI TCPv6(Transmission Control Protocol version 6) Protocol Definition
3 The EFI TCPv6 Service Binding Protocol is used to locate EFI TCPv6 Protocol drivers to create
4 and destroy child of the driver to communicate with other host using TCP protocol.
5 The EFI TCPv6 Protocol provides services to send and receive data stream.
6
7 Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 @par Revision Reference:
11 This Protocol is introduced in UEFI Specification 2.2
12
13 **/
14
15 #ifndef __EFI_TCP6_PROTOCOL_H__
16 #define __EFI_TCP6_PROTOCOL_H__
17
18 #include <Protocol/ManagedNetwork.h>
19 #include <Protocol/Ip6.h>
20
21 #define EFI_TCP6_SERVICE_BINDING_PROTOCOL_GUID \
22 { \
23 0xec20eb79, 0x6c1a, 0x4664, {0x9a, 0x0d, 0xd2, 0xe4, 0xcc, 0x16, 0xd6, 0x64 } \
24 }
25
26 #define EFI_TCP6_PROTOCOL_GUID \
27 { \
28 0x46e44855, 0xbd60, 0x4ab7, {0xab, 0x0d, 0xa6, 0x79, 0xb9, 0x44, 0x7d, 0x77 } \
29 }
30
31
32 typedef struct _EFI_TCP6_PROTOCOL EFI_TCP6_PROTOCOL;
33
34 ///
35 /// EFI_TCP6_SERVICE_POINT is deprecated in the UEFI 2.4B and should not be used any more.
36 /// The definition in here is only present to provide backwards compatability.
37 ///
38 typedef struct {
39 ///
40 /// The EFI TCPv6 Protocol instance handle that is using this
41 /// address/port pair.
42 ///
43 EFI_HANDLE InstanceHandle;
44 ///
45 /// The local IPv6 address to which this TCP instance is bound. Set
46 /// to 0::/128, if this TCP instance is configured to listen on all
47 /// available source addresses.
48 ///
49 EFI_IPv6_ADDRESS LocalAddress;
50 ///
51 /// The local port number in host byte order.
52 ///
53 UINT16 LocalPort;
54 ///
55 /// The remote IPv6 address. It may be 0::/128 if this TCP instance is
56 /// not connected to any remote host.
57 ///
58 EFI_IPv6_ADDRESS RemoteAddress;
59 ///
60 /// The remote port number in host byte order. It may be zero if this
61 /// TCP instance is not connected to any remote host.
62 ///
63 UINT16 RemotePort;
64 } EFI_TCP6_SERVICE_POINT;
65
66 ///
67 /// EFI_TCP6_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.
68 /// The definition in here is only present to provide backwards compatability.
69 ///
70 typedef struct {
71 EFI_HANDLE DriverHandle; ///< The handle of the driver that creates this entry.
72 UINT32 ServiceCount; ///< The number of address/port pairs following this data structure.
73 EFI_TCP6_SERVICE_POINT Services[1]; ///< List of address/port pairs that are currently in use.
74 } EFI_TCP6_VARIABLE_DATA;
75
76 ///
77 /// EFI_TCP6_ACCESS_POINT
78 ///
79 typedef struct {
80 ///
81 /// The local IP address assigned to this TCP instance. The EFI
82 /// TCPv6 driver will only deliver incoming packets whose
83 /// destination addresses exactly match the IP address. Set to zero to
84 /// let the underlying IPv6 driver choose a source address. If not zero
85 /// it must be one of the configured IP addresses in the underlying
86 /// IPv6 driver.
87 ///
88 EFI_IPv6_ADDRESS StationAddress;
89 ///
90 /// The local port number to which this EFI TCPv6 Protocol instance
91 /// is bound. If the instance doesn't care the local port number, set
92 /// StationPort to zero to use an ephemeral port.
93 ///
94 UINT16 StationPort;
95 ///
96 /// The remote IP address to which this EFI TCPv6 Protocol instance
97 /// is connected. If ActiveFlag is FALSE (i.e. a passive TCPv6
98 /// instance), the instance only accepts connections from the
99 /// RemoteAddress. If ActiveFlag is TRUE the instance will
100 /// connect to the RemoteAddress, i.e., outgoing segments will be
101 /// sent to this address and only segments from this address will be
102 /// delivered to the application. When ActiveFlag is FALSE, it
103 /// can be set to zero and means that incoming connection requests
104 /// from any address will be accepted.
105 ///
106 EFI_IPv6_ADDRESS RemoteAddress;
107 ///
108 /// The remote port to which this EFI TCPv6 Protocol instance
109 /// connects or from which connection request will be accepted by
110 /// this EFI TCPv6 Protocol instance. If ActiveFlag is FALSE it
111 /// can be zero and means that incoming connection request from
112 /// any port will be accepted. Its value can not be zero when
113 /// ActiveFlag is TRUE.
114 ///
115 UINT16 RemotePort;
116 ///
117 /// Set it to TRUE to initiate an active open. Set it to FALSE to
118 /// initiate a passive open to act as a server.
119 ///
120 BOOLEAN ActiveFlag;
121 } EFI_TCP6_ACCESS_POINT;
122
123 ///
124 /// EFI_TCP6_OPTION
125 ///
126 typedef struct {
127 ///
128 /// The size of the TCP receive buffer.
129 ///
130 UINT32 ReceiveBufferSize;
131 ///
132 /// The size of the TCP send buffer.
133 ///
134 UINT32 SendBufferSize;
135 ///
136 /// The length of incoming connect request queue for a passive
137 /// instance. When set to zero, the value is implementation specific.
138 ///
139 UINT32 MaxSynBackLog;
140 ///
141 /// The maximum seconds a TCP instance will wait for before a TCP
142 /// connection established. When set to zero, the value is
143 /// implementation specific.
144 ///
145 UINT32 ConnectionTimeout;
146 ///
147 ///The number of times TCP will attempt to retransmit a packet on
148 ///an established connection. When set to zero, the value is
149 ///implementation specific.
150 ///
151 UINT32 DataRetries;
152 ///
153 /// How many seconds to wait in the FIN_WAIT_2 states for a final
154 /// FIN flag before the TCP instance is closed. This timeout is in
155 /// effective only if the application has called Close() to
156 /// disconnect the connection completely. It is also called
157 /// FIN_WAIT_2 timer in other implementations. When set to zero,
158 /// it should be disabled because the FIN_WAIT_2 timer itself is
159 /// against the standard. The default value is 60.
160 ///
161 UINT32 FinTimeout;
162 ///
163 /// How many seconds to wait in TIME_WAIT state before the TCP
164 /// instance is closed. The timer is disabled completely to provide a
165 /// method to close the TCP connection quickly if it is set to zero. It
166 /// is against the related RFC documents.
167 ///
168 UINT32 TimeWaitTimeout;
169 ///
170 /// The maximum number of TCP keep-alive probes to send before
171 /// giving up and resetting the connection if no response from the
172 /// other end. Set to zero to disable keep-alive probe.
173 ///
174 UINT32 KeepAliveProbes;
175 ///
176 /// The number of seconds a connection needs to be idle before TCP
177 /// sends out periodical keep-alive probes. When set to zero, the
178 /// value is implementation specific. It should be ignored if keep-
179 /// alive probe is disabled.
180 ///
181 UINT32 KeepAliveTime;
182 ///
183 /// The number of seconds between TCP keep-alive probes after the
184 /// periodical keep-alive probe if no response. When set to zero, the
185 /// value is implementation specific. It should be ignored if keep-
186 /// alive probe is disabled.
187 ///
188 UINT32 KeepAliveInterval;
189 ///
190 /// Set it to TRUE to enable the Nagle algorithm as defined in
191 /// RFC896. Set it to FALSE to disable it.
192 ///
193 BOOLEAN EnableNagle;
194 ///
195 /// Set it to TRUE to enable TCP timestamps option as defined in
196 /// RFC1323. Set to FALSE to disable it.
197 ///
198 BOOLEAN EnableTimeStamp;
199 ///
200 /// Set it to TRUE to enable TCP window scale option as defined in
201 /// RFC1323. Set it to FALSE to disable it.
202 ///
203 BOOLEAN EnableWindowScaling;
204 ///
205 /// Set it to TRUE to enable selective acknowledge mechanism
206 /// described in RFC 2018. Set it to FALSE to disable it.
207 /// Implementation that supports SACK can optionally support
208 /// DSAK as defined in RFC 2883.
209 ///
210 BOOLEAN EnableSelectiveAck;
211 ///
212 /// Set it to TRUE to enable path MTU discovery as defined in
213 /// RFC 1191. Set to FALSE to disable it.
214 ///
215 BOOLEAN EnablePathMtuDiscovery;
216 } EFI_TCP6_OPTION;
217
218 ///
219 /// EFI_TCP6_CONFIG_DATA
220 ///
221 typedef struct {
222 ///
223 /// TrafficClass field in transmitted IPv6 packets.
224 ///
225 UINT8 TrafficClass;
226 ///
227 /// HopLimit field in transmitted IPv6 packets.
228 ///
229 UINT8 HopLimit;
230 ///
231 /// Used to specify TCP communication end settings for a TCP instance.
232 ///
233 EFI_TCP6_ACCESS_POINT AccessPoint;
234 ///
235 /// Used to configure the advance TCP option for a connection. If set
236 /// to NULL, implementation specific options for TCP connection will be used.
237 ///
238 EFI_TCP6_OPTION *ControlOption;
239 } EFI_TCP6_CONFIG_DATA;
240
241 ///
242 /// EFI_TCP6_CONNECTION_STATE
243 ///
244 typedef enum {
245 Tcp6StateClosed = 0,
246 Tcp6StateListen = 1,
247 Tcp6StateSynSent = 2,
248 Tcp6StateSynReceived = 3,
249 Tcp6StateEstablished = 4,
250 Tcp6StateFinWait1 = 5,
251 Tcp6StateFinWait2 = 6,
252 Tcp6StateClosing = 7,
253 Tcp6StateTimeWait = 8,
254 Tcp6StateCloseWait = 9,
255 Tcp6StateLastAck = 10
256 } EFI_TCP6_CONNECTION_STATE;
257
258 ///
259 /// EFI_TCP6_COMPLETION_TOKEN
260 /// is used as a common header for various asynchronous tokens.
261 ///
262 typedef struct {
263 ///
264 /// The Event to signal after request is finished and Status field is
265 /// updated by the EFI TCPv6 Protocol driver.
266 ///
267 EFI_EVENT Event;
268 ///
269 /// The result of the completed operation.
270 ///
271 EFI_STATUS Status;
272 } EFI_TCP6_COMPLETION_TOKEN;
273
274 ///
275 /// EFI_TCP6_CONNECTION_TOKEN
276 /// will be set if the active open succeeds or an unexpected
277 /// error happens.
278 ///
279 typedef struct {
280 ///
281 /// The Status in the CompletionToken will be set to one of
282 /// the following values if the active open succeeds or an unexpected
283 /// error happens:
284 /// EFI_SUCCESS: The active open succeeds and the instance's
285 /// state is Tcp6StateEstablished.
286 /// EFI_CONNECTION_RESET: The connect fails because the connection is reset
287 /// either by instance itself or the communication peer.
288 /// EFI_CONNECTION_REFUSED: The receiving or transmission operation fails because this
289 /// connection is refused.
290 /// EFI_ABORTED: The active open is aborted.
291 /// EFI_TIMEOUT: The connection establishment timer expires and
292 /// no more specific information is available.
293 /// EFI_NETWORK_UNREACHABLE: The active open fails because
294 /// an ICMP network unreachable error is received.
295 /// EFI_HOST_UNREACHABLE: The active open fails because an
296 /// ICMP host unreachable error is received.
297 /// EFI_PROTOCOL_UNREACHABLE: The active open fails
298 /// because an ICMP protocol unreachable error is received.
299 /// EFI_PORT_UNREACHABLE: The connection establishment
300 /// timer times out and an ICMP port unreachable error is received.
301 /// EFI_ICMP_ERROR: The connection establishment timer times
302 /// out and some other ICMP error is received.
303 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
304 /// EFI_SECURITY_VIOLATION: The active open was failed because of IPSec policy check.
305 /// EFI_NO_MEDIA: There was a media error.
306 ///
307 EFI_TCP6_COMPLETION_TOKEN CompletionToken;
308 } EFI_TCP6_CONNECTION_TOKEN;
309
310 ///
311 /// EFI_TCP6_LISTEN_TOKEN
312 /// returns when list operation finishes.
313 ///
314 typedef struct {
315 ///
316 /// The Status in CompletionToken will be set to the
317 /// following value if accept finishes:
318 /// EFI_SUCCESS: A remote peer has successfully established a
319 /// connection to this instance. A new TCP instance has also been
320 /// created for the connection.
321 /// EFI_CONNECTION_RESET: The accept fails because the connection is reset either
322 /// by instance itself or communication peer.
323 /// EFI_ABORTED: The accept request has been aborted.
324 /// EFI_SECURITY_VIOLATION: The accept operation was failed because of IPSec policy check.
325 ///
326 EFI_TCP6_COMPLETION_TOKEN CompletionToken;
327 EFI_HANDLE NewChildHandle;
328 } EFI_TCP6_LISTEN_TOKEN;
329
330 ///
331 /// EFI_TCP6_FRAGMENT_DATA
332 /// allows multiple receive or transmit buffers to be specified. The
333 /// purpose of this structure is to provide scattered read and write.
334 ///
335 typedef struct {
336 UINT32 FragmentLength; ///< Length of data buffer in the fragment.
337 VOID *FragmentBuffer; ///< Pointer to the data buffer in the fragment.
338 } EFI_TCP6_FRAGMENT_DATA;
339
340 ///
341 /// EFI_TCP6_RECEIVE_DATA
342 /// When TCPv6 driver wants to deliver received data to the application,
343 /// it will pick up the first queued receiving token, update its
344 /// Token->Packet.RxData then signal the Token->CompletionToken.Event.
345 ///
346 typedef struct {
347 ///
348 /// Whether the data is urgent. When this flag is set, the instance is in
349 /// urgent mode.
350 ///
351 BOOLEAN UrgentFlag;
352 ///
353 /// When calling Receive() function, it is the byte counts of all
354 /// Fragmentbuffer in FragmentTable allocated by user.
355 /// When the token is signaled by TCPv6 driver it is the length of
356 /// received data in the fragments.
357 ///
358 UINT32 DataLength;
359 ///
360 /// Number of fragments.
361 ///
362 UINT32 FragmentCount;
363 ///
364 /// An array of fragment descriptors.
365 ///
366 EFI_TCP6_FRAGMENT_DATA FragmentTable[1];
367 } EFI_TCP6_RECEIVE_DATA;
368
369 ///
370 /// EFI_TCP6_TRANSMIT_DATA
371 /// The EFI TCPv6 Protocol user must fill this data structure before sending a packet.
372 /// The packet may contain multiple buffers in non-continuous memory locations.
373 ///
374 typedef struct {
375 ///
376 /// Push If TRUE, data must be transmitted promptly, and the PUSH bit in
377 /// the last TCP segment created will be set. If FALSE, data
378 /// transmission may be delayed to combine with data from
379 /// subsequent Transmit()s for efficiency.
380 ///
381 BOOLEAN Push;
382 ///
383 /// The data in the fragment table are urgent and urgent point is in
384 /// effect if TRUE. Otherwise those data are NOT considered urgent.
385 ///
386 BOOLEAN Urgent;
387 ///
388 /// Length of the data in the fragments.
389 ///
390 UINT32 DataLength;
391 ///
392 /// Number of fragments.
393 ///
394 UINT32 FragmentCount;
395 ///
396 /// An array of fragment descriptors.
397 ///
398 EFI_TCP6_FRAGMENT_DATA FragmentTable[1];
399 } EFI_TCP6_TRANSMIT_DATA;
400
401 ///
402 /// EFI_TCP6_IO_TOKEN
403 /// returns When transmission finishes or meets any unexpected error.
404 ///
405 typedef struct {
406 ///
407 /// When transmission finishes or meets any unexpected error it will
408 /// be set to one of the following values:
409 /// EFI_SUCCESS: The receiving or transmission operation
410 /// completes successfully.
411 /// EFI_CONNECTION_FIN: The receiving operation fails because the communication peer
412 /// has closed the connection and there is no more data in the
413 /// receive buffer of the instance.
414 /// EFI_CONNECTION_RESET: The receiving or transmission operation fails
415 /// because this connection is reset either by instance
416 /// itself or the communication peer.
417 /// EFI_ABORTED: The receiving or transmission is aborted.
418 /// EFI_TIMEOUT: The transmission timer expires and no more
419 /// specific information is available.
420 /// EFI_NETWORK_UNREACHABLE: The transmission fails
421 /// because an ICMP network unreachable error is received.
422 /// EFI_HOST_UNREACHABLE: The transmission fails because an
423 /// ICMP host unreachable error is received.
424 /// EFI_PROTOCOL_UNREACHABLE: The transmission fails
425 /// because an ICMP protocol unreachable error is received.
426 /// EFI_PORT_UNREACHABLE: The transmission fails and an
427 /// ICMP port unreachable error is received.
428 /// EFI_ICMP_ERROR: The transmission fails and some other
429 /// ICMP error is received.
430 /// EFI_DEVICE_ERROR: An unexpected system or network error occurs.
431 /// EFI_SECURITY_VIOLATION: The receiving or transmission
432 /// operation was failed because of IPSec policy check
433 /// EFI_NO_MEDIA: There was a media error.
434 ///
435 EFI_TCP6_COMPLETION_TOKEN CompletionToken;
436 union {
437 ///
438 /// When this token is used for receiving, RxData is a pointer to
439 /// EFI_TCP6_RECEIVE_DATA.
440 ///
441 EFI_TCP6_RECEIVE_DATA *RxData;
442 ///
443 /// When this token is used for transmitting, TxData is a pointer to
444 /// EFI_TCP6_TRANSMIT_DATA.
445 ///
446 EFI_TCP6_TRANSMIT_DATA *TxData;
447 } Packet;
448 } EFI_TCP6_IO_TOKEN;
449
450 ///
451 /// EFI_TCP6_CLOSE_TOKEN
452 /// returns when close operation finishes.
453 ///
454 typedef struct {
455 ///
456 /// When close finishes or meets any unexpected error it will be set
457 /// to one of the following values:
458 /// EFI_SUCCESS: The close operation completes successfully.
459 /// EFI_ABORTED: User called configure with NULL without close stopping.
460 /// EFI_SECURITY_VIOLATION: The close operation was failed because of IPSec policy check.
461 ///
462 EFI_TCP6_COMPLETION_TOKEN CompletionToken;
463 ///
464 /// Abort the TCP connection on close instead of the standard TCP
465 /// close process when it is set to TRUE. This option can be used to
466 /// satisfy a fast disconnect.
467 ///
468 BOOLEAN AbortOnClose;
469 } EFI_TCP6_CLOSE_TOKEN;
470
471 /**
472 Get the current operational status.
473
474 The GetModeData() function copies the current operational settings of this EFI TCPv6
475 Protocol instance into user-supplied buffers. This function can also be used to retrieve
476 the operational setting of underlying drivers such as IPv6, MNP, or SNP.
477
478 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
479 @param[out] Tcp6State The buffer in which the current TCP state is returned.
480 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration is returned.
481 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration data used by
482 the TCP instance is returned.
483 @param[out] MnpConfigData The buffer in which the current MNP configuration data used
484 indirectly by the TCP instance is returned.
485 @param[out] SnpModeData The buffer in which the current SNP mode data used indirectly by
486 the TCP instance is returned.
487
488 @retval EFI_SUCCESS The mode data was read.
489 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
490 been started.
491 @retval EFI_INVALID_PARAMETER This is NULL.
492
493 **/
494 typedef
495 EFI_STATUS
496 (EFIAPI *EFI_TCP6_GET_MODE_DATA)(
497 IN EFI_TCP6_PROTOCOL *This,
498 OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL,
499 OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL,
500 OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
501 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
502 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
503 );
504
505 /**
506 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
507
508 The Configure() function does the following:
509 - Initialize this TCP instance, i.e., initialize the communication end settings and
510 specify active open or passive open for an instance.
511 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
512 transmission and receiving buffer directly without informing the communication peer.
513
514 No other TCPv6 Protocol operation except Poll() can be executed by this instance until
515 it is configured properly. For an active TCP instance, after a proper configuration it
516 may call Connect() to initiates the three-way handshake. For a passive TCP instance,
517 its state will transit to Tcp6StateListen after configuration, and Accept() may be
518 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
519 the instance is reset. Resetting process will be done brutally, the state machine will
520 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
521 and no traffic is allowed through this instance.
522
523 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
524 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
525 If Tcp6ConfigData is set to NULL, the instance is reset.
526
527 @retval EFI_SUCCESS The operational settings are set, changed, or reset
528 successfully.
529 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
530 address for this instance, but no source address was available for
531 use.
532 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
533 - This is NULL.
534 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
535 one of the configured IP addresses in the underlying IPv6 driver.
536 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
537 IPv6 address.
538 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
539 Tcp6ConfigData->AccessPoint.RemotePort is zero when
540 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
541 - A same access point has been configured in other TCP
542 instance properly.
543 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without
544 calling Configure() with NULL to reset it.
545 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
546 the implementation.
547 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
548 executing Configure().
549 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
550
551 **/
552 typedef
553 EFI_STATUS
554 (EFIAPI *EFI_TCP6_CONFIGURE)(
555 IN EFI_TCP6_PROTOCOL *This,
556 IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL
557 );
558
559 /**
560 Initiate a nonblocking TCP connection request for an active TCP instance.
561
562 The Connect() function will initiate an active open to the remote peer configured
563 in current TCP instance if it is configured active. If the connection succeeds or
564 fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
565 and ConnectionToken->CompletionToken.Status will be updated accordingly. This
566 function can only be called for the TCP instance in Tcp6StateClosed state. The
567 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
568 If TCP three-way handshake succeeds, its state will become Tcp6StateEstablished,
569 otherwise, the state will return to Tcp6StateClosed.
570
571 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
572 @param[in] ConnectionToken Pointer to the connection token to return when the TCP three
573 way handshake finishes.
574
575 @retval EFI_SUCCESS The connection request is successfully initiated and the state of
576 this TCP instance has been changed to Tcp6StateSynSent.
577 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
578 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
579 - This instance is not configured as an active one.
580 - This instance is not in Tcp6StateClosed state.
581 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
582 - This is NULL.
583 - ConnectionToken is NULL.
584 - ConnectionToken->CompletionToken.Event is NULL.
585 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to initiate the active open.
586 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
587
588 **/
589 typedef
590 EFI_STATUS
591 (EFIAPI *EFI_TCP6_CONNECT)(
592 IN EFI_TCP6_PROTOCOL *This,
593 IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken
594 );
595
596 /**
597 Listen on the passive instance to accept an incoming connection request. This is a
598 nonblocking operation.
599
600 The Accept() function initiates an asynchronous accept request to wait for an incoming
601 connection on the passive TCP instance. If a remote peer successfully establishes a
602 connection with this instance, a new TCP instance will be created and its handle will
603 be returned in ListenToken->NewChildHandle. The newly created instance is configured
604 by inheriting the passive instance's configuration and is ready for use upon return.
605 The new instance is in the Tcp6StateEstablished state.
606
607 The ListenToken->CompletionToken.Event will be signaled when a new connection is
608 accepted, user aborts the listen or connection is reset.
609
610 This function only can be called when current TCP instance is in Tcp6StateListen state.
611
612 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
613 @param[in] ListenToken Pointer to the listen token to return when operation finishes.
614
615
616 @retval EFI_SUCCESS The listen token has been queued successfully.
617 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
618 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
619 - This instance is not a passive instance.
620 - This instance is not in Tcp6StateListen state.
621 - The same listen token has already existed in the listen
622 token queue of this TCP instance.
623 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
624 - This is NULL.
625 - ListenToken is NULL.
626 - ListentToken->CompletionToken.Event is NULL.
627 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
628 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.
629
630 **/
631 typedef
632 EFI_STATUS
633 (EFIAPI *EFI_TCP6_ACCEPT)(
634 IN EFI_TCP6_PROTOCOL *This,
635 IN EFI_TCP6_LISTEN_TOKEN *ListenToken
636 );
637
638 /**
639 Queues outgoing data into the transmit queue.
640
641 The Transmit() function queues a sending request to this TCP instance along with the
642 user data. The status of the token is updated and the event in the token will be
643 signaled once the data is sent out or some error occurs.
644
645 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
646 @param[in] Token Pointer to the completion token to queue to the transmit queue.
647
648 @retval EFI_SUCCESS The data has been queued for transmission.
649 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
650 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
651 source address for this instance, but no source address was
652 available for use.
653 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
654 - This is NULL.
655 - Token is NULL.
656 - Token->CompletionToken.Event is NULL.
657 - Token->Packet.TxData is NULL.
658 - Token->Packet.FragmentCount is zero.
659 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
660 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
661 - A transmit completion token with the same Token->
662 CompletionToken.Event was already in the
663 transmission queue.
664 - The current instance is in Tcp6StateClosed state.
665 - The current instance is a passive one and it is in
666 Tcp6StateListen state.
667 - User has called Close() to disconnect this connection.
668 @retval EFI_NOT_READY The completion token could not be queued because the
669 transmit queue is full.
670 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
671 shortage.
672 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
673
674 **/
675 typedef
676 EFI_STATUS
677 (EFIAPI *EFI_TCP6_TRANSMIT)(
678 IN EFI_TCP6_PROTOCOL *This,
679 IN EFI_TCP6_IO_TOKEN *Token
680 );
681
682 /**
683 Places an asynchronous receive request into the receiving queue.
684
685 The Receive() function places a completion token into the receive packet queue. This
686 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
687 and the FragmentBuffer used to receive data. The caller also must fill the DataLength which
688 represents the whole length of all FragmentBuffer. When the receive operation completes, the
689 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
690 fields and the Token->CompletionToken.Event is signaled. If got data the data and its length
691 will be copied into the FragmentTable, at the same time the full length of received data will
692 be recorded in the DataLength fields. Providing a proper notification function and context
693 for the event will enable the user to receive the notification and receiving status. That
694 notification function is guaranteed to not be re-entered.
695
696 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
697 @param[in] Token Pointer to a token that is associated with the receive data
698 descriptor.
699
700 @retval EFI_SUCCESS The receive completion token was cached.
701 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
702 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
703 address for this instance, but no source address was available for use.
704 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
705 - This is NULL.
706 - Token is NULL.
707 - Token->CompletionToken.Event is NULL.
708 - Token->Packet.RxData is NULL.
709 - Token->Packet.RxData->DataLength is 0.
710 - The Token->Packet.RxData->DataLength is not the
711 sum of all FragmentBuffer length in FragmentTable.
712 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
713 system resources (usually memory).
714 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
715 The EFI TCPv6 Protocol instance has been reset to startup defaults.
716 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
717 - A receive completion token with the same Token->CompletionToken.Event
718 was already in the receive queue.
719 - The current instance is in Tcp6StateClosed state.
720 - The current instance is a passive one and it is in
721 Tcp6StateListen state.
722 - User has called Close() to disconnect this connection.
723 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no
724 any buffered data in the receive buffer of this instance
725 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
726
727 **/
728 typedef
729 EFI_STATUS
730 (EFIAPI *EFI_TCP6_RECEIVE)(
731 IN EFI_TCP6_PROTOCOL *This,
732 IN EFI_TCP6_IO_TOKEN *Token
733 );
734
735 /**
736 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
737 nonblocking operation.
738
739 Initiate an asynchronous close token to TCP driver. After Close() is called, any buffered
740 transmission data will be sent by TCP driver and the current instance will have a graceful close
741 working flow described as RFC 793 if AbortOnClose is set to FALSE, otherwise, a rest packet
742 will be sent by TCP driver to fast disconnect this connection. When the close operation completes
743 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
744 operations are signaled and any buffers used for TCP network traffic are flushed.
745
746 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
747 @param[in] CloseToken Pointer to the close token to return when operation finishes.
748
749 @retval EFI_SUCCESS The Close() is called successfully.
750 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
751 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
752 - CloseToken or CloseToken->CompletionToken.Event is already in use.
753 - Previous Close() call on this instance has not finished.
754 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
755 - This is NULL.
756 - CloseToken is NULL.
757 - CloseToken->CompletionToken.Event is NULL.
758 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
759 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.
760
761 **/
762 typedef
763 EFI_STATUS
764 (EFIAPI *EFI_TCP6_CLOSE)(
765 IN EFI_TCP6_PROTOCOL *This,
766 IN EFI_TCP6_CLOSE_TOKEN *CloseToken
767 );
768
769 /**
770 Abort an asynchronous connection, listen, transmission or receive request.
771
772 The Cancel() function aborts a pending connection, listen, transmit or
773 receive request.
774
775 If Token is not NULL and the token is in the connection, listen, transmission
776 or receive queue when it is being cancelled, its Token->Status will be set
777 to EFI_ABORTED and then Token->Event will be signaled.
778
779 If the token is not in one of the queues, which usually means that the
780 asynchronous operation has completed, EFI_NOT_FOUND is returned.
781
782 If Token is NULL all asynchronous token issued by Connect(), Accept(),
783 Transmit() and Receive() will be aborted.
784
785 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
786 @param[in] Token Pointer to a token that has been issued by
787 EFI_TCP6_PROTOCOL.Connect(),
788 EFI_TCP6_PROTOCOL.Accept(),
789 EFI_TCP6_PROTOCOL.Transmit() or
790 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
791 tokens issued by above four functions will be aborted. Type
792 EFI_TCP6_COMPLETION_TOKEN is defined in
793 EFI_TCP_PROTOCOL.Connect().
794
795 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
796 is signaled.
797 @retval EFI_INVALID_PARAMETER This is NULL.
798 @retval EFI_NOT_STARTED This instance hasn't been configured.
799 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or
800 receive queue. It has either completed or wasn't issued by
801 Transmit() and Receive().
802 @retval EFI_UNSUPPORTED The implementation does not support this function.
803
804 **/
805 typedef
806 EFI_STATUS
807 (EFIAPI *EFI_TCP6_CANCEL)(
808 IN EFI_TCP6_PROTOCOL *This,
809 IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL
810 );
811
812 /**
813 Poll to receive incoming data and transmit outgoing segments.
814
815 The Poll() function increases the rate that data is moved between the network
816 and application and can be called when the TCP instance is created successfully.
817 Its use is optional.
818
819 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
820
821 @retval EFI_SUCCESS Incoming or outgoing data was processed.
822 @retval EFI_INVALID_PARAMETER This is NULL.
823 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
824 @retval EFI_NOT_READY No incoming or outgoing data is processed.
825 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
826 Consider increasing the polling rate.
827
828 **/
829 typedef
830 EFI_STATUS
831 (EFIAPI *EFI_TCP6_POLL)(
832 IN EFI_TCP6_PROTOCOL *This
833 );
834
835 ///
836 /// EFI_TCP6_PROTOCOL
837 /// defines the EFI TCPv6 Protocol child to be used by any network drivers or
838 /// applications to send or receive data stream. It can either listen on a
839 /// specified port as a service or actively connect to remote peer as a client.
840 /// Each instance has its own independent settings.
841 ///
842 struct _EFI_TCP6_PROTOCOL {
843 EFI_TCP6_GET_MODE_DATA GetModeData;
844 EFI_TCP6_CONFIGURE Configure;
845 EFI_TCP6_CONNECT Connect;
846 EFI_TCP6_ACCEPT Accept;
847 EFI_TCP6_TRANSMIT Transmit;
848 EFI_TCP6_RECEIVE Receive;
849 EFI_TCP6_CLOSE Close;
850 EFI_TCP6_CANCEL Cancel;
851 EFI_TCP6_POLL Poll;
852 };
853
854 extern EFI_GUID gEfiTcp6ServiceBindingProtocolGuid;
855 extern EFI_GUID gEfiTcp6ProtocolGuid;
856
857 #endif
858