/** @file\r
Implementation of the Socket.\r
\r
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
}\r
}\r
\r
+/**\r
+ Cancel the tokens in the specific token list.\r
+\r
+ @param[in] Token Pointer to the Token. If NULL, all tokens \r
+ in SpecifiedTokenList will be canceled. \r
+ @param[in, out] SpecifiedTokenList Pointer to the token list to be checked.\r
+ \r
+ @retval EFI_SUCCESS Cancel the tokens in the specific token listsuccessfully.\r
+ @retval EFI_NOT_FOUND The Token is not found in SpecifiedTokenList.\r
+ \r
+**/\r
+EFI_STATUS\r
+SockCancelToken (\r
+ IN SOCK_COMPLETION_TOKEN *Token,\r
+ IN OUT LIST_ENTRY *SpecifiedTokenList\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+ SOCK_TOKEN *SockToken;\r
+\r
+ Status = EFI_SUCCESS;\r
+ Entry = NULL;\r
+ Next = NULL;\r
+ SockToken = NULL;\r
+\r
+ if (IsListEmpty (SpecifiedTokenList) && Token != NULL) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ \r
+ //\r
+ // Iterate through the SpecifiedTokenList.\r
+ //\r
+ Entry = SpecifiedTokenList->ForwardLink;\r
+ while (Entry != SpecifiedTokenList) {\r
+ SockToken = NET_LIST_USER_STRUCT (Entry, SOCK_TOKEN, TokenList);\r
+ \r
+ if (Token == NULL) {\r
+ SIGNAL_TOKEN (SockToken->Token, EFI_ABORTED);\r
+ RemoveEntryList (&SockToken->TokenList);\r
+ FreePool (SockToken);\r
+ \r
+ Entry = SpecifiedTokenList->ForwardLink;\r
+ Status = EFI_SUCCESS;\r
+ } else {\r
+ if (Token == (VOID *) SockToken->Token) {\r
+ SIGNAL_TOKEN (Token, EFI_ABORTED);\r
+ RemoveEntryList (&(SockToken->TokenList));\r
+ FreePool (SockToken);\r
+ \r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Status = EFI_NOT_FOUND;\r
+ \r
+ Entry = Entry->ForwardLink;\r
+ } \r
+ }\r
+\r
+ ASSERT (IsListEmpty (SpecifiedTokenList) || Token != NULL);\r
+ \r
+ return Status;\r
+}\r
+\r
/**\r
Create a socket with initial data SockInitData.\r
\r
/** @file\r
The function declaration that provided for Socket Interface.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
IN OUT SOCKET *Sock\r
);\r
\r
+/**\r
+ Cancel the tokens in the specific token list.\r
+\r
+ @param[in] Token Pointer to the Token. If NULL, all tokens \r
+ in SpecifiedTokenList will be canceled. \r
+ @param[in, out] SpecifiedTokenList Pointer to the token list to be checked.\r
+ \r
+ @retval EFI_SUCCESS Cancel the tokens in the specific token listsuccessfully.\r
+ @retval EFI_NOT_FOUND The Token is not found in SpecifiedTokenList.\r
+ \r
+**/\r
+EFI_STATUS\r
+SockCancelToken (\r
+ IN SOCK_COMPLETION_TOKEN *Token,\r
+ IN OUT LIST_ENTRY *SpecifiedTokenList\r
+ );\r
+\r
/**\r
Create a socket with initial data SockInitData.\r
\r
/** @file\r
Interface function of the Socket.\r
\r
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
return Status;\r
}\r
\r
+/**\r
+ Abort the socket associated connection, listen, transmission or receive request.\r
+\r
+ @param[in, out] Sock Pointer to the socket to abort.\r
+ @param[in] Token Pointer to a token that has been issued by\r
+ Connect(), Accept(), Transmit() or Receive(). If\r
+ NULL, all pending tokens issued by the four\r
+ functions listed above will be aborted.\r
+\r
+ @retval EFI_UNSUPPORTED The operation is not supported in the current\r
+ implementation.\r
+**/\r
+EFI_STATUS\r
+SockCancel (\r
+ IN OUT SOCKET *Sock,\r
+ IN VOID *Token\r
+ ) \r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ ASSERT (SockStream == Sock->Type);\r
+\r
+ Status = EfiAcquireLockOrFail (&(Sock->Lock));\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG (\r
+ (EFI_D_ERROR,\r
+ "SockCancel: Get the access for socket failed with %r",\r
+ Status)\r
+ );\r
+\r
+ return EFI_ACCESS_DENIED;\r
+ }\r
+\r
+ if (SOCK_IS_UNCONFIGURED (Sock)) {\r
+ Status = EFI_NOT_STARTED;\r
+ goto Exit;\r
+ }\r
+ \r
+ //\r
+ // 1. Check ConnectionToken.\r
+ //\r
+ if (Token == NULL || (SOCK_COMPLETION_TOKEN *) Token == Sock->ConnectionToken) {\r
+ if (Sock->ConnectionToken != NULL) {\r
+ SIGNAL_TOKEN (Sock->ConnectionToken, EFI_ABORTED);\r
+ Sock->ConnectionToken = NULL;\r
+ }\r
+\r
+ if (Token != NULL) {\r
+ Status = EFI_SUCCESS;\r
+ goto Exit;\r
+ }\r
+ }\r
+\r
+ //\r
+ // 2. Check ListenTokenList.\r
+ //\r
+ Status = SockCancelToken (Token, &Sock->ListenTokenList);\r
+ if (Token != NULL && !EFI_ERROR (Status)) {\r
+ goto Exit;\r
+ }\r
+\r
+ //\r
+ // 3. Check RcvTokenList.\r
+ //\r
+ Status = SockCancelToken (Token, &Sock->RcvTokenList);\r
+ if (Token != NULL && !EFI_ERROR (Status)) {\r
+ goto Exit;\r
+ }\r
+ \r
+ //\r
+ // 4. Check SndTokenList.\r
+ //\r
+ Status = SockCancelToken (Token, &Sock->SndTokenList);\r
+ if (Token != NULL && !EFI_ERROR (Status)) {\r
+ goto Exit;\r
+ }\r
+\r
+ //\r
+ // 5. Check ProcessingSndTokenList.\r
+ //\r
+ Status = SockCancelToken (Token, &Sock->ProcessingSndTokenList);\r
+ \r
+Exit:\r
+ EfiReleaseLock (&(Sock->Lock));\r
+ return Status;\r
+}\r
+\r
+\r
/**\r
Get the mode data of the low layer protocol.\r
\r
/** @file\r
Common head file for TCP socket.\r
\r
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
IN BOOLEAN OnAbort\r
);\r
\r
+/**\r
+ Abort the socket associated connection, listen, transmission or receive request.\r
+\r
+ @param[in, out] Sock Pointer to the socket to abort.\r
+ @param[in] Token Pointer to a token that has been issued by\r
+ Connect(), Accept(), Transmit() or Receive(). If\r
+ NULL, all pending tokens issued by the four\r
+ functions listed above will be aborted.\r
+\r
+ @retval EFI_UNSUPPORTED The operation is not supported in the current\r
+ implementation.\r
+**/\r
+EFI_STATUS\r
+SockCancel (\r
+ IN OUT SOCKET *Sock,\r
+ IN VOID *Token\r
+ );\r
+\r
/**\r
Get the mode data of the low layer protocol.\r
\r
Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.\r
\r
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
/**\r
Abort an asynchronous connection, listen, transmission or receive request.\r
\r
- @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
- @param[in] Token Pointer to a token that has been issued by\r
- Connect(), Accept(), Transmit() or Receive(). If\r
- NULL, all pending tokens issued by the four\r
- functions listed above will be aborted.\r
-\r
- @retval EFI_UNSUPPORTED The operation is not supported in the current\r
- implementation.\r
+ @param This The pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param Token The pointer to a token that has been issued by\r
+ EFI_TCP4_PROTOCOL.Connect(),\r
+ EFI_TCP4_PROTOCOL.Accept(),\r
+ EFI_TCP4_PROTOCOL.Transmit() or\r
+ EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending\r
+ tokens issued by above four functions will be aborted. Type\r
+ EFI_TCP4_COMPLETION_TOKEN is defined in\r
+ EFI_TCP4_PROTOCOL.Connect().\r
+\r
+ @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r
+ is signaled.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_NOT_STARTED This instance hasn't been configured.\r
+ @retval EFI_NO_MAPPING When using the default address, configuration\r
+ (DHCP, BOOTP,RARP, etc.) hasn't finished yet.\r
+ @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the\r
+ transmission or receive queue. It has either\r
+ completed or wasn't issued by Transmit() and Receive().\r
\r
**/\r
EFI_STATUS\r
IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL\r
)\r
{\r
- return EFI_UNSUPPORTED;\r
+ SOCKET *Sock;\r
+\r
+ if (NULL == This) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Sock = SOCK_FROM_THIS (This);\r
+\r
+ return SockCancel (Sock, Token);\r
}\r
\r
/**\r
}\r
\r
/**\r
- Abort an asynchronous connection, listen, transmission, or receive request.\r
+ Abort an asynchronous connection, listen, transmission or receive request.\r
\r
- The Cancel() function aborts a pending connection, listen, transmit, or\r
+ The Cancel() function aborts a pending connection, listen, transmit or\r
receive request.\r
\r
- If Token is not NULL and the token is in the connection, listen, transmission,\r
+ If Token is not NULL and the token is in the connection, listen, transmission\r
or receive queue when it is being cancelled, its Token->Status will be set\r
- to EFI_ABORTED, and then Token->Event will be signaled.\r
+ to EFI_ABORTED and then Token->Event will be signaled.\r
\r
If the token is not in one of the queues, which usually means that the\r
asynchronous operation has completed, EFI_NOT_FOUND is returned.\r
\r
If Token is NULL all asynchronous token issued by Connect(), Accept(),\r
- Transmit(), and Receive() will be aborted.\r
+ Transmit() and Receive() will be aborted.\r
\r
@param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
@param[in] Token Pointer to a token that has been issued by\r
EFI_TCP6_COMPLETION_TOKEN is defined in\r
EFI_TCP_PROTOCOL.Connect().\r
\r
- @retval EFI_UNSUPPORTED The implementation does not support this function.\r
+ @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r
+ is signaled.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_NOT_STARTED This instance hasn't been configured.\r
+ @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or\r
+ receive queue. It has either completed or wasn't issued by\r
+ Transmit() and Receive().\r
\r
**/\r
EFI_STATUS\r
IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL\r
)\r
{\r
- return EFI_UNSUPPORTED;\r
+ SOCKET *Sock;\r
+\r
+ if (NULL == This) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Sock = SOCK_FROM_THIS (This);\r
+\r
+ return SockCancel (Sock, Token);\r
}\r
\r
/**\r
Declaration of protocol interfaces in EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.\r
It is the common head file for all Tcp*.c in TCP driver.\r
\r
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
/**\r
Abort an asynchronous connection, listen, transmission or receive request.\r
\r
- @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
- @param[in] Token Pointer to a token that has been issued by\r
- Connect(), Accept(), Transmit() or Receive(). If\r
- NULL, all pending tokens issued by the above four\r
- functions will be aborted.\r
-\r
- @retval EFI_UNSUPPORTED The operation is not supported in the current\r
- implementation.\r
+ @param This The pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param Token The pointer to a token that has been issued by\r
+ EFI_TCP4_PROTOCOL.Connect(),\r
+ EFI_TCP4_PROTOCOL.Accept(),\r
+ EFI_TCP4_PROTOCOL.Transmit() or\r
+ EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending\r
+ tokens issued by above four functions will be aborted. Type\r
+ EFI_TCP4_COMPLETION_TOKEN is defined in\r
+ EFI_TCP4_PROTOCOL.Connect().\r
+\r
+ @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r
+ is signaled.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_NOT_STARTED This instance hasn't been configured.\r
+ @retval EFI_NO_MAPPING When using the default address, configuration\r
+ (DHCP, BOOTP,RARP, etc.) hasn't finished yet.\r
+ @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the\r
+ transmission or receive queue. It has either\r
+ completed or wasn't issued by Transmit() and Receive().\r
\r
**/\r
EFI_STATUS\r
EFI_TCP6_COMPLETION_TOKEN is defined in\r
EFI_TCP_PROTOCOL.Connect().\r
\r
- @retval EFI_UNSUPPORTED The implementation does not support this function.\r
+ @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r
+ is signaled.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_NOT_STARTED This instance hasn't been configured.\r
+ @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or\r
+ receive queue. It has either completed or wasn't issued by\r
+ Transmit() and Receive().\r
\r
**/\r
EFI_STATUS\r