]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix coding style issues for Tcp4Dxe driver.
authorniry <niry@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 28 Nov 2008 08:32:24 +0000 (08:32 +0000)
committerniry <niry@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 28 Nov 2008 08:32:24 +0000 (08:32 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6774 6f19259b-4bc3-4df7-8a09-765794883524

13 files changed:
MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
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/Tcp4Input.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.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 32542094c7b29000e776e0eb597e03abe2757484..602765b25237007f2589a141848b3a44cb57f93b 100644 (file)
@@ -558,7 +558,7 @@ SockCreate (
 \r
   Parent = SockInitData->Parent;\r
 \r
-  if (Parent && (Parent->ConnCnt == Parent->BackLog)) {\r
+  if ((Parent != NULL) && (Parent->ConnCnt == Parent->BackLog)) {\r
     DEBUG (\r
       (EFI_D_ERROR,\r
       "SockCreate: Socket parent has "\r
@@ -744,7 +744,7 @@ SockDestroy (
   //\r
   // Remove it from parent connection list if needed\r
   //\r
-  if (Sock->Parent) {\r
+  if (Sock->Parent != NULL) {\r
 \r
     RemoveEntryList (&(Sock->ConnectionList));\r
     (Sock->Parent->ConnCnt)--;\r
@@ -982,7 +982,7 @@ SockConnClosed (
   IN SOCKET *Sock\r
   )\r
 {\r
-  if (Sock->CloseToken) {\r
+  if (Sock->CloseToken != NULL) {\r
     SIGNAL_TOKEN (Sock->CloseToken, EFI_SUCCESS);\r
     Sock->CloseToken = NULL;\r
   }\r
index 1c78147b1bdb8e31c1f8f068d040d8cb39bbf974..a25bd4e1b4bb20e216e5c20644ca4d33f00249b2 100644 (file)
@@ -205,9 +205,7 @@ SockDestroyChild (
   data ProtoData.\r
 \r
   @param  SockInitData         Inital data to setting the socket.\r
-  @param  ProtoData            Pointer to the protocol specific data.\r
-  @param  Len                  Length of the protocol specific data.\r
-\r
+  \r
   @return Pointer to the newly created socket. If NULL, error condition occured.\r
 \r
 **/\r
index 0e987109d0f231e2a9992a15da181689a4cf1c76..4ee8e6c39e9027cbb9fafe13da0e3dd9e31b5dd0 100644 (file)
@@ -344,6 +344,14 @@ typedef struct _SOCK_INIT_DATA {
 \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
+} NET_PROTOCOL;\r
 //\r
 // the socket structure representing a network service access point\r
 //\r
@@ -391,10 +399,7 @@ struct _SOCKET {
   //\r
   SOCK_PROTO_HANDLER    ProtoHandler; // the request handler of protocol\r
   UINT8 ProtoReserved[PROTO_RESERVED_LEN];  // Data fields reserved for protocol\r
-  union {\r
-    EFI_TCP4_PROTOCOL TcpProtocol;\r
-    EFI_UDP4_PROTOCOL UdpProtocol;\r
-  } NetProtocol;\r
+  NET_PROTOCOL          NetProtocol;\r
 \r
   //\r
   // Callbacks.\r
index b2f93b45df1175ee56fc6d53973179ce64ca3d35..9f170677f947886d526996fce3d8bf2607fc70d5 100644 (file)
@@ -101,11 +101,11 @@ Tcp4GetMode (
     return EFI_NOT_STARTED;\r
   }\r
 \r
-  if (Mode->Tcp4State) {\r
+  if (Mode->Tcp4State != NULL) {\r
     *(Mode->Tcp4State) = (EFI_TCP4_CONNECTION_STATE) Tcb->State;\r
   }\r
 \r
-  if (Mode->Tcp4ConfigData) {\r
+  if (Mode->Tcp4ConfigData != NULL) {\r
 \r
     ConfigData                      = Mode->Tcp4ConfigData;\r
     AccessPoint                     = &(ConfigData->AccessPoint);\r
@@ -220,13 +220,13 @@ Tcp4Bind (
 \r
 \r
 /**\r
-  Flush the Tcb add its associated protocols..\r
+  Flush the Tcb add its associated protocols.\r
 \r
   @param  Tcb                    Pointer to the TCP_CB to be flushed.\r
 \r
-  @retval EFI_SUCCESS            The operation is completed successfully.\r
+  None\r
 \r
-**/\r
+ **/\r
 VOID\r
 Tcp4FlushPcb (\r
   IN TCP_CB *Tcb\r
@@ -329,7 +329,6 @@ Tcp4DetachPcb (
   Configure the Tcb using CfgData.\r
 \r
   @param  Sk                     Pointer to the socket of this TCP instance.\r
-  @param  SkTcb                  Pointer to the TCP_CB of this TCP instance.\r
   @param  CfgData                Pointer to the TCP configuration data.\r
 \r
   @retval EFI_SUCCESS            The operation is completed successfully.\r
index 9d9cc69003b53e1637521020a504ced109406da4..cfdfbe68f29151ab28527b687262a8d6a68b6601 100644 (file)
@@ -123,16 +123,14 @@ Tcp4CreateTimer (
 \r
 /**\r
   Stop and destroy the heartbeat timer for TCP driver.\r
-\r
-  None.\r
-\r
-  @return None.\r
+  \r
+  None\r
+  \r
+  None\r
 \r
 **/\r
 VOID\r
-Tcp4DestroyTimer (\r
-  VOID\r
-  )\r
+Tcp4DestroyTimer ()\r
 {\r
   ASSERT (mTcp4Timer.RefCnt > 0);\r
 \r
@@ -147,32 +145,24 @@ Tcp4DestroyTimer (
   mTcp4Timer.TimerEvent = NULL;\r
 }\r
 \r
+/**\r
+  The entry point for Tcp4 driver. \r
+  Used to install Tcp4 driver on the ImageHandle.\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
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The entry point for Tcp4 driver. used to install\r
-  Tcp4 driver on the ImageHandle.\r
-\r
-Arguments:\r
-\r
-  ImageHandle - The firmware allocated handle for this\r
-                driver image.\r
-  SystemTable - Pointer to the EFI system table.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - Driver loaded.\r
-  other       - Driver not loaded.\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
   UINT32      Seed;\r
index 8ef2432f0d2be0026d1dbec96bb32dd69072c48c..2e436249f23b14b71a01977feb624f8da43892ae 100644 (file)
@@ -328,7 +328,7 @@ TcpTrimSegment (
       }\r
     }\r
 \r
-    if (Drop) {\r
+    if (Drop != 0) {\r
       NetbufTrim (Nbuf, Drop, NET_BUF_HEAD);\r
     }\r
   }\r
@@ -346,7 +346,7 @@ TcpTrimSegment (
       Drop--;\r
     }\r
 \r
-    if (Drop) {\r
+    if (Drop != 0) {\r
       NetbufTrim (Nbuf, Drop, NET_BUF_TAIL);\r
     }\r
   }\r
@@ -735,7 +735,7 @@ TcpInput (
   Len     = Nbuf->TotalSize - (Head->HeadLen << 2);\r
 \r
   if ((Head->HeadLen < 5) || (Len < 0) ||\r
-      TcpChecksum (Nbuf, NetPseudoHeadChecksum (Src, Dst, 6, 0))) {\r
+      (TcpChecksum (Nbuf, NetPseudoHeadChecksum (Src, Dst, 6, 0)) != 0)) {\r
 \r
     DEBUG ((EFI_D_INFO, "TcpInput: received an mal-formated packet\n"));\r
     goto DISCARD;\r
@@ -953,7 +953,7 @@ TcpInput (
   //\r
   // First step: Check whether SEG.SEQ is acceptable\r
   //\r
-  if (!TcpSeqAcceptable (Tcb, Seg)) {\r
+  if (TcpSeqAcceptable (Tcb, Seg) == 0) {\r
     DEBUG ((EFI_D_WARN, "TcpInput: sequence acceptance"\r
       " test failed for segment of TCB %p\n", Tcb));\r
 \r
@@ -1371,13 +1371,13 @@ StepSix:
   // Tcb is a new child of the listening Parent,\r
   // commit it.\r
   //\r
-  if (Parent) {\r
+  if (Parent != NULL) {\r
     Tcb->Parent = Parent;\r
     TcpInsertTcb (Tcb);\r
   }\r
 \r
   if ((Tcb->State != TCP_CLOSED) &&\r
-      (!TcpToSendData (Tcb, 0)) &&\r
+      (TcpToSendData (Tcb, 0) == 0) &&\r
       (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) || Nbuf->TotalSize)) {\r
 \r
     TcpToSendAck (Tcb);\r
@@ -1409,7 +1409,7 @@ DISCARD:
   DEBUG ((EFI_D_WARN, "Tcp4Input: Discard a packet\n"));\r
   NetbufFree (Nbuf);\r
 \r
-  if (Parent && Tcb) {\r
+  if ((Parent != NULL) && (Tcb != NULL)) {\r
 \r
     ASSERT (Tcb->Sk);\r
     TcpClose (Tcb);\r
index 9673b7b918288b7945268c19997856e37fbdae8e..b01704efc65e51381b48b84a1180363c58bfebd1 100644 (file)
@@ -60,14 +60,19 @@ Tcp4ChkDataBuf (
 \r
 /**\r
   Get the current operational status.\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\r
-                                   IPv4 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
@@ -84,12 +89,12 @@ Tcp4ChkDataBuf (
 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
   TCP4_MODE_DATA  TcpMode;\r
@@ -114,6 +119,22 @@ Tcp4GetModeData (
 /**\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
@@ -136,8 +157,8 @@ Tcp4GetModeData (
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Configure (\r
-  IN EFI_TCP4_PROTOCOL        * This,\r
-  IN EFI_TCP4_CONFIG_DATA     * TcpConfigData OPTIONAL\r
+  IN EFI_TCP4_PROTOCOL        *This,\r
+  IN EFI_TCP4_CONFIG_DATA     *TcpConfigData     OPTIONAL\r
   )\r
 {\r
   EFI_TCP4_OPTION  *Option;\r
@@ -199,15 +220,35 @@ Tcp4Configure (
 \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
-\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
@@ -253,12 +294,22 @@ Tcp4Routes (
 /**\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\r
-                                   initiated.\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
@@ -293,6 +344,16 @@ Tcp4Connect (
 /**\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
@@ -307,7 +368,7 @@ Tcp4Connect (
   @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         An unexpected system or network error occurred.\r
+  @retval EFI_DEVICE_ERROR         Any unexpected and not belonged to above category error.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -334,6 +395,10 @@ Tcp4Accept (
 /**\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
@@ -346,12 +411,13 @@ Tcp4Accept (
   @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. * The current instance is in\r
-                                   Tcp4StateClosed state * The current instance is\r
-                                   a passive one and it is in Tcp4StateListen\r
-                                   state. * User has called Close() to disconnect\r
-                                   this connection.\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
@@ -399,6 +465,18 @@ Tcp4Transmit (
 /**\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
@@ -412,14 +490,17 @@ Tcp4Transmit (
   @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 the\r
-                                   receive queue. * The current instance is in\r
-                                   Tcp4StateClosed state. * The current instance is\r
-                                   a passive one and it is in Tcp4StateListen\r
-                                   state. * User has called Close() to disconnect\r
-                                   this connection.\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
@@ -466,6 +547,15 @@ Tcp4Receive (
 /**\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
@@ -473,11 +563,11 @@ Tcp4Receive (
   @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
+  @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
+                                     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
@@ -509,21 +599,38 @@ Tcp4Close (
 /**\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
+\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_UNSUPPORTED          The operation is not supported in current\r
+                                   \r
+  @retval  EFI_SUCCESS             The asynchronous I/O request is aborted and Token->Event\r
+                                   is signaled.\r
+  @retval  EFI_INVALID_PARAMETER   This is NULL.\r
+  @retval  EFI_NOT_STARTED         This instance hasn¡¯t been configured.\r
+  @retval  EFI_NO_MAPPING          When using the default address, configuration\r
+                                   (DHCP, BOOTP,RARP, etc.) hasn¡¯t finished yet.\r
+  @retval  EFI_NOT_FOUND           The asynchronous I/O request isn¡¯t found in the \r
+                                   transmission or receive queue. It has either \r
+                                   completed or wasn¡¯t issued by Transmit() and Receive().\r
+  @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_PROTOCOL           *This,\r
+  IN EFI_TCP4_COMPLETION_TOKEN   *Token    OPTIONAL\r
   )\r
 {\r
   return EFI_UNSUPPORTED;\r
@@ -533,6 +640,13 @@ Tcp4Cancel (
 /**\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
index 0f5d17a93fb8784581b42904995768ba85e453dd..f1a69ab63ddb578f5953d3af56f6d08911241aa9 100644 (file)
@@ -64,12 +64,12 @@ typedef struct _TCP4_ROUTE_INFO {
 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
@@ -78,8 +78,8 @@ Tcp4GetModeData (
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Configure (\r
-  IN EFI_TCP4_PROTOCOL        * This,\r
-  IN EFI_TCP4_CONFIG_DATA     * TcpConfigData OPTIONAL\r
+  IN EFI_TCP4_PROTOCOL        *This,\r
+  IN EFI_TCP4_CONFIG_DATA     *TcpConfigData OPTIONAL\r
   );\r
 \r
 //\r
@@ -133,6 +133,7 @@ Tcp4Transmit (
 // through this TCP instance\r
 //\r
 EFI_STATUS\r
+EFIAPI\r
 Tcp4Receive (\r
   IN EFI_TCP4_PROTOCOL           *This,\r
   IN EFI_TCP4_IO_TOKEN           *Token\r
@@ -155,8 +156,8 @@ Tcp4Close (
 EFI_STATUS\r
 EFIAPI\r
 Tcp4Cancel (\r
-  IN EFI_TCP4_PROTOCOL           * This,\r
-  IN EFI_TCP4_COMPLETION_TOKEN   * Token OPTIONAL\r
+  IN EFI_TCP4_PROTOCOL           *This,\r
+  IN EFI_TCP4_COMPLETION_TOKEN   *Token OPTIONAL\r
   );\r
 \r
 //\r
index 12f5e4354e8cef2ad1d197bfb80b2f0b996d0a93..ca65f3e7568cc222ebef83114f27adff1b45bc65 100644 (file)
@@ -477,7 +477,7 @@ TcpGetIss (
 /**\r
   Get the local mss.\r
 \r
-  None\r
+  @param  Sock        Pointer to the socket to get mss\r
 \r
   @return The mss size.\r
 \r
index ad856c777a6e92e4b3ca2c1daf640475498be09d..faa4ffa587638f4db4bc36bf1eae4f3127f3806f 100644 (file)
@@ -33,7 +33,7 @@ typedef struct s_TCP_OPTION {
   UINT32  TSEcr;    // the TSEcr field in a timestamp option\r
 } TCP_OPTION;\r
 \r
-enum {\r
+typedef enum {\r
 \r
   //\r
   // supported TCP option type and their length\r
@@ -68,12 +68,12 @@ enum {
   //\r
   // Other misc definations\r
   //\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_RCVD_MSS       = 0x01,\r
   TCP_OPTION_RCVD_WS        = 0x02,\r
-  TCP_OPTION_RCVD_TS        = 0x04\r
-};\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_TYPE;\r
 \r
 UINT8\r
 TcpComputeScale (\r
index 82170e23f3a7b9cbd7bb2663607faafc2217c81e..39fbc3b73562c032a075986102dbee4c38fe7b03 100644 (file)
@@ -235,7 +235,7 @@ TcpDataToSend (
     Len = Tcb->SndMss;\r
   }\r
 \r
-  if (Force || (Len == 0 && Left == 0)) {\r
+  if ((Force != 0)|| (Len == 0 && Left == 0)) {\r
     return Len;\r
   }\r
 \r
@@ -528,7 +528,7 @@ TcpGetSegmentSndQue (
   //\r
   // copy data to the segment\r
   //\r
-  if (CopyLen) {\r
+  if (CopyLen != 0) {\r
     Data = NetbufAllocSpace (Nbuf, CopyLen, NET_BUF_TAIL);\r
     ASSERT (Data);\r
 \r
@@ -587,7 +587,7 @@ TcpGetSegmentSock (
 \r
   DataGet = 0;\r
 \r
-  if (Len) {\r
+  if (Len != 0) {\r
     //\r
     // copy data to the segment.\r
     //\r
@@ -762,7 +762,7 @@ SEND_AGAIN:
 \r
   Flag  = mTcpOutFlag[Tcb->State];\r
 \r
-  if (Flag & TCP_FLG_SYN) {\r
+  if ((Flag & TCP_FLG_SYN) != 0) {\r
 \r
     Seq = Tcb->Iss;\r
     Len = 0;\r
@@ -772,7 +772,8 @@ SEND_AGAIN:
   // only send a segment without data if SYN or\r
   // FIN is set.\r
   //\r
-  if ((Len == 0) && !(Flag & (TCP_FLG_SYN | TCP_FLG_FIN))) {\r
+  if ((Len == 0) && \r
+      ((Flag & (TCP_FLG_SYN | TCP_FLG_FIN)) == 0)) {\r
     return Sent;\r
   }\r
 \r
@@ -799,7 +800,7 @@ SEND_AGAIN:
     End++;\r
   }\r
 \r
-  if (Flag & TCP_FLG_FIN) {\r
+  if ((Flag & TCP_FLG_FIN) != 0) {\r
     //\r
     // Send FIN if all data is sent, and FIN is\r
     // in the window\r
@@ -843,7 +844,7 @@ SEND_AGAIN:
     NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);\r
     Nbuf->Tcp = NULL;\r
 \r
-    if (Flag & TCP_FLG_FIN) {\r
+    if ((Flag & TCP_FLG_FIN) != 0)  {\r
       TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_FIN_SENT);\r
     }\r
 \r
@@ -867,7 +868,7 @@ SEND_AGAIN:
   //\r
   Tcb->DelayedAck = 0;\r
 \r
-  if (Flag & TCP_FLG_FIN) {\r
+  if ((Flag & TCP_FLG_FIN) != 0) {\r
     TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_FIN_SENT);\r
   }\r
 \r
index d0e7fd4c14d228ac11e37c7193f01e0e2463e33d..ee278e3516efbfbd64c4676754d6c240d83f7053 100644 (file)
@@ -31,7 +31,7 @@ typedef struct _TCP_CB  TCP_CB;
 // tcp states, Don't change their order, it is used as\r
 // index to mTcpOutFlag and other macros\r
 //\r
-enum {\r
+typedef enum {\r
   TCP_CLOSED      = 0,\r
   TCP_LISTEN,\r
   TCP_SYN_SENT,\r
@@ -43,12 +43,12 @@ enum {
   TCP_TIME_WAIT,\r
   TCP_CLOSE_WAIT,\r
   TCP_LAST_ACK\r
-};\r
+} TCP_STATES;\r
 \r
 //\r
 // flags in the TCP header\r
 //\r
-enum {\r
+typedef enum {\r
 \r
   TCP_FLG_FIN     = 0x01,\r
   TCP_FLG_SYN     = 0x02,\r
@@ -57,9 +57,9 @@ enum {
   TCP_FLG_ACK     = 0x10,\r
   TCP_FLG_URG     = 0x20,\r
   TCP_FLG_FLAG    = 0x3F  // mask for all the flags\r
-};\r
+} TCP_HEADER_FLAG;\r
 \r
-enum {\r
+typedef enum {\r
 \r
   //\r
   // TCP error status\r
@@ -145,7 +145,7 @@ enum {
   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
-};\r
+} TCP_MISC_VALUES;\r
 \r
 typedef struct _TCP_SEG {\r
   TCP_SEQNO Seq;  // Starting sequence number\r
index 0b151795abcfb1b58ae2fd615f2b423d9f1fa218..3c02c53912d19a56b404981d5a049064a2e812b2 100644 (file)
@@ -461,7 +461,7 @@ TcpBackoffRto (
   // may be wrong, fold it. So the next time a valid\r
   // measurement is sampled, we can start fresh.\r
   //\r
-  if ((Tcb->LossTimes >= TCP_FOLD_RTT) && Tcb->SRtt) {\r
+  if ((Tcb->LossTimes >= TCP_FOLD_RTT) && (Tcb->SRtt != 0)) {\r
     Tcb->RttVar += Tcb->SRtt >> 2;\r
     Tcb->SRtt = 0;\r
   }\r
@@ -521,7 +521,7 @@ TcpTickingDpc (
 \r
     Tcb->Idle++;\r
 \r
-    if (Tcb->DelayedAck) {\r
+    if (Tcb->DelayedAck != 0) {\r
       TcpSendAck (Tcb);\r
     }\r
 \r