]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Update IP4 stack drivers for classless address unicast check.
authorFu Siyuan <siyuan.fu@intel.com>
Thu, 27 Oct 2016 01:23:08 +0000 (09:23 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Fri, 28 Oct 2016 06:20:10 +0000 (14:20 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
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>
14 files changed:
MdeModulePkg/Include/Library/IpIoLib.h
MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c
MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c

index 37cba070a1fb946eec7bbdae94b219fd10646b07..aab0c6805948573cd37a5be372eead13418e7dcd 100644 (file)
@@ -2,7 +2,7 @@
   This library is only intended to be used by UEFI network stack modules.\r
   It provides the combined IpIo layer on the EFI IP4 Protocol and EFI IP6 protocol.\r
 \r
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -261,6 +261,8 @@ typedef struct _IP_IO {
   PKT_RCVD_NOTIFY               PktRcvdNotify;   ///< See IP_IO_OPEN_DATA::PktRcvdNotify.\r
   PKT_SENT_NOTIFY               PktSentNotify;   ///< See IP_IO_OPEN_DATA::PktSentNotify.\r
   UINT8                         IpVersion;\r
+  IP4_ADDR                      StationIp;\r
+  IP4_ADDR                      SubnetMask;\r
 } IP_IO;\r
 \r
 ///\r
index 27fef71e2c0707a260b3d91e81070d40d2ed2e7c..9a70e9075d9abe43d2b3691bc36b344aadf838b7 100644 (file)
@@ -1029,7 +1029,9 @@ IpIoListenHandlerDpc (
 \r
   if (IpIo->IpVersion == IP_VERSION_4) {\r
     if ((EFI_IP4 (RxData->Ip4RxData.Header->SourceAddress) != 0) &&\r
-        !NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), 0)) {\r
+        (IpIo->SubnetMask != 0) &&\r
+        IP4_NET_EQUAL (IpIo->StationIp, EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), IpIo->SubnetMask) &&\r
+        !NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), IpIo->SubnetMask)) {\r
       //\r
       // The source address is not zero and it's not a unicast IP address, discard it.\r
       //\r
@@ -1300,6 +1302,11 @@ IpIoOpen (
     if (OpenData->IpConfigData.Ip4CfgData.RawData) {\r
       return EFI_UNSUPPORTED;\r
     }\r
+\r
+    if (!OpenData->IpConfigData.Ip4CfgData.UseDefaultAddress) {\r
+      IpIo->StationIp = EFI_NTOHL (OpenData->IpConfigData.Ip4CfgData.StationAddress);\r
+      IpIo->SubnetMask = EFI_NTOHL (OpenData->IpConfigData.Ip4CfgData.SubnetMask);\r
+    }\r
     \r
     Status = IpIo->Ip.Ip4->Configure (\r
                              IpIo->Ip.Ip4,\r
index afe49298781d181d62af7ba9c9b47fe3de752c74..a02de203c0770ebb544f1819475246077571bb05 100644 (file)
@@ -943,9 +943,9 @@ ArpConfigureInstance (
       if (ConfigData->SwAddressType == IPV4_ETHER_PROTO_TYPE) {\r
         CopyMem (&Ip, ConfigData->StationAddress, sizeof (IP4_ADDR));\r
 \r
-        if (!NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
+        if (IP4_IS_UNSPECIFIED (Ip) || IP4_IS_LOCAL_BROADCAST (Ip)) {\r
           //\r
-          // The station address is not a valid IPv4 unicast address.\r
+          // The station address should not be zero or broadcast address.\r
           //\r
           return EFI_INVALID_PARAMETER;\r
         }\r
index 79f7cded8ddd9f965250da6ee683448f402b3bfa..18796fdbfb81f41d1e5db9fc516771c2526a91a0 100644 (file)
@@ -660,9 +660,7 @@ EfiDhcp4Configure (
     }\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
@@ -1192,9 +1190,9 @@ Dhcp4InstanceConfigUdpIo (
   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
@@ -1212,6 +1210,13 @@ Dhcp4InstanceConfigUdpIo (
   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
@@ -1492,8 +1497,6 @@ EfiDhcp4TransmitReceive (
   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
@@ -1583,19 +1586,11 @@ EfiDhcp4TransmitReceive (
     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
index 037d1cc39e7cdbe3813512d1cfa2a882c5a90aa9..3898223af5db37d910862e360bcdff9fbd245a14 100644 (file)
@@ -393,8 +393,6 @@ DhcpLeaseAcquired (
   IN OUT DHCP_SERVICE           *DhcpSb\r
   )\r
 {\r
-  INTN                      Class;\r
-\r
   DhcpSb->ClientAddr = EFI_NTOHL (DhcpSb->Selected->Dhcp4.Header.YourAddr);\r
 \r
   if (DhcpSb->Para != NULL) {\r
@@ -403,9 +401,7 @@ DhcpLeaseAcquired (
   }\r
 \r
   if (DhcpSb->Netmask == 0) {\r
-    Class           = NetGetIpClass (DhcpSb->ClientAddr);\r
-    ASSERT (Class < IP4_ADDR_CLASSE);\r
-    DhcpSb->Netmask = gIp4AllMasks[Class << 3];\r
+    return EFI_ABORTED;\r
   }\r
 \r
   if (DhcpSb->LeaseIoPort != NULL) {\r
index ca53fd5077f665c960e1693a6617d6f88daff5b5..77ccd6717835a355a20f5e797445b60400f9964d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Helper functions for configuring or getting the parameters relating to iSCSI.\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -727,7 +727,9 @@ IScsiFormCallback (
     case KEY_LOCAL_IP:\r
       IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String);\r
       Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);\r
-      if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+      if (EFI_ERROR (Status) || \r
+          ((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) && \r
+           !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {\r
         CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
         Status = EFI_INVALID_PARAMETER;\r
       } else {\r
@@ -751,7 +753,10 @@ IScsiFormCallback (
     case KEY_GATE_WAY:\r
       IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String);\r
       Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4);\r
-      if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
+      if (EFI_ERROR (Status) || \r
+          ((Gateway.Addr[0] != 0) && \r
+           (Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) && \r
+           !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {\r
         CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);\r
         Status = EFI_INVALID_PARAMETER;\r
       } else {\r
@@ -763,7 +768,7 @@ IScsiFormCallback (
     case KEY_TARGET_IP:\r
       IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String);\r
       Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);\r
-      if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+      if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST (EFI_NTOHL(HostIp.v4)) || IP4_IS_UNSPECIFIED (EFI_NTOHL(HostIp.v4))) {\r
         CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
         Status = EFI_INVALID_PARAMETER;\r
       } else {\r
@@ -867,7 +872,7 @@ IScsiFormCallback (
         //\r
         if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) {\r
           CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4));\r
-          if (!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+          if (IP4_IS_UNSPECIFIED (NTOHL (HostIp.Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (HostIp.Addr[0]))) {\r
             CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Target IP is invalid!", NULL);\r
             Status = EFI_INVALID_PARAMETER;\r
             break;\r
index d868957896e6ec6e691cf3efc1ee392b63563814..a931bb3e77286fce85334fe0e9647263c0cdd50c 100644 (file)
@@ -737,8 +737,7 @@ Ip4Config2SetDnsServerWorker (
 \r
   for (NewIndex = 0; NewIndex < NewDnsCount; NewIndex++) {\r
     CopyMem (&DnsAddress, NewDns + NewIndex, sizeof (IP4_ADDR));\r
-\r
-    if (!NetIp4IsUnicast (NTOHL (DnsAddress), 0)) {\r
+    if (IP4_IS_UNSPECIFIED (NTOHL (DnsAddress)) || IP4_IS_LOCAL_BROADCAST (NTOHL (DnsAddress))) {\r
       //\r
       // The dns server address must be unicast.\r
       //\r
@@ -1347,14 +1346,15 @@ Ip4Config2SetGateway (
     return EFI_WRITE_PROTECTED;\r
   }\r
 \r
+  IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);\r
 \r
   NewGateway      = (EFI_IPv4_ADDRESS *) Data;\r
   NewGatewayCount = DataSize / sizeof (EFI_IPv4_ADDRESS);\r
   for (Index1 = 0; Index1 < NewGatewayCount; Index1++) {\r
     CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR));\r
-    \r
-    if (!NetIp4IsUnicast (NTOHL (Gateway), 0)) {\r
 \r
+    if ((IpSb->DefaultInterface->SubnetMask != 0) && \r
+        !NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->SubnetMask)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -1365,7 +1365,6 @@ Ip4Config2SetGateway (
     }\r
   }\r
  \r
-  IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);\r
   DataItem = &Instance->DataItem[Ip4Config2DataTypeGateway];\r
   OldGateway      = DataItem->Data.Gateway;\r
   OldGatewayCount = DataItem->DataSize / sizeof (EFI_IPv4_ADDRESS);\r
index ee771e3d6df5cc60db21a8b6e2781c216ae44310..8eea8877bfb4b7f62f6f9589c7030ec6e293a97e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Helper functions for configuring or getting the parameters relating to Ip4.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -608,20 +608,20 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
     //\r
     Ip4NvData->Policy = Ip4Config2PolicyStatic;\r
 \r
-    Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);\r
-    if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), 0)) {\r
-      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    \r
     Status = Ip4Config2StrToIp (IfrFormNvData->SubnetMask, &SubnetMask.v4);\r
     if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (GetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {\r
       CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);\r
       return EFI_INVALID_PARAMETER;\r
     }\r
+\r
+    Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);\r
+    if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) {\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
     \r
     Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);\r
-    if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
+    if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0])))) {\r
       CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);\r
       return EFI_INVALID_PARAMETER;\r
     }\r
@@ -630,7 +630,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
     if (!EFI_ERROR (Status) && DnsCount > 0) {\r
       for (Index = 0; Index < DnsCount; Index ++) {\r
         CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));\r
-        if (!NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
+        if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {\r
           CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);\r
           FreePool(DnsAddress);\r
           return EFI_INVALID_PARAMETER;\r
@@ -1146,7 +1146,7 @@ Ip4FormCallback (
     switch (QuestionId) {\r
     case KEY_LOCAL_IP:\r
       Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);\r
-      if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), 0)) {\r
+      if (EFI_ERROR (Status) || IP4_IS_UNSPECIFIED (NTOHL (StationAddress.Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (StationAddress.Addr[0]))) {\r
         CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
         Status = EFI_INVALID_PARAMETER;\r
       }\r
@@ -1162,7 +1162,7 @@ Ip4FormCallback (
 \r
     case KEY_GATE_WAY:\r
       Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);\r
-      if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
+      if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST(NTOHL(Gateway.Addr[0]))) {\r
         CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);\r
         Status = EFI_INVALID_PARAMETER;\r
       }\r
@@ -1173,7 +1173,7 @@ Ip4FormCallback (
       if (!EFI_ERROR (Status) && DnsCount > 0) {\r
         for (Index = 0; Index < DnsCount; Index ++) {\r
           CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));\r
-          if (!NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
+          if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {\r
             CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);\r
             Status = EFI_INVALID_PARAMETER;\r
             break;\r
index e45727679638106bf2a021d833fa822fbb43aa8e..9cd5dd547ab2303b8a690a355ee3b4d03f0e7726 100644 (file)
@@ -560,9 +560,7 @@ Ip4SetAddress (
 {\r
   EFI_ARP_CONFIG_DATA       ArpConfig;\r
   EFI_STATUS                Status;\r
-  INTN                      Type;\r
   INTN                      Len;\r
-  IP4_ADDR                  Netmask;\r
 \r
   NET_CHECK_SIGNATURE (Interface, IP4_INTERFACE_SIGNATURE);\r
 \r
@@ -578,12 +576,9 @@ Ip4SetAddress (
   Interface->SubnetMask     = SubnetMask;\r
   Interface->SubnetBrdcast  = (IpAddr | ~SubnetMask);\r
 \r
-  Type                      = NetGetIpClass (IpAddr);\r
-  ASSERT (Type <= IP4_ADDR_CLASSC);\r
   Len                       = NetGetMaskLength (SubnetMask);\r
   ASSERT (Len <= IP4_MASK_MAX);\r
-  Netmask                   = gIp4AllMasks[MIN (Len, Type << 3)];\r
-  Interface->NetBrdcast     = (IpAddr | ~Netmask);\r
+  Interface->NetBrdcast     = (IpAddr | ~SubnetMask);\r
 \r
   //\r
   // Do clean up for Arp child\r
index 7ed2e5250f1256d85dbd63ed57be08fd95179823..6223895620d87b32987a2058b2d369e530817f6b 100644 (file)
@@ -2,7 +2,7 @@
   Interface routine for Mtftp4.\r
   \r
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -192,7 +192,7 @@ Mtftp4OverrideValid (
   IP4_ADDR                  Gateway;\r
 \r
   CopyMem (&Ip, &Override->ServerIp, sizeof (IP4_ADDR));\r
-  if (!NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
+  if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {\r
     return FALSE;\r
   }\r
 \r
@@ -667,10 +667,6 @@ EfiMtftp4Configure (
     Gateway  = NTOHL (Gateway);\r
     ServerIp = NTOHL (ServerIp);\r
 \r
-    if (!NetIp4IsUnicast (ServerIp, 0)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
     if (!ConfigData->UseDefaultSetting &&\r
        ((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)))) {\r
 \r
index c7d3d32185e1df3574ae862e55dc29a14dedca8f..8e70e01ab11e45035469272c57deb9553ed859b1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of TCP4 protocol services.\r
 \r
-Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -170,7 +170,7 @@ Tcp4Configure (
   if (NULL != TcpConfigData) {\r
 \r
     CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR));\r
-    if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
+    if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -183,7 +183,7 @@ Tcp4Configure (
 \r
       CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));\r
       CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));\r
-      if (!NetIp4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) {\r
+      if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask))) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
     }\r
index 20dbefff4e19fe54918b0bb734dc50db54222b04..df41433a1a8dd30b1305d60096315d78f170b687 100644 (file)
@@ -827,7 +827,9 @@ Udp4ValidateTxToken (
   if (TxData->GatewayAddress != NULL) {\r
     CopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR));\r
 \r
-    if (!NetIp4IsUnicast (NTOHL (GatewayAddress), 0)) {\r
+    if (!Instance->ConfigData.UseDefaultAddress &&\r
+        (EFI_NTOHL(Instance->ConfigData.SubnetMask) != 0) &&\r
+        !NetIp4IsUnicast (NTOHL (GatewayAddress), EFI_NTOHL(Instance->ConfigData.SubnetMask))) {\r
       //\r
       // The specified GatewayAddress is not a unicast IPv4 address while it's not 0.\r
       //\r
@@ -842,7 +844,10 @@ Udp4ValidateTxToken (
 \r
     CopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR));\r
 \r
-    if ((SourceAddress != 0) && !NetIp4IsUnicast (HTONL (SourceAddress), 0)) {\r
+    if ((SourceAddress != 0) && \r
+        !Instance->ConfigData.UseDefaultAddress &&\r
+        (EFI_NTOHL(Instance->ConfigData.SubnetMask) != 0) &&\r
+        !NetIp4IsUnicast (HTONL (SourceAddress), EFI_NTOHL(Instance->ConfigData.SubnetMask))) {\r
       //\r
       // Check whether SourceAddress is a valid IPv4 address in case it's not zero.\r
       // The configured station address is used if SourceAddress is zero.\r
index 5ea22acb14f96c4f71c7cb41134fc6c3b340dc3b..bdb79b3abde33a52b1c38aa7c6479b5dc70126ff 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -171,9 +171,9 @@ Udp4Configure (
 \r
 \r
     if (!UdpConfigData->UseDefaultAddress &&\r
-      (!IP4_IS_VALID_NETMASK (SubnetMask) ||\r
-      !((StationAddress == 0) || NetIp4IsUnicast (StationAddress, SubnetMask)) ||\r
-      !((RemoteAddress  == 0) || NetIp4IsUnicast (RemoteAddress, 0)))) {\r
+        (!IP4_IS_VALID_NETMASK (SubnetMask) ||\r
+         !((StationAddress == 0) || NetIp4IsUnicast (StationAddress, SubnetMask)) ||\r
+         IP4_IS_LOCAL_BROADCAST (RemoteAddress))) {\r
       //\r
       // Don't use default address, and subnet mask is invalid or StationAddress is not\r
       // a valid unicast IPv4 address or RemoteAddress is not a valid unicast IPv4 address\r
index cf7b7b566e67ad923d7b3485fb45beb19f6e3fee..4746256fa0fcf1676df321d8e9a2faec585b83da 100644 (file)
@@ -176,7 +176,9 @@ IcmpErrorListenHandlerDpc (
   }\r
 \r
   if (EFI_IP4 (RxData->Header->SourceAddress) != 0 &&\r
-      !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) {\r
+      (NTOHL (Mode->SubnetMask.Addr[0]) != 0) &&\r
+      IP4_NET_EQUAL (NTOHL(Mode->StationIp.Addr[0]), EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) &&\r
+      !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0]))) {\r
     //\r
     // The source address is not zero and it's not a unicast IP address, discard it.\r
     //\r
@@ -1163,7 +1165,9 @@ EfiPxeBcMtftp (
   if ((This == NULL)                                                          ||\r
       (Filename == NULL)                                                      ||\r
       (BufferSize == NULL)                                                    ||\r
-      ((ServerIp == NULL) || !NetIp4IsUnicast (NTOHL (ServerIp->Addr[0]), 0)) ||\r
+      ((ServerIp == NULL) || \r
+       (IP4_IS_UNSPECIFIED (NTOHL (ServerIp->Addr[0])) || \r
+        IP4_IS_LOCAL_BROADCAST (NTOHL (ServerIp->Addr[0]))))                  ||\r
       ((BufferPtr == NULL) && DontUseBuffer)                                  ||\r
       ((BlockSize != NULL) && (*BlockSize < 512))) {\r
 \r
@@ -1378,7 +1382,7 @@ EfiPxeBcUdpWrite (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if ((GatewayIp != NULL) && !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), 0)) {\r
+  if ((GatewayIp != NULL) && (IP4_IS_UNSPECIFIED (NTOHL (GatewayIp->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (GatewayIp->Addr[0])))) {\r
     //\r
     // Gateway is provided but it's not a unicast IP address.\r
     //\r
@@ -1964,9 +1968,11 @@ EfiPxeBcSetIpFilter (
       DEBUG ((EFI_D_ERROR, "There is broadcast address in NewFilter.\n"));\r
       return EFI_INVALID_PARAMETER;\r
     }\r
-    if (NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), 0) &&\r
-        ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0)\r
-       ) {\r
+    if ((EFI_NTOHL(Mode->StationIp) != 0) &&\r
+        (EFI_NTOHL(Mode->SubnetMask) != 0) &&\r
+        IP4_NET_EQUAL(EFI_NTOHL(Mode->StationIp), EFI_NTOHL(NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask)) &&\r
+        NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask)) &&\r
+        ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0)) {\r
       //\r
       // If EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP is set and IP4 address is in IpList,\r
       // promiscuous mode is needed.\r
@@ -2308,11 +2314,11 @@ EfiPxeBcSetStationIP (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), 0)) {\r
+  if (NewSubnetMask != NULL && !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask->Addr[0]))) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-\r
-  if (NewSubnetMask != NULL && !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask->Addr[0]))) {\r
+  \r
+  if (NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r