]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
refine the code and add more security check.
[mirror_edk2.git] / MdeModulePkg / Library / DxeUdpIoLib / DxeUdpIoLib.c
index bb85aebc282a13f76bb603ded45eea784fa5b083..afcde8199a5ccff9eb3d1938c7bd2a0d40e3475d 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
   Help functions to access UDP service, it is used by both the DHCP and MTFTP.\r
 /** @file\r
   Help functions to access UDP service, it is used by both the DHCP and MTFTP.\r
-  \r
+\r
 Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -44,7 +44,7 @@ UdpIoFreeTxToken (
   } else {\r
     ASSERT (FALSE);\r
   }\r
   } else {\r
     ASSERT (FALSE);\r
   }\r
-  \r
+\r
   FreePool (TxToken);\r
 }\r
 \r
   FreePool (TxToken);\r
 }\r
 \r
@@ -65,14 +65,14 @@ UdpIoFreeRxToken (
     gBS->CloseEvent (RxToken->Token.Udp6.Event);\r
   } else {\r
     ASSERT (FALSE);\r
     gBS->CloseEvent (RxToken->Token.Udp6.Event);\r
   } else {\r
     ASSERT (FALSE);\r
-  }  \r
+  }\r
 \r
   FreePool (RxToken);\r
 }\r
 \r
 /**\r
   The callback function when the packet is sent by UDP.\r
 \r
   FreePool (RxToken);\r
 }\r
 \r
 /**\r
   The callback function when the packet is sent by UDP.\r
-  \r
+\r
   It will remove the packet from the local list then call\r
   the packet owner's callback function set by UdpIoSendDatagram.\r
 \r
   It will remove the packet from the local list then call\r
   the packet owner's callback function set by UdpIoSendDatagram.\r
 \r
@@ -91,7 +91,7 @@ UdpIoOnDgramSentDpc (
   ASSERT (TxToken->Signature == UDP_IO_TX_SIGNATURE);\r
   ASSERT ((TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
           (TxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));\r
   ASSERT (TxToken->Signature == UDP_IO_TX_SIGNATURE);\r
   ASSERT ((TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
           (TxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));\r
-  \r
+\r
   RemoveEntryList (&TxToken->Link);\r
 \r
   if (TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {\r
   RemoveEntryList (&TxToken->Link);\r
 \r
   if (TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {\r
@@ -105,7 +105,7 @@ UdpIoOnDgramSentDpc (
 \r
 /**\r
   Request UdpIoOnDgramSentDpc as a DPC at TPL_CALLBACK.\r
 \r
 /**\r
   Request UdpIoOnDgramSentDpc as a DPC at TPL_CALLBACK.\r
-  \r
+\r
   @param[in]  Event                 The event signaled.\r
   @param[in]  Context               The UDP TX Token.\r
 \r
   @param[in]  Event                 The event signaled.\r
   @param[in]  Context               The UDP TX Token.\r
 \r
@@ -133,7 +133,7 @@ VOID
 UdpIoRecycleDgram (\r
   IN VOID                   *Context\r
   )\r
 UdpIoRecycleDgram (\r
   IN VOID                   *Context\r
   )\r
-{ \r
+{\r
   UDP_RX_TOKEN              *RxToken;\r
 \r
   RxToken = (UDP_RX_TOKEN *) Context;\r
   UDP_RX_TOKEN              *RxToken;\r
 \r
   RxToken = (UDP_RX_TOKEN *) Context;\r
@@ -151,7 +151,7 @@ UdpIoRecycleDgram (
 \r
 /**\r
   The event handle for UDP receive request.\r
 \r
 /**\r
   The event handle for UDP receive request.\r
-  \r
+\r
   It will build a NET_BUF from the recieved UDP data, then deliver it\r
   to the receiver.\r
 \r
   It will build a NET_BUF from the recieved UDP data, then deliver it\r
   to the receiver.\r
 \r
@@ -176,7 +176,7 @@ UdpIoOnDgramRcvdDpc (
 \r
   ZeroMem (&EndPoint, sizeof(UDP_END_POINT));\r
 \r
 \r
   ZeroMem (&EndPoint, sizeof(UDP_END_POINT));\r
 \r
-  ASSERT ((RxToken->Signature == UDP_IO_RX_SIGNATURE) && \r
+  ASSERT ((RxToken->Signature == UDP_IO_RX_SIGNATURE) &&\r
           (RxToken == RxToken->UdpIo->RecvRequest));\r
 \r
   ASSERT ((RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
           (RxToken == RxToken->UdpIo->RecvRequest));\r
 \r
   ASSERT ((RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
@@ -214,7 +214,7 @@ UdpIoOnDgramRcvdDpc (
   // Build a NET_BUF from the UDP receive data, then deliver it up.\r
   //\r
   if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {\r
   // Build a NET_BUF from the UDP receive data, then deliver it up.\r
   //\r
   if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {\r
-    \r
+\r
     Netbuf = NetbufFromExt (\r
                (NET_FRAGMENT *)((EFI_UDP4_RECEIVE_DATA *) RxData)->FragmentTable,\r
                ((EFI_UDP4_RECEIVE_DATA *) RxData)->FragmentCount,\r
     Netbuf = NetbufFromExt (\r
                (NET_FRAGMENT *)((EFI_UDP4_RECEIVE_DATA *) RxData)->FragmentTable,\r
                ((EFI_UDP4_RECEIVE_DATA *) RxData)->FragmentCount,\r
@@ -251,7 +251,7 @@ UdpIoOnDgramRcvdDpc (
     EndPoint.LocalAddr.Addr[0]  = NTOHL (EndPoint.LocalAddr.Addr[0]);\r
     EndPoint.RemoteAddr.Addr[0] = NTOHL (EndPoint.RemoteAddr.Addr[0]);\r
   } else {\r
     EndPoint.LocalAddr.Addr[0]  = NTOHL (EndPoint.LocalAddr.Addr[0]);\r
     EndPoint.RemoteAddr.Addr[0] = NTOHL (EndPoint.RemoteAddr.Addr[0]);\r
   } else {\r
-  \r
+\r
     Netbuf = NetbufFromExt (\r
                (NET_FRAGMENT *)((EFI_UDP6_RECEIVE_DATA *) RxData)->FragmentTable,\r
                ((EFI_UDP6_RECEIVE_DATA *) RxData)->FragmentCount,\r
     Netbuf = NetbufFromExt (\r
                (NET_FRAGMENT *)((EFI_UDP6_RECEIVE_DATA *) RxData)->FragmentTable,\r
                ((EFI_UDP6_RECEIVE_DATA *) RxData)->FragmentCount,\r
@@ -260,19 +260,19 @@ UdpIoOnDgramRcvdDpc (
                UdpIoRecycleDgram,\r
                RxToken\r
                );\r
                UdpIoRecycleDgram,\r
                RxToken\r
                );\r
-  \r
+\r
     if (Netbuf == NULL) {\r
       gBS->SignalEvent (((EFI_UDP6_RECEIVE_DATA *) RxData)->RecycleSignal);\r
       RxToken->CallBack (NULL, NULL, EFI_OUT_OF_RESOURCES, RxToken->Context);\r
     if (Netbuf == NULL) {\r
       gBS->SignalEvent (((EFI_UDP6_RECEIVE_DATA *) RxData)->RecycleSignal);\r
       RxToken->CallBack (NULL, NULL, EFI_OUT_OF_RESOURCES, RxToken->Context);\r
-  \r
+\r
       UdpIoFreeRxToken (RxToken);\r
       return;\r
     }\r
       UdpIoFreeRxToken (RxToken);\r
       return;\r
     }\r
-  \r
+\r
     Session             = &((EFI_UDP6_RECEIVE_DATA *) RxData)->UdpSession;\r
     EndPoint.LocalPort  = ((EFI_UDP6_SESSION_DATA *) Session)->DestinationPort;\r
     EndPoint.RemotePort = ((EFI_UDP6_SESSION_DATA *) Session)->SourcePort;\r
     Session             = &((EFI_UDP6_RECEIVE_DATA *) RxData)->UdpSession;\r
     EndPoint.LocalPort  = ((EFI_UDP6_SESSION_DATA *) Session)->DestinationPort;\r
     EndPoint.RemotePort = ((EFI_UDP6_SESSION_DATA *) Session)->SourcePort;\r
-  \r
+\r
     CopyMem (\r
       &EndPoint.LocalAddr,\r
       &((EFI_UDP6_SESSION_DATA *) Session)->DestinationAddress,\r
     CopyMem (\r
       &EndPoint.LocalAddr,\r
       &((EFI_UDP6_SESSION_DATA *) Session)->DestinationAddress,\r
@@ -362,7 +362,7 @@ UdpIoCreateRxToken (
                     &Token->Token.Udp4.Event\r
                     );\r
     } else {\r
                     &Token->Token.Udp4.Event\r
                     );\r
     } else {\r
-  \r
+\r
     Token->Token.Udp6.Status        = EFI_NOT_READY;\r
     Token->Token.Udp6.Packet.RxData = NULL;\r
 \r
     Token->Token.Udp6.Status        = EFI_NOT_READY;\r
     Token->Token.Udp6.Packet.RxData = NULL;\r
 \r
@@ -373,7 +373,7 @@ UdpIoCreateRxToken (
                     Token,\r
                     &Token->Token.Udp6.Event\r
                     );\r
                     Token,\r
                     &Token->Token.Udp6.Event\r
                     );\r
-  } \r
+  }\r
 \r
 \r
   if (EFI_ERROR (Status)) {\r
 \r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -394,7 +394,7 @@ UdpIoCreateRxToken (
   @param[in]  CallBack              The function to call when transmission completed.\r
   @param[in]  Context               The opaque parameter to the call back.\r
 \r
   @param[in]  CallBack              The function to call when transmission completed.\r
   @param[in]  Context               The opaque parameter to the call back.\r
 \r
-  @return The wrapped transmission request or NULL if failed to allocate resources \r
+  @return The wrapped transmission request or NULL if failed to allocate resources\r
           or for some errors.\r
 \r
 **/\r
           or for some errors.\r
 \r
 **/\r
@@ -414,7 +414,7 @@ UdpIoCreateTxToken (
   EFI_STATUS                Status;\r
   UINT32                    Count;\r
   UINTN                     Size;\r
   EFI_STATUS                Status;\r
   UINT32                    Count;\r
   UINTN                     Size;\r
-  IP4_ADDR                  Ip;  \r
+  IP4_ADDR                  Ip;\r
 \r
   ASSERT (Packet != NULL);\r
   ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
 \r
   ASSERT (Packet != NULL);\r
   ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
@@ -478,15 +478,15 @@ UdpIoCreateTxToken (
     if (EndPoint != NULL) {\r
       Ip = HTONL (EndPoint->LocalAddr.Addr[0]);\r
       CopyMem (\r
     if (EndPoint != NULL) {\r
       Ip = HTONL (EndPoint->LocalAddr.Addr[0]);\r
       CopyMem (\r
-        &TxToken->Session.Udp4.SourceAddress, \r
-        &Ip, \r
+        &TxToken->Session.Udp4.SourceAddress,\r
+        &Ip,\r
         sizeof (EFI_IPv4_ADDRESS)\r
         );\r
 \r
       Ip = HTONL (EndPoint->RemoteAddr.Addr[0]);\r
       CopyMem (\r
         sizeof (EFI_IPv4_ADDRESS)\r
         );\r
 \r
       Ip = HTONL (EndPoint->RemoteAddr.Addr[0]);\r
       CopyMem (\r
-        &TxToken->Session.Udp4.DestinationAddress, \r
-        &Ip, \r
+        &TxToken->Session.Udp4.DestinationAddress,\r
+        &Ip,\r
         sizeof (EFI_IPv4_ADDRESS)\r
         );\r
 \r
         sizeof (EFI_IPv4_ADDRESS)\r
         );\r
 \r
@@ -498,13 +498,13 @@ UdpIoCreateTxToken (
     if (Gateway != NULL && (Gateway->Addr[0] != 0)) {\r
       Ip = HTONL (Gateway->Addr[0]);\r
       CopyMem (&TxToken->Gateway, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
     if (Gateway != NULL && (Gateway->Addr[0] != 0)) {\r
       Ip = HTONL (Gateway->Addr[0]);\r
       CopyMem (&TxToken->Gateway, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
-      ((EFI_UDP4_TRANSMIT_DATA *) Data)->GatewayAddress = &TxToken->Gateway;      \r
+      ((EFI_UDP4_TRANSMIT_DATA *) Data)->GatewayAddress = &TxToken->Gateway;\r
     }\r
 \r
   } else {\r
     }\r
 \r
   } else {\r
-  \r
+\r
     ((EFI_UDP6_COMPLETION_TOKEN *) Token)->Status = EFI_NOT_READY;\r
     ((EFI_UDP6_COMPLETION_TOKEN *) Token)->Status = EFI_NOT_READY;\r
-    \r
+\r
     Status = gBS->CreateEvent (\r
                     EVT_NOTIFY_SIGNAL,\r
                     TPL_NOTIFY,\r
     Status = gBS->CreateEvent (\r
                     EVT_NOTIFY_SIGNAL,\r
                     TPL_NOTIFY,\r
@@ -517,7 +517,7 @@ UdpIoCreateTxToken (
       FreePool (TxToken);\r
       return NULL;\r
     }\r
       FreePool (TxToken);\r
       return NULL;\r
     }\r
-    \r
+\r
     Data = &(TxToken->Data.Udp6);\r
     ((EFI_UDP6_COMPLETION_TOKEN *) Token)->Packet.TxData  = Data;\r
     ((EFI_UDP6_TRANSMIT_DATA *) Data)->UdpSessionData     = NULL;\r
     Data = &(TxToken->Data.Udp6);\r
     ((EFI_UDP6_COMPLETION_TOKEN *) Token)->Packet.TxData  = Data;\r
     ((EFI_UDP6_TRANSMIT_DATA *) Data)->UdpSessionData     = NULL;\r
@@ -533,21 +533,21 @@ UdpIoCreateTxToken (
 \r
     if (EndPoint != NULL) {\r
       CopyMem (\r
 \r
     if (EndPoint != NULL) {\r
       CopyMem (\r
-        &TxToken->Session.Udp6.SourceAddress, \r
-        &EndPoint->LocalAddr.v6, \r
+        &TxToken->Session.Udp6.SourceAddress,\r
+        &EndPoint->LocalAddr.v6,\r
         sizeof(EFI_IPv6_ADDRESS)\r
         );\r
 \r
       CopyMem (\r
         sizeof(EFI_IPv6_ADDRESS)\r
         );\r
 \r
       CopyMem (\r
-        &TxToken->Session.Udp6.DestinationAddress, \r
-        &EndPoint->RemoteAddr.v6, \r
+        &TxToken->Session.Udp6.DestinationAddress,\r
+        &EndPoint->RemoteAddr.v6,\r
         sizeof(EFI_IPv6_ADDRESS)\r
         );\r
 \r
       TxToken->Session.Udp6.SourcePort                   = EndPoint->LocalPort;\r
       TxToken->Session.Udp6.DestinationPort              = EndPoint->RemotePort;\r
       ((EFI_UDP6_TRANSMIT_DATA *) Data)->UdpSessionData  = &(TxToken->Session.Udp6);\r
         sizeof(EFI_IPv6_ADDRESS)\r
         );\r
 \r
       TxToken->Session.Udp6.SourcePort                   = EndPoint->LocalPort;\r
       TxToken->Session.Udp6.DestinationPort              = EndPoint->RemotePort;\r
       ((EFI_UDP6_TRANSMIT_DATA *) Data)->UdpSessionData  = &(TxToken->Session.Udp6);\r
-    } \r
+    }\r
   }\r
 \r
   return TxToken;\r
   }\r
 \r
   return TxToken;\r
@@ -556,12 +556,11 @@ UdpIoCreateTxToken (
 /**\r
   Creates a UDP_IO to access the UDP service. It creates and configures\r
   a UDP child.\r
 /**\r
   Creates a UDP_IO to access the UDP service. It creates and configures\r
   a UDP child.\r
-  \r
-  This function:\r
-  # locates the UDP service binding prototype on the Controller parameter\r
-  # uses the UDP service binding prototype to create a UDP child (also known as a UDP instance)\r
-  # configures the UDP child by calling Configure function prototype. \r
-  Any failures in creating or configuring the UDP child return NULL for failure. \r
+\r
+  It locates the UDP service binding prototype on the Controller parameter\r
+  uses the UDP service binding prototype to create a UDP child (also known as\r
+  a UDP instance) configures the UDP child by calling Configure function prototype.\r
+  Any failures in creating or configuring the UDP child return NULL for failure.\r
 \r
   @param[in]  Controller            The controller that has the UDP service binding.\r
                                     protocol installed.\r
 \r
   @param[in]  Controller            The controller that has the UDP service binding.\r
                                     protocol installed.\r
@@ -617,7 +616,7 @@ UdpIoCreateIo (
                &gEfiUdp4ServiceBindingProtocolGuid,\r
                &UdpIo->UdpHandle\r
                );\r
                &gEfiUdp4ServiceBindingProtocolGuid,\r
                &UdpIo->UdpHandle\r
                );\r
-  \r
+\r
     if (EFI_ERROR (Status)) {\r
       goto FREE_MEM;\r
     }\r
     if (EFI_ERROR (Status)) {\r
       goto FREE_MEM;\r
     }\r
@@ -638,32 +637,32 @@ UdpIoCreateIo (
     if (EFI_ERROR (Configure (UdpIo, Context))) {\r
       goto CLOSE_PROTOCOL;\r
     }\r
     if (EFI_ERROR (Configure (UdpIo, Context))) {\r
       goto CLOSE_PROTOCOL;\r
     }\r
-  \r
+\r
     Status = UdpIo->Protocol.Udp4->GetModeData (\r
     Status = UdpIo->Protocol.Udp4->GetModeData (\r
-                                     UdpIo->Protocol.Udp4, \r
-                                     NULL, \r
-                                     NULL, \r
-                                     NULL, \r
+                                     UdpIo->Protocol.Udp4,\r
+                                     NULL,\r
+                                     NULL,\r
+                                     NULL,\r
                                      &UdpIo->SnpMode\r
                                      );\r
                                      &UdpIo->SnpMode\r
                                      );\r
-  \r
+\r
     if (EFI_ERROR (Status)) {\r
       goto CLOSE_PROTOCOL;\r
     }\r
 \r
   } else {\r
     if (EFI_ERROR (Status)) {\r
       goto CLOSE_PROTOCOL;\r
     }\r
 \r
   } else {\r
-    \r
+\r
     Status = NetLibCreateServiceChild (\r
                Controller,\r
                ImageHandle,\r
                &gEfiUdp6ServiceBindingProtocolGuid,\r
                &UdpIo->UdpHandle\r
                );\r
     Status = NetLibCreateServiceChild (\r
                Controller,\r
                ImageHandle,\r
                &gEfiUdp6ServiceBindingProtocolGuid,\r
                &UdpIo->UdpHandle\r
                );\r
-  \r
+\r
     if (EFI_ERROR (Status)) {\r
       goto FREE_MEM;\r
     }\r
     if (EFI_ERROR (Status)) {\r
       goto FREE_MEM;\r
     }\r
-  \r
+\r
     Status = gBS->OpenProtocol (\r
                     UdpIo->UdpHandle,\r
                     &gEfiUdp6ProtocolGuid,\r
     Status = gBS->OpenProtocol (\r
                     UdpIo->UdpHandle,\r
                     &gEfiUdp6ProtocolGuid,\r
@@ -672,23 +671,23 @@ UdpIoCreateIo (
                     Controller,\r
                     EFI_OPEN_PROTOCOL_BY_DRIVER\r
                     );\r
                     Controller,\r
                     EFI_OPEN_PROTOCOL_BY_DRIVER\r
                     );\r
-  \r
+\r
     if (EFI_ERROR (Status)) {\r
       goto FREE_CHILD;\r
     }\r
     if (EFI_ERROR (Status)) {\r
       goto FREE_CHILD;\r
     }\r
-  \r
+\r
     if (EFI_ERROR (Configure (UdpIo, Context))) {\r
       goto CLOSE_PROTOCOL;\r
     }\r
     if (EFI_ERROR (Configure (UdpIo, Context))) {\r
       goto CLOSE_PROTOCOL;\r
     }\r
-  \r
+\r
     Status = UdpIo->Protocol.Udp6->GetModeData (\r
     Status = UdpIo->Protocol.Udp6->GetModeData (\r
-                                     UdpIo->Protocol.Udp6, \r
-                                     NULL, \r
-                                     NULL, \r
-                                     NULL, \r
+                                     UdpIo->Protocol.Udp6,\r
+                                     NULL,\r
+                                     NULL,\r
+                                     NULL,\r
                                      &UdpIo->SnpMode\r
                                      );\r
                                      &UdpIo->SnpMode\r
                                      );\r
-  \r
+\r
     if (EFI_ERROR (Status)) {\r
       goto CLOSE_PROTOCOL;\r
     }\r
     if (EFI_ERROR (Status)) {\r
       goto CLOSE_PROTOCOL;\r
     }\r
@@ -763,12 +762,12 @@ UdpIoCancelDgrams (
         UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &TxToken->Token.Udp6);\r
       }\r
     }\r
         UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &TxToken->Token.Udp6);\r
       }\r
     }\r
-  }  \r
+  }\r
 }\r
 \r
 /**\r
   Free the UDP_IO and all its related resources.\r
 }\r
 \r
 /**\r
   Free the UDP_IO and all its related resources.\r
-  \r
+\r
   The function will cancel all sent datagram and receive request.\r
 \r
   @param[in]  UdpIo             The UDP_IO to free.\r
   The function will cancel all sent datagram and receive request.\r
 \r
   @param[in]  UdpIo             The UDP_IO to free.\r
@@ -825,7 +824,7 @@ UdpIoFreeIo (
     if ((RxToken = UdpIo->RecvRequest) != NULL) {\r
       UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);\r
     }\r
     if ((RxToken = UdpIo->RecvRequest) != NULL) {\r
       UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);\r
     }\r
-    \r
+\r
     //\r
     // Close then destory the Udp6 child\r
     //\r
     //\r
     // Close then destory the Udp6 child\r
     //\r
@@ -835,7 +834,7 @@ UdpIoFreeIo (
            UdpIo->Image,\r
            UdpIo->Controller\r
            );\r
            UdpIo->Image,\r
            UdpIo->Controller\r
            );\r
-  \r
+\r
     NetLibDestroyServiceChild (\r
       UdpIo->Controller,\r
       UdpIo->Image,\r
     NetLibDestroyServiceChild (\r
       UdpIo->Controller,\r
       UdpIo->Image,\r
@@ -856,7 +855,7 @@ UdpIoFreeIo (
 /**\r
   Clean up the UDP_IO without freeing it. The function is called when\r
   user wants to re-use the UDP_IO later.\r
 /**\r
   Clean up the UDP_IO without freeing it. The function is called when\r
   user wants to re-use the UDP_IO later.\r
-  \r
+\r
   It will release all the transmitted datagrams and receive request. It will\r
   also configure NULL for the UDP instance.\r
 \r
   It will release all the transmitted datagrams and receive request. It will\r
   also configure NULL for the UDP instance.\r
 \r
@@ -897,7 +896,7 @@ UdpIoCleanIo (
 \r
 /**\r
   Send a packet through the UDP_IO.\r
 \r
 /**\r
   Send a packet through the UDP_IO.\r
-  \r
+\r
   The packet will be wrapped in UDP_TX_TOKEN. Function Callback will be called\r
   when the packet is sent. The optional parameter EndPoint overrides the default\r
   address pair if specified.\r
   The packet will be wrapped in UDP_TX_TOKEN. Function Callback will be called\r
   when the packet is sent. The optional parameter EndPoint overrides the default\r
   address pair if specified.\r
@@ -906,7 +905,7 @@ UdpIoCleanIo (
   @param[in]  Packet                The packet to send.\r
   @param[in]  EndPoint              The local and remote access point. Override the\r
                                     default address pair set during configuration.\r
   @param[in]  Packet                The packet to send.\r
   @param[in]  EndPoint              The local and remote access point. Override the\r
                                     default address pair set during configuration.\r
-  @param[in]  Gateway               The gateway to use.  \r
+  @param[in]  Gateway               The gateway to use.\r
   @param[in]  CallBack              The function being called when packet is\r
                                     transmitted or failed.\r
   @param[in]  Context               The opaque parameter passed to CallBack.\r
   @param[in]  CallBack              The function being called when packet is\r
                                     transmitted or failed.\r
   @param[in]  Context               The opaque parameter passed to CallBack.\r
@@ -1006,7 +1005,7 @@ UdpIoCancelSentDatagram (
 \r
 /**\r
   Issue a receive request to the UDP_IO.\r
 \r
 /**\r
   Issue a receive request to the UDP_IO.\r
-  \r
+\r
   This function is called when upper-layer needs packet from UDP for processing.\r
   Only one receive request is acceptable at a time so a common usage model is\r
   to invoke this function inside its Callback function when the former packet\r
   This function is called when upper-layer needs packet from UDP for processing.\r
   Only one receive request is acceptable at a time so a common usage model is\r
   to invoke this function inside its Callback function when the former packet\r