/** @file\r
+ Implementation of the Socket.\r
\r
-Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
+Copyright (c) 2005 - 2009, Intel Corporation<BR>\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
**/\r
VOID\r
SockProcessSndToken (\r
- IN SOCKET *Sock\r
+ IN OUT SOCKET *Sock\r
);\r
\r
/**\r
UINT32 DataLen;\r
TCP_RSV_DATA *TcpRsvData;\r
BOOLEAN Urg;\r
-\r
ASSERT ((SockBuffer != NULL) && (IsUrg != NULL) && (BufLen > 0));\r
\r
RcvBufEntry = SockBufFirst (SockBuffer);\r
@param Sock Pointer to the socket.\r
@param TcpRxData Pointer to the application provided receive buffer.\r
@param RcvdBytes The maximum length of the data can be copied.\r
- @param IsOOB If TURE the data is OOB, else the data is normal.\r
+ @param IsOOB If TURE the data is OOB, FALSE the data is normal.\r
\r
**/\r
VOID\r
**/\r
UINT32\r
SockProcessRcvToken (\r
- IN SOCKET *Sock,\r
- IN SOCK_IO_TOKEN *RcvToken\r
+ IN SOCKET *Sock,\r
+ IN OUT SOCK_IO_TOKEN *RcvToken\r
)\r
{\r
UINT32 TokenRcvdBytes;\r
\r
ASSERT (Sock != NULL);\r
\r
- ASSERT (SOCK_STREAM == Sock->Type);\r
+ ASSERT (SockStream == Sock->Type);\r
\r
RxData = RcvToken->Packet.RxData;\r
\r
SockSetTcpRxData (Sock, RxData, TokenRcvdBytes, IsUrg);\r
\r
NetbufQueTrim (Sock->RcvBuffer.DataQueue, TokenRcvdBytes);\r
-// SOCK_TRIM_RCV_BUFF (Sock, TokenRcvdBytes);\r
SIGNAL_TOKEN (&(RcvToken->Token), EFI_SUCCESS);\r
\r
return TokenRcvdBytes;\r
the buffer to socket send buffer,then try to send it.\r
\r
@param Sock Pointer to the socket.\r
- @param TcpTxData Pointer to the tcp txdata.\r
+ @param TcpTxData Pointer to the application provided send buffer.\r
\r
@retval EFI_SUCCESS The operation is completed successfully.\r
@retval EFI_OUT_OF_RESOURCES Failed due to resource limit.\r
**/\r
VOID\r
SockWakeConnToken (\r
- IN SOCKET *Sock\r
+ IN OUT SOCKET *Sock\r
)\r
{\r
ASSERT (Sock->ConnectionToken != NULL);\r
**/\r
VOID\r
SockWakeListenToken (\r
- IN SOCKET *Sock\r
+ IN OUT SOCKET *Sock\r
)\r
{\r
SOCKET *Parent;\r
**/\r
VOID\r
SockProcessSndToken (\r
- IN SOCKET *Sock\r
+ IN OUT SOCKET *Sock\r
)\r
{\r
UINT32 FreeSpace;\r
EFI_TCP4_TRANSMIT_DATA *TxData;\r
EFI_STATUS Status;\r
\r
- ASSERT ((Sock != NULL) && (SOCK_STREAM == Sock->Type));\r
+ ASSERT ((Sock != NULL) && (SockStream == Sock->Type));\r
\r
FreeSpace = SockGetFreeSpace (Sock, SOCK_SND_BUF);\r
\r
\r
@param SockInitData Pointer to the initial data of the socket.\r
\r
- @return Pointer to the newly created socket.\r
+ @return Pointer to the newly created socket, return NULL when exception occured.\r
\r
**/\r
SOCKET *\r
EFI_STATUS Status;\r
\r
ASSERT ((SockInitData != NULL) && (SockInitData->ProtoHandler != NULL));\r
- ASSERT (SockInitData->Type == SOCK_STREAM);\r
+ ASSERT (SockInitData->Type == SockStream);\r
ASSERT ((SockInitData->ProtoData != NULL) && (SockInitData->DataSize <= PROTO_RESERVED_LEN));\r
\r
Parent = SockInitData->Parent;\r
**/\r
VOID\r
SockDestroy (\r
- IN SOCKET *Sock\r
+ IN OUT SOCKET *Sock\r
)\r
{\r
VOID *SockProtocol;\r
EFI_GUID *ProtocolGuid;\r
EFI_STATUS Status;\r
\r
- ASSERT (SOCK_STREAM == Sock->Type);\r
+ ASSERT (SockStream == Sock->Type);\r
\r
if (Sock->DestroyCallback != NULL) {\r
Sock->DestroyCallback (Sock, Sock->Context);\r
\r
\r
/**\r
- Flush the socket.\r
+ Flush the sndBuffer and rcvBuffer of socket.\r
\r
@param Sock Pointer to the socket.\r
\r
**/\r
VOID\r
SockConnFlush (\r
- IN SOCKET *Sock\r
+ IN OUT SOCKET *Sock\r
)\r
{\r
SOCKET *Child;\r
Set the state of the socket.\r
\r
@param Sock Pointer to the socket.\r
- @param State The new state to be set.\r
+ @param State The new socket state to be set.\r
\r
**/\r
VOID\r
SockSetState (\r
- IN SOCKET *Sock,\r
- IN SOCK_STATE State\r
+ IN OUT SOCKET *Sock,\r
+ IN UINT8 State\r
)\r
{\r
Sock->State = State;\r
\r
/**\r
Called by the low layer protocol to indicate the socket a connection is \r
- established. This function just changes the socket's state to SO_CONNECTED \r
+ established. \r
+ \r
+ This function just changes the socket's state to SO_CONNECTED \r
and signals the token used for connection establishment.\r
\r
@param Sock Pointer to the socket associated with the\r
\r
\r
/**\r
- Called by the low layer protocol to indicate the connection is closed; This \r
- function flushes the socket, sets the state to SO_CLOSED and signals the close \r
- token.\r
+ Called by the low layer protocol to indicate the connection is closed.\r
+ \r
+ This function flushes the socket, sets the state to SO_CLOSED and signals \r
+ the close token.\r
\r
@param Sock Pointer to the socket associated with the closed\r
connection.\r
+ \r
**/\r
VOID\r
SockConnClosed (\r
- IN SOCKET *Sock\r
+ IN OUT SOCKET *Sock\r
)\r
{\r
if (Sock->CloseToken != NULL) {\r
\r
\r
/**\r
- Called by low layer protocol to indicate that some data is sent or processed; \r
+ Called by low layer protocol to indicate that some data is sent or processed.\r
+ \r
This function trims the sent data in the socket send buffer, signals the data \r
token if proper.\r
\r
IN UINT8 *Dest\r
)\r
{\r
- ASSERT ((Sock != NULL) && SOCK_STREAM == Sock->Type);\r
+ ASSERT ((Sock != NULL) && SockStream == Sock->Type);\r
\r
return NetbufQueCopy (\r
Sock->SndBuffer.DataQueue,\r
\r
\r
/**\r
- Called by the low layer protocol to deliver received data to socket layer; \r
+ Called by the low layer protocol to deliver received data to socket layer.\r
+ \r
This function will append the data to the socket receive buffer, set ther \r
urgent data length and then check if any receive token can be signaled.\r
\r
**/\r
VOID\r
SockDataRcvd (\r
- IN SOCKET *Sock,\r
- IN NET_BUF *NetBuffer,\r
- IN UINT32 UrgLen\r
+ IN SOCKET *Sock,\r
+ IN OUT NET_BUF *NetBuffer,\r
+ IN UINT32 UrgLen\r
)\r
{\r
ASSERT ((Sock != NULL) && (Sock->RcvBuffer.DataQueue != NULL) &&\r
**/\r
VOID\r
SockRcvdErr (\r
- IN SOCKET *Sock,\r
- IN EFI_STATUS Error\r
+ IN OUT SOCKET *Sock,\r
+ IN EFI_STATUS Error\r
)\r
{\r
SOCK_TOKEN *SockToken;\r
\r
\r
/**\r
- Called by the low layer protocol to indicate that there\r
- will be no more data from the communication peer; This\r
- function set the socket's state to SO_NO_MORE_DATA and\r
- signal all queued IO tokens with the error status\r
- EFI_CONNECTION_FIN.\r
+ Called by the low layer protocol to indicate that there will be no more data \r
+ from the communication peer.\r
+ \r
+ This function set the socket's state to SO_NO_MORE_DATA and signal all queued \r
+ IO tokens with the error status EFI_CONNECTION_FIN.\r
\r
@param Sock Pointer to the socket.\r
\r
**/\r
VOID\r
SockNoMoreData (\r
- IN SOCKET *Sock\r
+ IN OUT SOCKET *Sock\r
)\r
{\r
EFI_STATUS Err;\r