MdeModulePkg: Remove DHCP4.TransmitReceive()and DORA process dependency.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17652 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Wu Jiaxin 2015-06-18 00:43:15 +00:00 committed by jiaxinwu
parent cc63add853
commit ce96473329
1 changed files with 23 additions and 10 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
This file implement the EFI_DHCP4_PROTOCOL interface. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -1191,7 +1191,10 @@ Dhcp4InstanceConfigUdpIo (
DHCP_SERVICE *DhcpSb; DHCP_SERVICE *DhcpSb;
EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token; EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;
EFI_UDP4_CONFIG_DATA UdpConfigData; EFI_UDP4_CONFIG_DATA UdpConfigData;
IP4_ADDR ClientAddr;
IP4_ADDR Ip; IP4_ADDR Ip;
INTN Class;
IP4_ADDR SubnetMask;
Instance = (DHCP_PROTOCOL *) Context; Instance = (DHCP_PROTOCOL *) Context;
DhcpSb = Instance->Service; DhcpSb = Instance->Service;
@ -1204,10 +1207,14 @@ Dhcp4InstanceConfigUdpIo (
UdpConfigData.TimeToLive = 64; UdpConfigData.TimeToLive = 64;
UdpConfigData.DoNotFragment = TRUE; 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)); 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)); CopyMem (&UdpConfigData.SubnetMask, &Ip, sizeof (EFI_IPv4_ADDRESS));
if ((Token->ListenPointCount == 0) || (Token->ListenPoints[0].ListenPort == 0)) { if ((Token->ListenPointCount == 0) || (Token->ListenPoints[0].ListenPort == 0)) {
@ -1357,7 +1364,7 @@ PxeDhcpInput (
// //
if ((Head->OpCode != BOOTP_REPLY) || if ((Head->OpCode != BOOTP_REPLY) ||
(Head->Xid != Token->Packet->Dhcp4.Header.Xid) || (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; goto RESTART;
} }
@ -1481,6 +1488,8 @@ EfiDhcp4TransmitReceive (
IP4_ADDR Ip; IP4_ADDR Ip;
DHCP_SERVICE *DhcpSb; DHCP_SERVICE *DhcpSb;
EFI_IP_ADDRESS Gateway; EFI_IP_ADDRESS Gateway;
IP4_ADDR ClientAddr;
INTN Class;
IP4_ADDR SubnetMask; IP4_ADDR SubnetMask;
if ((This == NULL) || (Token == NULL) || (Token->Packet == NULL)) { if ((This == NULL) || (Token == NULL) || (Token->Packet == NULL)) {
@ -1489,6 +1498,7 @@ EfiDhcp4TransmitReceive (
Instance = DHCP_INSTANCE_FROM_THIS (This); Instance = DHCP_INSTANCE_FROM_THIS (This);
DhcpSb = Instance->Service; DhcpSb = Instance->Service;
DhcpSb->ActiveChild = Instance;
if (Instance->Token != NULL) { if (Instance->Token != NULL) {
// //
@ -1512,8 +1522,9 @@ EfiDhcp4TransmitReceive (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (DhcpSb->ClientAddr == 0) { ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr);
if (ClientAddr == 0) {
return EFI_NO_MAPPING; return EFI_NO_MAPPING;
} }
@ -1573,9 +1584,11 @@ EfiDhcp4TransmitReceive (
// //
// Get the gateway. // Get the gateway.
// //
SubnetMask = DhcpSb->Netmask; Class = NetGetIpClass (ClientAddr);
ASSERT (Class < IP4_ADDR_CLASSE);
SubnetMask = gIp4AllMasks[Class << 3];
ZeroMem (&Gateway, sizeof (Gateway)); 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)); CopyMem (&Gateway.v4, &Token->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
Gateway.Addr[0] = NTOHL (Gateway.Addr[0]); Gateway.Addr[0] = NTOHL (Gateway.Addr[0]);
} }