]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
Fixed GCC 4.4 build issues due to EFIAPI not being used when required.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Impl.c
index 0f14021e2397407b9ae63f4103f1dd5ac6311f69..de9ee2cacac251ff57e2e917d93677666bcb23bf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of the Udp4 protocol.\r
   \r
-Copyright (c) 2006 - 2009, Intel Corporation.<BR>                                                         \r
+Copyright (c) 2006 - 2010, 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
@@ -64,6 +64,7 @@ Udp4FindInstanceByPort (
 \r
 **/\r
 VOID\r
+EFIAPI\r
 Udp4DgramSent (\r
   IN EFI_STATUS  Status,\r
   IN VOID        *Context,\r
@@ -84,9 +85,10 @@ Udp4DgramSent (
 \r
 **/\r
 VOID\r
+EFIAPI\r
 Udp4DgramRcvd (\r
   IN EFI_STATUS            Status,\r
-  IN ICMP_ERROR            IcmpError,\r
+  IN UINT8                 IcmpError,\r
   IN EFI_NET_SESSION_DATA  *NetSession,\r
   IN NET_BUF               *Packet,\r
   IN VOID                  *Context\r
@@ -109,6 +111,7 @@ Udp4DgramRcvd (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Udp4CancelTokens (\r
   IN NET_MAP       *Map,\r
   IN NET_MAP_ITEM  *Item,\r
@@ -227,7 +230,7 @@ Udp4Demultiplex (
 VOID\r
 Udp4IcmpHandler (\r
   IN UDP4_SERVICE_DATA     *Udp4Service,\r
-  IN ICMP_ERROR            IcmpError,\r
+  IN UINT8                 IcmpError,\r
   IN EFI_NET_SESSION_DATA  *NetSession,\r
   IN NET_BUF               *Packet\r
   );\r
@@ -253,14 +256,14 @@ Udp4SendPortUnreach (
 /**\r
   Create the Udp service context data.\r
 \r
-  @param  Udp4Service            Pointer to the UDP4_SERVICE_DATA.\r
-  @param  ImageHandle            The image handle of this udp4 driver.\r
-  @param  ControllerHandle       The controller handle this udp4 driver binds on.\r
+  @param[in, out] Udp4Service      Pointer to the UDP4_SERVICE_DATA.\r
+  @param[in]      ImageHandle      The image handle of this udp4 driver.\r
+  @param[in]      ControllerHandle The controller handle this udp4 driver binds on.\r
 \r
-  @retval EFI_SUCCESS            The udp4 service context data is created and\r
-                                 initialized.\r
-  @retval EFI_OUT_OF_RESOURCES   Cannot allocate memory.\r
-  @retval other                  Other error occurs.\r
+  @retval EFI_SUCCESS              The udp4 service context data is created and\r
+                                   initialized.\r
+  @retval EFI_OUT_OF_RESOURCES     Cannot allocate memory.\r
+  @retval other                    Other error occurs.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -270,8 +273,9 @@ Udp4CreateService (
   IN     EFI_HANDLE         ControllerHandle\r
   )\r
 {\r
-  EFI_STATUS       Status;\r
-  IP_IO_OPEN_DATA  OpenData;\r
+  EFI_STATUS          Status;\r
+  IP_IO_OPEN_DATA     OpenData;\r
+  EFI_IP4_CONFIG_DATA *Ip4ConfigData;\r
 \r
   ZeroMem (Udp4Service, sizeof (UDP4_SERVICE_DATA));\r
 \r
@@ -286,7 +290,7 @@ Udp4CreateService (
   //\r
   // Create the IpIo for this service context.\r
   //\r
-  Udp4Service->IpIo = IpIoCreate (ImageHandle, ControllerHandle);\r
+  Udp4Service->IpIo = IpIoCreate (ImageHandle, ControllerHandle, IP_VERSION_4);\r
   if (Udp4Service->IpIo == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -294,12 +298,13 @@ Udp4CreateService (
   //\r
   // Set the OpenData used to open the IpIo.\r
   //\r
-  CopyMem (&OpenData.IpConfigData, &mIpIoDefaultIpConfigData, sizeof (OpenData.IpConfigData));\r
-  OpenData.IpConfigData.AcceptBroadcast = TRUE;\r
-  OpenData.RcvdContext                  = (VOID *) Udp4Service;\r
-  OpenData.SndContext                   = NULL;\r
-  OpenData.PktRcvdNotify                = Udp4DgramRcvd;\r
-  OpenData.PktSentNotify                = Udp4DgramSent;\r
+  Ip4ConfigData = &OpenData.IpConfigData.Ip4CfgData;\r
+  CopyMem (Ip4ConfigData, &mIp4IoDefaultIpConfigData, sizeof (EFI_IP4_CONFIG_DATA));\r
+  Ip4ConfigData->AcceptBroadcast = TRUE;\r
+  OpenData.RcvdContext           = (VOID *) Udp4Service;\r
+  OpenData.SndContext            = NULL;\r
+  OpenData.PktRcvdNotify         = Udp4DgramRcvd;\r
+  OpenData.PktSentNotify         = Udp4DgramSent;\r
 \r
   //\r
   // Configure and start the IpIo.\r
@@ -424,7 +429,7 @@ Udp4CheckTimeout (
       Wrap = NET_LIST_USER_STRUCT (WrapEntry, UDP4_RXDATA_WRAP, Link);\r
 \r
       //\r
-      // TimeoutTick unit is ms, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.\r
+      // TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.\r
       //\r
       if (Wrap->TimeoutTick <= (UDP4_TIMEOUT_INTERVAL / 10)) {\r
         //\r
@@ -442,8 +447,8 @@ Udp4CheckTimeout (
 /**\r
   This function intializes the new created udp instance.\r
 \r
-  @param  Udp4Service            Pointer to the UDP4_SERVICE_DATA.\r
-  @param  Instance               Pointer to the un-initialized UDP4_INSTANCE_DATA.\r
+  @param[in]      Udp4Service       Pointer to the UDP4_SERVICE_DATA.\r
+  @param[in, out] Instance          Pointer to the un-initialized UDP4_INSTANCE_DATA.\r
 \r
 **/\r
 VOID\r
@@ -558,9 +563,9 @@ Udp4FindInstanceByPort (
   This function tries to bind the udp instance according to the configured port\r
   allocation strategy.\r
 \r
-  @param  InstanceList           Pointer to the head of the list linking the udp\r
+  @param[in]      InstanceList   Pointer to the head of the list linking the udp\r
                                  instances.\r
-  @param  ConfigData             Pointer to the ConfigData of the instance to be\r
+  @param[in, out] ConfigData     Pointer to the ConfigData of the instance to be\r
                                  bound. ConfigData->StationPort will be assigned\r
                                  with an available port value on success.\r
 \r
@@ -731,7 +736,7 @@ Udp4BuildIp4ConfigData (
   IN OUT EFI_IP4_CONFIG_DATA   *Ip4ConfigData\r
   )\r
 {\r
-  CopyMem (Ip4ConfigData, &mIpIoDefaultIpConfigData, sizeof (*Ip4ConfigData));\r
+  CopyMem (Ip4ConfigData, &mIp4IoDefaultIpConfigData, sizeof (*Ip4ConfigData));\r
 \r
   Ip4ConfigData->DefaultProtocol   = EFI_IP_PROTO_UDP;\r
   Ip4ConfigData->AcceptBroadcast   = Udp4ConfigData->AcceptBroadcast;\r
@@ -822,7 +827,7 @@ Udp4ValidateTxToken (
   if (TxData->GatewayAddress != NULL) {\r
     CopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR));\r
 \r
-    if (!Ip4IsUnicast (NTOHL (GatewayAddress), 0)) {\r
+    if (!NetIp4IsUnicast (NTOHL (GatewayAddress), 0)) {\r
       //\r
       // The specified GatewayAddress is not a unicast IPv4 address while it's not 0.\r
       //\r
@@ -837,7 +842,7 @@ Udp4ValidateTxToken (
 \r
     CopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR));\r
 \r
-    if ((SourceAddress != 0) && !Ip4IsUnicast (HTONL (SourceAddress), 0)) {\r
+    if ((SourceAddress != 0) && !NetIp4IsUnicast (HTONL (SourceAddress), 0)) {\r
       //\r
       // Check whether SourceAddress is a valid IPv4 address in case it's not zero.\r
       // The configured station address is used if SourceAddress is zero.\r
@@ -888,6 +893,7 @@ Udp4ValidateTxToken (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Udp4TokenExist (\r
   IN NET_MAP       *Map,\r
   IN NET_MAP_ITEM  *Item,\r
@@ -943,8 +949,8 @@ Udp4Checksum (
 /**\r
   This function removes the specified Token from the TokenMap.\r
 \r
-  @param  TokenMap           Pointer to the NET_MAP containing the tokens.\r
-  @param  Token              Pointer to the Token to be removed.\r
+  @param[in, out] TokenMap       Pointer to the NET_MAP containing the tokens.\r
+  @param[in]      Token          Pointer to the Token to be removed.\r
 \r
   @retval EFI_SUCCESS            The specified Token is removed from the TokenMap.\r
   @retval EFI_NOT_FOUND          The specified Token is not found in the TokenMap.\r
@@ -988,6 +994,7 @@ Udp4RemoveToken (
 \r
 **/\r
 VOID\r
+EFIAPI\r
 Udp4DgramSent (\r
   IN EFI_STATUS  Status,\r
   IN VOID        *Context,\r
@@ -1007,7 +1014,7 @@ Udp4DgramSent (
     //\r
     Token->Status = Status;\r
     gBS->SignalEvent (Token->Event);\r
-    NetLibDispatchDpc ();\r
+    DispatchDpc ();\r
   }\r
 }\r
 \r
@@ -1025,9 +1032,10 @@ Udp4DgramSent (
 \r
 **/\r
 VOID\r
+EFIAPI\r
 Udp4DgramRcvd (\r
   IN EFI_STATUS            Status,\r
-  IN ICMP_ERROR            IcmpError,\r
+  IN UINT8                 IcmpError,\r
   IN EFI_NET_SESSION_DATA  *NetSession,\r
   IN NET_BUF               *Packet,\r
   IN VOID                  *Context\r
@@ -1054,16 +1062,16 @@ Udp4DgramRcvd (
   // Dispatch the DPC queued by the NotifyFunction of the rx token's events\r
   // which are signaled with received data.\r
   //\r
-  NetLibDispatchDpc ();\r
+  DispatchDpc ();\r
 }\r
 \r
 \r
 /**\r
   This function removes the multicast group specified by Arg from the Map.\r
 \r
-  @param  Map                    Pointer to the NET_MAP.\r
-  @param  Item                   Pointer to the NET_MAP_ITEM.\r
-  @param  Arg                    Pointer to the Arg, it's the pointer to a\r
+  @param[in, out] Map            Pointer to the NET_MAP.\r
+  @param[in]      Item           Pointer to the NET_MAP_ITEM.\r
+  @param[in]      Arg            Pointer to the Arg, it's the pointer to a\r
                                  multicast IPv4 Address.\r
 \r
   @retval EFI_SUCCESS            The multicast address is removed.\r
@@ -1072,6 +1080,7 @@ Udp4DgramRcvd (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Udp4LeaveGroup (\r
   IN OUT NET_MAP       *Map,\r
   IN     NET_MAP_ITEM  *Item,\r
@@ -1123,6 +1132,7 @@ Udp4LeaveGroup (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Udp4CancelTokens (\r
   IN NET_MAP       *Map,\r
   IN NET_MAP_ITEM  *Item,\r
@@ -1361,7 +1371,7 @@ Udp4RecycleRxDataWrap (
   //\r
   gBS->CloseEvent (Wrap->RxData.RecycleSignal);\r
 \r
-  gBS->FreePool (Wrap);\r
+  FreePool (Wrap);\r
 }\r
 \r
 \r
@@ -1411,7 +1421,7 @@ Udp4WrapRxData (
                   &Wrap->RxData.RecycleSignal\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (Wrap);\r
+    FreePool (Wrap);\r
     return NULL;\r
   }\r
 \r
@@ -1592,7 +1602,7 @@ Udp4Demultiplex (
   IN NET_BUF               *Packet\r
   )\r
 {\r
-  EFI_UDP4_HEADER        *Udp4Header;\r
+  EFI_UDP_HEADER        *Udp4Header;\r
   UINT16                 HeadSum;\r
   EFI_UDP4_RECEIVE_DATA  RxData;\r
   EFI_UDP4_SESSION_DATA  *Udp4Session;\r
@@ -1601,15 +1611,15 @@ Udp4Demultiplex (
   //\r
   // Get the datagram header from the packet buffer.\r
   //\r
-  Udp4Header = (EFI_UDP4_HEADER *) NetbufGetByte (Packet, 0, NULL);\r
+  Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);\r
 \r
   if (Udp4Header->Checksum != 0) {\r
     //\r
     // check the checksum.\r
     //\r
     HeadSum = NetPseudoHeadChecksum (\r
-                NetSession->Source,\r
-                NetSession->Dest,\r
+                NetSession->Source.Addr[0],\r
+                NetSession->Dest.Addr[0],\r
                 EFI_IP_PROTO_UDP,\r
                 0\r
                 );\r
@@ -1689,7 +1699,7 @@ Udp4SendPortUnreach (
   IP_IO_OVERRIDE       Override;\r
   IP_IO_IP_INFO        *IpSender;\r
 \r
-  IpSender = IpIoFindSender (&IpIo, NetSession->Dest);\r
+  IpSender = IpIoFindSender (&IpIo, NetSession->IpVersion, &NetSession->Dest);\r
   if (IpSender == NULL) {\r
     //\r
     // No apropriate sender, since we cannot send out the ICMP message through\r
@@ -1698,7 +1708,7 @@ Udp4SendPortUnreach (
     return;\r
   }\r
 \r
-  IpHdr = NetSession->IpHdr;\r
+  IpHdr = NetSession->IpHdr.Ip4Hdr;\r
 \r
   //\r
   // Calculate the requried length of the icmp error message.\r
@@ -1747,18 +1757,18 @@ Udp4SendPortUnreach (
   //\r
   // Fill the override data.\r
   //\r
-  Override.DoNotFragment = FALSE;\r
-  Override.TypeOfService = 0;\r
-  Override.TimeToLive    = 255;\r
-  Override.Protocol      = EFI_IP_PROTO_ICMP;\r
+  Override.Ip4OverrideData.DoNotFragment = FALSE;\r
+  Override.Ip4OverrideData.TypeOfService = 0;\r
+  Override.Ip4OverrideData.TimeToLive    = 255;\r
+  Override.Ip4OverrideData.Protocol      = EFI_IP_PROTO_ICMP;\r
 \r
-  CopyMem (&Override.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
-  ZeroMem (&Override.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&Override.Ip4OverrideData.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
+  ZeroMem (&Override.Ip4OverrideData.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   //\r
   // Send out this icmp packet.\r
   //\r
-  IpIoSend (IpIo, Packet, IpSender, NULL, NULL, NetSession->Source, &Override);\r
+  IpIoSend (IpIo, Packet, IpSender, NULL, NULL, &NetSession->Source, &Override);\r
 \r
   NetbufFree (Packet);\r
 }\r
@@ -1778,17 +1788,17 @@ Udp4SendPortUnreach (
 VOID\r
 Udp4IcmpHandler (\r
   IN UDP4_SERVICE_DATA     *Udp4Service,\r
-  IN ICMP_ERROR            IcmpError,\r
+  IN UINT8                 IcmpError,\r
   IN EFI_NET_SESSION_DATA  *NetSession,\r
   IN NET_BUF               *Packet\r
   )\r
 {\r
-  EFI_UDP4_HEADER        *Udp4Header;\r
+  EFI_UDP_HEADER        *Udp4Header;\r
   EFI_UDP4_SESSION_DATA  Udp4Session;\r
   LIST_ENTRY             *Entry;\r
   UDP4_INSTANCE_DATA     *Instance;\r
 \r
-  Udp4Header = (EFI_UDP4_HEADER *) NetbufGetByte (Packet, 0, NULL);\r
+  Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);\r
 \r
   CopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));\r
   CopyMem (&Udp4Session.DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
@@ -1802,16 +1812,7 @@ Udp4IcmpHandler (
     //\r
     Instance = NET_LIST_USER_STRUCT (Entry, UDP4_INSTANCE_DATA, Link);\r
 \r
-    if (!Instance->Configured ||\r
-        Instance->ConfigData.AcceptPromiscuous ||\r
-        Instance->ConfigData.AcceptAnyPort ||\r
-        EFI_IP4_EQUAL (&Instance->ConfigData.StationAddress, &mZeroIp4Addr)\r
-        ) {\r
-      //\r
-      // Don't try to deliver the ICMP error to this instance if it is not configured,\r
-      // or it's configured to be promiscuous or accept any port or accept all the\r
-      // datagrams.\r
-      //\r
+    if (!Instance->Configured) {\r
       continue;\r
     }\r
 \r
@@ -1819,7 +1820,7 @@ Udp4IcmpHandler (
       //\r
       // Translate the Icmp Error code according to the udp spec.\r
       //\r
-      Instance->IcmpError = IpIoGetIcmpErrStatus (IcmpError, NULL, NULL);\r
+      Instance->IcmpError = IpIoGetIcmpErrStatus (IcmpError, IP_VERSION_4, NULL, NULL);\r
 \r
       if (IcmpError > ICMP_ERR_UNREACH_PORT) {\r
         Instance->IcmpError = EFI_ICMP_ERROR;\r
@@ -1888,6 +1889,7 @@ Udp4ReportIcmpError (
 \r
 **/\r
 VOID\r
+EFIAPI\r
 Udp4NetVectorExtFree (\r
   VOID  *Context\r
   )\r
@@ -1898,7 +1900,7 @@ Udp4NetVectorExtFree (
 /**\r
   Set the Udp4 variable data.\r
 \r
-  @param  Udp4Service            Udp4 service data.\r
+  @param[in] Udp4Service         Udp4 service data.\r
 \r
   @retval EFI_OUT_OF_RESOURCES   There are not enough resources to set the\r
                                  variable.\r
@@ -2010,7 +2012,7 @@ Udp4SetVariableData (
              );\r
     }\r
 \r
-    gBS->FreePool (Udp4Service->MacString);\r
+    FreePool (Udp4Service->MacString);\r
   }\r
 \r
   Udp4Service->MacString = NewMacString;\r
@@ -2025,7 +2027,7 @@ Udp4SetVariableData (
 \r
 ON_ERROR:\r
 \r
-  gBS->FreePool (Udp4VariableData);\r
+  FreePool (Udp4VariableData);\r
 \r
   return Status;\r
 }\r
@@ -2052,6 +2054,6 @@ Udp4ClearVariableData (
          NULL\r
          );\r
 \r
-  gBS->FreePool (Udp4Service->MacString);\r
+  FreePool (Udp4Service->MacString);\r
   Udp4Service->MacString = NULL;\r
 }\r