1 /** @file
2   Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.
3 
4   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
5   Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
6 
7   This program and the accompanying materials
8   are licensed and made available under the terms and conditions of the BSD License
9   which accompanies this distribution.  The full text of the license may be found at
10   http://opensource.org/licenses/bsd-license.php.
11 
12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 
15 **/
16 
17 #include "TcpMain.h"
18 
19 /**
20   Check the integrity of the data buffer.
21 
22   @param[in]  DataLen              The total length of the data buffer.
23   @param[in]  FragmentCount        The fragment count of the fragment table.
24   @param[in]  FragmentTable        Pointer to the fragment table of the data
25                                    buffer.
26 
27   @retval EFI_SUCCESS              The integrity check passed.
28   @retval EFI_INVALID_PARAMETER    The integrity check failed.
29 
30 **/
31 EFI_STATUS
TcpChkDataBuf(IN UINT32 DataLen,IN UINT32 FragmentCount,IN EFI_TCP4_FRAGMENT_DATA * FragmentTable)32 TcpChkDataBuf (
33   IN UINT32                 DataLen,
34   IN UINT32                 FragmentCount,
35   IN EFI_TCP4_FRAGMENT_DATA *FragmentTable
36   )
37 {
38   UINT32 Index;
39 
40   UINT32 Len;
41 
42   for (Index = 0, Len = 0; Index < FragmentCount; Index++) {
43     Len = Len + FragmentTable[Index].FragmentLength;
44   }
45 
46   if (DataLen != Len) {
47     return EFI_INVALID_PARAMETER;
48   }
49 
50   return EFI_SUCCESS;
51 }
52 
53 /**
54   Get the current operational status.
55 
56   @param[in]   This                Pointer to the EFI_TCP4_PROTOCOL instance.
57   @param[out]  Tcp4State           Pointer to the buffer to receive the current TCP
58                                    state. Optional parameter that may be NULL.
59   @param[out]  Tcp4ConfigData      Pointer to the buffer to receive the current TCP
60                                    configuration. Optional parameter that may be NULL.
61   @param[out]  Ip4ModeData         Pointer to the buffer to receive the current
62                                    IPv4 configuration. Optional parameter that may be NULL.
63   @param[out]  MnpConfigData       Pointer to the buffer to receive the current MNP
64                                    configuration data indirectly used by the TCPv4
65                                    Instance. Optional parameter that may be NULL.
66   @param[out]  SnpModeData         Pointer to the buffer to receive the current SNP
67                                    configuration data indirectly used by the TCPv4
68                                    Instance. Optional parameter that may be NULL.
69 
70   @retval EFI_SUCCESS              The mode data was read.
71   @retval EFI_NOT_STARTED          No configuration data is available because this
72                                    instance hasn't been started.
73   @retval EFI_INVALID_PARAMETER    This is NULL.
74 
75 **/
76 EFI_STATUS
77 EFIAPI
Tcp4GetModeData(IN EFI_TCP4_PROTOCOL * This,OUT EFI_TCP4_CONNECTION_STATE * Tcp4State OPTIONAL,OUT EFI_TCP4_CONFIG_DATA * Tcp4ConfigData OPTIONAL,OUT EFI_IP4_MODE_DATA * Ip4ModeData OPTIONAL,OUT EFI_MANAGED_NETWORK_CONFIG_DATA * MnpConfigData OPTIONAL,OUT EFI_SIMPLE_NETWORK_MODE * SnpModeData OPTIONAL)78 Tcp4GetModeData (
79   IN   EFI_TCP4_PROTOCOL                  *This,
80   OUT  EFI_TCP4_CONNECTION_STATE          *Tcp4State      OPTIONAL,
81   OUT  EFI_TCP4_CONFIG_DATA               *Tcp4ConfigData OPTIONAL,
82   OUT  EFI_IP4_MODE_DATA                  *Ip4ModeData    OPTIONAL,
83   OUT  EFI_MANAGED_NETWORK_CONFIG_DATA    *MnpConfigData  OPTIONAL,
84   OUT  EFI_SIMPLE_NETWORK_MODE            *SnpModeData    OPTIONAL
85   )
86 {
87   TCP4_MODE_DATA  TcpMode;
88   SOCKET          *Sock;
89 
90   if (NULL == This) {
91     return EFI_INVALID_PARAMETER;
92   }
93 
94   Sock                    = SOCK_FROM_THIS (This);
95 
96   TcpMode.Tcp4State       = Tcp4State;
97   TcpMode.Tcp4ConfigData  = Tcp4ConfigData;
98   TcpMode.Ip4ModeData     = Ip4ModeData;
99   TcpMode.MnpConfigData   = MnpConfigData;
100   TcpMode.SnpModeData     = SnpModeData;
101 
102   return SockGetMode (Sock, &TcpMode);
103 }
104 
105 /**
106   Initialize or brutally reset the operational parameters for
107   this EFI TCPv4 instance.
108 
109   @param[in]   This                Pointer to the EFI_TCP4_PROTOCOL instance.
110   @param[in]   TcpConfigData       Pointer to the configure data to configure the
111                                    instance. Optional parameter that may be NULL.
112 
113   @retval EFI_SUCCESS              The operational settings were set, changed, or
114                                    reset successfully.
115   @retval EFI_NO_MAPPING           When using a default address, configuration
116                                    (through DHCP, BOOTP, RARP, etc.) is not
117                                    finished.
118   @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.
119   @retval EFI_ACCESS_DENIED        Configuring TCP instance when it is already
120                                    configured.
121   @retval EFI_DEVICE_ERROR         An unexpected network or system error occurred.
122   @retval EFI_UNSUPPORTED          One or more of the control options are not
123                                    supported in the implementation.
124   @retval EFI_OUT_OF_RESOURCES     Could not allocate enough system resources.
125 
126 **/
127 EFI_STATUS
128 EFIAPI
Tcp4Configure(IN EFI_TCP4_PROTOCOL * This,IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL)129 Tcp4Configure (
130   IN EFI_TCP4_PROTOCOL        * This,
131   IN EFI_TCP4_CONFIG_DATA     * TcpConfigData OPTIONAL
132   )
133 {
134   EFI_TCP4_OPTION  *Option;
135   SOCKET           *Sock;
136   EFI_STATUS       Status;
137   IP4_ADDR         Ip;
138   IP4_ADDR         SubnetMask;
139 
140   if (NULL == This) {
141     return EFI_INVALID_PARAMETER;
142   }
143 
144   //
145   // Tcp protocol related parameter check will be conducted here
146   //
147   if (NULL != TcpConfigData) {
148 
149     CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR));
150     if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {
151       return EFI_INVALID_PARAMETER;
152     }
153 
154     if (TcpConfigData->AccessPoint.ActiveFlag && (0 == TcpConfigData->AccessPoint.RemotePort || (Ip == 0))) {
155       return EFI_INVALID_PARAMETER;
156     }
157 
158     if (!TcpConfigData->AccessPoint.UseDefaultAddress) {
159 
160       CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));
161       CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));
162       if (!NetIp4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) {
163         return EFI_INVALID_PARAMETER;
164       }
165     }
166 
167     Option = TcpConfigData->ControlOption;
168     if ((NULL != Option) && (Option->EnableSelectiveAck || Option->EnablePathMtuDiscovery)) {
169       return EFI_UNSUPPORTED;
170     }
171   }
172 
173   Sock = SOCK_FROM_THIS (This);
174 
175   if (NULL == TcpConfigData) {
176     return SockFlush (Sock);
177   }
178 
179   Status = SockConfigure (Sock, TcpConfigData);
180 
181   if (EFI_NO_MAPPING == Status) {
182     Sock->ConfigureState = SO_NO_MAPPING;
183   }
184 
185   return Status;
186 }
187 
188 /**
189   Add or delete routing entries.
190 
191   @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.
192   @param[in]  DeleteRoute          If TRUE, delete the specified route from routing
193                                    table; if FALSE, add the specified route to
194                                    routing table.
195   @param[in]  SubnetAddress        The destination network.
196   @param[in]  SubnetMask           The subnet mask for the destination network.
197   @param[in]  GatewayAddress       The gateway address for this route.
198 
199   @retval EFI_SUCCESS              The operation completed successfully.
200   @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance has not been
201                                    configured.
202   @retval EFI_NO_MAPPING           When using a default address, configuration
203                                    (through DHCP, BOOTP, RARP, etc.) is not
204                                    finished.
205   @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.
206   @retval EFI_OUT_OF_RESOURCES     Could not allocate enough resources to add the
207                                    entry to the routing table.
208   @retval EFI_NOT_FOUND            This route is not in the routing table.
209   @retval EFI_ACCESS_DENIED        This route is already in the routing table.
210   @retval EFI_UNSUPPORTED          The TCP driver does not support this operation.
211 
212 **/
213 EFI_STATUS
214 EFIAPI
Tcp4Routes(IN EFI_TCP4_PROTOCOL * This,IN BOOLEAN DeleteRoute,IN EFI_IPv4_ADDRESS * SubnetAddress,IN EFI_IPv4_ADDRESS * SubnetMask,IN EFI_IPv4_ADDRESS * GatewayAddress)215 Tcp4Routes (
216   IN EFI_TCP4_PROTOCOL           *This,
217   IN BOOLEAN                     DeleteRoute,
218   IN EFI_IPv4_ADDRESS            *SubnetAddress,
219   IN EFI_IPv4_ADDRESS            *SubnetMask,
220   IN EFI_IPv4_ADDRESS            *GatewayAddress
221   )
222 {
223   SOCKET          *Sock;
224   TCP4_ROUTE_INFO RouteInfo;
225 
226   if (NULL == This) {
227     return EFI_INVALID_PARAMETER;
228   }
229 
230   Sock                      = SOCK_FROM_THIS (This);
231 
232   RouteInfo.DeleteRoute     = DeleteRoute;
233   RouteInfo.SubnetAddress   = SubnetAddress;
234   RouteInfo.SubnetMask      = SubnetMask;
235   RouteInfo.GatewayAddress  = GatewayAddress;
236 
237   return SockRoute (Sock, &RouteInfo);
238 }
239 
240 /**
241   Initiate a non-blocking TCP connection request for an active TCP instance.
242 
243   @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.
244   @param[in]  ConnectionToken      Pointer to the connection token to return when
245                                    the TCP three way handshake finishes.
246 
247   @retval EFI_SUCCESS              The connection request successfully
248                                    initiated.
249   @retval EFI_NOT_STARTED          This EFI_TCP4_PROTOCOL instance hasn't been
250                                    configured.
251   @retval EFI_ACCESS_DENIED        The instance is not configured as an active one,
252                                    or it is not in Tcp4StateClosed state.
253   @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.
254   @retval EFI_OUT_OF_RESOURCES     The driver can't allocate enough resources to
255                                    initiate the active open.
256   @retval EFI_DEVICE_ERROR         An unexpected system or network error occurred.
257 
258 **/
259 EFI_STATUS
260 EFIAPI
Tcp4Connect(IN EFI_TCP4_PROTOCOL * This,IN EFI_TCP4_CONNECTION_TOKEN * ConnectionToken)261 Tcp4Connect (
262   IN EFI_TCP4_PROTOCOL           *This,
263   IN EFI_TCP4_CONNECTION_TOKEN   *ConnectionToken
264   )
265 {
266   SOCKET  *Sock;
267 
268   if (NULL == This || NULL == ConnectionToken || NULL == ConnectionToken->CompletionToken.Event) {
269     return EFI_INVALID_PARAMETER;
270   }
271 
272   Sock = SOCK_FROM_THIS (This);
273 
274   return SockConnect (Sock, ConnectionToken);
275 }
276 
277 /**
278   Listen on the passive instance to accept an incoming connection request.
279 
280   @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.
281   @param[in]  ListenToken          Pointer to the listen token to return when
282                                    operation finishes.
283 
284   @retval EFI_SUCCESS              The listen token was queued successfully.
285   @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance hasn't been
286                                    configured.
287   @retval EFI_ACCESS_DENIED        The instatnce is not a passive one or it is not
288                                    in Tcp4StateListen state or a same listen token
289                                    has already existed in the listen token queue of
290                                    this TCP instance.
291   @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.
292   @retval EFI_OUT_OF_RESOURCES     Could not allocate enough resources to finish
293                                    the operation.
294   @retval EFI_DEVICE_ERROR         An unexpected system or network error occurred.
295 
296 **/
297 EFI_STATUS
298 EFIAPI
Tcp4Accept(IN EFI_TCP4_PROTOCOL * This,IN EFI_TCP4_LISTEN_TOKEN * ListenToken)299 Tcp4Accept (
300   IN EFI_TCP4_PROTOCOL             *This,
301   IN EFI_TCP4_LISTEN_TOKEN         *ListenToken
302   )
303 {
304   SOCKET  *Sock;
305 
306   if (NULL == This || NULL == ListenToken || NULL == ListenToken->CompletionToken.Event) {
307     return EFI_INVALID_PARAMETER;
308   }
309 
310   Sock = SOCK_FROM_THIS (This);
311 
312   return SockAccept (Sock, ListenToken);
313 }
314 
315 /**
316   Queues outgoing data into the transmit queue
317 
318   @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.
319   @param[in]  Token                Pointer to the completion token to queue to the
320                                    transmit queue.
321 
322   @retval EFI_SUCCESS              The data has been queued for transmission.
323   @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance hasn't been
324                                    configured.
325   @retval EFI_NO_MAPPING           When using a default address, configuration
326                                    (DHCP, BOOTP, RARP, etc.) is not finished yet.
327   @retval EFI_INVALID_PARAMETER    One or more parameters are invalid
328   @retval EFI_ACCESS_DENIED        One or more of the following conditions is TRUE:
329                                    * A transmit completion token with the same
330                                    Token-> CompletionToken.Event was already in the
331                                    transmission queue. * The current instance is in
332                                    Tcp4StateClosed state. * The current instance is
333                                    a passive one and it is in Tcp4StateListen
334                                    state. * User has called Close() to disconnect
335                                    this connection.
336   @retval EFI_NOT_READY            The completion token could not be queued because
337                                    the transmit queue is full.
338   @retval EFI_OUT_OF_RESOURCES     Could not queue the transmit data because of a
339                                    resource shortage.
340   @retval EFI_NETWORK_UNREACHABLE  There is no route to the destination network or
341                                    address.
342 
343 **/
344 EFI_STATUS
345 EFIAPI
Tcp4Transmit(IN EFI_TCP4_PROTOCOL * This,IN EFI_TCP4_IO_TOKEN * Token)346 Tcp4Transmit (
347   IN EFI_TCP4_PROTOCOL            *This,
348   IN EFI_TCP4_IO_TOKEN            *Token
349   )
350 {
351   SOCKET      *Sock;
352   EFI_STATUS  Status;
353 
354   if (NULL == This ||
355       NULL == Token ||
356       NULL == Token->CompletionToken.Event ||
357       NULL == Token->Packet.TxData ||
358       0 == Token->Packet.TxData->FragmentCount ||
359       0 == Token->Packet.TxData->DataLength
360       ) {
361     return EFI_INVALID_PARAMETER;
362   }
363 
364   Status = TcpChkDataBuf (
365             Token->Packet.TxData->DataLength,
366             Token->Packet.TxData->FragmentCount,
367             Token->Packet.TxData->FragmentTable
368             );
369   if (EFI_ERROR (Status)) {
370     return Status;
371   }
372 
373   Sock = SOCK_FROM_THIS (This);
374 
375   return SockSend (Sock, Token);
376 }
377 
378 /**
379   Place an asynchronous receive request into the receiving queue.
380 
381   @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.
382   @param[in]  Token                Pointer to a token that is associated with the
383                                    receive data descriptor.
384 
385   @retval EFI_SUCCESS              The receive completion token was cached
386   @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance hasn't been
387                                    configured.
388   @retval EFI_NO_MAPPING           When using a default address, configuration
389                                    (DHCP, BOOTP, RARP, etc.) is not finished yet.
390   @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.
391   @retval EFI_OUT_OF_RESOURCES     The receive completion token could not be queued
392                                    due to a lack of system resources.
393   @retval EFI_DEVICE_ERROR         An unexpected system or network error occurred.
394   @retval EFI_ACCESS_DENIED        One or more of the following conditions is TRUE:
395                                    * A receive completion token with the same
396                                    Token->CompletionToken.Event was already in the
397                                    receive queue. * The current instance is in
398                                    Tcp4StateClosed state. * The current instance is
399                                    a passive one and it is in Tcp4StateListen
400                                    state. * User has called Close() to disconnect
401                                    this connection.
402   @retval EFI_CONNECTION_FIN       The communication peer has closed the connection,
403                                    and there is no any buffered data in the receive
404                                    buffer of this instance.
405   @retval EFI_NOT_READY            The receive request could not be queued because
406                                    the receive queue is full.
407 
408 **/
409 EFI_STATUS
410 EFIAPI
Tcp4Receive(IN EFI_TCP4_PROTOCOL * This,IN EFI_TCP4_IO_TOKEN * Token)411 Tcp4Receive (
412   IN EFI_TCP4_PROTOCOL           *This,
413   IN EFI_TCP4_IO_TOKEN           *Token
414   )
415 {
416   SOCKET      *Sock;
417   EFI_STATUS  Status;
418 
419   if (NULL == This ||
420       NULL == Token ||
421       NULL == Token->CompletionToken.Event ||
422       NULL == Token->Packet.RxData ||
423       0 == Token->Packet.RxData->FragmentCount ||
424       0 == Token->Packet.RxData->DataLength
425       ) {
426     return EFI_INVALID_PARAMETER;
427   }
428 
429   Status = TcpChkDataBuf (
430             Token->Packet.RxData->DataLength,
431             Token->Packet.RxData->FragmentCount,
432             Token->Packet.RxData->FragmentTable
433             );
434   if (EFI_ERROR (Status)) {
435     return Status;
436   }
437 
438   Sock = SOCK_FROM_THIS (This);
439 
440   return SockRcv (Sock, Token);
441 
442 }
443 
444 /**
445   Disconnecting a TCP connection gracefully or reset a TCP connection.
446 
447   @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.
448   @param[in]  CloseToken           Pointer to the close token to return when
449                                    operation finishes.
450 
451   @retval EFI_SUCCESS              The operation completed successfully.
452   @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance hasn't been
453                                    configured.
454   @retval EFI_ACCESS_DENIED        One or more of the following are TRUE: *
455                                    Configure() has been called with TcpConfigData
456                                    set to NULL, and this function has not returned.
457                                    * Previous Close() call on this instance has not
458                                    finished.
459   @retval EFI_INVALID_PARAMETER    One ore more parameters are invalid.
460   @retval EFI_OUT_OF_RESOURCES     Could not allocate enough resources to finish the
461                                    operation.
462   @retval EFI_DEVICE_ERROR         Any unexpected category error not belonging to those
463                                    listed above.
464 
465 **/
466 EFI_STATUS
467 EFIAPI
Tcp4Close(IN EFI_TCP4_PROTOCOL * This,IN EFI_TCP4_CLOSE_TOKEN * CloseToken)468 Tcp4Close (
469   IN EFI_TCP4_PROTOCOL           *This,
470   IN EFI_TCP4_CLOSE_TOKEN        *CloseToken
471   )
472 {
473   SOCKET  *Sock;
474 
475   if (NULL == This || NULL == CloseToken || NULL == CloseToken->CompletionToken.Event) {
476     return EFI_INVALID_PARAMETER;
477   }
478 
479   Sock = SOCK_FROM_THIS (This);
480 
481   return SockClose (Sock, CloseToken, CloseToken->AbortOnClose);
482 }
483 
484 /**
485   Abort an asynchronous connection, listen, transmission or receive request.
486 
487   @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.
488   @param[in]  Token                Pointer to a token that has been issued by
489                                    Connect(), Accept(), Transmit() or Receive(). If
490                                    NULL, all pending tokens issued by the four
491                                    functions listed above will be aborted.
492 
493   @retval EFI_UNSUPPORTED          The operation is not supported in the current
494                                    implementation.
495 
496 **/
497 EFI_STATUS
498 EFIAPI
Tcp4Cancel(IN EFI_TCP4_PROTOCOL * This,IN EFI_TCP4_COMPLETION_TOKEN * Token OPTIONAL)499 Tcp4Cancel (
500   IN EFI_TCP4_PROTOCOL             *This,
501   IN EFI_TCP4_COMPLETION_TOKEN     *Token OPTIONAL
502   )
503 {
504   return EFI_UNSUPPORTED;
505 }
506 
507 /**
508   Poll to receive incoming data and transmit outgoing segments.
509 
510   @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.
511 
512   @retval EFI_SUCCESS              Incoming or outgoing data was processed.
513   @retval EFI_INVALID_PARAMETER    This is NULL.
514   @retval EFI_DEVICE_ERROR         An unexpected system or network error occurred.
515   @retval EFI_NOT_READY            No incoming or outgoing data was processed.
516   @retval EFI_TIMEOUT              Data was dropped out of the transmission or
517                                    receive queue. Consider increasing the polling
518                                    rate.
519 
520 **/
521 EFI_STATUS
522 EFIAPI
Tcp4Poll(IN EFI_TCP4_PROTOCOL * This)523 Tcp4Poll (
524   IN EFI_TCP4_PROTOCOL        *This
525   )
526 {
527   SOCKET      *Sock;
528   EFI_STATUS  Status;
529 
530   if (NULL == This) {
531     return EFI_INVALID_PARAMETER;
532   }
533 
534   Sock   = SOCK_FROM_THIS (This);
535 
536   Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL);
537 
538   return Status;
539 }
540 
541 /**
542   Get the current operational status.
543 
544   The GetModeData() function copies the current operational settings of this EFI TCPv6
545   Protocol instance into user-supplied buffers. This function can also be used to retrieve
546   the operational setting of underlying drivers such as IPv6, MNP, or SNP.
547 
548   @param[in]  This              Pointer to the EFI_TCP6_PROTOCOL instance.
549   @param[out] Tcp6State         The buffer in which the current TCP state is
550                                 returned. Optional parameter that may be NULL.
551   @param[out] Tcp6ConfigData    The buffer in which the current TCP configuration
552                                 is returned. Optional parameter that may be NULL.
553   @param[out] Ip6ModeData       The buffer in which the current IPv6 configuration
554                                 data used by the TCP instance is returned.
555                                 Optional parameter that may be NULL.
556   @param[out] MnpConfigData     The buffer in which the current MNP configuration
557                                 data indirectly used by the TCP instance is returned.
558                                 Optional parameter that may be NULL.
559   @param[out] SnpModeData       The buffer in which the current SNP mode data
560                                 indirectly used by the TCP instance is returned.
561                                 Optional parameter that may be NULL.
562 
563   @retval EFI_SUCCESS           The mode data was read.
564   @retval EFI_NOT_STARTED       No configuration data is available because this instance hasn't
565                                 been started.
566   @retval EFI_INVALID_PARAMETER This is NULL.
567 
568 **/
569 EFI_STATUS
570 EFIAPI
Tcp6GetModeData(IN EFI_TCP6_PROTOCOL * This,OUT EFI_TCP6_CONNECTION_STATE * Tcp6State OPTIONAL,OUT EFI_TCP6_CONFIG_DATA * Tcp6ConfigData OPTIONAL,OUT EFI_IP6_MODE_DATA * Ip6ModeData OPTIONAL,OUT EFI_MANAGED_NETWORK_CONFIG_DATA * MnpConfigData OPTIONAL,OUT EFI_SIMPLE_NETWORK_MODE * SnpModeData OPTIONAL)571 Tcp6GetModeData (
572   IN  EFI_TCP6_PROTOCOL                  *This,
573   OUT EFI_TCP6_CONNECTION_STATE          *Tcp6State      OPTIONAL,
574   OUT EFI_TCP6_CONFIG_DATA               *Tcp6ConfigData OPTIONAL,
575   OUT EFI_IP6_MODE_DATA                  *Ip6ModeData    OPTIONAL,
576   OUT EFI_MANAGED_NETWORK_CONFIG_DATA    *MnpConfigData  OPTIONAL,
577   OUT EFI_SIMPLE_NETWORK_MODE            *SnpModeData    OPTIONAL
578   )
579 {
580   TCP6_MODE_DATA  TcpMode;
581   SOCKET          *Sock;
582 
583   if (NULL == This) {
584     return EFI_INVALID_PARAMETER;
585   }
586 
587   Sock                   = SOCK_FROM_THIS (This);
588 
589   TcpMode.Tcp6State      = Tcp6State;
590   TcpMode.Tcp6ConfigData = Tcp6ConfigData;
591   TcpMode.Ip6ModeData    = Ip6ModeData;
592   TcpMode.MnpConfigData  = MnpConfigData;
593   TcpMode.SnpModeData    = SnpModeData;
594 
595   return SockGetMode (Sock, &TcpMode);
596 }
597 
598 /**
599   Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
600 
601   The Configure() function does the following:
602   - Initialize this TCP instance, i.e., initialize the communication end settings and
603     specify active open or passive open for an instance.
604   - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
605     transmission and receiving buffer directly without informing the communication peer.
606 
607   No other TCPv6 Protocol operation except Poll() can be executed by this instance until
608   it is configured properly. For an active TCP instance, after a proper configuration it
609   may call Connect() to initiate a three-way handshake. For a passive TCP instance,
610   its state transits to Tcp6StateListen after configuration, and Accept() may be
611   called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
612   the instance is reset. The resetting process will be done brutally, the state machine will
613   be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
614   and no traffic is allowed through this instance.
615 
616   @param[in] This               Pointer to the EFI_TCP6_PROTOCOL instance.
617   @param[in] Tcp6ConfigData     Pointer to the configure data to configure the instance.
618                                 If Tcp6ConfigData is set to NULL, the instance is reset.
619 
620   @retval EFI_SUCCESS           The operational settings were set, changed, or reset
621                                 successfully.
622   @retval EFI_NO_MAPPING        The underlying IPv6 driver was responsible for choosing a source
623                                 address for this instance, but no source address was available for
624                                 use.
625   @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
626                                 - This is NULL.
627                                 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
628                                   one of the configured IP addresses in the underlying IPv6 driver.
629                                 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
630                                   IPv6 address.
631                                 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
632                                   Tcp6ConfigData->AccessPoint.RemotePort is zero when
633                                   Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
634                                 - A same access point has been configured in other TCP
635                                   instance properly.
636   @retval EFI_ACCESS_DENIED     Configuring a TCP instance when it is configured without
637                                 calling Configure() with NULL to reset it.
638   @retval EFI_UNSUPPORTED       One or more of the control options are not supported in
639                                 the implementation.
640   @retval EFI_OUT_OF_RESOURCES  Could not allocate enough system resources when
641                                 executing Configure().
642   @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
643 
644 **/
645 EFI_STATUS
646 EFIAPI
Tcp6Configure(IN EFI_TCP6_PROTOCOL * This,IN EFI_TCP6_CONFIG_DATA * Tcp6ConfigData OPTIONAL)647 Tcp6Configure (
648   IN EFI_TCP6_PROTOCOL        *This,
649   IN EFI_TCP6_CONFIG_DATA     *Tcp6ConfigData OPTIONAL
650   )
651 {
652   EFI_TCP6_OPTION   *Option;
653   SOCKET            *Sock;
654   EFI_STATUS        Status;
655   EFI_IPv6_ADDRESS  *Ip;
656 
657   if (NULL == This) {
658     return EFI_INVALID_PARAMETER;
659   }
660 
661   //
662   // Tcp protocol related parameter check will be conducted here
663   //
664   if (NULL != Tcp6ConfigData) {
665 
666     Ip = &Tcp6ConfigData->AccessPoint.RemoteAddress;
667     if (!NetIp6IsUnspecifiedAddr (Ip) && !NetIp6IsValidUnicast (Ip)) {
668       return EFI_INVALID_PARAMETER;
669     }
670 
671     if (Tcp6ConfigData->AccessPoint.ActiveFlag &&
672         (0 == Tcp6ConfigData->AccessPoint.RemotePort || NetIp6IsUnspecifiedAddr (Ip))
673         ) {
674       return EFI_INVALID_PARAMETER;
675     }
676 
677     Ip = &Tcp6ConfigData->AccessPoint.StationAddress;
678     if (!NetIp6IsUnspecifiedAddr (Ip) && !NetIp6IsValidUnicast (Ip)) {
679       return EFI_INVALID_PARAMETER;
680     }
681 
682     Option = Tcp6ConfigData->ControlOption;
683     if ((NULL != Option) && (Option->EnableSelectiveAck || Option->EnablePathMtuDiscovery)) {
684       return EFI_UNSUPPORTED;
685     }
686   }
687 
688   Sock = SOCK_FROM_THIS (This);
689 
690   if (NULL == Tcp6ConfigData) {
691     return SockFlush (Sock);
692   }
693 
694   Status = SockConfigure (Sock, Tcp6ConfigData);
695 
696   if (EFI_NO_MAPPING == Status) {
697     Sock->ConfigureState = SO_NO_MAPPING;
698   }
699 
700   return Status;
701 }
702 
703 /**
704   Initiate a nonblocking TCP connection request for an active TCP instance.
705 
706   The Connect() function will initiate an active open to the remote peer configured
707   in a current TCP instance if it is configured active. If the connection succeeds or
708   fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
709   and ConnectionToken->CompletionToken.Status will be updated accordingly. This
710   function can only be called for the TCP instance in the Tcp6StateClosed state. The
711   instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
712   If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.
713   Otherwise, the state will return to Tcp6StateClosed.
714 
715   @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
716   @param[in] ConnectionToken     Pointer to the connection token to return when the TCP three
717                                  way handshake finishes.
718 
719   @retval EFI_SUCCESS            The connection request successfully initiated and the state of
720                                  this TCP instance has been changed to Tcp6StateSynSent.
721   @retval EFI_NOT_STARTED        This EFI TCPv6 Protocol instance has not been configured.
722   @retval EFI_ACCESS_DENIED      One or more of the following conditions are TRUE:
723                                  - This instance is not configured as an active one.
724                                  - This instance is not in Tcp6StateClosed state.
725   @retval EFI_INVALID_PARAMETER  One or more of the following are TRUE:
726                                  - This is NULL.
727                                  - ConnectionToken is NULL.
728                                  - ConnectionToken->CompletionToken.Event is NULL.
729   @retval EFI_OUT_OF_RESOURCES   The driver can't allocate enough resources to initiate the active open.
730   @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
731 
732 **/
733 EFI_STATUS
734 EFIAPI
Tcp6Connect(IN EFI_TCP6_PROTOCOL * This,IN EFI_TCP6_CONNECTION_TOKEN * ConnectionToken)735 Tcp6Connect (
736   IN EFI_TCP6_PROTOCOL           *This,
737   IN EFI_TCP6_CONNECTION_TOKEN   *ConnectionToken
738   )
739 {
740   SOCKET  *Sock;
741 
742   if (NULL == This || NULL == ConnectionToken || NULL == ConnectionToken->CompletionToken.Event) {
743     return EFI_INVALID_PARAMETER;
744   }
745 
746   Sock = SOCK_FROM_THIS (This);
747 
748   return SockConnect (Sock, ConnectionToken);
749 }
750 
751 /**
752   Listen on the passive instance to accept an incoming connection request. This is a
753   nonblocking operation.
754 
755   The Accept() function initiates an asynchronous accept request to wait for an incoming
756   connection on the passive TCP instance. If a remote peer successfully establishes a
757   connection with this instance, a new TCP instance will be created and its handle will
758   be returned in ListenToken->NewChildHandle. The newly created instance is configured
759   by inheriting the passive instance's configuration and is ready for use upon return.
760   The new instance is in the Tcp6StateEstablished state.
761 
762   The ListenToken->CompletionToken.Event will be signaled when a new connection is
763   accepted, when a user aborts the listen or when a connection is reset.
764 
765   This function only can be called when a current TCP instance is in Tcp6StateListen state.
766 
767   @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
768   @param[in] ListenToken         Pointer to the listen token to return when operation finishes.
769 
770 
771   @retval EFI_SUCCESS            The listen token queued successfully.
772   @retval EFI_NOT_STARTED        This EFI TCPv6 Protocol instance has not been configured.
773   @retval EFI_ACCESS_DENIED      One or more of the following are TRUE:
774                                  - This instance is not a passive instance.
775                                  - This instance is not in Tcp6StateListen state.
776                                  - The same listen token has already existed in the listen
777                                    token queue of this TCP instance.
778   @retval EFI_INVALID_PARAMETER  One or more of the following are TRUE:
779                                  - This is NULL.
780                                  - ListenToken is NULL.
781                                  - ListentToken->CompletionToken.Event is NULL.
782   @retval EFI_OUT_OF_RESOURCES   Could not allocate enough resource to finish the operation.
783   @retval EFI_DEVICE_ERROR       Any unexpected error not belonging to a category listed above.
784 
785 **/
786 EFI_STATUS
787 EFIAPI
Tcp6Accept(IN EFI_TCP6_PROTOCOL * This,IN EFI_TCP6_LISTEN_TOKEN * ListenToken)788 Tcp6Accept (
789   IN EFI_TCP6_PROTOCOL             *This,
790   IN EFI_TCP6_LISTEN_TOKEN         *ListenToken
791   )
792 {
793   SOCKET  *Sock;
794 
795   if (NULL == This || NULL == ListenToken || NULL == ListenToken->CompletionToken.Event) {
796     return EFI_INVALID_PARAMETER;
797   }
798 
799   Sock = SOCK_FROM_THIS (This);
800 
801   return SockAccept (Sock, ListenToken);
802 }
803 
804 /**
805   Queues outgoing data into the transmit queue.
806 
807   The Transmit() function queues a sending request to this TCP instance along with the
808   user data. The status of the token is updated and the event in the token will be
809   signaled once the data is sent out or an error occurs.
810 
811   @param[in] This                 Pointer to the EFI_TCP6_PROTOCOL instance.
812   @param[in] Token                Pointer to the completion token to queue to the transmit queue.
813 
814   @retval EFI_SUCCESS             The data has been queued for transmission.
815   @retval EFI_NOT_STARTED         This EFI TCPv6 Protocol instance has not been configured.
816   @retval EFI_NO_MAPPING          The underlying IPv6 driver was responsible for choosing a
817                                   source address for this instance, but no source address was
818                                   available for use.
819   @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
820                                   - This is NULL.
821                                   - Token is NULL.
822                                   - Token->CompletionToken.Event is NULL.
823                                   - Token->Packet.TxData is NULL.
824                                   - Token->Packet.FragmentCount is zero.
825                                   - Token->Packet.DataLength is not equal to the sum of fragment lengths.
826   @retval EFI_ACCESS_DENIED       One or more of the following conditions are TRUE:
827                                   - A transmit completion token with the same Token->
828                                     CompletionToken.Event was already in the
829                                     transmission queue.
830                                   - The current instance is in Tcp6StateClosed state.
831                                   - The current instance is a passive one and it is in
832                                     Tcp6StateListen state.
833                                   - User has called Close() to disconnect this connection.
834   @retval EFI_NOT_READY           The completion token could not be queued because the
835                                   transmit queue is full.
836   @retval EFI_OUT_OF_RESOURCES    Could not queue the transmit data because of resource
837                                   shortage.
838   @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
839 
840 **/
841 EFI_STATUS
842 EFIAPI
Tcp6Transmit(IN EFI_TCP6_PROTOCOL * This,IN EFI_TCP6_IO_TOKEN * Token)843 Tcp6Transmit (
844   IN EFI_TCP6_PROTOCOL            *This,
845   IN EFI_TCP6_IO_TOKEN            *Token
846   )
847 {
848   SOCKET      *Sock;
849   EFI_STATUS  Status;
850 
851   if (NULL == This ||
852       NULL == Token ||
853       NULL == Token->CompletionToken.Event ||
854       NULL == Token->Packet.TxData ||
855       0 == Token->Packet.TxData->FragmentCount ||
856       0 == Token->Packet.TxData->DataLength
857       ) {
858     return EFI_INVALID_PARAMETER;
859   }
860 
861   Status = TcpChkDataBuf (
862             Token->Packet.TxData->DataLength,
863             Token->Packet.TxData->FragmentCount,
864             (EFI_TCP4_FRAGMENT_DATA *) Token->Packet.TxData->FragmentTable
865             );
866   if (EFI_ERROR (Status)) {
867     return Status;
868   }
869 
870   Sock = SOCK_FROM_THIS (This);
871 
872   return SockSend (Sock, Token);
873 }
874 
875 /**
876   Places an asynchronous receive request into the receiving queue.
877 
878   The Receive() function places a completion token into the receive packet queue. This
879   function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
880   and the FragmentBuffer used to receive data. The caller also must fill the DataLength that
881   represents the whole length of all FragmentBuffer. When the receive operation completes, the
882   EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
883   fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length
884   will be copied into the FragmentTable; at the same time the full length of received data will
885   be recorded in the DataLength fields. Providing a proper notification function and context
886   for the event enables the user to receive the notification and receiving status. That
887   notification function is guaranteed to not be re-entered.
888 
889   @param[in] This               Pointer to the EFI_TCP6_PROTOCOL instance.
890   @param[in] Token              Pointer to a token that is associated with the receive data
891                                 descriptor.
892 
893   @retval EFI_SUCCESS            The receive completion token was cached.
894   @retval EFI_NOT_STARTED        This EFI TCPv6 Protocol instance has not been configured.
895   @retval EFI_NO_MAPPING         The underlying IPv6 driver was responsible for choosing a source
896                                  address for this instance, but no source address was available for use.
897   @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
898                                  - This is NULL.
899                                  - Token is NULL.
900                                  - Token->CompletionToken.Event is NULL.
901                                  - Token->Packet.RxData is NULL.
902                                  - Token->Packet.RxData->DataLength is 0.
903                                  - The Token->Packet.RxData->DataLength is not the
904                                    sum of all FragmentBuffer length in FragmentTable.
905   @retval EFI_OUT_OF_RESOURCES   The receive completion token could not be queued due to a lack of
906                                  system resources (usually memory).
907   @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
908                                  The EFI TCPv6 Protocol instance has been reset to startup defaults.
909   @retval EFI_ACCESS_DENIED      One or more of the following conditions is TRUE:
910                                  - A receive completion token with the same Token->CompletionToken.Event
911                                    was already in the receive queue.
912                                  - The current instance is in Tcp6StateClosed state.
913                                  - The current instance is a passive one and it is in
914                                    Tcp6StateListen state.
915                                  - User has called Close() to disconnect this connection.
916   @retval EFI_CONNECTION_FIN     The communication peer has closed the connection and there is no
917                                  buffered data in the receive buffer of this instance.
918   @retval EFI_NOT_READY          The receive request could not be queued because the receive queue is full.
919 
920 **/
921 EFI_STATUS
922 EFIAPI
Tcp6Receive(IN EFI_TCP6_PROTOCOL * This,IN EFI_TCP6_IO_TOKEN * Token)923 Tcp6Receive (
924   IN EFI_TCP6_PROTOCOL           *This,
925   IN EFI_TCP6_IO_TOKEN           *Token
926   )
927 {
928   SOCKET      *Sock;
929   EFI_STATUS  Status;
930 
931   if (NULL == This ||
932       NULL == Token ||
933       NULL == Token->CompletionToken.Event ||
934       NULL == Token->Packet.RxData ||
935       0 == Token->Packet.RxData->FragmentCount ||
936       0 == Token->Packet.RxData->DataLength
937       ) {
938     return EFI_INVALID_PARAMETER;
939   }
940 
941   Status = TcpChkDataBuf (
942             Token->Packet.RxData->DataLength,
943             Token->Packet.RxData->FragmentCount,
944             (EFI_TCP4_FRAGMENT_DATA *) Token->Packet.RxData->FragmentTable
945             );
946   if (EFI_ERROR (Status)) {
947     return Status;
948   }
949 
950   Sock = SOCK_FROM_THIS (This);
951 
952   return SockRcv (Sock, Token);
953 }
954 
955 /**
956   Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
957   nonblocking operation.
958 
959   Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
960   transmission data will be sent by the TCP driver, and the current instance will have a graceful close
961   working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet
962   will be sent by TCP driver to fast disconnect this connection. When the close operation completes
963   successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
964   operations are signaled, and any buffers used for TCP network traffic are flushed.
965 
966   @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
967   @param[in] CloseToken          Pointer to the close token to return when operation finishes.
968 
969   @retval EFI_SUCCESS            The Close() was called successfully.
970   @retval EFI_NOT_STARTED        This EFI TCPv6 Protocol instance has not been configured.
971   @retval EFI_ACCESS_DENIED      One or more of the following are TRUE:
972                                  - CloseToken or CloseToken->CompletionToken.Event is already in use.
973                                  - Previous Close() call on this instance has not finished.
974   @retval EFI_INVALID_PARAMETER  One or more of the following are TRUE:
975                                  - This is NULL.
976                                  - CloseToken is NULL.
977                                  - CloseToken->CompletionToken.Event is NULL.
978   @retval EFI_OUT_OF_RESOURCES   Could not allocate enough resource to finish the operation.
979   @retval EFI_DEVICE_ERROR       Any unexpected error not belonging to error categories given above.
980 
981 **/
982 EFI_STATUS
983 EFIAPI
Tcp6Close(IN EFI_TCP6_PROTOCOL * This,IN EFI_TCP6_CLOSE_TOKEN * CloseToken)984 Tcp6Close (
985   IN EFI_TCP6_PROTOCOL           *This,
986   IN EFI_TCP6_CLOSE_TOKEN        *CloseToken
987   )
988 {
989   SOCKET  *Sock;
990 
991   if (NULL == This || NULL == CloseToken || NULL == CloseToken->CompletionToken.Event) {
992     return EFI_INVALID_PARAMETER;
993   }
994 
995   Sock = SOCK_FROM_THIS (This);
996 
997   return SockClose (Sock, CloseToken, CloseToken->AbortOnClose);
998 }
999 
1000 /**
1001   Abort an asynchronous connection, listen, transmission, or receive request.
1002 
1003   The Cancel() function aborts a pending connection, listen, transmit, or
1004   receive request.
1005 
1006   If Token is not NULL and the token is in the connection, listen, transmission,
1007   or receive queue when it is being cancelled, its Token->Status will be set
1008   to EFI_ABORTED, and then Token->Event will be signaled.
1009 
1010   If the token is not in one of the queues, which usually means that the
1011   asynchronous operation has completed, EFI_NOT_FOUND is returned.
1012 
1013   If Token is NULL all asynchronous token issued by Connect(), Accept(),
1014   Transmit(), and Receive() will be aborted.
1015 
1016   @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
1017   @param[in] Token               Pointer to a token that has been issued by
1018                                  EFI_TCP6_PROTOCOL.Connect(),
1019                                  EFI_TCP6_PROTOCOL.Accept(),
1020                                  EFI_TCP6_PROTOCOL.Transmit() or
1021                                  EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
1022                                  tokens issued by above four functions will be aborted. Type
1023                                  EFI_TCP6_COMPLETION_TOKEN is defined in
1024                                  EFI_TCP_PROTOCOL.Connect().
1025 
1026   @retval EFI_UNSUPPORTED        The implementation does not support this function.
1027 
1028 **/
1029 EFI_STATUS
1030 EFIAPI
Tcp6Cancel(IN EFI_TCP6_PROTOCOL * This,IN EFI_TCP6_COMPLETION_TOKEN * Token OPTIONAL)1031 Tcp6Cancel (
1032   IN EFI_TCP6_PROTOCOL           *This,
1033   IN EFI_TCP6_COMPLETION_TOKEN   *Token OPTIONAL
1034   )
1035 {
1036   return EFI_UNSUPPORTED;
1037 }
1038 
1039 /**
1040   Poll to receive incoming data and transmit outgoing segments.
1041 
1042   The Poll() function increases the rate that data is moved between the network
1043   and application, and can be called when the TCP instance is created successfully.
1044   Its use is optional.
1045 
1046   @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
1047 
1048   @retval EFI_SUCCESS            Incoming or outgoing data was processed.
1049   @retval EFI_INVALID_PARAMETER  This is NULL.
1050   @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
1051   @retval EFI_NOT_READY          No incoming or outgoing data is processed.
1052   @retval EFI_TIMEOUT            Data was dropped out of the transmission or receive queue.
1053                                  Consider increasing the polling rate.
1054 
1055 **/
1056 EFI_STATUS
1057 EFIAPI
Tcp6Poll(IN EFI_TCP6_PROTOCOL * This)1058 Tcp6Poll (
1059   IN EFI_TCP6_PROTOCOL        *This
1060   )
1061 {
1062   SOCKET      *Sock;
1063   EFI_STATUS  Status;
1064 
1065   if (NULL == This) {
1066     return EFI_INVALID_PARAMETER;
1067   }
1068 
1069   Sock   = SOCK_FROM_THIS (This);
1070 
1071   Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL);
1072 
1073   return Status;
1074 }
1075 
1076