X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FUdp4Dxe%2FUdp4Impl.c;h=fb1951fb135774591ac3cc859b6d47ce1cf531c5;hp=4b281bb283fc6de41c2e590c8bf2e9a9e37c2681;hb=9d510e61fceee7b92955ef9a3c20343752d8ce3f;hpb=8792362f22e4fac66aeec04b13b7a6b70cb571e9 diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c index 4b281bb283..fb1951fb13 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c @@ -1,22 +1,8 @@ /** @file - -Copyright (c) 2006 - 2008, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Udp4Impl.c - -Abstract: - The implementation of the Udp4 protocol. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -25,7 +11,15 @@ Abstract: UINT16 mUdp4RandomPort; -STATIC +/** + This function checks and timeouts the I/O datagrams holding by the corresponding + service context. + + @param[in] Event The event this function registered to. + @param[in] Context The context data registered during the creation of + the Event. + +**/ VOID EFIAPI Udp4CheckTimeout ( @@ -33,7 +27,18 @@ Udp4CheckTimeout ( IN VOID *Context ); -STATIC +/** + This function finds the udp instance by the specified pair. + + @param[in] InstanceList Pointer to the head of the list linking the udp + instances. + @param[in] Address Pointer to the specified IPv4 address. + @param[in] Port The udp port number. + + @retval TRUE The specified pair is found. + @retval FALSE Otherwise. + +**/ BOOLEAN Udp4FindInstanceByPort ( IN LIST_ENTRY *InstanceList, @@ -41,41 +46,97 @@ Udp4FindInstanceByPort ( IN UINT16 Port ); -STATIC +/** + This function is the packet transmitting notify function registered to the IpIo + interface. It's called to signal the udp TxToken when IpIo layer completes the + transmitting of the udp datagram. + + @param[in] Status The completion status of the output udp datagram. + @param[in] Context Pointer to the context data. + @param[in] Sender Specify a pointer of EFI_IP4_PROTOCOL for sending. + @param[in] NotifyData Pointer to the notify data. + +**/ VOID +EFIAPI Udp4DgramSent ( - IN EFI_STATUS Status, - IN VOID *Context, - IN VOID *Sender, - IN VOID *NotifyData + IN EFI_STATUS Status, + IN VOID *Context, + IN IP_IO_IP_PROTOCOL Sender, + IN VOID *NotifyData ); -STATIC +/** + This function processes the received datagram passed up by the IpIo layer. + + @param[in] Status The status of this udp datagram. + @param[in] IcmpError The IcmpError code, only available when Status is + EFI_ICMP_ERROR. + @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA. + @param[in] Packet Pointer to the NET_BUF containing the received udp + datagram. + @param[in] Context Pointer to the context data. + +**/ VOID +EFIAPI Udp4DgramRcvd ( IN EFI_STATUS Status, - IN ICMP_ERROR IcmpError, + IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet, IN VOID *Context ); -STATIC +/** + This function cancels the token specified by Arg in the Map. This is a callback + used by Udp4InstanceCancelToken(). + + @param[in] Map Pointer to the NET_MAP. + @param[in] Item Pointer to the NET_MAP_ITEM. + @param[in] Arg Pointer to the token to be cancelled, if NULL, + the token specified by Item is cancelled. + + @retval EFI_SUCCESS The token is cancelled if Arg is NULL or the token + is not the same as that in the Item if Arg is not + NULL. + @retval EFI_ABORTED Arg is not NULL, and the token specified by Arg is + cancelled. + +**/ EFI_STATUS +EFIAPI Udp4CancelTokens ( IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL ); -STATIC +/** + This function matches the received udp datagram with the Instance. + + @param[in] Instance Pointer to the udp instance context data. + @param[in] Udp4Session Pointer to the EFI_UDP4_SESSION_DATA abstracted + from the received udp datagram. + + @retval TRUE The udp datagram matches the receiving requirments of the + udp Instance. + @retval FALSE Otherwise. + +**/ BOOLEAN Udp4MatchDgram ( IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_SESSION_DATA *Udp4Session ); -STATIC +/** + This function removes the Wrap specified by Context and release relevant resources. + + @param[in] Event The Event this notify function registered to. + @param[in] Context Pointer to the context data. + +**/ VOID EFIAPI Udp4RecycleRxDataWrap ( @@ -83,7 +144,18 @@ Udp4RecycleRxDataWrap ( IN VOID *Context ); -STATIC +/** + This function wraps the Packet and the RxData. + + @param[in] Instance Pointer to the instance context data. + @param[in] Packet Pointer to the buffer containing the received + datagram. + @param[in] RxData Pointer to the EFI_UDP4_RECEIVE_DATA of this + datagram. + + @return Pointer to the structure wrapping the RxData and the Packet. + +**/ UDP4_RXDATA_WRAP * Udp4WrapRxData ( IN UDP4_INSTANCE_DATA *Instance, @@ -91,7 +163,18 @@ Udp4WrapRxData ( IN EFI_UDP4_RECEIVE_DATA *RxData ); -STATIC +/** + This function enqueues the received datagram into the instances' receiving queues. + + @param[in] Udp4Service Pointer to the udp service context data. + @param[in] Packet Pointer to the buffer containing the received + datagram. + @param[in] RxData Pointer to the EFI_UDP4_RECEIVE_DATA of this + datagram. + + @return The times this datagram is enqueued. + +**/ UINTN Udp4EnqueueDgram ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -99,13 +182,27 @@ Udp4EnqueueDgram ( IN EFI_UDP4_RECEIVE_DATA *RxData ); -STATIC +/** + This function delivers the datagrams enqueued in the instances. + + @param[in] Udp4Service Pointer to the udp service context data. + +**/ VOID Udp4DeliverDgram ( IN UDP4_SERVICE_DATA *Udp4Service ); -STATIC +/** + This function demultiplexes the received udp datagram to the appropriate instances. + + @param[in] Udp4Service Pointer to the udp service context data. + @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA abstracted from + the received datagram. + @param[in] Packet Pointer to the buffer containing the received udp + datagram. + +**/ VOID Udp4Demultiplex ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -113,16 +210,35 @@ Udp4Demultiplex ( IN NET_BUF *Packet ); -STATIC +/** + This function handles the received Icmp Error message and demultiplexes it to the + instance. + + @param[in] Udp4Service Pointer to the udp service context data. + @param[in] IcmpError The icmp error code. + @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA abstracted + from the received Icmp Error packet. + @param[in] Packet Pointer to the Icmp Error packet. + +**/ VOID Udp4IcmpHandler ( IN UDP4_SERVICE_DATA *Udp4Service, - IN ICMP_ERROR IcmpError, + IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet ); -STATIC +/** + This function builds and sends out a icmp port unreachable message. + + @param[in] IpIo Pointer to the IP_IO instance. + @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA of the packet + causes this icmp error message. + @param[in] Udp4Header Pointer to the udp header of the datagram causes + this icmp error message. + +**/ VOID Udp4SendPortUnreach ( IN IP_IO *IpIo, @@ -134,24 +250,26 @@ Udp4SendPortUnreach ( /** Create the Udp service context data. - @param Udp4Service Pointer to the UDP4_SERVICE_DATA. - @param ImageHandle The image handle of this udp4 driver. - @param ControllerHandle The controller handle this udp4 driver binds on. + @param[in, out] Udp4Service Pointer to the UDP4_SERVICE_DATA. + @param[in] ImageHandle The image handle of this udp4 driver. + @param[in] ControllerHandle The controller handle this udp4 driver binds on. - @retval EFI_SUCCESS The udp4 service context data is created and - initialized. - @retval EFI_OUT_OF_RESOURCES Cannot allocate memory. + @retval EFI_SUCCESS The udp4 service context data is created and + initialized. + @retval EFI_OUT_OF_RESOURCES Cannot allocate memory. + @retval other Other error occurs. **/ EFI_STATUS Udp4CreateService ( - IN UDP4_SERVICE_DATA *Udp4Service, - IN EFI_HANDLE ImageHandle, - IN EFI_HANDLE ControllerHandle + IN OUT UDP4_SERVICE_DATA *Udp4Service, + IN EFI_HANDLE ImageHandle, + IN EFI_HANDLE ControllerHandle ) { - EFI_STATUS Status; - IP_IO_OPEN_DATA OpenData; + EFI_STATUS Status; + IP_IO_OPEN_DATA OpenData; + EFI_IP4_CONFIG_DATA *Ip4ConfigData; ZeroMem (Udp4Service, sizeof (UDP4_SERVICE_DATA)); @@ -166,7 +284,7 @@ Udp4CreateService ( // // Create the IpIo for this service context. // - Udp4Service->IpIo = IpIoCreate (ImageHandle, ControllerHandle); + Udp4Service->IpIo = IpIoCreate (ImageHandle, ControllerHandle, IP_VERSION_4); if (Udp4Service->IpIo == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -174,12 +292,13 @@ Udp4CreateService ( // // Set the OpenData used to open the IpIo. // - CopyMem (&OpenData.IpConfigData, &mIpIoDefaultIpConfigData, sizeof (OpenData.IpConfigData)); - OpenData.IpConfigData.AcceptBroadcast = TRUE; - OpenData.RcvdContext = (VOID *) Udp4Service; - OpenData.SndContext = NULL; - OpenData.PktRcvdNotify = Udp4DgramRcvd; - OpenData.PktSentNotify = Udp4DgramSent; + Ip4ConfigData = &OpenData.IpConfigData.Ip4CfgData; + CopyMem (Ip4ConfigData, &mIp4IoDefaultIpConfigData, sizeof (EFI_IP4_CONFIG_DATA)); + Ip4ConfigData->AcceptBroadcast = TRUE; + OpenData.RcvdContext = (VOID *) Udp4Service; + OpenData.SndContext = NULL; + OpenData.PktRcvdNotify = Udp4DgramRcvd; + OpenData.PktSentNotify = Udp4DgramSent; // // Configure and start the IpIo. @@ -232,9 +351,7 @@ ON_ERROR: /** Clean the Udp service context data. - @param Udp4Service Pointer to the UDP4_SERVICE_DATA. - - @return None. + @param[in] Udp4Service Pointer to the UDP4_SERVICE_DATA. **/ VOID @@ -263,14 +380,11 @@ Udp4CleanService ( This function checks and timeouts the I/O datagrams holding by the corresponding service context. - @param Event The event this function registered to. - @param Conext The context data registered during the creation of - the Event. - - @return None. + @param[in] Event The event this function registered to. + @param[in] Context The context data registered during the creation of + the Event. **/ -STATIC VOID EFIAPI Udp4CheckTimeout ( @@ -308,13 +422,16 @@ Udp4CheckTimeout ( // Wrap = NET_LIST_USER_STRUCT (WrapEntry, UDP4_RXDATA_WRAP, Link); - if (Wrap->TimeoutTick <= UDP4_TIMEOUT_INTERVAL / 1000) { + // + // TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns. + // + if (Wrap->TimeoutTick < (UDP4_TIMEOUT_INTERVAL / 10)) { // // Remove this RxData if it timeouts. // Udp4RecycleRxDataWrap (NULL, (VOID *) Wrap); } else { - Wrap->TimeoutTick -= UDP4_TIMEOUT_INTERVAL / 1000; + Wrap->TimeoutTick -= (UDP4_TIMEOUT_INTERVAL / 10); } } } @@ -324,16 +441,14 @@ Udp4CheckTimeout ( /** This function intializes the new created udp instance. - @param Udp4Service Pointer to the UDP4_SERVICE_DATA. - @param Instance Pointer to the un-initialized UDP4_INSTANCE_DATA. - - @return None. + @param[in] Udp4Service Pointer to the UDP4_SERVICE_DATA. + @param[in, out] Instance Pointer to the un-initialized UDP4_INSTANCE_DATA. **/ VOID Udp4InitInstance ( - IN UDP4_SERVICE_DATA *Udp4Service, - IN UDP4_INSTANCE_DATA *Instance + IN UDP4_SERVICE_DATA *Udp4Service, + IN OUT UDP4_INSTANCE_DATA *Instance ) { // @@ -363,16 +478,14 @@ Udp4InitInstance ( Instance->IcmpError = EFI_SUCCESS; Instance->Configured = FALSE; Instance->IsNoMapping = FALSE; - Instance->Destroyed = FALSE; + Instance->InDestroy = FALSE; } /** This function cleans the udp instance. - @param Instance Pointer to the UDP4_INSTANCE_DATA to clean. - - @return None. + @param[in] Instance Pointer to the UDP4_INSTANCE_DATA to clean. **/ VOID @@ -389,15 +502,15 @@ Udp4CleanInstance ( /** This function finds the udp instance by the specified pair. - @param InstanceList Pointer to the head of the list linking the udp - instances. - @param Address Pointer to the specified IPv4 address. - @param Port The udp port number. + @param[in] InstanceList Pointer to the head of the list linking the udp + instances. + @param[in] Address Pointer to the specified IPv4 address. + @param[in] Port The udp port number. - @return Is the specified pair found or not. + @retval TRUE The specified pair is found. + @retval FALSE Otherwise. **/ -STATIC BOOLEAN Udp4FindInstanceByPort ( IN LIST_ENTRY *InstanceList, @@ -442,12 +555,13 @@ Udp4FindInstanceByPort ( /** This function tries to bind the udp instance according to the configured port - allocation stragety. + allocation strategy. - @param InstanceList Pointer to the head of the list linking the udp + @param[in] InstanceList Pointer to the head of the list linking the udp instances. - @param ConfigData Pointer to the ConfigData of the instance to be - bound. + @param[in, out] ConfigData Pointer to the ConfigData of the instance to be + bound. ConfigData->StationPort will be assigned + with an available port value on success. @retval EFI_SUCCESS The bound operation is completed successfully. @retval EFI_ACCESS_DENIED The specified by the ConfigData is @@ -457,8 +571,8 @@ Udp4FindInstanceByPort ( **/ EFI_STATUS Udp4Bind ( - IN LIST_ENTRY *InstanceList, - IN EFI_UDP4_CONFIG_DATA *ConfigData + IN LIST_ENTRY *InstanceList, + IN OUT EFI_UDP4_CONFIG_DATA *ConfigData ) { EFI_IPv4_ADDRESS *StationAddress; @@ -525,11 +639,12 @@ Udp4Bind ( This function is used to check whether the NewConfigData has any un-reconfigurable parameters changed compared to the OldConfigData. - @param OldConfigData Pointer to the current ConfigData the udp instance + @param[in] OldConfigData Pointer to the current ConfigData the udp instance uses. - @param NewConfigData Pointer to the new ConfigData. + @param[in] NewConfigData Pointer to the new ConfigData. - @return The instance is reconfigurable or not according to the NewConfigData. + @retval TRUE The instance is reconfigurable. + @retval FALSE Otherwise. **/ BOOLEAN @@ -538,10 +653,11 @@ Udp4IsReconfigurable ( IN EFI_UDP4_CONFIG_DATA *NewConfigData ) { - if ((NewConfigData->AcceptAnyPort != OldConfigData->AcceptAnyPort) || - (NewConfigData->AcceptBroadcast != OldConfigData->AcceptBroadcast) || - (NewConfigData->AcceptPromiscuous != OldConfigData->AcceptPromiscuous) || - (NewConfigData->AllowDuplicatePort != OldConfigData->AllowDuplicatePort)) { + if ((NewConfigData->AcceptAnyPort != OldConfigData->AcceptAnyPort) || + (NewConfigData->AcceptBroadcast != OldConfigData->AcceptBroadcast) || + (NewConfigData->AcceptPromiscuous != OldConfigData->AcceptPromiscuous) || + (NewConfigData->AllowDuplicatePort != OldConfigData->AllowDuplicatePort) + ) { // // The receiving filter parameters cannot be changed. // @@ -549,7 +665,8 @@ Udp4IsReconfigurable ( } if ((!NewConfigData->AcceptAnyPort) && - (NewConfigData->StationPort != OldConfigData->StationPort)) { + (NewConfigData->StationPort != OldConfigData->StationPort) + ) { // // The port is not changeable. // @@ -566,8 +683,9 @@ Udp4IsReconfigurable ( } if (!NewConfigData->UseDefaultAddress && - (!EFI_IP4_EQUAL (&NewConfigData->StationAddress, &OldConfigData->StationAddress) || - !EFI_IP4_EQUAL (&NewConfigData->SubnetMask, &OldConfigData->SubnetMask))) { + (!EFI_IP4_EQUAL (&NewConfigData->StationAddress, &OldConfigData->StationAddress) || + !EFI_IP4_EQUAL (&NewConfigData->SubnetMask, &OldConfigData->SubnetMask)) + ) { // // If the instance doesn't use the default address, and the new address or // new subnet mask is different from the old values. @@ -583,7 +701,9 @@ Udp4IsReconfigurable ( return FALSE; } - if (!EFI_IP4_EQUAL (&NewConfigData->RemoteAddress, &mZeroIp4Addr) && (NewConfigData->RemotePort != OldConfigData->RemotePort)) { + if (!EFI_IP4_EQUAL (&NewConfigData->RemoteAddress, &mZeroIp4Addr) && + NewConfigData->RemotePort != OldConfigData->RemotePort + ) { // // The RemotePort differs if it's designated in the configdata. // @@ -600,19 +720,17 @@ Udp4IsReconfigurable ( /** This function builds the Ip4 configdata from the Udp4ConfigData. - @param Udp4ConfigData Pointer to the EFI_UDP4_CONFIG_DATA. - @param Ip4ConfigData Pointer to the EFI_IP4_CONFIG_DATA. - - @return None. + @param[in] Udp4ConfigData Pointer to the EFI_UDP4_CONFIG_DATA. + @param[in, out] Ip4ConfigData Pointer to the EFI_IP4_CONFIG_DATA. **/ VOID Udp4BuildIp4ConfigData ( - IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, - IN EFI_IP4_CONFIG_DATA *Ip4ConfigData + IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, + IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData ) { - CopyMem (Ip4ConfigData, &mIpIoDefaultIpConfigData, sizeof (*Ip4ConfigData)); + CopyMem (Ip4ConfigData, &mIp4IoDefaultIpConfigData, sizeof (*Ip4ConfigData)); Ip4ConfigData->DefaultProtocol = EFI_IP_PROTO_UDP; Ip4ConfigData->AcceptBroadcast = Udp4ConfigData->AcceptBroadcast; @@ -631,8 +749,8 @@ Udp4BuildIp4ConfigData ( /** This function validates the TxToken, it returns the error code according to the spec. - @param Instance Pointer to the udp instance context data. - @param TxToken Pointer to the token to be checked. + @param[in] Instance Pointer to the udp instance context data. + @param[in] TxToken Pointer to the token to be checked. @retval EFI_SUCCESS The TxToken is valid. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: This is @@ -703,7 +821,9 @@ Udp4ValidateTxToken ( if (TxData->GatewayAddress != NULL) { CopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR)); - if (!Ip4IsUnicast (NTOHL (GatewayAddress), 0)) { + if (!Instance->ConfigData.UseDefaultAddress && + (EFI_NTOHL(Instance->ConfigData.SubnetMask) != 0) && + !NetIp4IsUnicast (NTOHL (GatewayAddress), EFI_NTOHL(Instance->ConfigData.SubnetMask))) { // // The specified GatewayAddress is not a unicast IPv4 address while it's not 0. // @@ -718,7 +838,10 @@ Udp4ValidateTxToken ( CopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR)); - if ((SourceAddress != 0) && !Ip4IsUnicast (HTONL (SourceAddress), 0)) { + if ((SourceAddress != 0) && + !Instance->ConfigData.UseDefaultAddress && + (EFI_NTOHL(Instance->ConfigData.SubnetMask) != 0) && + !NetIp4IsUnicast (HTONL (SourceAddress), EFI_NTOHL(Instance->ConfigData.SubnetMask))) { // // Check whether SourceAddress is a valid IPv4 address in case it's not zero. // The configured station address is used if SourceAddress is zero. @@ -758,10 +881,10 @@ Udp4ValidateTxToken ( /** This function checks whether the specified Token duplicates with the one in the Map. - @param Map Pointer to the NET_MAP. - @param Item Pointer to the NET_MAP_ITEM contain the pointer to + @param[in] Map Pointer to the NET_MAP. + @param[in] Item Pointer to the NET_MAP_ITEM contain the pointer to the Token. - @param Context Pointer to the Token to be checked. + @param[in] Context Pointer to the Token to be checked. @retval EFI_SUCCESS The Token specified by Context differs from the one in the Item. @@ -769,6 +892,7 @@ Udp4ValidateTxToken ( **/ EFI_STATUS +EFIAPI Udp4TokenExist ( IN NET_MAP *Map, IN NET_MAP_ITEM *Item, @@ -797,11 +921,11 @@ Udp4TokenExist ( This function calculates the checksum for the Packet, utilizing the pre-calculated pseudo HeadSum to reduce some overhead. - @param Packet Pointer to the NET_BUF contains the udp datagram. - @param HeadSum Checksum of the pseudo header execpt the length + @param[in] Packet Pointer to the NET_BUF contains the udp datagram. + @param[in] HeadSum Checksum of the pseudo header execpt the length field. - @return The 16-bit checksum of this udp datagram. + @retval The 16-bit checksum of this udp datagram. **/ UINT16 @@ -824,8 +948,8 @@ Udp4Checksum ( /** This function removes the specified Token from the TokenMap. - @param TokenMap Pointer to the NET_MAP containing the tokens. - @param Token Pointer to the Token to be removed. + @param[in, out] TokenMap Pointer to the NET_MAP containing the tokens. + @param[in] Token Pointer to the Token to be removed. @retval EFI_SUCCESS The specified Token is removed from the TokenMap. @retval EFI_NOT_FOUND The specified Token is not found in the TokenMap. @@ -833,8 +957,8 @@ Udp4Checksum ( **/ EFI_STATUS Udp4RemoveToken ( - IN NET_MAP *TokenMap, - IN EFI_UDP4_COMPLETION_TOKEN *Token + IN OUT NET_MAP *TokenMap, + IN EFI_UDP4_COMPLETION_TOKEN *Token ) { NET_MAP_ITEM *Item; @@ -862,21 +986,19 @@ Udp4RemoveToken ( interface. It's called to signal the udp TxToken when IpIo layer completes the transmitting of the udp datagram. - @param Status The completion status of the output udp datagram. - @param Context Pointer to the context data. - @param Sender Pointer to the Ip sender of the udp datagram. - @param NotifyData Pointer to the notify data. - - @return None. + @param[in] Status The completion status of the output udp datagram. + @param[in] Context Pointer to the context data. + @param[in] Sender Specify a pointer of EFI_IP4_PROTOCOL for sending. + @param[in] NotifyData Pointer to the notify data. **/ -STATIC VOID +EFIAPI Udp4DgramSent ( - IN EFI_STATUS Status, - IN VOID *Context, - IN VOID *Sender, - IN VOID *NotifyData + IN EFI_STATUS Status, + IN VOID *Context, + IN IP_IO_IP_PROTOCOL Sender, + IN VOID *NotifyData ) { UDP4_INSTANCE_DATA *Instance; @@ -891,7 +1013,7 @@ Udp4DgramSent ( // Token->Status = Status; gBS->SignalEvent (Token->Event); - NetLibDispatchDpc (); + DispatchDpc (); } } @@ -899,22 +1021,20 @@ Udp4DgramSent ( /** This function processes the received datagram passed up by the IpIo layer. - @param Status The status of this udp datagram. - @param IcmpError The IcmpError code, only available when Status is + @param[in] Status The status of this udp datagram. + @param[in] IcmpError The IcmpError code, only available when Status is EFI_ICMP_ERROR. - @param NetSession Pointer to the EFI_NET_SESSION_DATA. - @param Packet Pointer to the NET_BUF containing the received udp + @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA. + @param[in] Packet Pointer to the NET_BUF containing the received udp datagram. - @param Context Pointer to the context data. - - @return None. + @param[in] Context Pointer to the context data. **/ -STATIC VOID +EFIAPI Udp4DgramRcvd ( IN EFI_STATUS Status, - IN ICMP_ERROR IcmpError, + IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet, IN VOID *Context @@ -941,16 +1061,16 @@ Udp4DgramRcvd ( // Dispatch the DPC queued by the NotifyFunction of the rx token's events // which are signaled with received data. // - NetLibDispatchDpc (); + DispatchDpc (); } /** This function removes the multicast group specified by Arg from the Map. - @param Map Pointer to the NET_MAP. - @param Item Pointer to the NET_MAP_ITEM. - @param Arg Pointer to the Arg, it's the pointer to a + @param[in, out] Map Pointer to the NET_MAP. + @param[in] Item Pointer to the NET_MAP_ITEM. + @param[in] Arg Pointer to the Arg, it's the pointer to a multicast IPv4 Address. @retval EFI_SUCCESS The multicast address is removed. @@ -959,10 +1079,11 @@ Udp4DgramRcvd ( **/ EFI_STATUS +EFIAPI Udp4LeaveGroup ( - IN NET_MAP *Map, - IN NET_MAP_ITEM *Item, - IN VOID *Arg OPTIONAL + IN OUT NET_MAP *Map, + IN NET_MAP_ITEM *Item, + IN VOID *Arg OPTIONAL ) { EFI_IPv4_ADDRESS *McastIp; @@ -994,12 +1115,13 @@ Udp4LeaveGroup ( /** - This function cancle the token specified by Arg in the Map. + This function cancels the token specified by Arg in the Map. This is a callback + used by Udp4InstanceCancelToken(). - @param Map Pointer to the NET_MAP. - @param Item Pointer to the NET_MAP_ITEM. - @param Arg Pointer to the token to be cancelled, if NULL, all - the tokens in this Map will be cancelled. + @param[in] Map Pointer to the NET_MAP. + @param[in] Item Pointer to the NET_MAP_ITEM. + @param[in] Arg Pointer to the token to be cancelled, if NULL, + the token specified by Item is cancelled. @retval EFI_SUCCESS The token is cancelled if Arg is NULL or the token is not the same as that in the Item if Arg is not @@ -1008,8 +1130,8 @@ Udp4LeaveGroup ( cancelled. **/ -STATIC EFI_STATUS +EFIAPI Udp4CancelTokens ( IN NET_MAP *Map, IN NET_MAP_ITEM *Item, @@ -1057,9 +1179,7 @@ Udp4CancelTokens ( /** This function removes all the Wrap datas in the RcvdDgramQue. - @param RcvdDgramQue Pointer to the list containing all the Wrap datas. - - @return None. + @param[in] Instance Pointer to the udp instance context data. **/ VOID @@ -1085,9 +1205,10 @@ Udp4FlushRcvdDgram ( /** + Cancel Udp4 tokens from the Udp4 instance. - @param Instance Pointer to the udp instance context data. - @param Token Pointer to the token to be canceled, if NULL, all + @param[in] Instance Pointer to the udp instance context data. + @param[in] Token Pointer to the token to be canceled, if NULL, all tokens in this instance will be cancelled. @retval EFI_SUCCESS The Token is cancelled. @@ -1103,7 +1224,7 @@ Udp4InstanceCancelToken ( EFI_STATUS Status; // - // Cancle this token from the TxTokens map. + // Cancel this token from the TxTokens map. // Status = NetMapIterate (&Instance->TxTokens, Udp4CancelTokens, Token); @@ -1139,14 +1260,15 @@ Udp4InstanceCancelToken ( /** This function matches the received udp datagram with the Instance. - @param Instance Pointer to the udp instance context data. - @param Udp4Session Pointer to the EFI_UDP4_SESSION_DATA abstracted + @param[in] Instance Pointer to the udp instance context data. + @param[in] Udp4Session Pointer to the EFI_UDP4_SESSION_DATA abstracted from the received udp datagram. - @return The udp datagram matches the receiving requirments of the Instance or not. + @retval TRUE The udp datagram matches the receiving requirments of the + udp Instance. + @retval FALSE Otherwise. **/ -STATIC BOOLEAN Udp4MatchDgram ( IN UDP4_INSTANCE_DATA *Instance, @@ -1166,7 +1288,8 @@ Udp4MatchDgram ( } if ((!ConfigData->AcceptAnyPort && (Udp4Session->DestinationPort != ConfigData->StationPort)) || - ((ConfigData->RemotePort != 0) && (Udp4Session->SourcePort != ConfigData->RemotePort))) { + ((ConfigData->RemotePort != 0) && (Udp4Session->SourcePort != ConfigData->RemotePort)) + ) { // // The local port or the remote port doesn't match. // @@ -1174,7 +1297,8 @@ Udp4MatchDgram ( } if (!EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &mZeroIp4Addr) && - !EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &Udp4Session->SourceAddress)) { + !EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &Udp4Session->SourceAddress) + ) { // // This datagram doesn't come from the instance's specified sender. // @@ -1182,9 +1306,10 @@ Udp4MatchDgram ( } if (EFI_IP4_EQUAL (&ConfigData->StationAddress, &mZeroIp4Addr) || - EFI_IP4_EQUAL (&Udp4Session->DestinationAddress, &ConfigData->StationAddress)) { + EFI_IP4_EQUAL (&Udp4Session->DestinationAddress, &ConfigData->StationAddress) + ) { // - // The instance is configured to receive datagrams destinated to any station IP or + // The instance is configured to receive datagrams destined to any station IP or // the destination address of this datagram matches the configured station IP. // return TRUE; @@ -1200,7 +1325,8 @@ Udp4MatchDgram ( } if (IP4_IS_MULTICAST (NTOHL (Destination)) && - (NULL != NetMapFindKey (&Instance->McastIps, (VOID *) (UINTN) Destination))) { + NetMapFindKey (&Instance->McastIps, (VOID *) (UINTN) Destination) != NULL + ) { // // It's a multicast packet and the multicast address is accepted by this instance. // @@ -1214,13 +1340,10 @@ Udp4MatchDgram ( /** This function removes the Wrap specified by Context and release relevant resources. - @param Event The Event this notify function registered to. - @param Context Pointer to the context data. - - @return None. + @param[in] Event The Event this notify function registered to. + @param[in] Context Pointer to the context data. **/ -STATIC VOID EFIAPI Udp4RecycleRxDataWrap ( @@ -1247,23 +1370,22 @@ Udp4RecycleRxDataWrap ( // gBS->CloseEvent (Wrap->RxData.RecycleSignal); - gBS->FreePool (Wrap); + FreePool (Wrap); } /** This function wraps the Packet and the RxData. - @param Instance Pointer to the instance context data. - @param Packet Pointer to the buffer containing the received - datagram. - @param RxData Pointer to the EFI_UDP4_RECEIVE_DATA of this - datagram. + @param[in] Instance Pointer to the instance context data. + @param[in] Packet Pointer to the buffer containing the received + datagram. + @param[in] RxData Pointer to the EFI_UDP4_RECEIVE_DATA of this + datagram. @return Pointer to the structure wrapping the RxData and the Packet. **/ -STATIC UDP4_RXDATA_WRAP * Udp4WrapRxData ( IN UDP4_INSTANCE_DATA *Instance, @@ -1298,7 +1420,7 @@ Udp4WrapRxData ( &Wrap->RxData.RecycleSignal ); if (EFI_ERROR (Status)) { - gBS->FreePool (Wrap); + FreePool (Wrap); return NULL; } @@ -1312,16 +1434,15 @@ Udp4WrapRxData ( /** This function enqueues the received datagram into the instances' receiving queues. - @param Udp4Service Pointer to the udp service context data. - @param Packet Pointer to the buffer containing the received - datagram. - @param RxData Pointer to the EFI_UDP4_RECEIVE_DATA of this - datagram. + @param[in] Udp4Service Pointer to the udp service context data. + @param[in] Packet Pointer to the buffer containing the received + datagram. + @param[in] RxData Pointer to the EFI_UDP4_RECEIVE_DATA of this + datagram. @return The times this datagram is enqueued. **/ -STATIC UINTN Udp4EnqueueDgram ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -1370,9 +1491,7 @@ Udp4EnqueueDgram ( /** This function delivers the received datagrams for the specified instance. - @param Instance Pointer to the instance context data. - - @return None. + @param[in] Instance Pointer to the instance context data. **/ VOID @@ -1387,7 +1506,7 @@ Udp4InstanceDeliverDgram ( EFI_TPL OldTpl; if (!IsListEmpty (&Instance->RcvdDgramQue) && - !NetMapIsEmpty (&Instance->RxTokens)) { + !NetMapIsEmpty (&Instance->RxTokens)) { Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP4_RXDATA_WRAP, Link); @@ -1403,7 +1522,7 @@ Udp4InstanceDeliverDgram ( NetbufFree (Wrap->Packet); Wrap->Packet = Dup; - } + } NetListRemoveHead (&Instance->RcvdDgramQue); @@ -1436,12 +1555,9 @@ Udp4InstanceDeliverDgram ( /** This function delivers the datagrams enqueued in the instances. - @param Udp4Service Pointer to the udp service context data. - - @return None. + @param[in] Udp4Service Pointer to the udp service context data. **/ -STATIC VOID Udp4DeliverDgram ( IN UDP4_SERVICE_DATA *Udp4Service @@ -1469,18 +1585,15 @@ Udp4DeliverDgram ( /** - This function demultiplexes the received udp datagram to the apropriate instances. + This function demultiplexes the received udp datagram to the appropriate instances. - @param Udp4Service Pointer to the udp service context data. - @param NetSession Pointer to the EFI_NET_SESSION_DATA abstrated from - the received datagram. - @param Packet Pointer to the buffer containing the received udp - datagram. - - @return None. + @param[in] Udp4Service Pointer to the udp service context data. + @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA abstracted from + the received datagram. + @param[in] Packet Pointer to the buffer containing the received udp + datagram. **/ -STATIC VOID Udp4Demultiplex ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -1488,24 +1601,30 @@ Udp4Demultiplex ( IN NET_BUF *Packet ) { - EFI_UDP4_HEADER *Udp4Header; + EFI_UDP_HEADER *Udp4Header; UINT16 HeadSum; EFI_UDP4_RECEIVE_DATA RxData; EFI_UDP4_SESSION_DATA *Udp4Session; UINTN Enqueued; + if (Packet->TotalSize < sizeof (EFI_UDP_HEADER)) { + NetbufFree (Packet); + return; + } + // // Get the datagram header from the packet buffer. // - Udp4Header = (EFI_UDP4_HEADER *) NetbufGetByte (Packet, 0, NULL); + Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); + ASSERT (Udp4Header != NULL); if (Udp4Header->Checksum != 0) { // // check the checksum. // HeadSum = NetPseudoHeadChecksum ( - NetSession->Source, - NetSession->Dest, + NetSession->Source.Addr[0], + NetSession->Dest.Addr[0], EFI_IP_PROTO_UDP, 0 ); @@ -1514,12 +1633,11 @@ Udp4Demultiplex ( // // Wrong checksum. // + NetbufFree (Packet); return; } } - gRT->GetTime (&RxData.TimeStamp, NULL); - Udp4Session = &RxData.UdpSession; Udp4Session->SourcePort = NTOHS (Udp4Header->SrcPort); Udp4Session->DestinationPort = NTOHS (Udp4Header->DstPort); @@ -1563,16 +1681,13 @@ Udp4Demultiplex ( /** This function builds and sends out a icmp port unreachable message. - @param IpIo Pointer to the IP_IO instance. - @param NetSession Pointer to the EFI_NET_SESSION_DATA of the packet - causes this icmp error message. - @param Udp4Header Pointer to the udp header of the datagram causes - this icmp error message. - - @return None. + @param[in] IpIo Pointer to the IP_IO instance. + @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA of the packet + causes this icmp error message. + @param[in] Udp4Header Pointer to the udp header of the datagram causes + this icmp error message. **/ -STATIC VOID Udp4SendPortUnreach ( IN IP_IO *IpIo, @@ -1588,19 +1703,19 @@ Udp4SendPortUnreach ( IP_IO_OVERRIDE Override; IP_IO_IP_INFO *IpSender; - IpSender = IpIoFindSender (&IpIo, NetSession->Dest); + IpSender = IpIoFindSender (&IpIo, NetSession->IpVersion, &NetSession->Dest); if (IpSender == NULL) { // - // No apropriate sender, since we cannot send out the ICMP message through + // No appropriate sender, since we cannot send out the ICMP message through // the default zero station address IP instance, abort. // return; } - IpHdr = NetSession->IpHdr; + IpHdr = NetSession->IpHdr.Ip4Hdr; // - // Calculate the requried length of the icmp error message. + // Calculate the required length of the icmp error message. // Len = sizeof (IP4_ICMP_ERROR_HEAD) + (EFI_IP4_HEADER_LEN (IpHdr) - sizeof (IP4_HEAD)) + ICMP_ERROR_PACKET_LENGTH; @@ -1617,6 +1732,7 @@ Udp4SendPortUnreach ( // Allocate space for the IP4_ICMP_ERROR_HEAD. // IcmpErrHdr = (IP4_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FALSE); + ASSERT (IcmpErrHdr != NULL); // // Set the required fields for the icmp port unreachable message. @@ -1645,18 +1761,18 @@ Udp4SendPortUnreach ( // // Fill the override data. // - Override.DoNotFragment = FALSE; - Override.TypeOfService = 0; - Override.TimeToLive = 255; - Override.Protocol = EFI_IP_PROTO_ICMP; + Override.Ip4OverrideData.DoNotFragment = FALSE; + Override.Ip4OverrideData.TypeOfService = 0; + Override.Ip4OverrideData.TimeToLive = 255; + Override.Ip4OverrideData.Protocol = EFI_IP_PROTO_ICMP; - CopyMem (&Override.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS)); - ZeroMem (&Override.GatewayAddress, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Override.Ip4OverrideData.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS)); + ZeroMem (&Override.Ip4OverrideData.GatewayAddress, sizeof (EFI_IPv4_ADDRESS)); // // Send out this icmp packet. // - IpIoSend (IpIo, Packet, IpSender, NULL, NULL, NetSession->Source, &Override); + IpIoSend (IpIo, Packet, IpSender, NULL, NULL, &NetSession->Source, &Override); NetbufFree (Packet); } @@ -1666,30 +1782,33 @@ Udp4SendPortUnreach ( This function handles the received Icmp Error message and demultiplexes it to the instance. - @param Udp4Service Pointer to the udp service context data. - @param IcmpError The icmp error code. - @param NetSession Pointer to the EFI_NET_SESSION_DATA abstracted + @param[in] Udp4Service Pointer to the udp service context data. + @param[in] IcmpError The icmp error code. + @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA abstracted from the received Icmp Error packet. - @param Packet Pointer to the Icmp Error packet. - - @return None. + @param[in] Packet Pointer to the Icmp Error packet. **/ -STATIC VOID Udp4IcmpHandler ( IN UDP4_SERVICE_DATA *Udp4Service, - IN ICMP_ERROR IcmpError, + IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet ) { - EFI_UDP4_HEADER *Udp4Header; + EFI_UDP_HEADER *Udp4Header; EFI_UDP4_SESSION_DATA Udp4Session; LIST_ENTRY *Entry; UDP4_INSTANCE_DATA *Instance; - Udp4Header = (EFI_UDP4_HEADER *) NetbufGetByte (Packet, 0, NULL); + if (Packet->TotalSize < sizeof (EFI_UDP_HEADER)) { + NetbufFree (Packet); + return; + } + + Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); + ASSERT (Udp4Header != NULL); CopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS)); CopyMem (&Udp4Session.DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS)); @@ -1703,15 +1822,7 @@ Udp4IcmpHandler ( // Instance = NET_LIST_USER_STRUCT (Entry, UDP4_INSTANCE_DATA, Link); - if (!Instance->Configured || - Instance->ConfigData.AcceptPromiscuous || - Instance->ConfigData.AcceptAnyPort || - EFI_IP4_EQUAL (&Instance->ConfigData.StationAddress, &mZeroIp4Addr)) { - // - // Don't try to deliver the ICMP error to this instance if it is not configured, - // or it's configured to be promiscuous or accept any port or accept all the - // datagrams. - // + if (!Instance->Configured) { continue; } @@ -1719,7 +1830,7 @@ Udp4IcmpHandler ( // // Translate the Icmp Error code according to the udp spec. // - Instance->IcmpError = IpIoGetIcmpErrStatus (IcmpError, NULL, NULL); + Instance->IcmpError = IpIoGetIcmpErrStatus (IcmpError, IP_VERSION_4, NULL, NULL); if (IcmpError > ICMP_ERR_UNREACH_PORT) { Instance->IcmpError = EFI_ICMP_ERROR; @@ -1741,9 +1852,7 @@ Udp4IcmpHandler ( /** This function reports the received ICMP error. - @param Instance Pointer to the udp instance context data. - - @return None. + @param[in] Instance Pointer to the udp instance context data. **/ VOID @@ -1786,177 +1895,14 @@ Udp4ReportIcmpError ( This function is a dummy ext-free function for the NET_BUF created for the output udp datagram. - @param Context Pointer to the context data. - - @return None. + @param[in] Context Pointer to the context data. **/ VOID +EFIAPI Udp4NetVectorExtFree ( VOID *Context ) { } - -/** - Set the Udp4 variable data. - - @param Udp4Service Udp4 service data. - - @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the - variable. - @retval other Set variable failed. - -**/ -EFI_STATUS -Udp4SetVariableData ( - IN UDP4_SERVICE_DATA *Udp4Service - ) -{ - UINT32 NumConfiguredInstance; - LIST_ENTRY *Entry; - UINTN VariableDataSize; - EFI_UDP4_VARIABLE_DATA *Udp4VariableData; - EFI_UDP4_SERVICE_POINT *Udp4ServicePoint; - UDP4_INSTANCE_DATA *Udp4Instance; - CHAR16 *NewMacString; - EFI_STATUS Status; - - NumConfiguredInstance = 0; - - // - // Go through the children list to count the configured children. - // - NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) { - Udp4Instance = NET_LIST_USER_STRUCT_S ( - Entry, - UDP4_INSTANCE_DATA, - Link, - UDP4_INSTANCE_DATA_SIGNATURE - ); - - if (Udp4Instance->Configured) { - NumConfiguredInstance++; - } - } - - // - // Calculate the size of the Udp4VariableData. As there may be no Udp4 child, - // we should add extra buffer for the service points only if the number of configured - // children is more than 1. - // - VariableDataSize = sizeof (EFI_UDP4_VARIABLE_DATA); - - if (NumConfiguredInstance > 1) { - VariableDataSize += sizeof (EFI_UDP4_SERVICE_POINT) * (NumConfiguredInstance - 1); - } - - Udp4VariableData = AllocatePool (VariableDataSize); - if (Udp4VariableData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Udp4VariableData->DriverHandle = Udp4Service->ImageHandle; - Udp4VariableData->ServiceCount = NumConfiguredInstance; - - Udp4ServicePoint = &Udp4VariableData->Services[0]; - - // - // Go through the children list to fill the configured children's address pairs. - // - NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) { - Udp4Instance = NET_LIST_USER_STRUCT_S ( - Entry, - UDP4_INSTANCE_DATA, - Link, - UDP4_INSTANCE_DATA_SIGNATURE - ); - - if (Udp4Instance->Configured) { - Udp4ServicePoint->InstanceHandle = Udp4Instance->ChildHandle; - Udp4ServicePoint->LocalAddress = Udp4Instance->ConfigData.StationAddress; - Udp4ServicePoint->LocalPort = Udp4Instance->ConfigData.StationPort; - Udp4ServicePoint->RemoteAddress = Udp4Instance->ConfigData.RemoteAddress; - Udp4ServicePoint->RemotePort = Udp4Instance->ConfigData.RemotePort; - - Udp4ServicePoint++; - } - } - - // - // Get the mac string. - // - Status = NetLibGetMacString ( - Udp4Service->ControllerHandle, - Udp4Service->ImageHandle, - &NewMacString - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - if (Udp4Service->MacString != NULL) { - // - // The variable is set already, we're going to update it. - // - if (StrCmp (Udp4Service->MacString, NewMacString) != 0) { - // - // The mac address is changed, delete the previous variable first. - // - gRT->SetVariable ( - Udp4Service->MacString, - &gEfiUdp4ServiceBindingProtocolGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS, - 0, - NULL - ); - } - - gBS->FreePool (Udp4Service->MacString); - } - - Udp4Service->MacString = NewMacString; - - Status = gRT->SetVariable ( - Udp4Service->MacString, - &gEfiUdp4ServiceBindingProtocolGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS, - VariableDataSize, - (VOID *) Udp4VariableData - ); - -ON_ERROR: - - gBS->FreePool (Udp4VariableData); - - return Status; -} - - -/** - Clear the variable and free the resource. - - @param Udp4Service Udp4 service data. - - @return None. - -**/ -VOID -Udp4ClearVariableData ( - IN UDP4_SERVICE_DATA *Udp4Service - ) -{ - ASSERT (Udp4Service->MacString != NULL); - - gRT->SetVariable ( - Udp4Service->MacString, - &gEfiUdp4ServiceBindingProtocolGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS, - 0, - NULL - ); - - gBS->FreePool (Udp4Service->MacString); - Udp4Service->MacString = NULL; -}