]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add comments for functions.
authorniry <niry@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 16 Dec 2008 02:57:53 +0000 (02:57 +0000)
committerniry <niry@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 16 Dec 2008 02:57:53 +0000 (02:57 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7039 6f19259b-4bc3-4df7-8a09-765794883524

19 files changed:
MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h
MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Io.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c

index 2e318b7d09bf99b45bfb4c2dbcf99f64fb6b95e5..377fd3bb4bae05ce0c95c3c4b9fd25b1927cd671 100644 (file)
@@ -1,28 +1,18 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
+Copyright (c) 2005 - 2007, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  ComponentName.c\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #include "Tcp4Main.h"\r
 \r
-//\r
-// EFI Component Name Functions\r
-//\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the driver.\r
 \r
@@ -33,10 +23,10 @@ Abstract:
   by This does not support the language specified by Language,\r
   then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language. This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
@@ -45,7 +35,7 @@ Abstract:
                                 to the driver writer. Language is specified\r
                                 in RFC 3066 or ISO 639-2 language code format.\r
 \r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+  @param[out]  DriverName       A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 driver specified by This in the language\r
                                 specified by Language.\r
@@ -65,9 +55,9 @@ Abstract:
 EFI_STATUS\r
 EFIAPI\r
 TcpComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
+  IN     EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN     CHAR8                        *Language,\r
+     OUT CHAR16                       **DriverName\r
   );\r
 \r
 \r
@@ -84,15 +74,15 @@ TcpComponentNameGetDriverName (
   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
   support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+  @param[in]  ControllerHandle  The handle of a controller that the driver\r
                                 specified by This is managing.  This handle\r
                                 specifies the controller whose name is to be\r
                                 returned.\r
 \r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+  @param[in]  ChildHandle       The handle of the child controller to retrieve\r
                                 the name of.  This is an optional parameter that\r
                                 may be NULL.  It will be NULL for device\r
                                 drivers.  It will also be NULL for a bus drivers\r
@@ -101,7 +91,7 @@ TcpComponentNameGetDriverName (
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language.  This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
@@ -110,7 +100,7 @@ TcpComponentNameGetDriverName (
                                 to the driver writer. Language is specified in\r
                                 RFC 3066 or ISO 639-2 language code format.\r
 \r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+  @param[out]  ControllerName   A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 controller specified by ControllerHandle and\r
                                 ChildHandle in the language specified by\r
@@ -142,26 +132,26 @@ TcpComponentNameGetDriverName (
 EFI_STATUS\r
 EFIAPI\r
 TcpComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
+  IN     EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN     EFI_HANDLE                   ControllerHandle,\r
+  IN     EFI_HANDLE                   ChildHandle        OPTIONAL,\r
+  IN     CHAR8                        *Language,\r
+     OUT CHAR16                       **ControllerName\r
   );\r
 \r
 \r
-//\r
-// EFI Component Name Protocol\r
-//\r
+///\r
+/// EFI Component Name Protocol\r
+///\r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gTcp4ComponentName = {\r
   TcpComponentNameGetDriverName,\r
   TcpComponentNameGetControllerName,\r
   "eng"\r
 };\r
 \r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
+///\r
+/// EFI Component Name 2 Protocol\r
+///\r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gTcp4ComponentName2 = {\r
   (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) TcpComponentNameGetDriverName,\r
   (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) TcpComponentNameGetControllerName,\r
@@ -190,10 +180,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {
   by This does not support the language specified by Language,\r
   then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language. This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
@@ -202,7 +192,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {
                                 to the driver writer. Language is specified\r
                                 in RFC 3066 or ISO 639-2 language code format.\r
 \r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+  @param[out]  DriverName       A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 driver specified by This in the language\r
                                 specified by Language.\r
@@ -222,9 +212,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {
 EFI_STATUS\r
 EFIAPI\r
 TcpComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
+  IN     EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN     CHAR8                        *Language,\r
+     OUT CHAR16                       **DriverName\r
   )\r
 {\r
   return LookupUnicodeString2 (\r
@@ -249,15 +239,15 @@ TcpComponentNameGetDriverName (
   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
   support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+  @param[in]  ControllerHandle  The handle of a controller that the driver\r
                                 specified by This is managing.  This handle\r
                                 specifies the controller whose name is to be\r
                                 returned.\r
 \r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+  @param[in]  ChildHandle        The handle of the child controller to retrieve\r
                                 the name of.  This is an optional parameter that\r
                                 may be NULL.  It will be NULL for device\r
                                 drivers.  It will also be NULL for a bus drivers\r
@@ -266,7 +256,7 @@ TcpComponentNameGetDriverName (
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language.  This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
@@ -275,7 +265,7 @@ TcpComponentNameGetDriverName (
                                 to the driver writer. Language is specified in\r
                                 RFC 3066 or ISO 639-2 language code format.\r
 \r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+  @param[out]  ControllerName   A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 controller specified by ControllerHandle and\r
                                 ChildHandle in the language specified by\r
@@ -307,11 +297,11 @@ TcpComponentNameGetDriverName (
 EFI_STATUS\r
 EFIAPI\r
 TcpComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
+  IN     EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN     EFI_HANDLE                   ControllerHandle,\r
+  IN     EFI_HANDLE                   ChildHandle        OPTIONAL,\r
+  IN     CHAR8                        *Language,\r
+     OUT CHAR16                       **ControllerName\r
   )\r
 {\r
   return EFI_UNSUPPORTED;\r
index 14342dfff02ed37bec70f1d4712b225e65131855..7cd3a84f27743622b3630381df51c142a5e11ddc 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  SockImpl.c\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #include "SockImpl.h"\r
@@ -35,9 +28,9 @@ Abstract:
 **/\r
 UINT32\r
 SockTcpDataToRcv (\r
-  IN  SOCK_BUFFER   *SockBuffer,\r
-  OUT BOOLEAN       *IsOOB,\r
-  IN  UINT32        BufLen\r
+  IN     SOCK_BUFFER    *SockBuffer,\r
+     OUT BOOLEAN        *IsUrg,\r
+  IN     UINT32         BufLen\r
   );\r
   \r
 /**\r
@@ -52,8 +45,10 @@ SockProcessSndToken (
   );\r
 \r
 /**\r
-    \r
+  Supporting function for both SockImpl and SockInterface.\r
 \r
+  @param Event             The Event this notify function registered to, ignored.\r
+  \r
 **/\r
 VOID\r
 SockFreeFoo (\r
@@ -236,7 +231,8 @@ SockProcessRcvToken (
   //\r
   SockSetTcpRxData (Sock, RxData, TokenRcvdBytes, IsUrg);\r
 \r
-  SOCK_TRIM_RCV_BUFF (Sock, TokenRcvdBytes);\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
@@ -417,7 +413,7 @@ SockWakeListenToken (
     RemoveEntryList (&Sock->ConnectionList);\r
 \r
     Parent->ConnCnt--;\r
-    DEBUG ((EFI_D_WARN, "SockWakeListenToken: accept a socket, now conncnt is %d", Parent->ConnCnt));\r
+    DEBUG ((EFI_D_INFO, "SockWakeListenToken: accept a socket, now conncnt is %d", Parent->ConnCnt));\r
 \r
     Sock->Parent = NULL;\r
   }\r
@@ -668,7 +664,7 @@ SockCreate (
     Parent->ConnCnt++;\r
 \r
     DEBUG (\r
-      (EFI_D_WARN,\r
+      (EFI_D_INFO,\r
       "SockCreate: Create a new socket and add to parent, now conncnt is %d\n",\r
       Parent->ConnCnt)\r
       );\r
@@ -757,7 +753,7 @@ SockDestroy (
     (Sock->Parent->ConnCnt)--;\r
 \r
     DEBUG (\r
-      (EFI_D_WARN,\r
+      (EFI_D_INFO,\r
       "SockDestory: Delete a unaccepted socket from parent"\r
       "now conncnt is %d\n",\r
       Sock->Parent->ConnCnt)\r
index f06179578c4469aae47be6016c38d4cb6d69473e..7381f4460e6d59894e4164408cfeadb44323a961 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  SockImpl.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef _SOCK_IMPL_H_\r
@@ -23,56 +16,110 @@ Abstract:
 \r
 #include "Socket.h"\r
 \r
-\r
-#define SOCK_TRIM_RCV_BUFF(Sock, Len) \\r
-  (NetbufQueTrim ((Sock)->RcvBuffer.DataQueue, (Len)))\r
-\r
+/**\r
+  Signal a event with the given status.\r
+  \r
+  @param Token        The token's event is to be signaled.\r
+  @param TokenStatus  The status to be sent with the event.\r
+  \r
+**/\r
 #define SIGNAL_TOKEN(Token, TokenStatus) \\r
   do { \\r
     (Token)->Status = (TokenStatus); \\r
     gBS->SignalEvent ((Token)->Event); \\r
   } while (0)\r
 \r
-#define SOCK_HEADER_SPACE (60 + 60 + 72)\r
 \r
-//\r
-// Supporting function for both SockImpl and SockInterface\r
-//\r
+/**\r
+  Supporting function for both SockImpl and SockInterface.\r
+\r
+  @param Event  The Event this notify function registered to, ignored.\r
+  \r
+**/\r
 VOID\r
 SockFreeFoo (\r
   IN EFI_EVENT Event\r
   );\r
 \r
+/**\r
+  Process the TCP send data, buffer the tcp txdata and append\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
+\r
+  @retval EFI_SUCCESS           The operation is completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed due to resource limit.\r
+\r
+**/\r
 EFI_STATUS\r
 SockProcessTcpSndData (\r
-  IN SOCKET *Sock,\r
-  IN VOID   *TcpTxData\r
+  IN SOCKET   *Sock,\r
+  IN VOID     *TcpTxData\r
   );\r
 \r
+/**\r
+  Copy data from socket buffer to application provided receive buffer.\r
+\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
+\r
+**/\r
 VOID\r
 SockSetTcpRxData (\r
-  IN SOCKET         *Sock,\r
-  IN VOID           *TcpRxData,\r
-  IN UINT32         RcvdBytes,\r
-  IN BOOLEAN        IsOOB\r
+  IN SOCKET     *Sock,\r
+  IN VOID       *TcpRxData,\r
+  IN UINT32     RcvdBytes,\r
+  IN BOOLEAN    IsOOB\r
   );\r
 \r
+/**\r
+  Get received data from the socket layer to the receive token.\r
+\r
+  @param  Sock                  Pointer to the socket.\r
+  @param  RcvToken              Pointer to the application provided receive token.\r
+\r
+  @return The length of data received in this token.\r
+\r
+**/\r
 UINT32\r
 SockProcessRcvToken (\r
   IN SOCKET        *Sock,\r
   IN SOCK_IO_TOKEN *RcvToken\r
   );\r
 \r
+/**\r
+  Flush the socket.\r
+\r
+  @param  Sock                  Pointer to the socket.\r
+\r
+**/\r
 VOID\r
 SockConnFlush (\r
   IN SOCKET *Sock\r
   );\r
 \r
+/**\r
+  Create a socket with initial data SockInitData.\r
+\r
+  @param  SockInitData          Pointer to the initial data of the socket.\r
+\r
+  @return Pointer to the newly created socket.\r
+\r
+**/\r
 SOCKET *\r
 SockCreate (\r
   IN SOCK_INIT_DATA *SockInitData\r
   );\r
 \r
+/**\r
+  Destroy a socket.\r
+\r
+  @param  Sock                  Pointer to the socket.\r
+\r
+**/\r
 VOID\r
 SockDestroy (\r
   IN SOCKET *Sock\r
index 67aa919c338382595e38aff696c8ea6803735bc1..dd359823b4a50c49b52ed02c5f35cc57ef0dd908 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  SockInterface.c\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 \r
@@ -458,7 +451,7 @@ SockAccept (
       Socket->Parent->ConnCnt--;\r
 \r
       DEBUG (\r
-        (EFI_D_WARN,\r
+        (EFI_D_INFO,\r
         "SockAccept: Accept a socket, now conncount is %d",\r
         Socket->Parent->ConnCnt)\r
         );\r
index 4ee8e6c39e9027cbb9fafe13da0e3dd9e31b5dd0..3c687063c2431803e3beb9ee719003d97d7db5b1 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Socket.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef _SOCKET_H_\r
@@ -40,9 +33,9 @@ Abstract:
 #define SOCK_SND_BUF        0\r
 #define SOCK_RCV_BUF        1\r
 \r
-#define SOCK_BUFF_LOW_WATER 2 * 1024\r
-#define SOCK_RCV_BUFF_SIZE  8 * 1024\r
-#define SOCK_SND_BUFF_SIZE  8 * 1024\r
+#define SOCK_BUFF_LOW_WATER (2 * 1024)\r
+#define SOCK_RCV_BUFF_SIZE  (8 * 1024)\r
+#define SOCK_SND_BUFF_SIZE  (8 * 1024)\r
 #define SOCK_BACKLOG        5\r
 \r
 #define PROTO_RESERVED_LEN  20\r
@@ -70,6 +63,10 @@ Abstract:
 //\r
 //\r
 //\r
+\r
+///\r
+/// Socket state\r
+///\r
 typedef enum {\r
   SO_CLOSED       = 0,\r
   SO_LISTENING,\r
@@ -78,6 +75,9 @@ typedef enum {
   SO_DISCONNECTING\r
 } SOCK_STATE;\r
 \r
+///\r
+/// Socket configure state\r
+///\r
 typedef enum {\r
   SO_UNCONFIGURED       = 0,\r
   SO_CONFIGURED_ACTIVE,\r
@@ -102,21 +102,21 @@ typedef enum {
 #define SOCK_IS_NO_MAPPING(Sock) \\r
   ((Sock)->ConfigureState == SO_NO_MAPPING)\r
 \r
-#define SOCK_IS_CLOSED(Sock)         ((Sock)->State == SO_CLOSED)\r
+#define SOCK_IS_CLOSED(Sock)          ((Sock)->State == SO_CLOSED)\r
 \r
-#define SOCK_IS_LISTENING(Sock)      ((Sock)->State == SO_LISTENING)\r
+#define SOCK_IS_LISTENING(Sock)       ((Sock)->State == SO_LISTENING)\r
 \r
-#define SOCK_IS_CONNECTING(Sock)     ((Sock)->State == SO_CONNECTING)\r
+#define SOCK_IS_CONNECTING(Sock)      ((Sock)->State == SO_CONNECTING)\r
 \r
-#define SOCK_IS_CONNECTED(Sock)      ((Sock)->State == SO_CONNECTED)\r
+#define SOCK_IS_CONNECTED(Sock)       ((Sock)->State == SO_CONNECTED)\r
 \r
-#define SOCK_IS_DISCONNECTING(Sock)  ((Sock)->State == SO_DISCONNECTING)\r
+#define SOCK_IS_DISCONNECTING(Sock)   ((Sock)->State == SO_DISCONNECTING)\r
 \r
-#define SOCK_IS_NO_MORE_DATA(Sock)   (0 != ((Sock)->Flag & SO_NO_MORE_DATA))\r
+#define SOCK_IS_NO_MORE_DATA(Sock)    (0 != ((Sock)->Flag & SO_NO_MORE_DATA))\r
 \r
-#define SOCK_SIGNATURE           EFI_SIGNATURE_32 ('S', 'O', 'C', 'K')\r
+#define SOCK_SIGNATURE                EFI_SIGNATURE_32 ('S', 'O', 'C', 'K')\r
 \r
-#define SOCK_FROM_THIS(a)        CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)\r
+#define SOCK_FROM_THIS(a)             CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)\r
 \r
 #define SET_RCV_BUFFSIZE(Sock, Size)  ((Sock)->RcvBuffer.HighWater = (Size))\r
 \r
@@ -149,11 +149,17 @@ typedef enum {
 \r
 typedef struct _SOCKET SOCKET;\r
 \r
+///\r
+/// Socket completion token\r
+///\r
 typedef struct _SOCK_COMPLETION_TOKEN {\r
-  EFI_EVENT   Event;\r
-  EFI_STATUS  Status;\r
+  EFI_EVENT   Event;            ///< The event to be issued\r
+  EFI_STATUS  Status;           ///< The status to be issued\r
 } SOCK_COMPLETION_TOKEN;\r
 \r
+///\r
+/// The application token with data packet\r
+///\r
 typedef struct _SOCK_IO_TOKEN {\r
   SOCK_COMPLETION_TOKEN Token;\r
   union {\r
@@ -162,150 +168,230 @@ typedef struct _SOCK_IO_TOKEN {
   } Packet;\r
 } SOCK_IO_TOKEN;\r
 \r
-//\r
-// the request issued from socket layer to protocol layer\r
-//\r
+///\r
+///  The request issued from socket layer to protocol layer.  \r
+///\r
 typedef enum {\r
-  SOCK_ATTACH,    // attach current socket to a new PCB\r
-  SOCK_DETACH,    // detach current socket from the PCB\r
-  SOCK_CONFIGURE, // configure attached PCB\r
-  SOCK_FLUSH,     // flush attached PCB\r
-  SOCK_SND,       // need protocol to send something\r
-  SOCK_SNDPUSH,   // need protocol to send pushed data\r
-  SOCK_SNDURG,    // need protocol to send urgent data\r
-  SOCK_CONSUMED,  // application has retrieved data from socket\r
-  SOCK_CONNECT,   // need to connect to a peer\r
-  SOCK_CLOSE,     // need to close the protocol process\r
-  SOCK_ABORT,     // need to reset the protocol process\r
-  SOCK_POLL,      // need to poll to the protocol layer\r
-  SOCK_ROUTE,     // need to add a route information\r
-  SOCK_MODE,      // need to get the mode data of the protocol\r
-  SOCK_GROUP      // need to join a mcast group\r
+  SOCK_ATTACH,    ///< Attach current socket to a new PCB\r
+  SOCK_DETACH,    ///< Detach current socket from the PCB\r
+  SOCK_CONFIGURE, ///< Configure attached PCB\r
+  SOCK_FLUSH,     ///< Flush attached PCB\r
+  SOCK_SND,       ///< Need protocol to send something\r
+  SOCK_SNDPUSH,   ///< Need protocol to send pushed data\r
+  SOCK_SNDURG,    ///< Need protocol to send urgent data\r
+  SOCK_CONSUMED,  ///< Application has retrieved data from socket\r
+  SOCK_CONNECT,   ///< Need to connect to a peer\r
+  SOCK_CLOSE,     ///< Need to close the protocol process\r
+  SOCK_ABORT,     ///< Need to reset the protocol process\r
+  SOCK_POLL,      ///< Need to poll to the protocol layer\r
+  SOCK_ROUTE,     ///< Need to add a route information\r
+  SOCK_MODE,      ///< Need to get the mode data of the protocol\r
+  SOCK_GROUP      ///< Need to join a mcast group\r
 } SOCK_REQUEST;\r
 \r
-//\r
-// the socket type\r
-//\r
+///\r
+///  The socket type.\r
+///\r
 typedef enum {\r
-  SOCK_DGRAM, // this socket providing datagram service\r
-  SOCK_STREAM // this socket providing stream service\r
+  SOCK_DGRAM, ///< This socket providing datagram service\r
+  SOCK_STREAM ///< This socket providing stream service\r
 } SOCK_TYPE;\r
 \r
-//\r
-// the handler of protocol for request from socket\r
-//\r
+///\r
+///  The handler of protocol for request from socket.\r
+///\r
 typedef\r
 EFI_STATUS\r
 (*SOCK_PROTO_HANDLER) (\r
-  IN SOCKET       * Socket,  // the socket issuing the request to protocol\r
-  IN SOCK_REQUEST Request,   // the request issued by socket\r
-  IN VOID *RequestData       // the request related data\r
+  IN SOCKET       *Socket,      ///< The socket issuing the request to protocol\r
+  IN SOCK_REQUEST Request,      ///< The request issued by socket\r
+  IN VOID         *RequestData  ///< The request related data\r
   );\r
 \r
-//\r
-// the buffer structure of rcvd data and send data used by socket\r
-//\r
+///\r
+///  The buffer structure of rcvd data and send data used by socket.\r
+///\r
 typedef struct _SOCK_BUFFER {\r
-  UINT32        HighWater;  // the buffersize upper limit of sock_buffer\r
-  UINT32        LowWater;   // the low warter mark of sock_buffer\r
-  NET_BUF_QUEUE *DataQueue; // the queue to buffer data\r
+  UINT32        HighWater;  ///< The buffersize upper limit of sock_buffer\r
+  UINT32        LowWater;   ///< The low warter mark of sock_buffer\r
+  NET_BUF_QUEUE *DataQueue; ///< The queue to buffer data\r
 } SOCK_BUFFER;\r
 \r
 \r
 //\r
-// socket provided oprerations for low layer protocol\r
+// Socket provided oprerations for low layer protocol\r
 //\r
 \r
 //\r
-// socket provided operations for user interface\r
+// Socket provided operations for user interface\r
 //\r
+\r
+/**\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
+\r
+**/\r
 VOID\r
 SockSetState (\r
   IN SOCKET     *Sock,\r
   IN SOCK_STATE State\r
   );\r
 \r
-//\r
-// when the connection establishment process for a Sock\r
-// is finished low layer protocol calling this function\r
-// to notify socket layer\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
+  and signals the token used for connection establishment.\r
+\r
+  @param  Sock                  Pointer to the socket associated with the\r
+                                established connection.\r
+                                \r
+**/\r
 VOID\r
 SockConnEstablished (\r
   IN SOCKET *Sock\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
+\r
+  @param  Sock                  Pointer to the socket associated with the closed\r
+                                connection.\r
+                                \r
+**/\r
 VOID\r
 SockConnClosed (\r
   IN SOCKET *Sock\r
   );\r
 \r
-//\r
-// called by low layer protocol to trim send buffer of\r
-// Sock, when Count data is sent out completely\r
-//\r
+/**\r
+  Called by low layer protocol to indicate that some data is sent or processed; \r
+  This function trims the sent data in the socket send buffer, signals the data \r
+  token if proper.\r
+\r
+  @param  Sock                  Pointer to the socket.\r
+  @param  Count                 The length of the data processed or sent, in bytes.\r
+\r
+**/\r
 VOID\r
 SockDataSent (\r
-  IN SOCKET  *Sock,\r
-  IN UINT32  Count\r
+  IN SOCKET     *Sock,\r
+  IN UINT32     Count\r
   );\r
 \r
-//\r
-// called by low layer protocol to get Len of data from\r
-// socket to send and copy it in Dest\r
-//\r
+/**\r
+  Called by the low layer protocol to copy some data in socket send\r
+  buffer starting from the specific offset to a buffer provided by\r
+  the caller.\r
+\r
+  @param  Sock                  Pointer to the socket.\r
+  @param  Offset                The start point of the data to be copied.\r
+  @param  Len                   The length of the data to be copied.\r
+  @param  Dest                  Pointer to the destination to copy the data.\r
+\r
+  @return The data size copied.\r
+\r
+**/\r
 UINT32\r
 SockGetDataToSend (\r
-  IN SOCKET *Sock,\r
-  IN UINT32 Offset,\r
-  IN UINT32 Len,\r
-  IN UINT8  *Dest\r
+  IN SOCKET      *Sock,\r
+  IN UINT32      Offset,\r
+  IN UINT32      Len,\r
+  IN UINT8       *Dest\r
   );\r
 \r
-//\r
-//  called by low layer protocol to notify socket no more data can be\r
-//  received\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
+\r
+  @param  Sock                  Pointer to the socket.\r
+\r
+**/\r
 VOID\r
 SockNoMoreData (\r
   IN SOCKET *Sock\r
   );\r
 \r
-//\r
-// called by low layer protocol to append a NetBuffer\r
-// to rcv buffer of sock\r
-//\r
+/**\r
+  Called by the low layer protocol to deliver received data to socket layer; \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
+  @param  Sock                  Pointer to the socket.\r
+  @param  NetBuffer             Pointer to the buffer that contains the received\r
+                                data.\r
+  @param  UrgLen                The length of the urgent data in the received data.\r
+\r
+**/\r
 VOID\r
 SockDataRcvd (\r
   IN SOCKET    *Sock,\r
   IN NET_BUF   *NetBuffer,\r
-  IN UINT32     UrgLen\r
+  IN UINT32    UrgLen\r
   );\r
 \r
+/**\r
+  Get the length of the free space of the specific socket buffer.\r
+\r
+  @param  Sock                  Pointer to the socket.\r
+  @param  Which                 Flag to indicate which socket buffer to check,\r
+                                either send buffer or receive buffer.\r
+\r
+  @return The length of the free space, in bytes.\r
+\r
+**/\r
 UINT32\r
 SockGetFreeSpace (\r
-  IN SOCKET   *Sock,\r
-  IN UINT32   Which\r
+  IN SOCKET  *Sock,\r
+  IN UINT32  Which\r
   );\r
 \r
-SOCKET  *\r
+/**\r
+  Clone a new socket including its associated protocol control block.\r
+\r
+  @param  Sock                  Pointer to the socket to be cloned.\r
+\r
+  @return Pointer to the newly cloned socket. If NULL, error condition occurred.\r
+\r
+**/\r
+SOCKET *\r
 SockClone (\r
   IN SOCKET *Sock\r
   );\r
 \r
+/**\r
+  Signal the receive token with the specific error or\r
+  set socket error code after error is received.\r
+\r
+  @param  Sock                  Pointer to the socket.\r
+  @param  Error                 The error code received.\r
+\r
+**/\r
 VOID\r
 SockRcvdErr (\r
   IN SOCKET       *Sock,\r
   IN EFI_STATUS   Error\r
   );\r
 \r
+///\r
+/// Proto type of the create callback\r
+///\r
 typedef\r
 EFI_STATUS\r
 (*SOCK_CREATE_CALLBACK) (\r
   IN SOCKET  *This,\r
   IN VOID    *Context\r
   );\r
-\r
+  \r
+///\r
+/// Proto type of the destroy callback \r
+///\r
 typedef\r
 VOID\r
 (*SOCK_DESTROY_CALLBACK) (\r
@@ -313,26 +399,26 @@ VOID
   IN VOID    *Context\r
   );\r
 \r
-//\r
-// the initialize data for create a new socket\r
-//\r
+///\r
+///  The initialize data for create a new socket.\r
+///\r
 typedef struct _SOCK_INIT_DATA {\r
   SOCK_TYPE   Type;\r
   SOCK_STATE  State;\r
 \r
-  SOCKET      *Parent;        // the parent of this socket\r
-  UINT32      BackLog;        // the connection limit for listening socket\r
-  UINT32      SndBufferSize;  // the high warter mark of send buffer\r
-  UINT32      RcvBufferSize;  // the high warter mark of receive buffer\r
-  VOID        *Protocol;      // the pointer to protocol function template\r
-                              // wanted to install on socket\r
+  SOCKET      *Parent;        ///< The parent of this socket\r
+  UINT32      BackLog;        ///< The connection limit for listening socket\r
+  UINT32      SndBufferSize;  ///< The high warter mark of send buffer\r
+  UINT32      RcvBufferSize;  ///< The high warter mark of receive buffer\r
+  VOID        *Protocol;      ///< The pointer to protocol function template\r
+                              ///< wanted to install on socket\r
 \r
   //\r
   // Callbacks after socket is created and before socket is to be destroyed.\r
   //\r
-  SOCK_CREATE_CALLBACK   CreateCallback;\r
-  SOCK_DESTROY_CALLBACK  DestroyCallback;\r
-  VOID                   *Context;\r
+  SOCK_CREATE_CALLBACK   CreateCallback;  ///< Callback after created\r
+  SOCK_DESTROY_CALLBACK  DestroyCallback; ///< Callback before destroied\r
+  VOID                   *Context;        ///< The context of the callback\r
 \r
   //\r
   // Opaque protocol data.\r
@@ -340,29 +426,30 @@ typedef struct _SOCK_INIT_DATA {
   VOID                   *ProtoData;\r
   UINT32                 DataSize;\r
 \r
-  SOCK_PROTO_HANDLER     ProtoHandler;\r
+  SOCK_PROTO_HANDLER     ProtoHandler;  ///< The handler of protocol for socket request\r
 \r
-  EFI_HANDLE   DriverBinding; // the driver binding handle\r
+  EFI_HANDLE   DriverBinding;           ///< The driver binding handle\r
 } SOCK_INIT_DATA;\r
 \r
-//\r
-//the union type of TCP and UDP protocol\r
-//\r
-typedef union {\r
-  EFI_TCP4_PROTOCOL TcpProtocol;\r
-  EFI_UDP4_PROTOCOL UdpProtocol;\r
+///\r
+///  The union type of TCP and UDP protocol.\r
+///  \r
+typedef union _NET_PROTOCOL {\r
+  EFI_TCP4_PROTOCOL TcpProtocol;   ///< Tcp protocol\r
+  EFI_UDP4_PROTOCOL UdpProtocol;   ///< Udp protocol\r
 } NET_PROTOCOL;\r
-//\r
-// the socket structure representing a network service access point\r
-//\r
+\r
+///\r
+/// The socket structure representing a network service access point\r
+///\r
 struct _SOCKET {\r
 \r
   //\r
-  // socket description information\r
+  // Socket description information\r
   //\r
-  UINT32                Signature;\r
-  EFI_HANDLE            SockHandle;     // the virtual handle of the socket\r
-  EFI_HANDLE            DriverBinding;  // socket't driver binding protocol\r
+  UINT32                Signature;      ///< Signature of the socket\r
+  EFI_HANDLE            SockHandle;     ///< The virtual handle of the socket\r
+  EFI_HANDLE            DriverBinding;  ///< Socket's driver binding protocol\r
   EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
   LIST_ENTRY                Link;  \r
@@ -370,143 +457,249 @@ struct _SOCKET {
   SOCK_TYPE             Type;\r
   SOCK_STATE            State;\r
   UINT16                Flag;\r
-  EFI_LOCK              Lock;       // the lock of socket\r
-  SOCK_BUFFER           SndBuffer;  // send buffer of application's data\r
-  SOCK_BUFFER           RcvBuffer;  // receive buffer of received data\r
-  EFI_STATUS            SockError;  // the error returned by low layer protocol\r
+  EFI_LOCK              Lock;       ///< The lock of socket\r
+  SOCK_BUFFER           SndBuffer;  ///< Send buffer of application's data\r
+  SOCK_BUFFER           RcvBuffer;  ///< Receive buffer of received data\r
+  EFI_STATUS            SockError;  ///< The error returned by low layer protocol\r
   BOOLEAN               IsDestroyed;\r
 \r
   //\r
-  // fields used to manage the connection request\r
+  // Fields used to manage the connection request\r
   //\r
-  UINT32          BackLog;        // the limit of connection to this socket\r
-  UINT32          ConnCnt;        // the current count of connections to it\r
-  SOCKET          *Parent;        // listening parent that accept the connection\r
-  LIST_ENTRY      ConnectionList; // the connections maintained by this socket\r
+  UINT32          BackLog;        ///< the limit of connection to this socket\r
+  UINT32          ConnCnt;        ///< the current count of connections to it\r
+  SOCKET          *Parent;        ///< listening parent that accept the connection\r
+  LIST_ENTRY      ConnectionList; ///< the connections maintained by this socket\r
+  \r
   //\r
-  // the queue to buffer application's asynchronous token\r
+  // The queue to buffer application's asynchronous token\r
   //\r
   LIST_ENTRY      ListenTokenList;\r
   LIST_ENTRY      RcvTokenList;\r
   LIST_ENTRY      SndTokenList;\r
   LIST_ENTRY      ProcessingSndTokenList;\r
 \r
-  SOCK_COMPLETION_TOKEN *ConnectionToken; // app's token to signal if connected\r
-  SOCK_COMPLETION_TOKEN *CloseToken;      // app's token to signal if closed\r
+  SOCK_COMPLETION_TOKEN *ConnectionToken; ///< app's token to signal if connected\r
+  SOCK_COMPLETION_TOKEN *CloseToken;      ///< app's token to signal if closed\r
 \r
   //\r
-  // interface for low level protocol\r
+  // Interface for low level protocol\r
   //\r
-  SOCK_PROTO_HANDLER    ProtoHandler; // the request handler of protocol\r
-  UINT8 ProtoReserved[PROTO_RESERVED_LEN];  // Data fields reserved for protocol\r
-  NET_PROTOCOL          NetProtocol;\r
+  SOCK_PROTO_HANDLER    ProtoHandler;       ///< The request handler of protocol\r
+  UINT8 ProtoReserved[PROTO_RESERVED_LEN];  ///< Data fields reserved for protocol\r
+  NET_PROTOCOL          NetProtocol;        ///< TCP or UDP protocol socket used\r
 \r
   //\r
-  // Callbacks.\r
+  // Callbacks after socket is created and before socket is to be destroyed.\r
   //\r
-  SOCK_CREATE_CALLBACK   CreateCallback;\r
-  SOCK_DESTROY_CALLBACK  DestroyCallback;\r
-  VOID                   *Context;\r
+  SOCK_CREATE_CALLBACK   CreateCallback;    ///< Callback after created\r
+  SOCK_DESTROY_CALLBACK  DestroyCallback;   ///< Callback before destroied\r
+  VOID                   *Context;          ///< The context of the callback\r
 };\r
 \r
-//\r
-// the token structure buffered in socket layer\r
-//\r
+///\r
+///  The token structure buffered in socket layer.\r
+///\r
 typedef struct _SOCK_TOKEN {\r
-  LIST_ENTRY            TokenList;      // the entry to add in the token list\r
-  SOCK_COMPLETION_TOKEN *Token;         // The application's token\r
-  UINT32                RemainDataLen;  // unprocessed data length\r
-  SOCKET                *Sock;          // the poninter to the socket this token\r
-                                        // belongs to\r
+  LIST_ENTRY            TokenList;      ///< The entry to add in the token list\r
+  SOCK_COMPLETION_TOKEN *Token;         ///< The application's token\r
+  UINT32                RemainDataLen;  ///< Unprocessed data length\r
+  SOCKET                *Sock;          ///< The poninter to the socket this token\r
+                                        ///< belongs to\r
 } SOCK_TOKEN;\r
 \r
-//\r
-// reserved data to access the NET_BUF delivered by UDP driver\r
-//\r
+///\r
+/// Reserved data to access the NET_BUF delivered by UDP driver.\r
+///\r
 typedef struct _UDP_RSV_DATA {\r
   EFI_TIME              TimeStamp;\r
   EFI_UDP4_SESSION_DATA Session;\r
 } UDP_RSV_DATA;\r
 \r
-//\r
-// reserved data to access the NET_BUF delivered by TCP driver\r
-//\r
+///\r
+/// Reserved data to access the NET_BUF delivered by TCP driver.\r
+///\r
 typedef struct _TCP_RSV_DATA {\r
   UINT32 UrgLen;\r
 } TCP_RSV_DATA;\r
 \r
-//\r
-// call it to creat a socket and attach it to a PCB\r
-//\r
-SOCKET  *\r
+/**\r
+  Create a socket and its associated protocol control block\r
+  with the intial data SockInitData and protocol specific\r
+  data ProtoData.\r
+\r
+  @param  SockInitData         Inital data to setting the socket.\r
+  \r
+  @return Pointer to the newly created socket. If NULL, error condition occured.\r
+\r
+**/\r
+SOCKET *\r
 SockCreateChild (\r
   IN SOCK_INIT_DATA *SockInitData\r
   );\r
 \r
-//\r
-// call it to destroy a socket and its related PCB\r
-//\r
+/**\r
+  Destory the socket Sock and its associated protocol control block.\r
+\r
+  @param  Sock                 The socket to be destroyed.\r
+\r
+  @retval EFI_SUCCESS          The socket Sock is destroyed successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket.\r
+\r
+**/\r
 EFI_STATUS\r
 SockDestroyChild (\r
-  IN SOCKET *Sock\r
+  IN   SOCKET *Sock\r
   );\r
 \r
-//\r
-// call it to configure a socket and its related PCB\r
-//\r
+/**\r
+  Configure the specific socket Sock using configuration data ConfigData.\r
+\r
+  @param  Sock                 Pointer to the socket to be configured.\r
+  @param  ConfigData           Pointer to the configuration data.\r
+\r
+  @retval EFI_SUCCESS          The socket is configured successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket or the\r
+                               socket is already configured.\r
+\r
+**/\r
 EFI_STATUS\r
 SockConfigure (\r
   IN SOCKET *Sock,\r
   IN VOID   *ConfigData\r
   );\r
 \r
-//\r
-// call it to connect a socket to the peer\r
-//\r
+/**\r
+  Initiate a connection establishment process.\r
+\r
+  @param  Sock                 Pointer to the socket to initiate the initate the\r
+                               connection.\r
+  @param  Token                Pointer to the token used for the connection\r
+                               operation.\r
+\r
+  @retval EFI_SUCCESS          The connection is initialized successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket, or the\r
+                               socket is closed, or the socket is not configured to\r
+                               be an active one, or the token is already in one of\r
+                               this socket's lists.\r
+  @retval EFI_NO_MAPPING       The IP address configuration operation is not\r
+                               finished.\r
+  @retval EFI_NOT_STARTED      The socket is not configured.\r
+\r
+**/\r
 EFI_STATUS\r
 SockConnect (\r
   IN SOCKET *Sock,\r
   IN VOID   *Token\r
   );\r
 \r
-//\r
-// call it to issue an asynchronous listen token to the socket\r
-//\r
+/**\r
+  Issue a listen token to get an existed connected network instance\r
+  or wait for a connection if there is none.\r
+\r
+  @param  Sock                 Pointer to the socket to accept connections.\r
+  @param  Token                The token to accept a connection.\r
+\r
+  @retval EFI_SUCCESS          Either a connection is accpeted or the Token is\r
+                               buffered for further acception.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket, or the\r
+                               socket is closed, or the socket is not configured to\r
+                               be a passive one, or the token is already in one of\r
+                               this socket's lists.\r
+  @retval EFI_NO_MAPPING       The IP address configuration operation is not\r
+                               finished.\r
+  @retval EFI_NOT_STARTED      The socket is not configured.\r
+  @retval EFI_OUT_OF_RESOURCE  Failed to buffer the Token due to memory limit.\r
+\r
+**/\r
 EFI_STATUS\r
 SockAccept (\r
   IN SOCKET *Sock,\r
   IN VOID   *Token\r
   );\r
 \r
-//\r
-// Call it to send data using this socket\r
-//\r
+/**\r
+  Issue a token with data to the socket to send out.\r
+\r
+  @param  Sock                 Pointer to the socket to process the token with\r
+                               data.\r
+  @param  Token                The token with data that needs to send out.\r
+\r
+  @retval EFI_SUCCESS          The token is processed successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket, or the\r
+                               socket is closed, or the socket is not in a\r
+                               synchronized state , or the token is already in one\r
+                               of this socket's lists.\r
+  @retval EFI_NO_MAPPING       The IP address configuration operation is not\r
+                               finished.\r
+  @retval EFI_NOT_STARTED      The socket is not configured.\r
+  @retval EFI_OUT_OF_RESOURCE  Failed to buffer the token due to memory limit.\r
+\r
+**/\r
 EFI_STATUS\r
 SockSend (\r
   IN SOCKET *Sock,\r
   IN VOID   *Token\r
   );\r
 \r
-//\r
-// Call it to receive data from this socket\r
-//\r
+/**\r
+  Issue a token to get data from the socket.\r
+\r
+  @param  Sock                 Pointer to the socket to get data from.\r
+  @param  Token                The token to store the received data from the\r
+                               socket.\r
+\r
+  @retval EFI_SUCCESS          The token is processed successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket, or the\r
+                               socket is closed, or the socket is not in a\r
+                               synchronized state , or the token is already in one\r
+                               of this socket's lists.\r
+  @retval EFI_NO_MAPPING       The IP address configuration operation is not\r
+                               finished.\r
+  @retval EFI_NOT_STARTED      The socket is not configured.\r
+  @retval EFI_CONNECTION_FIN   The connection is closed and there is no more data.\r
+  @retval EFI_OUT_OF_RESOURCE  Failed to buffer the token due to memory limit.\r
+\r
+**/\r
 EFI_STATUS\r
 SockRcv (\r
   IN SOCKET *Sock,\r
   IN VOID   *Token\r
   );\r
 \r
-//\r
-// Call it to flush a socket\r
-//\r
+/**\r
+  Reset the socket and its associated protocol control block.\r
+\r
+  @param  Sock                 Pointer to the socket to be flushed.\r
+\r
+  @retval EFI_SUCCESS          The socket is flushed successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket.\r
+\r
+**/\r
 EFI_STATUS\r
 SockFlush (\r
   IN SOCKET *Sock\r
   );\r
 \r
-//\r
-// Call it to close a socket in the light of policy in Token\r
-//\r
+/**\r
+  Close or abort the socket associated connection.\r
+\r
+  @param  Sock                 Pointer to the socket of the connection to close or\r
+                               abort.\r
+  @param  Token                The token for close operation.\r
+  @param  OnAbort              TRUE for aborting the connection, FALSE to close it.\r
+\r
+  @retval EFI_SUCCESS          The close or abort operation is initialized\r
+                               successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket, or the\r
+                               socket is closed, or the socket is not in a\r
+                               synchronized state , or the token is already in one\r
+                               of this socket's lists.\r
+  @retval EFI_NO_MAPPING       The IP address configuration operation is not\r
+                               finished.\r
+  @retval EFI_NOT_STARTED      The socket is not configured.\r
+\r
+**/\r
 EFI_STATUS\r
 SockClose (\r
   IN SOCKET  *Sock,\r
@@ -514,27 +707,57 @@ SockClose (
   IN BOOLEAN OnAbort\r
   );\r
 \r
-//\r
-// Call it to get the mode data of low layer protocol\r
-//\r
+/**\r
+  Get the mode data of the low layer protocol.\r
+\r
+  @param  Sock                 Pointer to the socket to get mode data from.\r
+  @param  Mode                 Pointer to the data to store the low layer mode\r
+                               information.\r
+\r
+  @retval EFI_SUCCESS          The mode data is got successfully.\r
+  @retval EFI_NOT_STARTED      The socket is not configured.\r
+\r
+**/\r
 EFI_STATUS\r
 SockGetMode (\r
   IN SOCKET *Sock,\r
   IN VOID   *Mode\r
   );\r
 \r
-//\r
-// call it to add this socket instance into a group\r
-//\r
+/**\r
+  Configure the low level protocol to join a multicast group for\r
+  this socket's connection.\r
+\r
+  @param  Sock                 Pointer to the socket of the connection to join the\r
+                               specific multicast group.\r
+  @param  GroupInfo            Pointer to the multicast group info.\r
+\r
+  @retval EFI_SUCCESS          The configuration is done successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket.\r
+  @retval EFI_NOT_STARTED      The socket is not configured.\r
+\r
+**/\r
 EFI_STATUS\r
 SockGroup (\r
   IN SOCKET *Sock,\r
   IN VOID   *GroupInfo\r
   );\r
 \r
-//\r
-// call it to add a route entry for this socket instance\r
-//\r
+/**\r
+  Add or remove route information in IP route table associated\r
+  with this socket.\r
+\r
+  @param  Sock                 Pointer to the socket associated with the IP route\r
+                               table to operate on.\r
+  @param  RouteInfo            Pointer to the route information to be processed.\r
+\r
+  @retval EFI_SUCCESS          The route table is updated successfully.\r
+  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket.\r
+  @retval EFI_NO_MAPPING       The IP address configuration operation is  not\r
+                               finished.\r
+  @retval EFI_NOT_STARTED      The socket is not configured.\r
+\r
+**/\r
 EFI_STATUS\r
 SockRoute (\r
   IN SOCKET    *Sock,\r
@@ -544,11 +767,31 @@ SockRoute (
 //\r
 // Supporting function to operate on socket buffer\r
 //\r
+\r
+/**\r
+  Get the first buffer block in the specific socket buffer.\r
+\r
+  @param  Sockbuf               Pointer to the socket buffer.\r
+\r
+  @return Pointer to the first buffer in the queue. NULL if the queue is empty.\r
+\r
+**/\r
 NET_BUF *\r
 SockBufFirst (\r
   IN SOCK_BUFFER *Sockbuf\r
   );\r
 \r
+/**\r
+  Get the next buffer block in the specific socket buffer.\r
+\r
+  @param  Sockbuf               Pointer to the socket buffer.\r
+  @param  SockEntry             Pointer to the buffer block prior to the required\r
+                                one.\r
+\r
+  @return Pointer to the buffer block next to SockEntry. NULL if SockEntry is \r
+          the tail or head entry.\r
+\r
+**/\r
 NET_BUF *\r
 SockBufNext (\r
   IN SOCK_BUFFER *Sockbuf,\r
index 009ae582a505927ba761c6a28cc73b278253f220..62574fecf1bb12b7de914f2d859f09f3a52dc41c 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Dispatcher.c\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #include "Tcp4Main.h"\r
@@ -250,7 +243,7 @@ Tcp4FlushPcb (
 }\r
 \r
 /**\r
-  Attach a Tcb to the socket.\r
+  Attach a Pcb to the socket.\r
 \r
   @param  Sk                     Pointer to the socket of this TCP instance.\r
   \r
@@ -301,7 +294,7 @@ Tcp4AttachPcb (
 }\r
 \r
 /**\r
-  Detach the Tcb of the socket.\r
+  Detach the Pcb of the socket.\r
 \r
   @param  Sk                     Pointer to the socket of this TCP instance.\r
   \r
@@ -330,7 +323,7 @@ Tcp4DetachPcb (
 \r
 \r
 /**\r
-  Configure the Tcb using CfgData.\r
+  Configure the Pcb using CfgData.\r
 \r
   @param  Sk                     Pointer to the socket of this TCP instance.\r
   @param  CfgData                Pointer to the TCP configuration data.\r
index c51962ba9ebaf172f671403139f10a0d05131ee2..921332cbe069066638f3fcd3779d6ea9f72eb933 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
+Copyright (c) 2005 - 2007, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Driver.c\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #include "Tcp4Main.h"\r
@@ -187,17 +180,33 @@ Tcp4DriverEntryPoint (
 \r
 \r
 /**\r
-  Test to see if this driver supports ControllerHandle.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  ControllerHandle       Handle of device to test.\r
-  @param  RemainingDevicePath    Optional parameter use to pick a specific child\r
-                                 device to start.\r
-\r
-  @retval EFI_SUCCESS            This driver supports this device.\r
-  @retval EFI_ALREADY_STARTED    This driver is already running on this device.\r
-  @retval other                  This driver does not support this device.\r
-\r
+  Tests to see if this driver supports a given controller.\r
+  \r
+  If a child device is provided, it further tests to see if this driver supports \r
+  creating a handle for the specified child device.\r
+\r
+  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  ControllerHandle     The handle of the controller to test. This handle \r
+                               must support a protocol interface that supplies \r
+                               an I/O abstraction to the driver.\r
+  @param  RemainingDevicePath  A pointer to the remaining portion of a device path. \r
+                               This parameter is ignored by device drivers, and is optional for bus drivers.\r
+\r
+\r
+  @retval EFI_SUCCESS          The device specified by ControllerHandle and\r
+                               RemainingDevicePath is supported by the driver \r
+                               specified by This.\r
+  @retval EFI_ALREADY_STARTED  The device specified by ControllerHandle and\r
+                               RemainingDevicePath is already being managed by \r
+                               the driver specified by This.\r
+  @retval EFI_ACCESS_DENIED    The device specified by ControllerHandle and\r
+                               RemainingDevicePath is already being managed by a \r
+                               different driver or an application that requires \r
+                               exclusive access.\r
+  @retval EFI_UNSUPPORTED      The device specified by ControllerHandle and\r
+                               RemainingDevicePath is not supported by the driver \r
+                               specified by This.\r
+                               \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -241,17 +250,32 @@ Tcp4DriverBindingSupported (
 \r
 \r
 /**\r
-  Start this driver on ControllerHandle.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  ControllerHandle       Handle of device to bind driver to.\r
-  @param  RemainingDevicePath    Optional parameter use to pick a specific child\r
-                                 device to start.\r
-\r
-  @retval EFI_SUCCESS            The driver is added to ControllerHandle.\r
-  @retval EFI_OUT_OF_RESOURCES   There are not enough resources to start the\r
-                                 driver.\r
-  @retval other                  The driver cannot be added to ControllerHandle.\r
+  Start this driver on ControllerHandle. \r
+  \r
+  The Start() function is designed to be invoked from the EFI boot service \r
+  ConnectController(). As a result, much of the error checking on the parameters \r
+  to Start() has been moved into this common boot service. It is legal to call \r
+  Start() from other locations, but the following calling restrictions must be \r
+  followed or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE.\r
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally \r
+     aligned EFI_DEVICE_PATH_PROTOCOL.\r
+  3. Prior to calling Start(), the Supported() function for the driver specified \r
+     by This must have been called with the same calling parameters, and Supported() \r
+     must have returned EFI_SUCCESS.\r
+\r
+  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  ControllerHandle     The handle of the controller to start. This handle \r
+                               must support a protocol interface that supplies \r
+                               an I/O abstraction to the driver.\r
+  @param  RemainingDevicePath  A pointer to the remaining portion of a device path. \r
+                               This parameter is ignored by device drivers, and is \r
+                               optional for bus drivers.\r
+\r
+  @retval EFI_SUCCESS          The device was started.\r
+  @retval EFI_ALREADY_STARTED  The device could not be started due to a device error.\r
+  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack \r
+                               of resources.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -270,7 +294,7 @@ Tcp4DriverBindingStart (
 \r
   if (NULL == TcpServiceData) {\r
     DEBUG ((EFI_D_ERROR, "Tcp4DriverBindingStart: Have no enough"\r
-      " resource to create a Tcp Servcie Data!\n"));\r
+      " resource to create a Tcp Servcie Data\n"));\r
 \r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -282,7 +306,7 @@ Tcp4DriverBindingStart (
   if (NULL == TcpServiceData->IpIo) {\r
 \r
     DEBUG ((EFI_D_ERROR, "Tcp4DriverBindingStart: Have no enough"\r
-      " resource to create an Ip Io!\n"));\r
+      " resource to create an Ip Io\n"));\r
 \r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto ON_ERROR;\r
@@ -363,15 +387,29 @@ ON_ERROR:
 \r
 /**\r
   Stop this driver on ControllerHandle.\r
+  \r
+  The Stop() function is designed to be invoked from the EFI boot service \r
+  DisconnectController(). As a result, much of the error checking on the parameters \r
+  to Stop() has been moved into this common boot service. It is legal to call Stop() \r
+  from other locations, but the following calling restrictions must be followed \r
+  or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call \r
+     to this same driver's Start() function.\r
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+     EFI_HANDLE. In addition, all of these handles must have been created in this \r
+     driver's Start() function, and the Start() function must have called OpenProtocol() \r
+     on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  \r
+  @param  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  ControllerHandle  A handle to the device being stopped. The handle must \r
+                            support a bus specific I/O protocol for the driver \r
+                            to use to stop the device.\r
+  @param  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param  ChildHandleBuffer An array of child handles to be freed. May be NULL if \r
+                            NumberOfChildren is 0.\r
 \r
-  @param  This                   Protocol instance pointer.\r
-  @param  ControllerHandle       Handle of device to stop driver on.\r
-  @param  NumberOfChildren       Number of Handles in ChildHandleBuffer. If number\r
-                                 of children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer      List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS            This driver is removed from ControllerHandle.\r
-  @retval other                  This driver is not removed from ControllerHandle.\r
+  @retval EFI_SUCCESS       The device was stopped.\r
+  @retval EFI_DEVICE_ERROR  The device could not be stopped due to a device error.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -569,18 +607,23 @@ Tcp4DestroySocketCallback (
 }\r
 \r
 /**\r
-  Creates a child handle with a set of TCP4 services.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  ChildHandle            Pointer to the handle of the child to create.  If\r
-                                 it is NULL, then a new handle is created. If it is\r
-                                 not NULL, then the I/O services are added to the\r
-                                 existing child handle.\r
-\r
-  @retval EFI_SUCCESS            The child handle is created.\r
-  @retval EFI_INVALID_PARAMETER  One or more parameters are invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   There are not enough resources to create the\r
-                                 child.\r
+  Creates a child handle and installs a protocol.\r
+  \r
+  The CreateChild() function installs a protocol on ChildHandle. If ChildHandle \r
+  is a pointer to NULL, then a new handle is created and returned in ChildHandle. \r
+  If ChildHandle is not a pointer to NULL, then the protocol installs on the existing \r
+  ChildHandle.\r
+\r
+  @param  This        Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
+  @param  ChildHandle Pointer to the handle of the child to create. If it is NULL, then \r
+                      a new handle is created. If it is a pointer to an existing UEFI \r
+                      handle, then the protocol is added to the existing UEFI handle.\r
+\r
+  @retval EFI_SUCCES            The protocol was added to ChildHandle.\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resources availabe to create\r
+                                the child.\r
+  @retval other                 The child handle was not created.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -630,16 +673,23 @@ Tcp4ServiceBindingCreateChild (
 \r
 \r
 /**\r
-  Destroys a child handle with a set of UDP4 services.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  ChildHandle            Handle of the child to be destroyed.\r
-\r
-  @retval EFI_SUCCESS            The TCP4 services are removed from  the child\r
-                                 handle.\r
-  @retval EFI_INVALID_PARAMETER  One or more parameters are invalid.\r
-  @retval other                  The child handle is not destroyed.\r
-\r
+  Destroys a child handle with a protocol installed on it.\r
+  \r
+  The DestroyChild() function does the opposite of CreateChild(). It removes a protocol \r
+  that was installed by CreateChild() from ChildHandle. If the removed protocol is the \r
+  last protocol on ChildHandle, then ChildHandle is destroyed.\r
+\r
+  @param  This         Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
+  @param  ChildHandle  Handle of the child to destroy\r
+\r
+  @retval EFI_SUCCES            The protocol was removed from ChildHandle.\r
+  @retval EFI_UNSUPPORTED       ChildHandle does not support the protocol that is \r
+                                being removed.\r
+  @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r
+  @retval EFI_ACCESS_DENIED     The protocol could not be removed from the ChildHandle\r
+                                because its services are being used.\r
+  @retval other                 The child handle was not destroyed.\r
+  \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
index 82fd57c34da1453e487f6ce48b9a1e2759d5b14f..42303f3cf128cdfb7d72326e013f9182d91d2464 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Driver.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef _TCP4_DRIVER_H_\r
@@ -29,6 +22,14 @@ Abstract:
 #define TCP4_PORT_KNOWN         1024\r
 #define TCP4_PORT_USER_RESERVED 65535\r
 \r
+#define TCP4_FROM_THIS(a) \\r
+  CR ( \\r
+  (a), \\r
+  TCP4_SERVICE_DATA, \\r
+  Tcp4ServiceBinding, \\r
+  TCP4_DRIVER_SIGNATURE \\r
+  )\r
+\r
 typedef struct _TCP4_HEARTBEAT_TIMER {\r
   EFI_EVENT  TimerEvent;\r
   INTN       RefCnt;\r
@@ -44,9 +45,22 @@ typedef struct _TCP4_SERVICE_DATA {
   LIST_ENTRY                    SocketList;\r
 } TCP4_SERVICE_DATA;\r
 \r
-//\r
-// Prototype for TCP4 driver Rcv callback function registered to IP_IO\r
-//\r
+\r
+\r
+/**\r
+  Packet receive callback function provided to IP_IO, used to call\r
+  the proper function to handle the packet received by IP.\r
+\r
+  @param  Status      Status of the received packet.\r
+  @param  IcmpErr     ICMP error number.\r
+  @param  NetSession  Pointer to the net session of this packet.\r
+  @param  Pkt         Pointer to the recieved packet.\r
+  @param  Context     Pointer to the context configured in IpIoOpen(), not used\r
+                      now.\r
+\r
+  @return None\r
+\r
+**/\r
 VOID\r
 Tcp4RxCallback (\r
   IN EFI_STATUS                       Status,\r
@@ -56,6 +70,18 @@ Tcp4RxCallback (
   IN VOID                             *Context    OPTIONAL\r
   );\r
 \r
+/**\r
+  Send the segment to IP via IpIo function.\r
+\r
+  @param  Tcb         Pointer to the TCP_CB of this TCP instance.\r
+  @param  Nbuf        Pointer to the TCP segment to be sent.\r
+  @param  Src         Source address of the TCP segment.\r
+  @param  Dest        Destination address of the TCP segment.\r
+\r
+  @retval 0           The segment was sent out successfully.\r
+  @retval -1          The segment was failed to send.\r
+\r
+**/\r
 INTN\r
 TcpSendIpPacket (\r
   IN TCP_CB    *Tcb,\r
@@ -64,11 +90,26 @@ TcpSendIpPacket (
   IN UINT32    Dest\r
   );\r
 \r
+/**\r
+  The procotol handler provided to the socket layer, used to\r
+  dispatch the socket level requests by calling the corresponding\r
+  TCP layer functions.\r
+\r
+  @param  Sock                   Pointer to the socket of this TCP instance.\r
+  @param  Request                The code of this operation request.\r
+  @param  Data                   Pointer to the operation specific data passed in\r
+                                 together with the operation request.\r
+\r
+  @retval EFI_SUCCESS            The socket request is completed successfully.\r
+  @retval other                  The error status returned by the corresponding TCP\r
+                                 layer function.\r
+\r
+**/\r
 EFI_STATUS\r
 Tcp4Dispatcher (\r
   IN SOCKET                  *Sock,\r
   IN SOCK_REQUEST            Request,\r
-  IN VOID                    *Data   OPTIONAL\r
+  IN VOID                    *Data    OPTIONAL\r
   );\r
 \r
 typedef struct _TCP4_PROTO_DATA {\r
@@ -76,17 +117,17 @@ typedef struct _TCP4_PROTO_DATA {
   TCP_CB            *TcpPcb;\r
 } TCP4_PROTO_DATA;\r
 \r
-#define TCP4_FROM_THIS(a) \\r
-  CR ( \\r
-  (a), \\r
-  TCP4_SERVICE_DATA, \\r
-  Tcp4ServiceBinding, \\r
-  TCP4_DRIVER_SIGNATURE \\r
-  )\r
+/**\r
+  The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.\r
 \r
-//\r
-// Function prototype for the driver's entry point\r
-//\r
+  @param  ImageHandle   The firmware allocated handle for this\r
+                        driver image.\r
+  @param  SystemTable   Pointer to the EFI system table.\r
+\r
+  @retval EFI_SUCCESS   Driver loaded.\r
+  @retval other         Driver not loaded.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4DriverEntryPoint (\r
@@ -94,9 +135,36 @@ Tcp4DriverEntryPoint (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   );\r
 \r
-//\r
-// Function prototypes for the Drivr Binding Protocol\r
-//\r
+\r
+/**\r
+  Tests to see if this driver supports a given controller.\r
+  \r
+  If a child device is provided, it further tests to see if this driver supports \r
+  creating a handle for the specified child device.\r
+\r
+  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  ControllerHandle     The handle of the controller to test. This handle \r
+                               must support a protocol interface that supplies \r
+                               an I/O abstraction to the driver.\r
+  @param  RemainingDevicePath  A pointer to the remaining portion of a device path. \r
+                               This parameter is ignored by device drivers, and is optional for bus drivers.\r
+\r
+\r
+  @retval EFI_SUCCESS          The device specified by ControllerHandle and\r
+                               RemainingDevicePath is supported by the driver \r
+                               specified by This.\r
+  @retval EFI_ALREADY_STARTED  The device specified by ControllerHandle and\r
+                               RemainingDevicePath is already being managed by \r
+                               the driver specified by This.\r
+  @retval EFI_ACCESS_DENIED    The device specified by ControllerHandle and\r
+                               RemainingDevicePath is already being managed by a \r
+                               different driver or an application that requires \r
+                               exclusive access.\r
+  @retval EFI_UNSUPPORTED      The device specified by ControllerHandle and\r
+                               RemainingDevicePath is not supported by the driver \r
+                               specified by This.\r
+                               \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4DriverBindingSupported (\r
@@ -105,6 +173,35 @@ Tcp4DriverBindingSupported (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
   );\r
 \r
+/**\r
+  Start this driver on ControllerHandle. \r
+  \r
+  The Start() function is designed to be invoked from the EFI boot service \r
+  ConnectController(). As a result, much of the error checking on the parameters \r
+  to Start() has been moved into this common boot service. It is legal to call \r
+  Start() from other locations, but the following calling restrictions must be \r
+  followed or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE.\r
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally \r
+     aligned EFI_DEVICE_PATH_PROTOCOL.\r
+  3. Prior to calling Start(), the Supported() function for the driver specified \r
+     by This must have been called with the same calling parameters, and Supported() \r
+     must have returned EFI_SUCCESS.\r
+\r
+  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  ControllerHandle     The handle of the controller to start. This handle \r
+                               must support a protocol interface that supplies \r
+                               an I/O abstraction to the driver.\r
+  @param  RemainingDevicePath  A pointer to the remaining portion of a device path. \r
+                               This parameter is ignored by device drivers, and is \r
+                               optional for bus drivers.\r
+\r
+  @retval EFI_SUCCESS          The device was started.\r
+  @retval EFI_ALREADY_STARTED  The device could not be started due to a device error.\r
+  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack \r
+                               of resources.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4DriverBindingStart (\r
@@ -113,6 +210,33 @@ Tcp4DriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
   );\r
 \r
+/**\r
+  Stop this driver on ControllerHandle.\r
+  \r
+  The Stop() function is designed to be invoked from the EFI boot service \r
+  DisconnectController(). As a result, much of the error checking on the parameters \r
+  to Stop() has been moved into this common boot service. It is legal to call Stop() \r
+  from other locations, but the following calling restrictions must be followed \r
+  or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call \r
+     to this same driver's Start() function.\r
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+     EFI_HANDLE. In addition, all of these handles must have been created in this \r
+     driver's Start() function, and the Start() function must have called OpenProtocol() \r
+     on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  \r
+  @param  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  ControllerHandle  A handle to the device being stopped. The handle must \r
+                            support a bus specific I/O protocol for the driver \r
+                            to use to stop the device.\r
+  @param  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param  ChildHandleBuffer An array of child handles to be freed. May be NULL if \r
+                            NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS       The device was stopped.\r
+  @retval EFI_DEVICE_ERROR  The device could not be stopped due to a device error.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4DriverBindingStop (\r
@@ -122,21 +246,56 @@ Tcp4DriverBindingStop (
   IN  EFI_HANDLE                   *ChildHandleBuffer\r
   );\r
 \r
+/**\r
+  Open Ip4 and device path protocols for a created socket, and insert it in \r
+  socket list.\r
+  \r
+  @param  This                Pointer to the socket just created\r
+  @param  Context             Context of the socket\r
+  \r
+  @retval EFI_SUCCESS         This protocol is installed successfully.\r
+  @retval other               Some error occured.\r
+  \r
+**/\r
 EFI_STATUS\r
 Tcp4CreateSocketCallback (\r
   IN SOCKET  *This,\r
   IN VOID    *Context\r
   );\r
 \r
+/**\r
+  Close Ip4 and device path protocols for a socket, and remove it from socket list. \r
+    \r
+  @param  This                Pointer to the socket to be removed\r
+  @param  Context             Context of the socket\r
+  \r
+**/\r
 VOID\r
 Tcp4DestroySocketCallback (\r
   IN SOCKET  *This,\r
   IN VOID    *Context\r
   );\r
 \r
-//\r
-// Function ptototypes for the ServiceBinding Prococol\r
-//\r
+/**\r
+  Creates a child handle and installs a protocol.\r
+  \r
+  The CreateChild() function installs a protocol on ChildHandle. If ChildHandle \r
+  is a pointer to NULL, then a new handle is created and returned in ChildHandle. \r
+  If ChildHandle is not a pointer to NULL, then the protocol installs on the existing \r
+  ChildHandle.\r
+\r
+  @param  This        Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
+  @param  ChildHandle Pointer to the handle of the child to create. If it is NULL, then \r
+                      a new handle is created. If it is a pointer to an existing UEFI \r
+                      handle, then the protocol is added to the existing UEFI handle.\r
+\r
+  @retval EFI_SUCCES            The protocol was added to ChildHandle.\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resources availabe to create\r
+                                the child.\r
+  @retval other                 The child handle was not created.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4ServiceBindingCreateChild (\r
@@ -144,6 +303,25 @@ Tcp4ServiceBindingCreateChild (
   IN EFI_HANDLE                    *ChildHandle\r
   );\r
 \r
+/**\r
+  Destroys a child handle with a protocol installed on it.\r
+  \r
+  The DestroyChild() function does the opposite of CreateChild(). It removes a protocol \r
+  that was installed by CreateChild() from ChildHandle. If the removed protocol is the \r
+  last protocol on ChildHandle, then ChildHandle is destroyed.\r
+\r
+  @param  This         Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
+  @param  ChildHandle  Handle of the child to destroy\r
+\r
+  @retval EFI_SUCCES            The protocol was removed from ChildHandle.\r
+  @retval EFI_UNSUPPORTED       ChildHandle does not support the protocol that is \r
+                                being removed.\r
+  @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r
+  @retval EFI_ACCESS_DENIED     The protocol could not be removed from the ChildHandle\r
+                                because its services are being used.\r
+  @retval other                 The child handle was not destroyed.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4ServiceBindingDestroyChild (\r
index dbb1008b40617879162392067e7b66cda25ecf63..21922c7a023853999259966c6efdf6c014eec8a7 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Func.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef _TCP4_FUNC_H_\r
@@ -30,13 +23,36 @@ Abstract:
 //\r
 // Functions in tcp.c\r
 //\r
+\r
+/**\r
+  Try to find one Tcb whose <Ip, Port> equals to <IN Addr, IN Port>.\r
+\r
+  @param  Addr                  Pointer to the IP address needs to match.\r
+  @param  Port                  The port number needs to match.\r
+\r
+  @return  The Tcb which matches the <Addr Port> paire exists or not.\r
+\r
+**/\r
 BOOLEAN\r
 TcpFindTcbByPeer (\r
   IN EFI_IPv4_ADDRESS  *Addr,\r
   IN TCP_PORTNO        Port\r
   );\r
 \r
-TCP_CB  *\r
+/**\r
+  Locate the TCP_CB related to the socket pair.\r
+\r
+  @param  LocalPort             The local port number.\r
+  @param  LocalIp               The local IP address.\r
+  @param  RemotePort            The remote port number.\r
+  @param  RemoteIp              The remote IP address.\r
+  @param  Syn                   Whether to search the listen sockets, if TRUE, the\r
+                                listen sockets are searched.\r
+\r
+  @return  Pointer to the related TCP_CB, if NULL no match is found.\r
+\r
+**/\r
+TCP_CB *\r
 TcpLocateTcb (\r
   IN TCP_PORTNO  LocalPort,\r
   IN UINT32      LocalIp,\r
@@ -45,26 +61,64 @@ TcpLocateTcb (
   IN BOOLEAN     Syn\r
   );\r
 \r
+/**\r
+  Insert a Tcb into the proper queue.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB to be inserted.\r
+\r
+  @retval 0                     The Tcb is inserted successfully.\r
+  @retval -1                    Error condition occurred.\r
+\r
+**/\r
 INTN\r
 TcpInsertTcb (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
-TCP_CB  *\r
+/**\r
+  Clone a TCP_CB from Tcb.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB to be cloned.\r
+\r
+  @return  Pointer to the new cloned TCP_CB, if NULL error condition occurred.\r
+\r
+**/\r
+TCP_CB *\r
 TcpCloneTcb (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Compute an ISS to be used by a new connection.\r
+\r
+  @return  The result ISS.\r
+\r
+**/\r
 TCP_SEQNO\r
 TcpGetIss (\r
   VOID\r
   );\r
 \r
+/**\r
+  Initialize the Tcb local related members.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpInitTcbLocal (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Initialize the peer related members.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of this TCP instance.\r
+  @param  Seg                   Pointer to the segment that contains the peer's\r
+                                intial info.\r
+  @param  Opt                   Pointer to the options announced by the peer.\r
+\r
+**/\r
 VOID\r
 TcpInitTcbPeer (\r
   IN TCP_CB     *Tcb,\r
@@ -72,95 +126,241 @@ TcpInitTcbPeer (
   IN TCP_OPTION *Opt\r
   );\r
 \r
+/**\r
+  Get the local mss.\r
+\r
+  @param  Sock        Pointer to the socket to get mss\r
+\r
+  @return  The mss size.\r
+\r
+**/\r
 UINT16\r
 TcpGetRcvMss (\r
-  IN SOCKET *Sock\r
+  IN SOCKET  *Sock\r
   );\r
 \r
+/**\r
+  Set the Tcb's state.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of this TCP instance.\r
+  @param  State                 The state to be set.\r
+\r
+**/\r
 VOID\r
 TcpSetState (\r
-  IN TCP_CB *Tcb,\r
-  IN UINT8  State\r
+  IN TCP_CB      *Tcb,\r
+  IN TCP_STATES  State\r
   );\r
 \r
 //\r
 // Functions in Tcp4Output.c\r
 //\r
+/**\r
+  Send the segment to IP via IpIo function.\r
+\r
+  @param  Tcb         Pointer to the TCP_CB of this TCP instance.\r
+  @param  Nbuf        Pointer to the TCP segment to be sent.\r
+  @param  Src         Source address of the TCP segment.\r
+  @param  Dest        Destination address of the TCP segment.\r
+\r
+  @retval 0           The segment was sent out successfully.\r
+  @retval -1          The segment was failed to send.\r
+\r
+**/\r
 INTN\r
 TcpSendIpPacket (\r
-  IN TCP_CB  *Tcb,\r
-  IN NET_BUF *Nbuf,\r
-  IN UINT32  Src,\r
-  IN UINT32  Dst\r
+  IN TCP_CB    *Tcb,\r
+  IN NET_BUF   *Nbuf,\r
+  IN UINT32    Src,\r
+  IN UINT32    Dest\r
   );\r
 \r
+/**\r
+  Check whether to send data/SYN/FIN and piggy back an ACK.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Force   Whether to ignore the sender's SWS avoidance algorithm and send\r
+                  out data by force.\r
+\r
+  @return The number of bytes sent.\r
+\r
+**/\r
 INTN\r
 TcpToSendData (\r
   IN TCP_CB *Tcb,\r
-  IN INTN    Force\r
+  IN INTN Force\r
   );\r
 \r
+/**\r
+  Check whether to send an ACK or delayed ACK.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpToSendAck (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Send an ACK immediately.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpSendAck (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Send a zero probe segment. It can be used by keepalive and zero window probe.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+\r
+  @retval 0       The zero probe segment was sent out successfully.\r
+  @retval other   Error condition occurred.\r
+\r
+**/\r
 INTN\r
 TcpSendZeroProbe (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Process the data and FIN flag, check whether to deliver\r
+  data to the socket layer.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+\r
+  @retval 0        No error occurred to deliver data.\r
+  @retval -1       Error condition occurred. Proper response is to reset the\r
+                   connection.\r
+\r
+**/\r
 INTN\r
 TcpDeliverData (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Send a RESET segment in response to the segment received.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance, may be NULL.\r
+  @param  Head    TCP header of the segment that triggers the reset.\r
+  @param  Len     Length of the segment that triggers the reset.\r
+  @param  Local   Local IP address.\r
+  @param  Remote  Remote peer's IP address.\r
+\r
+  @retval 0       A reset is sent or no need to send it.\r
+  @retval -1      No reset is sent.\r
+\r
+**/\r
 INTN\r
 TcpSendReset (\r
-  IN TCP_CB   *Tcb,\r
-  IN TCP_HEAD *Head,\r
-  IN INT32    Len,\r
-  IN UINT32   Local,\r
-  IN UINT32   Remote\r
+  IN TCP_CB    *Tcb,\r
+  IN TCP_HEAD  *Head,\r
+  IN INT32     Len,\r
+  IN UINT32    Local,\r
+  IN UINT32    Remote\r
   );\r
 \r
+/**\r
+  Compute the sequence space left in the old receive window.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+\r
+  @return The sequence space left in the old receive window.\r
+\r
+**/\r
 UINT32\r
 TcpRcvWinOld (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Compute the current receive window.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+\r
+  @return The size of the current receive window, in bytes.\r
+\r
+**/\r
 UINT32\r
 TcpRcvWinNow (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Retransmit the segment from sequence Seq.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Seq     The sequence number of the segment to be retransmitted.\r
+\r
+  @retval 0       Retransmission succeeded.\r
+  @retval -1      Error condition occurred.\r
+\r
+**/\r
 INTN\r
 TcpRetransmit (\r
   IN TCP_CB    *Tcb,\r
   IN TCP_SEQNO Seq\r
   );\r
 \r
+/**\r
+  Compute how much data to send.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Force   Whether to ignore the sender's SWS avoidance algorithm and send\r
+                  out data by force.\r
+\r
+  @return The length of the data can be sent, if 0, no data can be sent.\r
+\r
+**/\r
 UINT32\r
 TcpDataToSend (\r
   IN TCP_CB *Tcb,\r
   IN INTN   Force\r
   );\r
 \r
+/**\r
+  Verify that the segment is in good shape.\r
+\r
+  @param  Nbuf    Buffer that contains the segment to be checked.\r
+\r
+  @retval 0       The segment is broken.\r
+  @retval 1       The segment is in good shape.\r
+\r
+**/\r
 INTN\r
 TcpVerifySegment (\r
   IN NET_BUF *Nbuf\r
   );\r
 \r
+/**\r
+  Verify that all the segments in SndQue are in good shape.\r
+\r
+  @param  Head    Pointer to the head node of the SndQue.\r
+\r
+  @retval 0       At least one segment is broken.\r
+  @retval 1       All segments in the specific queue are in good shape.\r
+\r
+**/\r
 INTN\r
 TcpCheckSndQue (\r
   IN LIST_ENTRY     *Head\r
   );\r
 \r
+/**\r
+  Get a segment from the Tcb's SndQue.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Seq     The sequence number of the segment.\r
+  @param  Len     The maximum length of the segment.\r
+\r
+  @return Pointer to the segment, if NULL some error occurred.\r
+\r
+**/\r
 NET_BUF *\r
 TcpGetSegmentSndQue (\r
   IN TCP_CB    *Tcb,\r
@@ -168,6 +368,16 @@ TcpGetSegmentSndQue (
   IN UINT32    Len\r
   );\r
 \r
+/**\r
+  Get a segment from the Tcb's socket buffer.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Seq     The sequence number of the segment.\r
+  @param  Len     The maximum length of the segment.\r
+\r
+  @return Pointer to the segment, if NULL some error occurred.\r
+\r
+**/\r
 NET_BUF *\r
 TcpGetSegmentSock (\r
   IN TCP_CB    *Tcb,\r
@@ -175,6 +385,17 @@ TcpGetSegmentSock (
   IN UINT32    Len\r
   );\r
 \r
+/**\r
+  Get a segment starting from sequence Seq of a maximum\r
+  length of Len.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Seq     The sequence number of the segment.\r
+  @param  Len     The maximum length of the segment.\r
+\r
+  @return Pointer to the segment, if NULL some error occurred.\r
+\r
+**/\r
 NET_BUF *\r
 TcpGetSegment (\r
   IN TCP_CB    *Tcb,\r
@@ -182,6 +403,14 @@ TcpGetSegment (
   IN UINT32    Len\r
   );\r
 \r
+/**\r
+  Get the maximum SndNxt.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+\r
+  @return The sequence number of the maximum SndNxt.\r
+\r
+**/\r
 TCP_SEQNO\r
 TcpGetMaxSndNxt (\r
   IN TCP_CB *Tcb\r
@@ -190,6 +419,16 @@ TcpGetMaxSndNxt (
 //\r
 // Functions from Tcp4Input.c\r
 //\r
+/**\r
+  Process the received ICMP error messages for TCP.\r
+\r
+  @param  Nbuf     Buffer that contains part of the TCP segment without IP header\r
+                   truncated from the ICMP error packet.\r
+  @param  IcmpErr  The ICMP error code interpreted from ICMP error packet.\r
+  @param  Src      Source address of the ICMP error message.\r
+  @param  Dst      Destination address of the ICMP error message.\r
+\r
+**/\r
 VOID\r
 TcpIcmpInput (\r
   IN NET_BUF     *Nbuf,\r
@@ -198,6 +437,19 @@ TcpIcmpInput (
   IN UINT32      Dst\r
   );\r
 \r
+/**\r
+  Process the received TCP segments.\r
+\r
+  @param  Nbuf     Buffer that contains received TCP segment without IP header.\r
+  @param  Src      Source address of the segment, or the peer's IP address.\r
+  @param  Dst      Destination address of the segment, or the local end's IP\r
+                   address.\r
+\r
+  @retval 0        Segment is processed successfully. It is either accepted or\r
+                   discarded. But no connection is reset by the segment.\r
+  @retval -1       A connection is reset by the segment.\r
+\r
+**/\r
 INTN\r
 TcpInput (\r
   IN NET_BUF *Nbuf,\r
@@ -205,42 +457,96 @@ TcpInput (
   IN UINT32  Dst\r
   );\r
 \r
+/**\r
+  Check whether the sequence number of the incoming segment is acceptable.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Seg      Pointer to the incoming segment.\r
+\r
+  @retval 1       The sequence number is acceptable.\r
+  @retval 0       The sequence number is not acceptable.\r
+\r
+**/\r
 INTN\r
 TcpSeqAcceptable (\r
   IN TCP_CB  *Tcb,\r
   IN TCP_SEG *Seg\r
   );\r
 \r
+/**\r
+  NewReno fast recovery, RFC3782.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Seg      Segment that triggers the fast recovery.\r
+\r
+**/\r
 VOID\r
 TcpFastRecover (\r
   IN TCP_CB  *Tcb,\r
   IN TCP_SEG *Seg\r
   );\r
 \r
+/**\r
+  NewReno fast loss recovery, RFC3792.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Seg      Segment that triggers the fast loss recovery.\r
+\r
+**/\r
 VOID\r
 TcpFastLossRecover (\r
   IN TCP_CB  *Tcb,\r
   IN TCP_SEG *Seg\r
   );\r
 \r
+/**\r
+  Compute the RTT as specified in RFC2988.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Measure  Currently measured RTT in heart beats.\r
+\r
+**/\r
 VOID\r
 TcpComputeRtt (\r
   IN TCP_CB *Tcb,\r
   IN UINT32 Measure\r
   );\r
 \r
+/**\r
+  Trim off the data outside the tcb's receive window.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Nbuf     Pointer to the NET_BUF containing the received tcp segment.\r
+\r
+  @return 0        The data is trimmed.\r
+\r
+**/\r
 INTN\r
 TcpTrimInWnd (\r
   IN TCP_CB  *Tcb,\r
-  IN NET_BUF *Buf\r
+  IN NET_BUF *Nbuf\r
   );\r
 \r
+/**\r
+  Store the data into the reassemble queue.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Nbuf     Pointer to the buffer containing the data to be queued.\r
+\r
+**/\r
 VOID\r
 TcpQueueData (\r
   IN TCP_CB  *Tcb,\r
   IN NET_BUF *Nbuf\r
   );\r
 \r
+/**\r
+  Ajust the send queue or the retransmit queue.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Ack      The acknowledge seuqence number of the received segment.\r
+\r
+**/\r
 VOID\r
 TcpAdjustSndQue (\r
   IN TCP_CB    *Tcb,\r
@@ -250,43 +556,110 @@ TcpAdjustSndQue (
 //\r
 // Functions from Tcp4Misc.c\r
 //\r
+/**\r
+  Compute the TCP segment's checksum.\r
+\r
+  @param  Nbuf                  Pointer to the buffer that contains the TCP\r
+                                segment.\r
+  @param  HeadSum               The checksum value of the fixed part of pseudo\r
+                                header.\r
+\r
+  @return  The checksum value.\r
+\r
+**/\r
 UINT16\r
 TcpChecksum (\r
-  IN NET_BUF *Buf,\r
-  IN UINT16  HeadChecksum\r
+  IN NET_BUF *Nbuf,\r
+  IN UINT16  HeadSum\r
   );\r
 \r
+/**\r
+  Translate the information from the head of the received TCP\r
+  segment Nbuf contains and fill it into a TCP_SEG structure.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of this TCP instance.\r
+  @param  Nbuf                  Pointer to the buffer contains the TCP segment.\r
+\r
+  @return  Pointer to the TCP_SEG that contains the translated TCP head information.\r
+\r
+**/\r
 TCP_SEG *\r
 TcpFormatNetbuf (\r
   IN TCP_CB  *Tcb,\r
   IN NET_BUF *Nbuf\r
   );\r
 \r
+/**\r
+  Initialize an active connection.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB that wants to initiate a\r
+                                connection.\r
+\r
+**/\r
 VOID\r
 TcpOnAppConnect (\r
   IN TCP_CB  *Tcb\r
   );\r
 \r
+/**\r
+  Application has consumed some data, check whether\r
+  to send a window updata ack or a delayed ack.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 INTN\r
 TcpOnAppConsume (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Initiate the connection close procedure, called when\r
+  applications want to close the connection.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpOnAppClose (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Check whether the application's newly delivered data can be sent out.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of this TCP instance.\r
+\r
+  @retval 0                     Whether the data is sent out or is buffered for\r
+                                further sending.\r
+  @retval -1                    The Tcb is not in a state that data is permitted to\r
+                                be sent out.\r
+\r
+**/\r
 INTN\r
 TcpOnAppSend (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Abort the connection by sending a reset segment, called\r
+  when the application wants to abort the connection.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of the TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpOnAppAbort (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Reset the connection related with Tcb.\r
+\r
+  @param  Tcb                   Pointer to the TCP_CB of the connection to be\r
+                                reset.\r
+\r
+**/\r
 VOID\r
 TcpResetConnection (\r
   IN TCP_CB *Tcb\r
@@ -295,11 +668,24 @@ TcpResetConnection (
 //\r
 // Functions in Tcp4Timer.c\r
 //\r
+/**\r
+  Close the TCP connection.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpClose (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Heart beat timer handler, queues the DPC at TPL_CALLBACK.\r
+\r
+  @param  Event    Timer event signaled, ignored.\r
+  @param  Context  Context of the timer event, ignored.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 TcpTicking (\r
@@ -307,6 +693,14 @@ TcpTicking (
   IN VOID      *Context\r
   );\r
 \r
+/**\r
+  Enable a TCP timer.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Timer    The index of the timer to be enabled.\r
+  @param  TimeOut  The timeout value of this timer.\r
+\r
+**/\r
 VOID\r
 TcpSetTimer (\r
   IN TCP_CB *Tcb,\r
@@ -314,45 +708,100 @@ TcpSetTimer (
   IN UINT32 TimeOut\r
   );\r
 \r
+/**\r
+  Clear one TCP timer.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+  @param  Timer    The index of the timer to be cleared.\r
+\r
+**/\r
 VOID\r
 TcpClearTimer (\r
   IN TCP_CB *Tcb,\r
   IN UINT16 Timer\r
   );\r
 \r
+/**\r
+  Clear all TCP timers.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpClearAllTimer (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Enable the window prober timer and set the timeout value.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpSetProbeTimer (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Enable the keepalive timer and set the timeout value.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpSetKeepaliveTimer (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Backoff the RTO.\r
+\r
+  @param  Tcb      Pointer to the TCP_CB of this TCP instance.\r
+\r
+**/\r
 VOID\r
 TcpBackoffRto (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Set the Tdp4 variable data.\r
+\r
+  @param  Tcp4Service           Pointer to Tcp4 service data.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resources to set the variable.\r
+  @retval other                 Set variable failed.\r
+\r
+**/\r
 EFI_STATUS\r
 TcpSetVariableData (\r
   IN TCP4_SERVICE_DATA  *Tcp4Service\r
   );\r
 \r
+/**\r
+  Clear the variable and free the resource.\r
+\r
+  @param  Tcp4Service           Pointer to Tcp4 service data.\r
+\r
+**/\r
 VOID\r
 TcpClearVariableData (\r
   IN TCP4_SERVICE_DATA  *Tcp4Service\r
   );\r
 \r
+/**\r
+  Install the device path protocol on the TCP instance.\r
+\r
+  @param  Sock             Pointer to the socket representing the TCP instance.\r
+\r
+  @retval  EFI_SUCCESS     The device path protocol is installed.\r
+  @retval  other           Failed to install the device path protocol.\r
+\r
+**/\r
 EFI_STATUS\r
 TcpInstallDevicePath (\r
-  IN SOCKET  *Sock\r
+  IN SOCKET *Sock\r
   );\r
 \r
 #endif\r
index f525f240e40604dec0d625da3a270f4249c7a8e8..f5ca9ac5484f39f996055502e3dd5f573eb4295e 100644 (file)
@@ -1,25 +1,18 @@
 /** @file\r
+  TCP input process routines.\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
+Copyright (c) 2005 - 2007, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Input.c\r
-\r
-Abstract:\r
-\r
-  TCP input process routines.\r
-\r
-\r
 **/\r
 \r
+\r
 #include "Tcp4Main.h"\r
 \r
 \r
@@ -491,6 +484,8 @@ TcpDeliverData (
         NetbufFree (Nbuf);\r
         return -1;\r
         break;\r
+      case default:\r
+        break;\r
       }\r
 \r
       TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW);\r
@@ -772,10 +767,6 @@ TcpInput (
   NetbufTrim (Nbuf, (Head->HeadLen << 2), NET_BUF_HEAD);\r
   Nbuf->Tcp = NULL;\r
 \r
-  //\r
-  // TODO: add fast path process here\r
-  //\r
-\r
   //\r
   // Process the segment in LISTEN state.\r
   //\r
@@ -861,14 +852,14 @@ TcpInput (
       if (TCP_FLG_ON (Seg->Flag, TCP_FLG_ACK)) {\r
 \r
         DEBUG ((EFI_D_WARN, "TcpInput: connection reset by"\r
-          " peer for TCB%x in SYN_SENT\n", Tcb));\r
+          " peer for TCB %p in SYN_SENT\n", Tcb));\r
 \r
         SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET);\r
         goto DROP_CONNECTION;\r
       } else {\r
 \r
         DEBUG ((EFI_D_WARN, "TcpInput: discard a reset segment "\r
-          "because of no ACK for TCB%x in SYN_SENT\n", Tcb));\r
+          "because of no ACK for TCB %p in SYN_SENT\n", Tcb));\r
 \r
         goto DISCARD;\r
       }\r
@@ -985,9 +976,7 @@ TcpInput (
       SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET);\r
 \r
     } else {\r
-      //\r
-      // TODO: set socket error to CLOSED\r
-      //\r
+\r
     }\r
 \r
     goto DROP_CONNECTION;\r
@@ -1174,7 +1163,7 @@ TcpInput (
       }\r
 \r
       DEBUG ((EFI_D_WARN, "TcpInput: peer shrinks the"\r
-        " window  for connected TCB %p\n", Tcb));\r
+        " window for connected TCB %p\n", Tcb));\r
 \r
       if ((Tcb->CongestState == TCP_CONGEST_RECOVER) &&\r
           (TCP_SEQ_LT (Right, Tcb->Recover))) {\r
index c468bba380097ac2cda677a81d0541e2c19706b7..e7f0df90e9d981c0f9c380dc0056dc43f190b06e 100644 (file)
@@ -1,26 +1,17 @@
 /** @file\r
+  I/O interfaces between TCP and IpIo.\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Io.c\r
-\r
-Abstract:\r
-\r
-  I/O interfaces between TCP and IpIo.\r
-\r
-\r
 **/\r
 \r
-\r
 #include "Tcp4Main.h"\r
 \r
 \r
index d43a4a4faf0f8edb28b9ffc54e2214a79678e577..25ca2101a8f9f68b2dda304f1e363a76b67cfa86 100644 (file)
@@ -1,25 +1,18 @@
 /** @file\r
+  Implementation of TCP4 protocol services.\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Main.c\r
-\r
-Abstract:\r
-\r
-  Implementation of TCP4 protocol services.\r
-\r
-\r
 **/\r
 \r
+\r
 #include "Tcp4Main.h"\r
 \r
 \r
@@ -221,9 +214,9 @@ Tcp4Configure (
 /**\r
   Add or delete routing entries.\r
   \r
-  The Routes() function adds or deletes a route from the instance\92s routing table.\r
+  The Routes() function adds or deletes a route from the instance's routing table.\r
   The most specific route is selected by comparing the SubnetAddress with the \r
-  destination IP address\92s arithmetical AND to the SubnetMask.\r
+  destination IP address's arithmetical AND to the SubnetMask.\r
   The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0. \r
   The default route matches all destination IP addresses if there is no more specific route.\r
   Direct route is added with GatewayAddress set to 0.0.0.0. Packets are sent to \r
@@ -231,9 +224,9 @@ Tcp4Configure (
   cache or it is on the local subnet. If the instance is configured to use default \r
   address, a direct route to the local network will be added automatically.\r
   Each TCP instance has its own independent routing table. Instance that uses the \r
-  default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL\92s routing table. \r
+  default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL's routing table. \r
   The copy will be updated automatically whenever the IP driver reconfigures its \r
-  instance. As a result, the previous modification to the instance\92s local copy \r
+  instance. As a result, the previous modification to the instance's local copy \r
   will be lost. The priority of checking the route table is specific with IP \r
   implementation and every IP implementation must comply with RFC 1122.\r
 \r
@@ -348,7 +341,7 @@ Tcp4Connect (
   incoming connection on the passive TCP instance. If a remote peer successfully \r
   establishes a connection with this instance, a new TCP instance will be created \r
   and its handle will be returned in ListenToken->NewChildHandle. The newly created \r
-  instance is configured by inheriting the passive instance\92s configuration and is \r
+  instance is configured by inheriting the passive instance's configuration and is \r
   ready for use upon return. The instance is in the Tcp4StateEstablished state.\r
   The ListenToken->CompletionToken.Event will be signaled when a new connection \r
   is accepted, user aborts the listen or connection is reset. This function only \r
@@ -617,12 +610,12 @@ Tcp4Close (
   @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\92t been configured.\r
+  @retval  EFI_NOT_STARTED         This instance hasn's been configured.\r
   @retval  EFI_NO_MAPPING          When using the default address, configuration\r
-                                   (DHCP, BOOTP,RARP, etc.) hasn\92t finished yet.\r
-  @retval  EFI_NOT_FOUND           The asynchronous I/O request isn\92t found in the \r
+                                   (DHCP, BOOTP,RARP, etc.) hasn's finished yet.\r
+  @retval  EFI_NOT_FOUND           The asynchronous I/O request isn's found in the \r
                                    transmission or receive queue. It has either \r
-                                   completed or wasn\92t issued by Transmit() and Receive().\r
+                                   completed or wasn's issued by Transmit() and Receive().\r
   @retval  EFI_UNSUPPORTED         The operation is not supported in current\r
                                    implementation.\r
   \r
index f1a69ab63ddb578f5953d3af56f6d08911241aa9..3c2accf9eb8840a0134ae4a970ea3be11946cbfb 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Main.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef _TCP4_MAIN_H_\r
@@ -28,6 +21,7 @@ Abstract:
 \r
 \r
 extern UINT16  mTcp4RandomPort;\r
+extern CHAR16  *mTcpStateName[];\r
 \r
 //\r
 // Driver Produced Protocol Prototypes\r
@@ -36,13 +30,31 @@ extern UINT16  mTcp4RandomPort;
 //\r
 // Function prototype for the Tcp4 socket request handler\r
 //\r
+/**\r
+  The procotol handler provided to the socket layer, used to\r
+  dispatch the socket level requests by calling the corresponding\r
+  TCP layer functions.\r
+\r
+  @param  Sock                   Pointer to the socket of this TCP instance.\r
+  @param  Request                The code of this operation request.\r
+  @param  Data                   Pointer to the operation specific data passed in\r
+                                 together with the operation request.\r
+\r
+  @retval EFI_SUCCESS            The socket request is completed successfully.\r
+  @retval other                  The error status returned by the corresponding TCP\r
+                                 layer function.\r
+\r
+**/\r
 EFI_STATUS\r
 Tcp4Dispatcher (\r
   IN SOCKET                  *Sock,\r
   IN SOCK_REQUEST            Request,\r
   IN VOID                    *Data    OPTIONAL\r
   );\r
-\r
+  \r
+///\r
+/// TCP mode data\r
+///\r
 typedef struct _TCP4_MODE_DATA {\r
   EFI_TCP4_CONNECTION_STATE       *Tcp4State;\r
   EFI_TCP4_CONFIG_DATA            *Tcp4ConfigData;\r
@@ -51,6 +63,9 @@ typedef struct _TCP4_MODE_DATA {
   EFI_SIMPLE_NETWORK_MODE         *SnpModeData;\r
 } TCP4_MODE_DATA;\r
 \r
+///\r
+/// TCP route infomation data\r
+///\r
 typedef struct _TCP4_ROUTE_INFO {\r
   BOOLEAN           DeleteRoute;\r
   EFI_IPv4_ADDRESS  *SubnetAddress;\r
@@ -58,33 +73,136 @@ typedef struct _TCP4_ROUTE_INFO {
   EFI_IPv4_ADDRESS  *GatewayAddress;\r
 } TCP4_ROUTE_INFO;\r
 \r
-//\r
-// Get the mode data of a TCP instance\r
-//\r
+/**\r
+  Get the current operational status of a TCP instance.\r
+  \r
+  The GetModeData() function copies the current operational settings of this \r
+  EFI TCPv4 Protocol instance into user-supplied buffers. This function can \r
+  also be used to retrieve the operational setting of underlying drivers \r
+  such as IPv4, MNP, or SNP.\r
+\r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance.\r
+  @param  Tcp4State                Pointer to the buffer to receive the current TCP\r
+                                   state.\r
+  @param  Tcp4ConfigData           Pointer to the buffer to receive the current TCP\r
+                                   configuration.\r
+  @param  Ip4ModeData              Pointer to the buffer to receive the current IPv4 \r
+                                   configuration data used by the TCPv4 instance.\r
+  @param  MnpConfigData            Pointer to the buffer to receive the current MNP\r
+                                   configuration data indirectly used by the TCPv4\r
+                                   Instance.\r
+  @param  SnpModeData              Pointer to the buffer to receive the current SNP\r
+                                   configuration data indirectly used by the TCPv4\r
+                                   Instance.\r
+\r
+  @retval EFI_SUCCESS              The mode data was read.\r
+  @retval EFI_NOT_STARTED          No configuration data is available because this\r
+                                   instance hasn't been started.\r
+  @retval EFI_INVALID_PARAMETER    This is NULL.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4GetModeData (\r
-  IN  CONST EFI_TCP4_PROTOCOL                  *This,\r
-  OUT       EFI_TCP4_CONNECTION_STATE          *Tcp4State OPTIONAL,\r
-  OUT       EFI_TCP4_CONFIG_DATA               *Tcp4ConfigData OPTIONAL,\r
-  OUT       EFI_IP4_MODE_DATA                  *Ip4ModeData OPTIONAL,\r
-  OUT       EFI_MANAGED_NETWORK_CONFIG_DATA    *MnpConfigData OPTIONAL,\r
-  OUT       EFI_SIMPLE_NETWORK_MODE            *SnpModeData OPTIONAL\r
+  IN     CONST EFI_TCP4_PROTOCOL                  *This,\r
+     OUT       EFI_TCP4_CONNECTION_STATE          *Tcp4State       OPTIONAL,\r
+     OUT       EFI_TCP4_CONFIG_DATA               *Tcp4ConfigData  OPTIONAL,\r
+     OUT       EFI_IP4_MODE_DATA                  *Ip4ModeData     OPTIONAL,\r
+     OUT       EFI_MANAGED_NETWORK_CONFIG_DATA    *MnpConfigData   OPTIONAL,\r
+     OUT       EFI_SIMPLE_NETWORK_MODE            *SnpModeData     OPTIONAL\r
   );\r
 \r
-//\r
-// Initialize or reset a TCP instance\r
-//\r
+\r
+/**\r
+  Initialize or brutally reset the operational parameters for\r
+  this EFI TCPv4 instance.\r
+  \r
+  The Configure() function does the following:\r
+  * Initialize this EFI TCPv4 instance, i.e., initialize the communication end \r
+  setting, specify active open or passive open for an instance.\r
+  * Reset this TCPv4 instance brutally, i.e., cancel all pending asynchronous \r
+  tokens, flush transmission and receiving buffer directly without informing \r
+  the communication peer.\r
+  No other TCPv4 Protocol operation can be executed by this instance \r
+  until it is configured properly. For an active TCP4 instance, after a proper \r
+  configuration it may call Connect() to initiates the three-way handshake. \r
+  For a passive TCP4 instance, its state will transit to Tcp4StateListen after \r
+  configuration, and Accept() may be called to listen the incoming TCP connection \r
+  request. If TcpConfigData is set to NULL, the instance is reset. Resetting \r
+  process will be done brutally, the state machine will be set to Tcp4StateClosed \r
+  directly, the receive queue and transmit queue will be flushed, and no traffic is \r
+  allowed through this instance.\r
+\r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance.\r
+  @param  TcpConfigData            Pointer to the configure data to configure the\r
+                                   instance.\r
+\r
+  @retval EFI_SUCCESS              The operational settings are set, changed, or\r
+                                   reset successfully.\r
+  @retval EFI_NO_MAPPING           When using a default address, configuration\r
+                                   (through DHCP, BOOTP, RARP, etc.) is not\r
+                                   finished.\r
+  @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.\r
+  @retval EFI_ACCESS_DENIED        Configuring TCP instance when it is already\r
+                                   configured.\r
+  @retval EFI_DEVICE_ERROR         An unexpected network or system error occurred.\r
+  @retval EFI_UNSUPPORTED          One or more of the control options are not\r
+                                   supported in the implementation.\r
+  @retval EFI_OUT_OF_RESOURCES     Could not allocate enough system resources.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Configure (\r
   IN EFI_TCP4_PROTOCOL        *This,\r
-  IN EFI_TCP4_CONFIG_DATA     *TcpConfigData OPTIONAL\r
+  IN EFI_TCP4_CONFIG_DATA     *TcpConfigData     OPTIONAL\r
   );\r
 \r
-//\r
-// Add a route entry to the route table\r
-//\r
+/**\r
+  Add or delete routing entries.\r
+  \r
+  The Routes() function adds or deletes a route from the instance's routing table.\r
+  The most specific route is selected by comparing the SubnetAddress with the \r
+  destination IP address's arithmetical AND to the SubnetMask.\r
+  The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0. \r
+  The default route matches all destination IP addresses if there is no more specific route.\r
+  Direct route is added with GatewayAddress set to 0.0.0.0. Packets are sent to \r
+  the destination host if its address can be found in the Address Resolution Protocol (ARP) \r
+  cache or it is on the local subnet. If the instance is configured to use default \r
+  address, a direct route to the local network will be added automatically.\r
+  Each TCP instance has its own independent routing table. Instance that uses the \r
+  default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL's routing table. \r
+  The copy will be updated automatically whenever the IP driver reconfigures its \r
+  instance. As a result, the previous modification to the instance's local copy \r
+  will be lost. The priority of checking the route table is specific with IP \r
+  implementation and every IP implementation must comply with RFC 1122.\r
+\r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance.\r
+  @param  DeleteRoute              If TRUE, delete the specified route from routing\r
+                                   table; if FALSE, add the specified route to\r
+                                   routing table.\r
+                                   DestinationAddress and SubnetMask are used as \r
+                                   the keywords to search route entry.\r
+  @param  SubnetAddress            The destination network.\r
+  @param  SubnetMask               The subnet mask for the destination network.\r
+  @param  GatewayAddress           The gateway address for this route. \r
+                                   It must be on the same subnet with the station \r
+                                   address unless a direct route is specified.\r
+                                   \r
+  @retval EFI_SUCCESS              The operation completed successfully.\r
+  @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance has not been\r
+                                   configured.\r
+  @retval EFI_NO_MAPPING           When using a default address, configuration\r
+                                   (through DHCP, BOOTP, RARP, etc.) is not\r
+                                   finished.\r
+  @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.\r
+  @retval EFI_OUT_OF_RESOURCES     Could not allocate enough resources to add the\r
+                                   entry to the routing table.\r
+  @retval EFI_NOT_FOUND            This route is not in the routing table.\r
+  @retval EFI_ACCESS_DENIED        This route is already in the routing table.\r
+  @retval EFI_UNSUPPORTED          The TCP driver does not support this operation.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Routes (\r
@@ -95,10 +213,35 @@ Tcp4Routes (
   IN EFI_IPv4_ADDRESS            *GatewayAddress\r
   );\r
 \r
-//\r
-// Issue an asynchronous connection establishment\r
-// request to the peer\r
-//\r
+/**\r
+  Initiate a nonblocking TCP connection request for an active TCP instance.\r
+\r
+  The Connect() function will initiate an active open to the remote peer configured \r
+  in current TCP instance if it is configured active. If the connection succeeds \r
+  or fails due to any error, the ConnectionToken->CompletionToken.Event will be \r
+  signaled and ConnectionToken->CompletionToken.Status will be updated accordingly. \r
+  This function can only be called for the TCP instance in Tcp4StateClosed state. \r
+  The instance will transfer into Tcp4StateSynSent if the function returns EFI_SUCCESS. \r
+  If TCP three way handshake succeeds, its state will become Tcp4StateEstablished, \r
+  otherwise, the state will return to Tcp4StateClosed.\r
+  \r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance\r
+  @param  ConnectionToken          Pointer to the connection token to return when\r
+                                   the TCP three way handshake finishes.\r
+\r
+  @retval EFI_SUCCESS              The connection request is successfully initiated \r
+                                   and the state of this TCPv4 instance has \r
+                                   been changed to Tcp4StateSynSent.\r
+  @retval EFI_NOT_STARTED          This EFI_TCP4_PROTOCOL instance hasn't been\r
+                                   configured.\r
+  @retval EFI_ACCESS_DENIED        The instance is not configured as an active one\r
+                                   or it is not in Tcp4StateClosed state.\r
+  @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.\r
+  @retval EFI_OUT_OF_RESOURCES     The driver can't allocate enough resource to\r
+                                   initiate the active open.\r
+  @retval EFI_DEVICE_ERROR         An unexpected system or network error occurred.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Connect (\r
@@ -106,10 +249,36 @@ Tcp4Connect (
   IN EFI_TCP4_CONNECTION_TOKEN   *ConnectionToken\r
   );\r
 \r
-//\r
-// Issue an asynchronous listent token to accept an\r
-// incoming connection reques\r
-//\r
+/**\r
+  Listen on the passive instance to accept an incoming connection request.\r
+\r
+  The Accept() function initiates an asynchronous accept request to wait for an \r
+  incoming connection on the passive TCP instance. If a remote peer successfully \r
+  establishes a connection with this instance, a new TCP instance will be created \r
+  and its handle will be returned in ListenToken->NewChildHandle. The newly created \r
+  instance is configured by inheriting the passive instance's configuration and is \r
+  ready for use upon return. The instance is in the Tcp4StateEstablished state.\r
+  The ListenToken->CompletionToken.Event will be signaled when a new connection \r
+  is accepted, user aborts the listen or connection is reset. This function only \r
+  can be called when current TCP instance is in Tcp4StateListen state.\r
+\r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance\r
+  @param  ListenToken              Pointer to the listen token to return when\r
+                                   operation finishes.\r
+\r
+  @retval EFI_SUCCESS              The listen token has been queued successfully.\r
+  @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance hasn't been\r
+                                   configured.\r
+  @retval EFI_ACCESS_DENIED        The instatnce is not a passive one or it is not\r
+                                   in Tcp4StateListen state or a same listen token\r
+                                   has already existed in the listen token queue of\r
+                                   this TCP instance.\r
+  @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.\r
+  @retval EFI_OUT_OF_RESOURCES     Could not allocate enough resources to finish\r
+                                   the operation.\r
+  @retval EFI_DEVICE_ERROR         Any unexpected and not belonged to above category error.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Accept (\r
@@ -117,10 +286,40 @@ Tcp4Accept (
   IN EFI_TCP4_LISTEN_TOKEN         *ListenToken\r
   );\r
 \r
-//\r
-// Issue an asynchronous IO token to transmit some data\r
-// through this TCP instance\r
-//\r
+/**\r
+  Queues outgoing data into the transmit queue.\r
+\r
+  The Transmit() function queues a sending request to this TCPv4 instance along \r
+  with the user data. The status of the token is updated and the event in the token \r
+  will be signaled once the data is sent out or some error occurs.\r
+\r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance\r
+  @param  Token                    Pointer to the completion token to queue to the\r
+                                   transmit queue\r
+\r
+  @retval EFI_SUCCESS              The data has been queued for transmission.\r
+  @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance hasn't been\r
+                                   configured.\r
+  @retval EFI_NO_MAPPING           When using a default address, configuration\r
+                                   (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
+  @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.\r
+  @retval EFI_ACCESS_DENIED        One or more of the following conditions is TRUE:\r
+                                   * A transmit completion token with the same\r
+                                     Token-> CompletionToken.Event was already in the\r
+                                     transmission queue. \r
+                                   * The current instance is in Tcp4StateClosed state \r
+                                   * The current instance is a passive one and \r
+                                     it is in Tcp4StateListen state. \r
+                                   * User has called Close() to disconnect this \r
+                                     connection.\r
+  @retval EFI_NOT_READY            The completion token could not be queued because\r
+                                   the transmit queue is full.\r
+  @retval EFI_OUT_OF_RESOURCES     Could not queue the transmit data because of\r
+                                   resource shortage.\r
+  @retval EFI_NETWORK_UNREACHABLE  There is no route to the destination network or\r
+                                   address.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Transmit (\r
@@ -128,10 +327,52 @@ Tcp4Transmit (
   IN EFI_TCP4_IO_TOKEN            *Token\r
   );\r
 \r
-//\r
-// Issue an asynchronous IO token to receive some data\r
-// through this TCP instance\r
-//\r
+/**\r
+  Place an asynchronous receive request into the receiving queue.\r
+\r
+  The Receive() function places a completion token into the receive packet queue. \r
+  This function is always asynchronous. The caller must allocate the \r
+  Token->CompletionToken.Event and the FragmentBuffer used to receive data. He also \r
+  must fill the DataLength which represents the whole length of all FragmentBuffer. \r
+  When the receive operation completes, the EFI TCPv4 Protocol driver updates the \r
+  Token->CompletionToken.Status and Token->Packet.RxData fields and the \r
+  Token->CompletionToken.Event is signaled. If got data the data and its length \r
+  will be copy into the FragmentTable, in the same time the full length of received \r
+  data will be recorded in the DataLength fields. Providing a proper notification \r
+  function and context for the event will enable the user to receive the notification \r
+  and receiving status. That notification function is guaranteed to not be re-entered.\r
+\r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance.\r
+  @param  Token                    Pointer to a token that is associated with the\r
+                                   receive data descriptor.\r
+\r
+  @retval EFI_SUCCESS              The receive completion token was cached.\r
+  @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance hasn't been\r
+                                   configured.\r
+  @retval EFI_NO_MAPPING           When using a default address, configuration\r
+                                   (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
+  @retval EFI_INVALID_PARAMETER    One or more parameters are invalid.\r
+  @retval EFI_OUT_OF_RESOURCES     The receive completion token could not be queued\r
+                                   due to a lack of system resources.\r
+  @retval EFI_DEVICE_ERROR         An unexpected system or network error occurred.\r
+                                   The EFI TCPv4 Protocol instance has been reset \r
+                                   to startup defaults.\r
+  @retval EFI_ACCESS_DENIED        One or more of the following conditions is TRUE:\r
+                                   * A receive completion token with the same\r
+                                     Token->CompletionToken.Event was already in \r
+                                     the receive queue. \r
+                                   * The current instance is in Tcp4StateClosed state. \r
+                                   * The current instance is a passive one and it \r
+                                     is in Tcp4StateListen state. \r
+                                   * User has called Close() to disconnect this \r
+                                     connection.\r
+  @retval EFI_CONNECTION_FIN       The communication peer has closed the connection\r
+                                   and there is no any buffered data in the receive\r
+                                   buffer of this instance.\r
+  @retval EFI_NOT_READY            The receive request could not be queued because\r
+                                   the receive queue is full.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Receive (\r
@@ -139,10 +380,37 @@ Tcp4Receive (
   IN EFI_TCP4_IO_TOKEN           *Token\r
   );\r
 \r
-//\r
-// Issue an asynchronous CloseToken to close a TCP\r
-// connection represented by instance\r
-//\r
+/**\r
+  Disconnecting a TCP connection gracefully or reset a TCP connection.\r
+\r
+  Initiate an asynchronous close token to TCP driver. After Close() is called, \r
+  any buffered transmission data will be sent by TCP driver and the current \r
+  instance will have a graceful close working flow described as RFC 793 if \r
+  AbortOnClose is set to FALSE, otherwise, a rest packet will be sent by TCP \r
+  driver to fast disconnect this connection. When the close operation completes \r
+  successfully the TCP instance is in Tcp4StateClosed state, all pending \r
+  asynchronous operation is signaled and any buffers used for TCP network traffic \r
+  is flushed.\r
+\r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance.\r
+  @param  CloseToken               Pointer to the close token to return when\r
+                                   operation finishes.\r
+\r
+  @retval EFI_SUCCESS              The operation completed successfully.\r
+  @retval EFI_NOT_STARTED          The EFI_TCP4_PROTOCOL instance hasn't been\r
+                                   configured.\r
+  @retval EFI_ACCESS_DENIED        One or more of the following are TRUE: \r
+                                   * Configure() has been called with TcpConfigData\r
+                                     set to NULL and this function has not returned.\r
+                                   * Previous Close() call on this instance has not\r
+                                     finished.\r
+  @retval EFI_INVALID_PARAMETER    One ore more parameters are invalid.\r
+  @retval EFI_OUT_OF_RESOURCES     Could not allocate enough resource to finish the\r
+                                   operation.\r
+  @retval EFI_DEVICE_ERROR         Any unexpected and not belonged to above\r
+                                   category error.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Close (\r
@@ -150,19 +418,65 @@ Tcp4Close (
   IN EFI_TCP4_CLOSE_TOKEN        *CloseToken\r
   );\r
 \r
-//\r
-// cancle an connect, listent or IO token\r
-//\r
+/**\r
+  Abort an asynchronous connection, listen, transmission or receive request.\r
+\r
+  The Cancel() function aborts a pending connection, listen, transmit or receive \r
+  request. If Token is not NULL and the token is in the connection, listen, \r
+  transmission or receive queue when it is being cancelled, its Token->Status \r
+  will be set to EFI_ABORTED and then Token->Event will be signaled. If the token \r
+  is not in one of the queues, which usually means that the asynchronous operation \r
+  has completed, EFI_NOT_FOUND is returned. If Token is NULL all asynchronous token \r
+  issued by Connect(), Accept(), Transmit() and Receive()will be aborted.\r
+  NOTE: It has not been implemented currently.\r
+    \r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance.\r
+  @param  Token                    Pointer to a token that has been issued by\r
+                                   Connect(), Accept(), Transmit() or Receive(). If\r
+                                   NULL, all pending tokens issued by above four\r
+                                   functions will be aborted.\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's been configured.\r
+  @retval  EFI_NO_MAPPING          When using the default address, configuration\r
+                                   (DHCP, BOOTP,RARP, etc.) hasn's finished yet.\r
+  @retval  EFI_NOT_FOUND           The asynchronous I/O request isn's found in the \r
+                                   transmission or receive queue. It has either \r
+                                   completed or wasn's issued by Transmit() and Receive().\r
+  @retval  EFI_UNSUPPORTED         The operation is not supported in current\r
+                                   implementation.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Cancel (\r
   IN EFI_TCP4_PROTOCOL           *This,\r
-  IN EFI_TCP4_COMPLETION_TOKEN   *Token OPTIONAL\r
+  IN EFI_TCP4_COMPLETION_TOKEN   *Token    OPTIONAL\r
   );\r
 \r
-//\r
-// poll data from NIC for receive\r
-//\r
+/**\r
+  Poll to receive incoming data and transmit outgoing segments.\r
+\r
+  The Poll() function increases the rate that data is moved between the network \r
+  and application and can be called when the TCP instance is created successfully. \r
+  Its use is optional. In some implementations, the periodical timer in the MNP \r
+  driver may not poll the underlying communications device fast enough to avoid \r
+  drop packets. Drivers and applications that are experiencing packet loss should \r
+  try calling the Poll() function in a high frequency.\r
+\r
+  @param  This                     Pointer to the EFI_TCP4_PROTOCOL instance.\r
+\r
+  @retval EFI_SUCCESS              Incoming or outgoing data was processed.\r
+  @retval EFI_INVALID_PARAMETER    This is NULL.\r
+  @retval EFI_DEVICE_ERROR         An unexpected system or network error occurred.\r
+  @retval EFI_NOT_READY            No incoming or outgoing data was processed.\r
+  @retval EFI_TIMEOUT              Data was dropped out of the transmission or\r
+                                   receive queue. Consider increasing the polling\r
+                                   rate.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Poll (\r
index 6d7117a164e586c146ca32d454ca61837fa45b2f..1c269929e34d5fa376bacd3c0397b2b0a5dc5ff1 100644 (file)
@@ -1,23 +1,15 @@
 /** @file\r
+  Misc support routines for tcp.\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Misc.c\r
-\r
-Abstract:\r
-\r
-  Misc support routines for tcp.\r
-\r
-\r
 **/\r
 \r
 \r
@@ -405,7 +397,7 @@ TcpInsertTcb (
 \r
 \r
 /**\r
-  Clone a TCP_CB from Tcb.\r
+  Clone a TCB_CB from Tcb.\r
 \r
   @param  Tcb                   Pointer to the TCP_CB to be cloned.\r
 \r
@@ -504,8 +496,8 @@ TcpGetRcvMss (
 **/\r
 VOID\r
 TcpSetState (\r
-  IN TCP_CB *Tcb,\r
-  IN UINT8  State\r
+  IN TCP_CB      *Tcb,\r
+  IN TCP_STATES  State\r
   )\r
 {\r
   DEBUG (\r
@@ -516,7 +508,7 @@ TcpSetState (
     mTcpStateName[State])\r
     );\r
 \r
-  Tcb->State = State;\r
+  Tcb->State = (TCP_STATES)State;\r
 \r
   switch (State) {\r
   case TCP_ESTABLISHED:\r
@@ -537,6 +529,8 @@ TcpSetState (
 \r
     SockConnClosed (Tcb->Sk);\r
 \r
+    break;\r
+  case default:\r
     break;\r
   }\r
 }\r
@@ -572,7 +566,6 @@ TcpChecksum (
   return (UINT16) ~Checksum;\r
 }\r
 \r
-\r
 /**\r
   Translate the information from the head of the received TCP\r
   segment Nbuf contains and fill it into a TCP_SEG structure.\r
@@ -731,6 +724,8 @@ TcpOnAppClose (
   case TCP_CLOSE_WAIT:\r
     TcpSetState (Tcb, TCP_LAST_ACK);\r
     break;\r
+  case default:\r
+    break;\r
   }\r
 \r
   TcpToSendData (Tcb, 1);\r
@@ -781,6 +776,8 @@ TcpOnAppSend (
   case TCP_TIME_WAIT:\r
     return -1;\r
     break;\r
+  case default:\r
+    break;\r
   }\r
 \r
   return 0;\r
@@ -822,13 +819,13 @@ TcpOnAppConsume (
       if (TcpOld < Tcb->RcvMss) {\r
 \r
         DEBUG ((EFI_D_INFO, "TcpOnAppConsume: send a window"\r
-          " update for a window closed Tcb(%p)\n", Tcb));\r
+          " update for a window closed Tcb %p\n", Tcb));\r
 \r
         TcpSendAck (Tcb);\r
       } else if (Tcb->DelayedAck == 0) {\r
 \r
         DEBUG ((EFI_D_INFO, "TcpOnAppConsume: scheduled a delayed"\r
-          " ACK to update window for Tcb(%p)\n", Tcb));\r
+          " ACK to update window for Tcb %p\n", Tcb));\r
 \r
         Tcb->DelayedAck = 1;\r
       }\r
index 35e858fb9a879ae7a61b94347832b439a9ce70a0..f321635323543dd174e3f240ba800929a5d4c394 100644 (file)
@@ -1,23 +1,15 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+  Routines to process TCP option.\r
+    \r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Option.c\r
-\r
-Abstract:\r
-\r
-  Routines to process TCP option.\r
-\r
-\r
 **/\r
 \r
 #include "Tcp4Main.h"\r
index faa4ffa587638f4db4bc36bf1eae4f3127f3806f..727c6f2dd4ba14710b50d5cd4b860b7e069b16a5 100644 (file)
@@ -1,36 +1,29 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+    \r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Option.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef _TCP4_OPTION_H_\r
 #define _TCP4_OPTION_H_\r
 \r
-//\r
-// The structure to store the parse option value.\r
-// ParseOption only parse the options, don't process them.\r
-//\r
-typedef struct s_TCP_OPTION {\r
-  UINT8   Flag;     // flag such as TCP_OPTION_RCVD_MSS\r
-  UINT8   WndScale; // the WndScale received\r
-  UINT16  Mss;      // the Mss received\r
-  UINT32  TSVal;    // the TSVal field in a timestamp option\r
-  UINT32  TSEcr;    // the TSEcr field in a timestamp option\r
+///\r
+/// The structure to store the parse option value.\r
+/// ParseOption only parse the options, don't process them.\r
+///\r
+typedef struct _TCP_OPTION {\r
+  UINT8   Flag;     ///< Flag such as TCP_OPTION_RCVD_MSS\r
+  UINT8   WndScale; ///< The WndScale received\r
+  UINT16  Mss;      ///< The Mss received\r
+  UINT32  TSVal;    ///< The TSVal field in a timestamp option\r
+  UINT32  TSEcr;    ///< The TSEcr field in a timestamp option\r
 } TCP_OPTION;\r
 \r
 typedef enum {\r
@@ -38,16 +31,16 @@ typedef enum {
   //\r
   // supported TCP option type and their length\r
   //\r
-  TCP_OPTION_EOP            = 0,  // End Of oPtion\r
-  TCP_OPTION_NOP            = 1,  // No-Option.\r
-  TCP_OPTION_MSS            = 2,  // Maximum Segment Size\r
-  TCP_OPTION_WS             = 3,  // Window scale\r
-  TCP_OPTION_TS             = 8,  // Timestamp\r
-  TCP_OPTION_MSS_LEN        = 4,  // length of MSS option\r
-  TCP_OPTION_WS_LEN         = 3,  // length of window scale option\r
-  TCP_OPTION_TS_LEN         = 10, // length of timestamp option\r
-  TCP_OPTION_WS_ALIGNED_LEN = 4,  // length of window scale option, aligned\r
-  TCP_OPTION_TS_ALIGNED_LEN = 12, // length of timestamp option, aligned\r
+  TCP_OPTION_EOP            = 0,  ///< End Of oPtion\r
+  TCP_OPTION_NOP            = 1,  ///< No-Option.\r
+  TCP_OPTION_MSS            = 2,  ///< Maximum Segment Size\r
+  TCP_OPTION_WS             = 3,  ///< Window scale\r
+  TCP_OPTION_TS             = 8,  ///< Timestamp\r
+  TCP_OPTION_MSS_LEN        = 4,  ///< Length of MSS option\r
+  TCP_OPTION_WS_LEN         = 3,  ///< Length of window scale option\r
+  TCP_OPTION_TS_LEN         = 10, ///< Length of timestamp option\r
+  TCP_OPTION_WS_ALIGNED_LEN = 4,  ///< Length of window scale option, aligned\r
+  TCP_OPTION_TS_ALIGNED_LEN = 12, ///< Length of timestamp option, aligned\r
 \r
   //\r
   // recommend format of timestamp window scale\r
@@ -71,33 +64,80 @@ typedef enum {
   TCP_OPTION_RCVD_MSS       = 0x01,\r
   TCP_OPTION_RCVD_WS        = 0x02,\r
   TCP_OPTION_RCVD_TS        = 0x04,\r
-  TCP_OPTION_MAX_WS         = 14,     // Maxium window scale value\r
-  TCP_OPTION_MAX_WIN        = 0xffff  // max window size in TCP header\r
+  TCP_OPTION_MAX_WS         = 14,     ///< Maxium window scale value\r
+  TCP_OPTION_MAX_WIN        = 0xffff  ///< Max window size in TCP header\r
 } TCP_OPTION_TYPE;\r
 \r
+/**\r
+  Compute the window scale value according to the given buffer size.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+\r
+  @return  The scale value.\r
+\r
+**/\r
 UINT8\r
 TcpComputeScale (\r
   IN TCP_CB *Tcb\r
   );\r
 \r
+/**\r
+  Build the TCP option in three-way handshake.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Nbuf    Pointer to the buffer to store the options.\r
+\r
+  @return  The total length of the TCP option field.\r
+\r
+**/\r
 UINT16\r
 TcpSynBuildOption (\r
   IN TCP_CB  *Tcb,\r
-  IN NET_BUF *Buf\r
+  IN NET_BUF *Nbuf\r
   );\r
 \r
+/**\r
+  Build the TCP option in synchronized states.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Nbuf    Pointer to the buffer to store the options.\r
+\r
+  @return  The total length of the TCP option field.\r
+\r
+**/\r
 UINT16\r
 TcpBuildOption (\r
   IN TCP_CB  *Tcb,\r
-  IN NET_BUF *Buf\r
+  IN NET_BUF *Nbuf\r
   );\r
 \r
+/**\r
+  Parse the supported options.\r
+\r
+  @param  Tcp     Pointer to the TCP_CB of this TCP instance.\r
+  @param  Option  Pointer to the TCP_OPTION used to store the successfully pasrsed\r
+                  options.\r
+\r
+  @retval 0       The options are successfully pasrsed.\r
+  @retval -1      Ilegal option was found.\r
+\r
+**/\r
 INTN\r
 TcpParseOption (\r
   IN TCP_HEAD   *Tcp,\r
   IN TCP_OPTION *Option\r
   );\r
 \r
+/**\r
+  Check the segment against PAWS.\r
+\r
+  @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
+  @param  TSVal   The timestamp value.\r
+\r
+  @retval 1       The segment passed the PAWS check.\r
+  @retval 0       The segment failed to pass the PAWS check.\r
+\r
+**/\r
 UINT32\r
 TcpPawsOK (\r
   IN TCP_CB *Tcb,\r
index 187fd955a9bcc623618b3efc5d75701fd61994e9..f12b2c5b4ca001ec88c95f20b1e22e510d24e414 100644 (file)
@@ -1,23 +1,15 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+  TCP output process routines.\r
+    \r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Output.c\r
-\r
-Abstract:\r
-\r
-  TCP output process routines.\r
-\r
-\r
 **/\r
 \r
 #include "Tcp4Main.h"\r
@@ -112,8 +104,7 @@ TcpRcvWinNow (
 \r
 \r
 /**\r
-  Compute the value to fill in the window size field\r
-  of the outgoing segment.\r
+  Compute the value to fill in the window size field of the outgoing segment.\r
 \r
   @param  Tcb     Pointer to the TCP_CB of this TCP instance.\r
   @param  Syn     The flag to indicate whether the outgoing segment is a SYN\r
@@ -808,8 +799,13 @@ SEND_AGAIN:
         (GET_SND_DATASIZE (Tcb->Sk) == 0) &&\r
         TCP_SEQ_LT (End + 1, Tcb->SndWnd + Tcb->SndWl2)) {\r
 \r
-      DEBUG ((EFI_D_INFO, "TcpToSendData: send FIN "\r
-        "to peer for TCB %p in state %d\n", Tcb, Tcb->State));\r
+      DEBUG (\r
+               (EFI_D_INFO, \r
+               "TcpToSendData: send FIN "\r
+        "to peer for TCB %p in state %s\n", \r
+        Tcb, \r
+        mTcpStateName[Tcb->State])\r
+      );\r
 \r
       End++;\r
     } else {\r
index ee278e3516efbfbd64c4676754d6c240d83f7053..8bb99caac0f07106354f06ba6cbad2c2aed208a9 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+        \r
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Proto.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef _TCP4_PROTO_H_\r
@@ -27,10 +20,12 @@ typedef struct _TCP_CB  TCP_CB;
 #include "Socket.h"\r
 #include "Tcp4Option.h"\r
 \r
-//\r
-// tcp states, Don't change their order, it is used as\r
-// index to mTcpOutFlag and other macros\r
-//\r
+\r
+\r
+///\r
+/// Tcp states, Don't change their order, it is used as\r
+/// index to mTcpOutFlag and other macros\r
+///\r
 typedef enum {\r
   TCP_CLOSED      = 0,\r
   TCP_LISTEN,\r
@@ -45,9 +40,9 @@ typedef enum {
   TCP_LAST_ACK\r
 } TCP_STATES;\r
 \r
-//\r
-// flags in the TCP header\r
-//\r
+///\r
+/// Flags in the TCP header\r
+///\r
 typedef enum {\r
 \r
   TCP_FLG_FIN     = 0x01,\r
@@ -56,72 +51,73 @@ typedef enum {
   TCP_FLG_PSH     = 0x08,\r
   TCP_FLG_ACK     = 0x10,\r
   TCP_FLG_URG     = 0x20,\r
-  TCP_FLG_FLAG    = 0x3F  // mask for all the flags\r
+  \r
+  //\r
+  // mask for all the flags\r
+  //\r
+  TCP_FLG_FLAG    = 0x3F  \r
 } TCP_HEADER_FLAG;\r
 \r
 typedef enum {\r
 \r
-  //\r
-  // TCP error status\r
-  //\r
-  TCP_CONNECT_REFUSED     = -1,\r
-  TCP_CONNECT_RESET       = -2,\r
-  TCP_CONNECT_CLOSED      = -3,\r
+  TCP_CONNECT_REFUSED     = -1, ///< TCP error status\r
+  TCP_CONNECT_RESET       = -2, ///< TCP error status\r
+  TCP_CONNECT_CLOSED      = -3, ///< TCP error status\r
 \r
   //\r
   // Current congestion status as suggested by RFC3782.\r
   //\r
-  TCP_CONGEST_RECOVER     = 1,  // during the NewReno fast recovery\r
-  TCP_CONGEST_LOSS        = 2,  // retxmit because of retxmit time out\r
-  TCP_CONGEST_OPEN        = 3,  // TCP is opening its congestion window\r
+  TCP_CONGEST_RECOVER     = 1,  ///< During the NewReno fast recovery\r
+  TCP_CONGEST_LOSS        = 2,  ///< Retxmit because of retxmit time out\r
+  TCP_CONGEST_OPEN        = 3,  ///< TCP is opening its congestion window\r
 \r
   //\r
   // TCP control flags\r
   //\r
-  TCP_CTRL_NO_NAGLE       = 0x0001, // disable Nagle algorithm\r
-  TCP_CTRL_NO_KEEPALIVE   = 0x0002, // disable keepalive timer\r
-  TCP_CTRL_NO_WS          = 0x0004, // disable window scale option\r
-  TCP_CTRL_RCVD_WS        = 0x0008, // rcvd a wnd scale option in syn\r
-  TCP_CTRL_NO_TS          = 0x0010, // disable Timestamp option\r
-  TCP_CTRL_RCVD_TS        = 0x0020, // rcvd a Timestamp option in syn\r
-  TCP_CTRL_SND_TS         = 0x0040, // Send Timestamp option to remote\r
-  TCP_CTRL_SND_URG        = 0x0080, // in urgent send mode\r
-  TCP_CTRL_RCVD_URG       = 0x0100, // in urgent receive mode\r
-  TCP_CTRL_SND_PSH        = 0x0200, // in PUSH send mode\r
-  TCP_CTRL_FIN_SENT       = 0x0400, // FIN is sent\r
-  TCP_CTRL_FIN_ACKED      = 0x0800, // FIN is ACKed.\r
-  TCP_CTRL_TIMER_ON       = 0x1000, // At least one of the timer is on\r
-  TCP_CTRL_RTT_ON         = 0x2000, // The RTT measurement is on\r
-  TCP_CTRL_ACK_NOW        = 0x4000, // Send the ACK now, don't delay\r
+  TCP_CTRL_NO_NAGLE       = 0x0001, ///< Disable Nagle algorithm\r
+  TCP_CTRL_NO_KEEPALIVE   = 0x0002, ///< Disable keepalive timer\r
+  TCP_CTRL_NO_WS          = 0x0004, ///< Disable window scale option\r
+  TCP_CTRL_RCVD_WS        = 0x0008, ///< Received a wnd scale option in syn\r
+  TCP_CTRL_NO_TS          = 0x0010, ///< Disable Timestamp option\r
+  TCP_CTRL_RCVD_TS        = 0x0020, ///< Received a Timestamp option in syn\r
+  TCP_CTRL_SND_TS         = 0x0040, ///< Send Timestamp option to remote\r
+  TCP_CTRL_SND_URG        = 0x0080, ///< In urgent send mode\r
+  TCP_CTRL_RCVD_URG       = 0x0100, ///< In urgent receive mode\r
+  TCP_CTRL_SND_PSH        = 0x0200, ///< In PUSH send mode\r
+  TCP_CTRL_FIN_SENT       = 0x0400, ///< FIN is sent\r
+  TCP_CTRL_FIN_ACKED      = 0x0800, ///< FIN is ACKed.\r
+  TCP_CTRL_TIMER_ON       = 0x1000, ///< At least one of the timer is on\r
+  TCP_CTRL_RTT_ON         = 0x2000, ///< The RTT measurement is on\r
+  TCP_CTRL_ACK_NOW        = 0x4000, ///< Send the ACK now, don't delay\r
 \r
   //\r
   // Timer related values\r
   //\r
-  TCP_TIMER_CONNECT       = 0,                // Connection establishment timer\r
-  TCP_TIMER_REXMIT        = 1,                // retransmit timer\r
-  TCP_TIMER_PROBE         = 2,                // Window probe timer\r
-  TCP_TIMER_KEEPALIVE     = 3,                // Keepalive timer\r
-  TCP_TIMER_FINWAIT2      = 4,                // FIN_WAIT_2 timer\r
-  TCP_TIMER_2MSL          = 5,                // TIME_WAIT tiemr\r
-  TCP_TIMER_NUMBER        = 6,                // the total number of TCP timer.\r
-  TCP_TICK                = 200,              // every TCP tick is 200ms\r
-  TCP_TICK_HZ             = 5,                // the frequence of TCP tick\r
-  TCP_RTT_SHIFT           = 3,                // SRTT & RTTVAR scaled by 8\r
-  TCP_RTO_MIN             = TCP_TICK_HZ,      // the minium value of RTO\r
-  TCP_RTO_MAX             = TCP_TICK_HZ *60,  // the maxium value of RTO\r
-  TCP_FOLD_RTT            = 4,                // timeout threshod to fold RTT\r
+  TCP_TIMER_CONNECT       = 0,                  ///< Connection establishment timer\r
+  TCP_TIMER_REXMIT        = 1,                  ///< Retransmit timer\r
+  TCP_TIMER_PROBE         = 2,                  ///< Window probe timer\r
+  TCP_TIMER_KEEPALIVE     = 3,                  ///< Keepalive timer\r
+  TCP_TIMER_FINWAIT2      = 4,                  ///< FIN_WAIT_2 timer\r
+  TCP_TIMER_2MSL          = 5,                  ///< TIME_WAIT tiemr\r
+  TCP_TIMER_NUMBER        = 6,                  ///< The total number of TCP timer.\r
+  TCP_TICK                = 200,                ///< Every TCP tick is 200ms\r
+  TCP_TICK_HZ             = 5,                  ///< The frequence of TCP tick\r
+  TCP_RTT_SHIFT           = 3,                  ///< SRTT & RTTVAR scaled by 8\r
+  TCP_RTO_MIN             = TCP_TICK_HZ,        ///< The minium value of RTO\r
+  TCP_RTO_MAX             = (TCP_TICK_HZ * 60), ///< The maxium value of RTO\r
+  TCP_FOLD_RTT            = 4,                  ///< Timeout threshod to fold RTT\r
 \r
   //\r
-  // default values for some timers\r
+  // Default values for some timers\r
   //\r
-  TCP_MAX_LOSS            = 12,                  // default max times to retxmit\r
-  TCP_KEEPALIVE_IDLE_MIN  = TCP_TICK_HZ *60 *60 *2, // First keep alive\r
-  TCP_KEEPALIVE_PERIOD    = TCP_TICK_HZ *60,\r
+  TCP_MAX_LOSS            = 12,                          ///< Default max times to retxmit\r
+  TCP_KEEPALIVE_IDLE_MIN  = (TCP_TICK_HZ * 60 * 60 * 2), ///< First keep alive\r
+  TCP_KEEPALIVE_PERIOD    = (TCP_TICK_HZ * 60),\r
   TCP_MAX_KEEPALIVE       = 8,\r
-  TCP_FIN_WAIT2_TIME      = 2 *TCP_TICK_HZ,         // * 60,\r
-  TCP_TIME_WAIT_TIME      = 2 *TCP_TICK_HZ,\r
-  TCP_PAWS_24DAY          = 24 *24 *60 *60 *TCP_TICK_HZ,\r
-  TCP_CONNECT_TIME        = 75 *TCP_TICK_HZ,\r
+  TCP_FIN_WAIT2_TIME      = (2 * TCP_TICK_HZ),\r
+  TCP_TIME_WAIT_TIME      = (2 * TCP_TICK_HZ),\r
+  TCP_PAWS_24DAY          = (24 * 24 * 60 * 60 * TCP_TICK_HZ),\r
+  TCP_CONNECT_TIME        = (75 * TCP_TICK_HZ),\r
 \r
   //\r
   // The header space to be reserved before TCP data to accomodate :\r
@@ -130,132 +126,133 @@ typedef enum {
   TCP_MAX_HEAD            = 192,\r
 \r
   //\r
-  // value ranges for some control option\r
+  // Value ranges for some control option\r
   //\r
-  TCP_RCV_BUF_SIZE        = 2 *1024 *1024,\r
-  TCP_RCV_BUF_SIZE_MIN    = 8 *1024,\r
-  TCP_SND_BUF_SIZE        = 2 *1024 *1024,\r
-  TCP_SND_BUF_SIZE_MIN    = 8 *1024,\r
+  TCP_RCV_BUF_SIZE        = (2 * 1024 * 1024),\r
+  TCP_RCV_BUF_SIZE_MIN    = (8 * 1024),\r
+  TCP_SND_BUF_SIZE        = (2 * 1024 * 1024),\r
+  TCP_SND_BUF_SIZE_MIN    = (8 * 1024),\r
   TCP_BACKLOG             = 10,\r
   TCP_BACKLOG_MIN         = 5,\r
   TCP_MAX_LOSS_MIN        = 6,\r
-  TCP_CONNECT_TIME_MIN    = 60 *TCP_TICK_HZ,\r
+  TCP_CONNECT_TIME_MIN    = (60 * TCP_TICK_HZ),\r
   TCP_MAX_KEEPALIVE_MIN   = 4,\r
-  TCP_KEEPALIVE_IDLE_MAX  = TCP_TICK_HZ *60 *60 *4,\r
-  TCP_KEEPALIVE_PERIOD_MIN= TCP_TICK_HZ *30,\r
-  TCP_FIN_WAIT2_TIME_MAX  = 4 *TCP_TICK_HZ,\r
-  TCP_TIME_WAIT_TIME_MAX  = 60 *TCP_TICK_HZ\r
+  TCP_KEEPALIVE_IDLE_MAX  = (TCP_TICK_HZ * 60 * 60 * 4),\r
+  TCP_KEEPALIVE_PERIOD_MIN= (TCP_TICK_HZ * 30),\r
+  TCP_FIN_WAIT2_TIME_MAX  = (4 * TCP_TICK_HZ),\r
+  TCP_TIME_WAIT_TIME_MAX  = (60 * TCP_TICK_HZ)\r
 } TCP_MISC_VALUES;\r
 \r
+///\r
+/// TCP segmentation data\r
+///\r
 typedef struct _TCP_SEG {\r
-  TCP_SEQNO Seq;  // Starting sequence number\r
-  TCP_SEQNO End;  // The sequence of the last byte + 1,\r
-                  // include SYN/FIN. End-Seq = SEG.LEN\r
-  TCP_SEQNO Ack;  // ACK fild in the segment\r
-  UINT8     Flag; // TCP header flags\r
-  UINT16    Urg;  // Valid if URG flag is set.\r
-  UINT32    Wnd;  // TCP window size field\r
+  TCP_SEQNO Seq;  ///< Starting sequence number\r
+  TCP_SEQNO End;  ///< The sequence of the last byte + 1, include SYN/FIN. End-Seq = SEG.LEN\r
+  TCP_SEQNO Ack;  ///< ACK field in the segment\r
+  UINT8     Flag; ///< TCP header flags\r
+  UINT16    Urg;  ///< Valid if URG flag is set.\r
+  UINT32    Wnd;  ///< TCP window size field\r
 } TCP_SEG;\r
 \r
+///\r
+/// Network endpoint, IP+Port structure\r
+///\r
 typedef struct _TCP_PEER {\r
-  UINT32      Ip;   // Network byte order\r
-  TCP_PORTNO  Port; // Network byte order\r
+  UINT32      Ip;   ///< IP address, network byte order\r
+  TCP_PORTNO  Port; ///< Port number, network byte order\r
 } TCP_PEER;\r
 \r
-//\r
-// tcp control block, it includes various states\r
-//\r
+///\r
+/// TCP control block, it includes various states\r
+///\r
 struct _TCP_CB {\r
-  LIST_ENTRY        List;\r
-  TCP_CB            *Parent;\r
+  LIST_ENTRY        List;     ///< Back and forward link entry\r
+  TCP_CB            *Parent;  ///< The parent TCP_CB structure\r
 \r
-  SOCKET            *Sk;\r
-  TCP_PEER          LocalEnd;\r
-  TCP_PEER          RemoteEnd;\r
+  SOCKET            *Sk;      ///< The socket it controled.\r
+  TCP_PEER          LocalEnd; ///< Local endpoint\r
+  TCP_PEER          RemoteEnd;///< Remote endpoint\r
 \r
-  LIST_ENTRY        SndQue;   // retxmission queue\r
-  LIST_ENTRY        RcvQue;   // reassemble queue\r
-  UINT32            CtrlFlag; // control flags, such as NO_NAGLE\r
-  INT32             Error;    // soft error status,TCP_CONNECT_RESET...\r
+  LIST_ENTRY        SndQue;   ///< Retxmission queue\r
+  LIST_ENTRY        RcvQue;   ///< Reassemble queue\r
+  UINT32            CtrlFlag; ///< Control flags, such as NO_NAGLE\r
+  INT32             Error;    ///< Soft error status, such as TCP_CONNECT_RESET\r
 \r
   //\r
   // RFC793 and RFC1122 defined variables\r
   //\r
-  UINT8             State;      // TCP state, such as SYN_SENT, LISTEN\r
-  UINT8             DelayedAck; // number of delayed ACKs\r
-  UINT16            HeadSum;    // checksum of the fixed parts of pesudo\r
-                                // header: Src IP, Dst IP, 0, Protocol,\r
-                                // not include the TCP length.\r
-\r
-  TCP_SEQNO         Iss;        // Initial Sending Sequence\r
-  TCP_SEQNO         SndUna;     // first unacknowledged data\r
-  TCP_SEQNO         SndNxt;     // next data sequence to send.\r
-  TCP_SEQNO         SndPsh;     // Send PUSH point\r
-  TCP_SEQNO         SndUp;      // Send urgent point\r
-  UINT32            SndWnd;     // Window advertised by the remote peer\r
-  UINT32            SndWndMax;  // max send window advertised by the peer\r
-  TCP_SEQNO         SndWl1;     // Seq number used for last window update\r
-  TCP_SEQNO         SndWl2;     // ack no of last window update\r
-  UINT16            SndMss;     // Max send segment size\r
-  TCP_SEQNO         RcvNxt;     // Next sequence no to receive\r
-  UINT32            RcvWnd;     // Window advertised by the local peer\r
-  TCP_SEQNO         RcvWl2;     // The RcvNxt (or ACK) of last window update.\r
-                                // It is necessary because of delayed ACK\r
-\r
-  TCP_SEQNO         RcvUp;                   // urgent point;\r
-  TCP_SEQNO         Irs;                     // Initial Receiving Sequence\r
-  UINT16            RcvMss;                  // Max receive segment size\r
-  UINT16            EnabledTimer;            // which timer is currently enabled\r
-  UINT32            Timer[TCP_TIMER_NUMBER]; // when the timer will expire\r
-  INT32             NextExpire;  // count down offset for the nearest timer\r
-  UINT32            Idle;        // How long the connection is in idle\r
-  UINT32            ProbeTime;   // the time out value for current window prober\r
+  TCP_STATES             State;      ///< TCP state, such as SYN_SENT, LISTEN\r
+  UINT8             DelayedAck; ///< Number of delayed ACKs\r
+  UINT16            HeadSum;    ///< Checksum of the fixed parts of pesudo\r
+                                ///< header: Src IP, Dst IP, 0, Protocol,\r
+                                ///< not include the TCP length.\r
+\r
+  TCP_SEQNO         Iss;        ///< Initial Sending Sequence\r
+  TCP_SEQNO         SndUna;     ///< First unacknowledged data\r
+  TCP_SEQNO         SndNxt;     ///< Next data sequence to send.\r
+  TCP_SEQNO         SndPsh;     ///< Send PUSH point\r
+  TCP_SEQNO         SndUp;      ///< Send urgent point\r
+  UINT32            SndWnd;     ///< Window advertised by the remote peer\r
+  UINT32            SndWndMax;  ///< Max send window advertised by the peer\r
+  TCP_SEQNO         SndWl1;     ///< Seq number used for last window update\r
+  TCP_SEQNO         SndWl2;     ///< Ack no of last window update\r
+  UINT16            SndMss;     ///< Max send segment size\r
+  TCP_SEQNO         RcvNxt;     ///< Next sequence no to receive\r
+  UINT32            RcvWnd;     ///< Window advertised by the local peer\r
+  TCP_SEQNO         RcvWl2;     ///< The RcvNxt (or ACK) of last window update.\r
+                                ///< It is necessary because of delayed ACK\r
+\r
+  TCP_SEQNO         RcvUp;                   ///< Urgent point;\r
+  TCP_SEQNO         Irs;                     ///< Initial Receiving Sequence\r
+  UINT16            RcvMss;                  ///< Max receive segment size\r
+  UINT16            EnabledTimer;            ///< Which timer is currently enabled\r
+  UINT32            Timer[TCP_TIMER_NUMBER]; ///< When the timer will expire\r
+  INT32             NextExpire;  ///< Count down offset for the nearest timer\r
+  UINT32            Idle;        ///< How long the connection is in idle\r
+  UINT32            ProbeTime;   ///< The time out value for current window prober\r
 \r
   //\r
   // RFC1323 defined variables, about window scale,\r
   // timestamp and PAWS\r
   //\r
-  UINT8             SndWndScale;  // Wndscale received from the peer\r
-  UINT8             RcvWndScale;  // Wndscale used to scale local buffer\r
-  UINT32            TsRecent;     // TsRecent to echo to the remote peer\r
-  UINT32            TsRecentAge;  // When this TsRecent is updated\r
-\r
-  // TCP_SEQNO  LastAckSent;\r
-  // It isn't necessary to add LastAckSent here,\r
-  // since it is the same as RcvWl2\r
+  UINT8             SndWndScale;  ///< Wndscale received from the peer\r
+  UINT8             RcvWndScale;  ///< Wndscale used to scale local buffer\r
+  UINT32            TsRecent;     ///< TsRecent to echo to the remote peer\r
+  UINT32            TsRecentAge;  ///< When this TsRecent is updated\r
 \r
   //\r
   // RFC2988 defined variables. about RTT measurement\r
   //\r
-  TCP_SEQNO         RttSeq;     // the seq of measured segment now\r
-  UINT32            RttMeasure; // currently measured RTT in heart beats\r
-  UINT32            SRtt;       // Smoothed RTT, scaled by 8\r
-  UINT32            RttVar;     // RTT variance, scaled by 8\r
-  UINT32            Rto;        // Current RTO, not scaled\r
+  TCP_SEQNO         RttSeq;     ///< The seq of measured segment now\r
+  UINT32            RttMeasure; ///< Currently measured RTT in heart beats\r
+  UINT32            SRtt;       ///< Smoothed RTT, scaled by 8\r
+  UINT32            RttVar;     ///< RTT variance, scaled by 8\r
+  UINT32            Rto;        ///< Current RTO, not scaled\r
 \r
   //\r
   // RFC2581, and 3782 variables.\r
   // Congestion control + NewReno fast recovery.\r
   //\r
-  UINT32            CWnd;         // Sender's congestion window\r
-  UINT32            Ssthresh;     // Slow start threshold.\r
-  TCP_SEQNO         Recover;      // recover point for NewReno\r
-  UINT16            DupAck;       // number of duplicate ACKs\r
-  UINT8             CongestState; // the current congestion state(RFC3782)\r
-  UINT8             LossTimes;    // number of retxmit timeouts in a row\r
-  TCP_SEQNO         LossRecover;  // recover point for retxmit\r
+  UINT32            CWnd;         ///< Sender's congestion window\r
+  UINT32            Ssthresh;     ///< Slow start threshold.\r
+  TCP_SEQNO         Recover;      ///< Recover point for NewReno\r
+  UINT16            DupAck;       ///< Number of duplicate ACKs\r
+  UINT8             CongestState; ///< The current congestion state(RFC3782)\r
+  UINT8             LossTimes;    ///< Number of retxmit timeouts in a row\r
+  TCP_SEQNO         LossRecover;  ///< Recover point for retxmit\r
 \r
   //\r
   // configuration parameters, for EFI_TCP4_PROTOCOL specification\r
   //\r
-  UINT32            KeepAliveIdle;   // idle time before sending first probe\r
-  UINT32            KeepAlivePeriod; // interval for subsequent keep alive probe\r
-  UINT8             MaxKeepAlive;    // Maxium keep alive probe times.\r
-  UINT8             KeepAliveProbes; // the number of keep alive probe.\r
-  UINT16            MaxRexmit;      // The maxium number of retxmit before abort\r
-  UINT32            FinWait2Timeout; // The FIN_WAIT_2 time out\r
-  UINT32            TimeWaitTimeout; // The TIME_WAIT time out\r
-  UINT32            ConnectTimeout;\r
+  UINT32            KeepAliveIdle;   ///< Idle time before sending first probe\r
+  UINT32            KeepAlivePeriod; ///< Interval for subsequent keep alive probe\r
+  UINT8             MaxKeepAlive;    ///< Maxium keep alive probe times.\r
+  UINT8             KeepAliveProbes; ///< The number of keep alive probe.\r
+  UINT16            MaxRexmit;       ///< The maxium number of retxmit before abort\r
+  UINT32            FinWait2Timeout; ///< The FIN_WAIT_2 time out\r
+  UINT32            TimeWaitTimeout; ///< The TIME_WAIT time out\r
+  UINT32            ConnectTimeout;  ///< The connect establishment time out\r
 \r
   //\r
   // configuration for tcp provided by user\r
@@ -265,10 +262,7 @@ struct _TCP_CB {
   UINT8             TTL;\r
   EFI_IPv4_ADDRESS  SubnetMask;\r
 \r
-  //\r
-  // pointer reference to Ip used to send pkt\r
-  //\r
-  IP_IO_IP_INFO     *IpInfo;\r
+  IP_IO_IP_INFO     *IpInfo;        ///<pointer reference to Ip used to send pkt\r
 };\r
 \r
 extern LIST_ENTRY     mTcpRunQue;\r
@@ -276,9 +270,9 @@ extern LIST_ENTRY     mTcpListenQue;
 extern TCP_SEQNO      mTcpGlobalIss;\r
 extern UINT32         mTcpTick;\r
 \r
-//\r
-// TCP_CONNECTED: both ends have synchronized their ISN.\r
-//\r
+///\r
+/// TCP_CONNECTED: both ends have synchronized their ISN.\r
+///\r
 #define TCP_CONNECTED(state)  ((state) > TCP_SYN_RCVD)\r
 \r
 #define TCP_FIN_RCVD(State) \\r
index 65c98de048fff4379efe92a91def6874dc4d3402..8ef9d2ceddf89866aa9028168af38d76b0212d8e 100644 (file)
@@ -1,23 +1,15 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2007, Intel Corporation\r
+  TCP timer related functions.\r
+    \r
+Copyright (c) 2005 - 2007, 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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Tcp4Timer.c\r
-\r
-Abstract:\r
-\r
-  TCP timer related functions.\r
-\r
-\r
 **/\r
 \r
 #include "Tcp4Main.h"\r