MdeModulePkg: Update IP4 stack to support point-to-point link with 31-bit mask.

V2 update: Directly use NetIp4IsUnicast() to check station address in IP driver.

This patch is to follow RFC3021 which allows to use 31-bit mask
in point-to-point link.
If a 31-bit subnet mask is assigned to a point-to-point link, it
leaves the <Host-number> with only 1 bit.  Consequently, only two
possible addresses may result:
  {<Network-number>, 0} and {<Network-number>, -1}
These addresses have historically been associated with network and
broadcast addresses (see Section 2.2).  In a point-to-point link with
a 31-bit subnet mask, the two addresses above MUST be interpreted as
host addresses.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
This commit is contained in:
Fu Siyuan
2017-10-18 10:13:39 +08:00
parent db04b706b7
commit 29788f178e
3 changed files with 18 additions and 27 deletions

View File

@ -637,7 +637,9 @@ NetGetIpClass (
ASSERT if NetMask is zero.
If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address.
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).
@param[in] Ip The IP to check against.
@param[in] NetMask The mask of the IP.
@ -657,9 +659,13 @@ NetIp4IsUnicast (
if (Ip == 0 || IP4_IS_LOCAL_BROADCAST (Ip)) {
return FALSE;
}
if (((Ip &~NetMask) == ~NetMask) || ((Ip &~NetMask) == 0)) {
return FALSE;
if (NetGetMaskLength (NetMask) != 31) {
if (((Ip &~NetMask) == ~NetMask) || ((Ip &~NetMask) == 0)) {
return FALSE;
}
} else {
return TRUE;
}
return TRUE;