X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=NetworkPkg%2FUefiPxeBcDxe%2FPxeBcSupport.c;h=60509fc9e61288097257cb19addf4fb2c2787e22;hb=233ffa90ccd852a8c6a478eb0426731d64598316;hp=47bb7c5dbbbcf12816c01ef9b1f4e9ea012b2fe7;hpb=3c06e6a9e28c5c1057ecf3b097a76e77474266c7;p=mirror_edk2.git diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c index 47bb7c5dbb..60509fc9e6 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c @@ -1,7 +1,7 @@ /** @file Support functions implementation for UefiPxeBc Driver. - Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2018, 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 @@ -36,16 +36,18 @@ PxeBcFlushStationIp ( { EFI_PXE_BASE_CODE_MODE *Mode; EFI_STATUS Status; + EFI_ARP_CONFIG_DATA ArpConfigData; Mode = Private->PxeBc.Mode; Status = EFI_SUCCESS; + ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA)); - if (Mode->UsingIpv6) { - - if (StationIp != NULL) { - CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS)); - CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS)); - } + if (Mode->UsingIpv6 && StationIp != NULL) { + // + // Overwrite Udp6CfgData/Ip6CfgData StationAddress. + // + CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS)); + CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS)); // // Reconfigure the Ip6 instance to capture background ICMP6 packets with new station Ip address. @@ -61,27 +63,55 @@ PxeBcFlushStationIp ( Status = Private->Ip6->Receive (Private->Ip6, &Private->Icmp6Token); } else { if (StationIp != NULL) { + // + // Reconfigure the ARP instance with station Ip address. + // + ArpConfigData.SwAddressType = 0x0800; + ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS); + ArpConfigData.StationAddress = StationIp; + + Private->Arp->Configure (Private->Arp, NULL); + Private->Arp->Configure (Private->Arp, &ArpConfigData); + + // + // Overwrite Udp4CfgData/Ip4CfgData StationAddress. + // CopyMem (&Private->Udp4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS)); CopyMem (&Private->Ip4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS)); } - + if (SubnetMask != NULL) { + // + // Overwrite Udp4CfgData/Ip4CfgData SubnetMask. + // CopyMem (&Private->Udp4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS)); CopyMem (&Private->Ip4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS)); } - // - // Reconfigure the Ip4 instance to capture background ICMP packets with new station Ip address. - // - Private->Ip4->Cancel (Private->Ip4, &Private->IcmpToken); - Private->Ip4->Configure (Private->Ip4, NULL); - - Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4CfgData); - if (EFI_ERROR (Status)) { - goto ON_EXIT; + if (StationIp != NULL && SubnetMask != NULL) { + // + // Updated the route table. + // + Mode->RouteTableEntries = 1; + Mode->RouteTable[0].IpAddr.Addr[0] = StationIp->Addr[0] & SubnetMask->Addr[0]; + Mode->RouteTable[0].SubnetMask.Addr[0] = SubnetMask->Addr[0]; + Mode->RouteTable[0].GwAddr.Addr[0] = 0; } - Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpToken); + if (StationIp != NULL || SubnetMask != NULL) { + // + // Reconfigure the Ip4 instance to capture background ICMP packets with new station Ip address. + // + Private->Ip4->Cancel (Private->Ip4, &Private->IcmpToken); + Private->Ip4->Configure (Private->Ip4, NULL); + + Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4CfgData); + if (EFI_ERROR (Status)) { + goto ON_EXIT; + } + + Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpToken); + } } ON_EXIT: @@ -276,7 +306,7 @@ PxeBcIcmpErrorDpcHandle ( // goto ON_RECYCLE; } - + // // The protocol has been configured to only receive ICMP packet. // @@ -452,7 +482,7 @@ PxeBcIcmp6ErrorDpcHandle ( ON_RECYCLE: gBS->SignalEvent (RxData->RecycleSignal); - + ON_EXIT: Private->Icmp6Token.Status = EFI_NOT_READY; Ip6->Receive (Ip6, &Private->Icmp6Token); @@ -487,7 +517,7 @@ PxeBcIcmp6ErrorUpdate ( @param[in, out] SrcPort The pointer to the source port. @param[in] DoNotFragment If TRUE, fragment is not enabled. Otherwise, fragment is enabled. - @param[in] Ttl The time to live field of the IP header. + @param[in] Ttl The time to live field of the IP header. @param[in] ToS The type of service field of the IP header. @retval EFI_SUCCESS Successfully configured this instance.