Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin...@intel.com> Signed-off-by: jiaxinwu <jiaxin...@intel.com> --- .../Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c index 41b5e95..f2e6d28 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c @@ -1,9 +1,9 @@ /** @file This file implement the EFI_DHCP4_PROTOCOL interface. -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> 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 @@ -1189,11 +1189,14 @@ Dhcp4InstanceConfigUdpIo ( { DHCP_PROTOCOL *Instance; DHCP_SERVICE *DhcpSb; EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token; EFI_UDP4_CONFIG_DATA UdpConfigData; - IP4_ADDR Ip; + IP4_ADDR ClientAddr; + IP4_ADDR Ip; + INTN Class; + IP4_ADDR SubnetMask; Instance = (DHCP_PROTOCOL *) Context; DhcpSb = Instance->Service; Token = Instance->Token; @@ -1202,14 +1205,18 @@ Dhcp4InstanceConfigUdpIo ( UdpConfigData.AcceptBroadcast = TRUE; UdpConfigData.AllowDuplicatePort = TRUE; UdpConfigData.TimeToLive = 64; UdpConfigData.DoNotFragment = TRUE; - Ip = HTONL (DhcpSb->ClientAddr); + ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr); + Ip = HTONL (ClientAddr); CopyMem (&UdpConfigData.StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS)); - - Ip = HTONL (DhcpSb->Netmask); + + Class = NetGetIpClass (ClientAddr); + ASSERT (Class < IP4_ADDR_CLASSE); + SubnetMask = gIp4AllMasks[Class << 3]; + Ip = HTONL (SubnetMask); CopyMem (&UdpConfigData.SubnetMask, &Ip, sizeof (EFI_IPv4_ADDRESS)); if ((Token->ListenPointCount == 0) || (Token->ListenPoints[0].ListenPort == 0)) { UdpConfigData.StationPort = DHCP_CLIENT_PORT; } else { @@ -1355,11 +1362,11 @@ PxeDhcpInput ( // // Is this packet the answer to our packet? // if ((Head->OpCode != BOOTP_REPLY) || (Head->Xid != Token->Packet->Dhcp4.Header.Xid) || - (CompareMem (DhcpSb->ClientAddressSendOut, Head->ClientHwAddr, Head->HwAddrLen) != 0)) { + (CompareMem (&Token->Packet->Dhcp4.Header.ClientHwAddr[0], Head->ClientHwAddr, Head->HwAddrLen) != 0)) { goto RESTART; } // // Validate the options and retrieve the interested options @@ -1479,18 +1486,21 @@ EfiDhcp4TransmitReceive ( NET_BUF *Wrap; UDP_END_POINT EndPoint; IP4_ADDR Ip; DHCP_SERVICE *DhcpSb; EFI_IP_ADDRESS Gateway; + IP4_ADDR ClientAddr; + INTN Class; IP4_ADDR SubnetMask; if ((This == NULL) || (Token == NULL) || (Token->Packet == NULL)) { return EFI_INVALID_PARAMETER; } Instance = DHCP_INSTANCE_FROM_THIS (This); DhcpSb = Instance->Service; + DhcpSb->ActiveChild = Instance; if (Instance->Token != NULL) { // // The previous call to TransmitReceive is not finished. // @@ -1510,12 +1520,13 @@ EfiDhcp4TransmitReceive ( // RemoteAddress is zero. // return EFI_INVALID_PARAMETER; } - if (DhcpSb->ClientAddr == 0) { - + ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr); + + if (ClientAddr == 0) { return EFI_NO_MAPPING; } OldTpl = gBS->RaiseTPL (TPL_CALLBACK); @@ -1571,13 +1582,15 @@ EfiDhcp4TransmitReceive ( } // // Get the gateway. // - SubnetMask = DhcpSb->Netmask; + Class = NetGetIpClass (ClientAddr); + ASSERT (Class < IP4_ADDR_CLASSE); + SubnetMask = gIp4AllMasks[Class << 3]; ZeroMem (&Gateway, sizeof (Gateway)); - if (!IP4_NET_EQUAL (DhcpSb->ClientAddr, EndPoint.RemoteAddr.Addr[0], SubnetMask)) { + if (!IP4_NET_EQUAL (ClientAddr, EndPoint.RemoteAddr.Addr[0], SubnetMask)) { CopyMem (&Gateway.v4, &Token->GatewayAddress, sizeof (EFI_IPv4_ADDRESS)); Gateway.Addr[0] = NTOHL (Gateway.Addr[0]); } // -- 1.9.5.msysgit.1 ------------------------------------------------------------------------------ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel