X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FUdp4Dxe%2FUdp4Impl.c;h=ab50830b680281d7281502ad4caa2b0f899ad743;hb=4cda7726e5fd30aaf3e05c80207ae1b264bfa123;hp=dd7522e91f85a2dd53ae3dd42cd2396b6b97dc9c;hpb=8a67d61da4d5a8f08a656cbeea2d902d0ad9042a;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c index dd7522e91f..ab50830b68 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2006 - 2007, Intel Corporation +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 @@ -25,7 +25,6 @@ Abstract: UINT16 mUdp4RandomPort; -STATIC VOID EFIAPI Udp4CheckTimeout ( @@ -33,15 +32,13 @@ Udp4CheckTimeout ( IN VOID *Context ); -STATIC BOOLEAN Udp4FindInstanceByPort ( - IN NET_LIST_ENTRY *InstanceList, + IN LIST_ENTRY *InstanceList, IN EFI_IPv4_ADDRESS *Address, IN UINT16 Port ); -STATIC VOID Udp4DgramSent ( IN EFI_STATUS Status, @@ -50,7 +47,6 @@ Udp4DgramSent ( IN VOID *NotifyData ); -STATIC VOID Udp4DgramRcvd ( IN EFI_STATUS Status, @@ -60,7 +56,6 @@ Udp4DgramRcvd ( IN VOID *Context ); -STATIC EFI_STATUS Udp4CancelTokens ( IN NET_MAP *Map, @@ -68,14 +63,12 @@ Udp4CancelTokens ( IN VOID *Arg OPTIONAL ); -STATIC BOOLEAN Udp4MatchDgram ( IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_SESSION_DATA *Udp4Session ); -STATIC VOID EFIAPI Udp4RecycleRxDataWrap ( @@ -83,7 +76,6 @@ Udp4RecycleRxDataWrap ( IN VOID *Context ); -STATIC UDP4_RXDATA_WRAP * Udp4WrapRxData ( IN UDP4_INSTANCE_DATA *Instance, @@ -91,7 +83,6 @@ Udp4WrapRxData ( IN EFI_UDP4_RECEIVE_DATA *RxData ); -STATIC UINTN Udp4EnqueueDgram ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -99,13 +90,11 @@ Udp4EnqueueDgram ( IN EFI_UDP4_RECEIVE_DATA *RxData ); -STATIC VOID Udp4DeliverDgram ( IN UDP4_SERVICE_DATA *Udp4Service ); -STATIC VOID Udp4Demultiplex ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -113,7 +102,6 @@ Udp4Demultiplex ( IN NET_BUF *Packet ); -STATIC VOID Udp4IcmpHandler ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -122,7 +110,6 @@ Udp4IcmpHandler ( IN NET_BUF *Packet ); -STATIC VOID Udp4SendPortUnreach ( IN IP_IO *IpIo, @@ -153,13 +140,15 @@ Udp4CreateService ( EFI_STATUS Status; IP_IO_OPEN_DATA OpenData; + ZeroMem (Udp4Service, sizeof (UDP4_SERVICE_DATA)); + Udp4Service->Signature = UDP4_SERVICE_DATA_SIGNATURE; Udp4Service->ServiceBinding = mUdp4ServiceBinding; Udp4Service->ImageHandle = ImageHandle; Udp4Service->ControllerHandle = ControllerHandle; Udp4Service->ChildrenNumber = 0; - NetListInit (&Udp4Service->ChildrenList); + InitializeListHead (&Udp4Service->ChildrenList); // // Create the IpIo for this service context. @@ -172,7 +161,7 @@ Udp4CreateService ( // // Set the OpenData used to open the IpIo. // - OpenData.IpConfigData = mIpIoDefaultIpConfigData; + CopyMem (&OpenData.IpConfigData, &mIpIoDefaultIpConfigData, sizeof (OpenData.IpConfigData)); OpenData.IpConfigData.AcceptBroadcast = TRUE; OpenData.RcvdContext = (VOID *) Udp4Service; OpenData.SndContext = NULL; @@ -184,7 +173,7 @@ Udp4CreateService ( // Status = IpIoOpen (Udp4Service->IpIo, &OpenData); if (EFI_ERROR (Status)) { - goto RELEASE_IPIO; + goto ON_ERROR; } // @@ -192,13 +181,13 @@ Udp4CreateService ( // Status = gBS->CreateEvent ( EVT_TIMER | EVT_NOTIFY_SIGNAL, - NET_TPL_FAST_TIMER, + TPL_CALLBACK, Udp4CheckTimeout, Udp4Service, &Udp4Service->TimeoutEvent ); if (EFI_ERROR (Status)) { - goto RELEASE_IPIO; + goto ON_ERROR; } // @@ -210,18 +199,16 @@ Udp4CreateService ( UDP4_TIMEOUT_INTERVAL ); if (EFI_ERROR (Status)) { - goto RELEASE_ALL; + goto ON_ERROR; } - Udp4Service->MacString = NULL; - return EFI_SUCCESS; -RELEASE_ALL: - - gBS->CloseEvent (Udp4Service->TimeoutEvent); +ON_ERROR: -RELEASE_IPIO: + if (Udp4Service->TimeoutEvent != NULL) { + gBS->CloseEvent (Udp4Service->TimeoutEvent); + } IpIoDestroy (Udp4Service->IpIo); @@ -270,7 +257,6 @@ Udp4CleanService ( @return None. **/ -STATIC VOID EFIAPI Udp4CheckTimeout ( @@ -279,10 +265,10 @@ Udp4CheckTimeout ( ) { UDP4_SERVICE_DATA *Udp4Service; - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; UDP4_INSTANCE_DATA *Instance; - NET_LIST_ENTRY *WrapEntry; - NET_LIST_ENTRY *NextEntry; + LIST_ENTRY *WrapEntry; + LIST_ENTRY *NextEntry; UDP4_RXDATA_WRAP *Wrap; Udp4Service = (UDP4_SERVICE_DATA *) Context; @@ -306,7 +292,7 @@ Udp4CheckTimeout ( // // Iterate all the rxdatas belonging to this udp instance. // - Wrap = NET_LIST_USER_STRUCT (Entry, UDP4_RXDATA_WRAP, Link); + Wrap = NET_LIST_USER_STRUCT (WrapEntry, UDP4_RXDATA_WRAP, Link); if (Wrap->TimeoutTick <= UDP4_TIMEOUT_INTERVAL / 1000) { // @@ -344,9 +330,9 @@ Udp4InitInstance ( // // Init the lists. // - NetListInit (&Instance->Link); - NetListInit (&Instance->RcvdDgramQue); - NetListInit (&Instance->DeliveredDgramQue); + InitializeListHead (&Instance->Link); + InitializeListHead (&Instance->RcvdDgramQue); + InitializeListHead (&Instance->DeliveredDgramQue); // // Init the NET_MAPs. @@ -359,7 +345,7 @@ Udp4InitInstance ( // Save the pointer to the UDP4_SERVICE_DATA, and initialize other members. // Instance->Udp4Service = Udp4Service; - Instance->Udp4Proto = mUdp4Protocol; + CopyMem (&Instance->Udp4Proto, &mUdp4Protocol, sizeof (Instance->Udp4Proto)); Instance->IcmpError = EFI_SUCCESS; Instance->Configured = FALSE; Instance->IsNoMapping = FALSE; @@ -397,15 +383,14 @@ Udp4CleanInstance ( @return Is the specified pair found or not. **/ -STATIC BOOLEAN Udp4FindInstanceByPort ( - IN NET_LIST_ENTRY *InstanceList, + IN LIST_ENTRY *InstanceList, IN EFI_IPv4_ADDRESS *Address, IN UINT16 Port ) { - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; UDP4_INSTANCE_DATA *Instance; EFI_UDP4_CONFIG_DATA *ConfigData; @@ -424,7 +409,7 @@ Udp4FindInstanceByPort ( continue; } - if (EFI_IP_EQUAL (ConfigData->StationAddress, *Address) && + if (EFI_IP4_EQUAL (&ConfigData->StationAddress, Address) && (ConfigData->StationPort == Port)) { // // if both the address and the port are the same, return TRUE. @@ -457,7 +442,7 @@ Udp4FindInstanceByPort ( **/ EFI_STATUS Udp4Bind ( - IN NET_LIST_ENTRY *InstanceList, + IN LIST_ENTRY *InstanceList, IN EFI_UDP4_CONFIG_DATA *ConfigData ) { @@ -566,8 +551,8 @@ Udp4IsReconfigurable ( } if (!NewConfigData->UseDefaultAddress && - (!EFI_IP_EQUAL (NewConfigData->StationAddress, OldConfigData->StationAddress) || - !EFI_IP_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. @@ -576,15 +561,14 @@ Udp4IsReconfigurable ( } } - if (!EFI_IP_EQUAL (NewConfigData->RemoteAddress, OldConfigData->RemoteAddress)) { + if (!EFI_IP4_EQUAL (&NewConfigData->RemoteAddress, &OldConfigData->RemoteAddress)) { // // The remoteaddress is not the same. // return FALSE; } - if ((EFI_IP4 (NewConfigData->RemoteAddress) != 0) && - (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. // @@ -613,13 +597,14 @@ Udp4BuildIp4ConfigData ( IN EFI_IP4_CONFIG_DATA *Ip4ConfigData ) { - *Ip4ConfigData = mIpIoDefaultIpConfigData; + CopyMem (Ip4ConfigData, &mIpIoDefaultIpConfigData, sizeof (*Ip4ConfigData)); + Ip4ConfigData->DefaultProtocol = EFI_IP_PROTO_UDP; Ip4ConfigData->AcceptBroadcast = Udp4ConfigData->AcceptBroadcast; Ip4ConfigData->AcceptPromiscuous = Udp4ConfigData->AcceptPromiscuous; Ip4ConfigData->UseDefaultAddress = Udp4ConfigData->UseDefaultAddress; - Ip4ConfigData->StationAddress = Udp4ConfigData->StationAddress; - Ip4ConfigData->SubnetMask = Udp4ConfigData->SubnetMask; + CopyMem (&Ip4ConfigData->StationAddress, &Udp4ConfigData->StationAddress, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Ip4ConfigData->SubnetMask, &Udp4ConfigData->SubnetMask, sizeof (EFI_IPv4_ADDRESS)); // // use the -1 magic number to disable the receiving process of the ip instance. @@ -666,6 +651,7 @@ Udp4ValidateTxToken ( EFI_UDP4_CONFIG_DATA *ConfigData; EFI_UDP4_SESSION_DATA *UdpSessionData; IP4_ADDR SourceAddress; + IP4_ADDR GatewayAddress; if (TxToken->Event == NULL) { return EFI_INVALID_PARAMETER; @@ -699,12 +685,15 @@ Udp4ValidateTxToken ( return EFI_INVALID_PARAMETER; } - if ((TxData->GatewayAddress != NULL) && - !Ip4IsUnicast(EFI_NTOHL (*(TxData->GatewayAddress)), 0)) { - // - // The specified GatewayAddress is not a unicast IPv4 address while it's not 0. - // - return EFI_INVALID_PARAMETER; + if (TxData->GatewayAddress != NULL) { + CopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR)); + + if (!Ip4IsUnicast (NTOHL (GatewayAddress), 0)) { + // + // The specified GatewayAddress is not a unicast IPv4 address while it's not 0. + // + return EFI_INVALID_PARAMETER; + } } ConfigData = &Instance->ConfigData; @@ -712,9 +701,9 @@ Udp4ValidateTxToken ( if (UdpSessionData != NULL) { - SourceAddress = EFI_NTOHL (UdpSessionData->SourceAddress); + CopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR)); - if ((SourceAddress != 0) && !Ip4IsUnicast (SourceAddress, 0)) { + if ((SourceAddress != 0) && !Ip4IsUnicast (HTONL (SourceAddress), 0)) { // // Check whether SourceAddress is a valid IPv4 address in case it's not zero. // The configured station address is used if SourceAddress is zero. @@ -729,13 +718,13 @@ Udp4ValidateTxToken ( return EFI_INVALID_PARAMETER; } - if (EFI_IP4 (UdpSessionData->DestinationAddress) == 0) { + if (EFI_IP4_EQUAL (&UdpSessionData->DestinationAddress, &mZeroIp4Addr)) { // // The DestinationAddress specified in the UdpSessionData is 0. // return EFI_INVALID_PARAMETER; } - } else if (EFI_IP4 (ConfigData->RemoteAddress) == 0) { + } else if (EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &mZeroIp4Addr)) { // // the configured RemoteAddress is all zero, and the user doens't override the // destination address. @@ -813,7 +802,7 @@ Udp4Checksum ( Checksum = NetAddChecksum (Checksum, HTONS ((UINT16) Packet->TotalSize)); - return ~Checksum; + return (UINT16) ~Checksum; } @@ -866,7 +855,6 @@ Udp4RemoveToken ( @return None. **/ -STATIC VOID Udp4DgramSent ( IN EFI_STATUS Status, @@ -887,6 +875,7 @@ Udp4DgramSent ( // Token->Status = Status; gBS->SignalEvent (Token->Event); + NetLibDispatchDpc (); } } @@ -905,7 +894,6 @@ Udp4DgramSent ( @return None. **/ -STATIC VOID Udp4DgramRcvd ( IN EFI_STATUS Status, @@ -931,6 +919,12 @@ Udp4DgramRcvd ( // Udp4IcmpHandler ((UDP4_SERVICE_DATA *) Context, IcmpError, NetSession, Packet); } + + // + // Dispatch the DPC queued by the NotifyFunction of the rx token's events + // which are signaled with received data. + // + NetLibDispatchDpc (); } @@ -958,7 +952,7 @@ Udp4LeaveGroup ( McastIp = Arg; - if ((McastIp != NULL) && ((UINTN) EFI_IP4 (*McastIp) != (UINTN) (Item->Key))) { + if ((McastIp != NULL) && (!EFI_IP4_EQUAL (McastIp, &(Item->Key)))) { // // McastIp is not NULL and the multicast address contained in the Item // is not the same as McastIp. @@ -997,7 +991,6 @@ Udp4LeaveGroup ( cancelled. **/ -STATIC EFI_STATUS Udp4CancelTokens ( IN NET_MAP *Map, @@ -1029,11 +1022,10 @@ Udp4CancelTokens ( // The token is a receive token. Abort it and remove it from the Map. // TokenToCancel = (EFI_UDP4_COMPLETION_TOKEN *) Item->Key; + NetMapRemoveItem (Map, Item, NULL); TokenToCancel->Status = EFI_ABORTED; gBS->SignalEvent (TokenToCancel->Event); - - NetMapRemoveItem (Map, Item, NULL); } if (Arg != NULL) { @@ -1053,28 +1045,23 @@ Udp4CancelTokens ( **/ VOID -Udp4FlushRxData ( - IN NET_LIST_ENTRY *RcvdDgramQue +Udp4FlushRcvdDgram ( + IN UDP4_INSTANCE_DATA *Instance ) { UDP4_RXDATA_WRAP *Wrap; - EFI_TPL OldTpl; - - OldTpl = NET_RAISE_TPL (NET_TPL_RECYCLE); - while (!NetListIsEmpty (RcvdDgramQue)) { + while (!IsListEmpty (&Instance->RcvdDgramQue)) { // // Iterate all the Wraps in the RcvdDgramQue. // - Wrap = NET_LIST_HEAD (RcvdDgramQue, UDP4_RXDATA_WRAP, Link); + Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP4_RXDATA_WRAP, Link); // // The Wrap will be removed from the RcvdDgramQue by this function call. // Udp4RecycleRxDataWrap (NULL, (VOID *) Wrap); } - - NET_RESTORE_TPL (OldTpl); } @@ -1141,7 +1128,6 @@ Udp4InstanceCancelToken ( @return The udp datagram matches the receiving requirments of the Instance or not. **/ -STATIC BOOLEAN Udp4MatchDgram ( IN UDP4_INSTANCE_DATA *Instance, @@ -1168,16 +1154,16 @@ Udp4MatchDgram ( return FALSE; } - if ((EFI_IP4 (ConfigData->RemoteAddress) != 0) && - !EFI_IP_EQUAL (ConfigData->RemoteAddress, Udp4Session->SourceAddress)) { + if (!EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &mZeroIp4Addr) && + !EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &Udp4Session->SourceAddress)) { // // This datagram doesn't come from the instance's specified sender. // return FALSE; } - if ((EFI_IP4 (ConfigData->StationAddress) == 0) || - EFI_IP_EQUAL (Udp4Session->DestinationAddress, ConfigData->StationAddress)) { + if (EFI_IP4_EQUAL (&ConfigData->StationAddress, &mZeroIp4Addr) || + EFI_IP4_EQUAL (&Udp4Session->DestinationAddress, &ConfigData->StationAddress)) { // // The instance is configured to receive datagrams destinated to any station IP or // the destination address of this datagram matches the configured station IP. @@ -1185,7 +1171,7 @@ Udp4MatchDgram ( return TRUE; } - Destination = EFI_IP4 (Udp4Session->DestinationAddress); + CopyMem (&Destination, &Udp4Session->DestinationAddress, sizeof (IP4_ADDR)); if (IP4_IS_LOCAL_BROADCAST (Destination) && ConfigData->AcceptBroadcast) { // @@ -1215,7 +1201,6 @@ Udp4MatchDgram ( @return None. **/ -STATIC VOID EFIAPI Udp4RecycleRxDataWrap ( @@ -1230,7 +1215,7 @@ Udp4RecycleRxDataWrap ( // // Remove the Wrap from the list it belongs to. // - NetListRemoveEntry (&Wrap->Link); + RemoveEntryList (&Wrap->Link); // // Free the Packet associated with this Wrap. @@ -1242,7 +1227,7 @@ Udp4RecycleRxDataWrap ( // gBS->CloseEvent (Wrap->RxData.RecycleSignal); - NetFreePool (Wrap); + gBS->FreePool (Wrap); } @@ -1258,7 +1243,6 @@ Udp4RecycleRxDataWrap ( @return Pointer to the structure wrapping the RxData and the Packet. **/ -STATIC UDP4_RXDATA_WRAP * Udp4WrapRxData ( IN UDP4_INSTANCE_DATA *Instance, @@ -1272,28 +1256,28 @@ Udp4WrapRxData ( // // Allocate buffer for the Wrap. // - Wrap = NetAllocatePool (sizeof (UDP4_RXDATA_WRAP) + + Wrap = AllocatePool (sizeof (UDP4_RXDATA_WRAP) + (Packet->BlockOpNum - 1) * sizeof (EFI_UDP4_FRAGMENT_DATA)); if (Wrap == NULL) { return NULL; } - NetListInit (&Wrap->Link); + InitializeListHead (&Wrap->Link); - Wrap->RxData = *RxData; + CopyMem (&Wrap->RxData, RxData, sizeof (Wrap->RxData)); // // Create the Recycle event. // Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL, - NET_TPL_RECYCLE, + TPL_NOTIFY, Udp4RecycleRxDataWrap, Wrap, &Wrap->RxData.RecycleSignal ); if (EFI_ERROR (Status)) { - NetFreePool (Wrap); + gBS->FreePool (Wrap); return NULL; } @@ -1316,7 +1300,6 @@ Udp4WrapRxData ( @return The times this datagram is enqueued. **/ -STATIC UINTN Udp4EnqueueDgram ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -1324,7 +1307,7 @@ Udp4EnqueueDgram ( IN EFI_UDP4_RECEIVE_DATA *RxData ) { - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; UDP4_INSTANCE_DATA *Instance; UDP4_RXDATA_WRAP *Wrap; UINTN Enqueued; @@ -1352,7 +1335,7 @@ Udp4EnqueueDgram ( NET_GET_REF (Packet); - NetListInsertTail (&Instance->RcvdDgramQue, &Wrap->Link); + InsertTailList (&Instance->RcvdDgramQue, &Wrap->Link); Enqueued++; } @@ -1379,8 +1362,9 @@ Udp4InstanceDeliverDgram ( EFI_UDP4_COMPLETION_TOKEN *Token; NET_BUF *Dup; EFI_UDP4_RECEIVE_DATA *RxData; + EFI_TPL OldTpl; - if (!NetListIsEmpty (&Instance->RcvdDgramQue) && + if (!IsListEmpty (&Instance->RcvdDgramQue) && !NetMapIsEmpty (&Instance->RxTokens)) { Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP4_RXDATA_WRAP, Link); @@ -1397,7 +1381,7 @@ Udp4InstanceDeliverDgram ( NetbufFree (Wrap->Packet); Wrap->Packet = Dup; - } + } NetListRemoveHead (&Instance->RcvdDgramQue); @@ -1418,9 +1402,11 @@ Udp4InstanceDeliverDgram ( Token->Status = EFI_SUCCESS; Token->Packet.RxData = &Wrap->RxData; - gBS->SignalEvent (Token->Event); + OldTpl = gBS->RaiseTPL (TPL_NOTIFY); + InsertTailList (&Instance->DeliveredDgramQue, &Wrap->Link); + gBS->RestoreTPL (OldTpl); - NetListInsertTail (&Instance->DeliveredDgramQue, &Wrap->Link); + gBS->SignalEvent (Token->Event); } } @@ -1433,13 +1419,12 @@ Udp4InstanceDeliverDgram ( @return None. **/ -STATIC VOID Udp4DeliverDgram ( IN UDP4_SERVICE_DATA *Udp4Service ) { - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; UDP4_INSTANCE_DATA *Instance; NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) { @@ -1472,7 +1457,6 @@ Udp4DeliverDgram ( @return None. **/ -STATIC VOID Udp4Demultiplex ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -1512,11 +1496,12 @@ Udp4Demultiplex ( gRT->GetTime (&RxData.TimeStamp, NULL); - Udp4Session = &RxData.UdpSession; - EFI_IP4 (Udp4Session->SourceAddress) = NetSession->Source; - EFI_IP4 (Udp4Session->DestinationAddress) = NetSession->Dest; - Udp4Session->SourcePort = NTOHS (Udp4Header->SrcPort); - Udp4Session->DestinationPort = NTOHS (Udp4Header->DstPort); + Udp4Session = &RxData.UdpSession; + Udp4Session->SourcePort = NTOHS (Udp4Header->SrcPort); + Udp4Session->DestinationPort = NTOHS (Udp4Header->DstPort); + + CopyMem (&Udp4Session->SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Udp4Session->DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS)); // // Trim the UDP header. @@ -1563,7 +1548,6 @@ Udp4Demultiplex ( @return None. **/ -STATIC VOID Udp4SendPortUnreach ( IN IP_IO *IpIo, @@ -1620,28 +1604,29 @@ Udp4SendPortUnreach ( // // Copy the IP header of the datagram tragged the error. // - NetCopyMem (&IcmpErrHdr->IpHead, IpHdr, EFI_IP4_HEADER_LEN (IpHdr)); + CopyMem (&IcmpErrHdr->IpHead, IpHdr, EFI_IP4_HEADER_LEN (IpHdr)); // // Copy the UDP header. // Ptr = (UINT8 *) &IcmpErrHdr->IpHead + EFI_IP4_HEADER_LEN (IpHdr); - NetCopyMem (Ptr, Udp4Header, ICMP_ERROR_PACKET_LENGTH); + CopyMem (Ptr, Udp4Header, ICMP_ERROR_PACKET_LENGTH); // // Calculate the checksum. // - IcmpErrHdr->Head.Checksum = ~(NetbufChecksum (Packet)); + IcmpErrHdr->Head.Checksum = (UINT16) ~(NetbufChecksum (Packet)); // // Fill the override data. // - Override.DoNotFragment = FALSE; - Override.TypeOfService = 0; - Override.TimeToLive = 255; - Override.Protocol = EFI_IP_PROTO_ICMP; - EFI_IP4 (Override.SourceAddress) = NetSession->Dest; - EFI_IP4 (Override.GatewayAddress) = 0; + Override.DoNotFragment = FALSE; + Override.TypeOfService = 0; + Override.TimeToLive = 255; + Override.Protocol = EFI_IP_PROTO_ICMP; + + CopyMem (&Override.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS)); + ZeroMem (&Override.GatewayAddress, sizeof (EFI_IPv4_ADDRESS)); // // Send out this icmp packet. @@ -1665,7 +1650,6 @@ Udp4SendPortUnreach ( @return None. **/ -STATIC VOID Udp4IcmpHandler ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -1676,15 +1660,16 @@ Udp4IcmpHandler ( { EFI_UDP4_HEADER *Udp4Header; EFI_UDP4_SESSION_DATA Udp4Session; - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; UDP4_INSTANCE_DATA *Instance; Udp4Header = (EFI_UDP4_HEADER *) NetbufGetByte (Packet, 0, NULL); - EFI_IP4 (Udp4Session.SourceAddress) = NetSession->Source; - EFI_IP4 (Udp4Session.DestinationAddress) = NetSession->Dest; - Udp4Session.SourcePort = NTOHS (Udp4Header->DstPort); - Udp4Session.DestinationPort = NTOHS (Udp4Header->SrcPort); + CopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Udp4Session.DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS)); + + Udp4Session.SourcePort = NTOHS (Udp4Header->DstPort); + Udp4Session.DestinationPort = NTOHS (Udp4Header->SrcPort); NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) { // @@ -1695,7 +1680,7 @@ Udp4IcmpHandler ( if (!Instance->Configured || Instance->ConfigData.AcceptPromiscuous || Instance->ConfigData.AcceptAnyPort || - (EFI_IP4 (Instance->ConfigData.StationAddress) == 0)) { + 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 @@ -1804,7 +1789,7 @@ Udp4SetVariableData ( ) { UINT32 NumConfiguredInstance; - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; UINTN VariableDataSize; EFI_UDP4_VARIABLE_DATA *Udp4VariableData; EFI_UDP4_SERVICE_POINT *Udp4ServicePoint; @@ -1841,7 +1826,7 @@ Udp4SetVariableData ( VariableDataSize += sizeof (EFI_UDP4_SERVICE_POINT) * (NumConfiguredInstance - 1); } - Udp4VariableData = NetAllocatePool (VariableDataSize); + Udp4VariableData = AllocatePool (VariableDataSize); if (Udp4VariableData == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -1902,7 +1887,7 @@ Udp4SetVariableData ( ); } - NetFreePool (Udp4Service->MacString); + gBS->FreePool (Udp4Service->MacString); } Udp4Service->MacString = NewMacString; @@ -1917,7 +1902,7 @@ Udp4SetVariableData ( ON_ERROR: - NetFreePool (Udp4VariableData); + gBS->FreePool (Udp4VariableData); return Status; } @@ -1946,6 +1931,6 @@ Udp4ClearVariableData ( NULL ); - NetFreePool (Udp4Service->MacString); + gBS->FreePool (Udp4Service->MacString); Udp4Service->MacString = NULL; }