}\r
\r
CopyMem (&Ip, &Dhcp4CfgData->ClientAddress, sizeof (IP4_ADDR));\r
-\r
- if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
-\r
+ if (IP4_IS_LOCAL_BROADCAST(NTOHL (Ip))) {\r
return EFI_INVALID_PARAMETER;\r
}\r
}\r
EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;\r
EFI_UDP4_CONFIG_DATA UdpConfigData;\r
IP4_ADDR ClientAddr;\r
- IP4_ADDR Ip; \r
+ IP4_ADDR Ip; \r
INTN Class; \r
- IP4_ADDR SubnetMask;\r
+ IP4_ADDR SubnetMask; \r
\r
Instance = (DHCP_PROTOCOL *) Context;\r
DhcpSb = Instance->Service;\r
CopyMem (&UdpConfigData.StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
\r
if (DhcpSb->Netmask == 0) {\r
+ //\r
+ // The Dhcp4.TransmitReceive() API should be able to used at any time according to\r
+ // UEFI spec, while in classless addressing network, the netmask must be explicitly\r
+ // provided together with the station address.\r
+ // If the DHCP instance haven't be configured with a valid netmask, we could only\r
+ // compute it accroding to the classful addressing rule.\r
+ //\r
Class = NetGetIpClass (ClientAddr);\r
ASSERT (Class < IP4_ADDR_CLASSE);\r
SubnetMask = gIp4AllMasks[Class << 3];\r
DHCP_SERVICE *DhcpSb;\r
EFI_IP_ADDRESS Gateway;\r
IP4_ADDR ClientAddr;\r
- INTN Class;\r
- IP4_ADDR SubnetMask;\r
\r
if ((This == NULL) || (Token == NULL) || (Token->Packet == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
EndPoint.RemotePort = Token->RemotePort;\r
}\r
\r
- if (DhcpSb->Netmask == 0) {\r
- Class = NetGetIpClass (ClientAddr);\r
- ASSERT (Class < IP4_ADDR_CLASSE);\r
- SubnetMask = gIp4AllMasks[Class << 3];\r
- } else {\r
- SubnetMask = DhcpSb->Netmask;\r
- }\r
- \r
//\r
// Get the gateway.\r
//\r
ZeroMem (&Gateway, sizeof (Gateway));\r
- if (!IP4_NET_EQUAL (ClientAddr, EndPoint.RemoteAddr.Addr[0], SubnetMask)) {\r
+ if (!IP4_NET_EQUAL (ClientAddr, EndPoint.RemoteAddr.Addr[0], DhcpSb->Netmask)) {\r
CopyMem (&Gateway.v4, &Token->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
Gateway.Addr[0] = NTOHL (Gateway.Addr[0]);\r
}\r