X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FMtftp4Dxe%2FMtftp4Rrq.c;h=e983d7979192b453b726be4da6c8c96aa268bc51;hb=36c19ee6c7c4455f5de2817052444d1a0dad0e3d;hp=264598f49a0c520113d95120982007d90e48bba8;hpb=49fd66cbf8144802976b727fcb541a185f73daf3;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c index 264598f49a..e983d79791 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c @@ -1,7 +1,8 @@ /** @file Routines to process Rrq (download). -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+(C) Copyright 2014 Hewlett-Packard Development Company, L.P.
+Copyright (c) 2006 - 2014, 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 @@ -413,13 +414,13 @@ Mtftp4RrqConfigMcastPort ( UdpConfig.ReceiveTimeout = 0; UdpConfig.TransmitTimeout = 0; UdpConfig.UseDefaultAddress = Config->UseDefaultSetting; - UdpConfig.StationAddress = Config->StationIp; - UdpConfig.SubnetMask = Config->SubnetMask; + IP4_COPY_ADDRESS (&UdpConfig.StationAddress, &Config->StationIp); + IP4_COPY_ADDRESS (&UdpConfig.SubnetMask, &Config->SubnetMask); UdpConfig.StationPort = Instance->McastPort; UdpConfig.RemotePort = 0; Ip = HTONL (Instance->ServerIp); - CopyMem (&UdpConfig.RemoteAddress, &Ip, sizeof (EFI_IPv4_ADDRESS)); + IP4_COPY_ADDRESS (&UdpConfig.RemoteAddress, &Ip); Status = McastIo->Protocol.Udp4->Configure (McastIo->Protocol.Udp4, &UdpConfig); @@ -451,7 +452,7 @@ Mtftp4RrqConfigMcastPort ( // join the multicast group // Ip = HTONL (Instance->McastIp); - CopyMem (&Group, &Ip, sizeof (EFI_IPv4_ADDRESS)); + IP4_COPY_ADDRESS (&Group, &Ip); return McastIo->Protocol.Udp4->Groups (McastIo->Protocol.Udp4, TRUE, &Group); } @@ -486,6 +487,7 @@ Mtftp4RrqHandleOack ( MTFTP4_OPTION Reply; EFI_STATUS Status; INTN Expected; + EFI_UDP4_PROTOCOL *Udp4; *Completed = FALSE; @@ -548,13 +550,31 @@ Mtftp4RrqHandleOack ( // Instance->McastIp = Reply.McastIp; Instance->McastPort = Reply.McastPort; - Instance->McastUdpPort = UdpIoCreateIo ( - Instance->Service->Controller, - Instance->Service->Image, - Mtftp4RrqConfigMcastPort, - UDP_IO_UDP4_VERSION, - Instance - ); + if (Instance->McastUdpPort == NULL) { + Instance->McastUdpPort = UdpIoCreateIo ( + Instance->Service->Controller, + Instance->Service->Image, + Mtftp4RrqConfigMcastPort, + UDP_IO_UDP4_VERSION, + Instance + ); + if (Instance->McastUdpPort != NULL) { + Status = gBS->OpenProtocol ( + Instance->McastUdpPort->UdpHandle, + &gEfiUdp4ProtocolGuid, + (VOID **) &Udp4, + Instance->Service->Image, + Instance->Handle, + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER + ); + if (EFI_ERROR (Status)) { + UdpIoFreeIo (Instance->McastUdpPort); + Instance->McastUdpPort = NULL; + return EFI_DEVICE_ERROR; + } + } + } + if (Instance->McastUdpPort == NULL) { return EFI_DEVICE_ERROR; @@ -685,6 +705,7 @@ Mtftp4RrqInput ( } else { Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL); + ASSERT (Packet != NULL); } Opcode = NTOHS (Packet->OpCode);