MdeModulePkg/Network: Add 32bit subnet mask support for IP4 PXE boot.
This patch updates IP4 stack to support 32bit subnet mask in PXE boot process. When 32bit subnet mask is used, the IP4 driver couldn't use the subnet mask to determine whether destination IP address is on-link or not, so it will always try to send all the packets to the destination IP address directly first, if failed it will continue to try the default gateway. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
This commit is contained in:
@ -654,8 +654,9 @@ NetGetIpClass (
|
||||
|
||||
If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address,
|
||||
except when the originator is one of the endpoints of a point-to-point link with a 31-bit
|
||||
mask (RFC3021).
|
||||
|
||||
mask (RFC3021), or a 32bit NetMask (all 0xFF) is used for special network environment (e.g.
|
||||
PPP link).
|
||||
|
||||
@param[in] Ip The IP to check against.
|
||||
@param[in] NetMask The mask of the IP.
|
||||
|
||||
@ -669,18 +670,20 @@ NetIp4IsUnicast (
|
||||
IN IP4_ADDR NetMask
|
||||
)
|
||||
{
|
||||
INTN MaskLength;
|
||||
|
||||
ASSERT (NetMask != 0);
|
||||
|
||||
if (Ip == 0 || IP4_IS_LOCAL_BROADCAST (Ip)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (NetGetMaskLength (NetMask) != 31) {
|
||||
MaskLength = NetGetMaskLength (NetMask);
|
||||
ASSERT ((MaskLength >= 0) && (MaskLength <= IP4_MASK_NUM));
|
||||
if (MaskLength < 31) {
|
||||
if (((Ip &~NetMask) == ~NetMask) || ((Ip &~NetMask) == 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
Reference in New Issue
Block a user