]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/UndiRuntimeDxe/Decode.c
Enable Undi driver to support multicast MAC address mapped from IPv6 address
[mirror_edk2.git] / OptionRomPkg / UndiRuntimeDxe / Decode.c
index 670fa18d533dfe64ea6cd663aa6c1e9fc737cdbb..d2d4aba888ea924c6bc7dab695ec609563898ea5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides the basic UNID functions.\r
 \r
 /** @file\r
   Provides the basic UNID functions.\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
 All rights reserved. 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
 All rights reserved. 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
@@ -557,6 +557,8 @@ UNDI_RecFilter (
   UINT16                  copy_len;\r
   UINT8                   *ptr1;\r
   UINT8                   *ptr2;\r
   UINT16                  copy_len;\r
   UINT8                   *ptr1;\r
   UINT8                   *ptr2;\r
+  BOOLEAN                 InvalidMacAddr;\r
+    \r
   OpFlags   = CdbPtr->OpFlags;\r
   NewFilter = (UINT16) (OpFlags & 0x1F);\r
 \r
   OpFlags   = CdbPtr->OpFlags;\r
   NewFilter = (UINT16) (OpFlags & 0x1F);\r
 \r
@@ -609,8 +611,32 @@ UNDI_RecFilter (
       MacAddr   = (UINT8 *) ((UINTN) (CdbPtr->CPBaddr));\r
       MacCount  = CdbPtr->CPBsize / sizeof (PXE_MAC_ADDR);\r
 \r
       MacAddr   = (UINT8 *) ((UINTN) (CdbPtr->CPBaddr));\r
       MacCount  = CdbPtr->CPBsize / sizeof (PXE_MAC_ADDR);\r
 \r
+      //\r
+      // The format of Ethernet multicast address for IPv6 is defined in RFC2464,\r
+      // for IPv4 is defined in RFC1112. Check whether the address is valid.\r
+      //\r
+      InvalidMacAddr = FALSE;\r
+      \r
       for (; MacCount-- != 0; MacAddr += sizeof (PXE_MAC_ADDR)) {\r
       for (; MacCount-- != 0; MacAddr += sizeof (PXE_MAC_ADDR)) {\r
-        if (MacAddr[0] != 0x01 || MacAddr[1] != 0x00 || MacAddr[2] != 0x5E || (MacAddr[3] & 0x80) != 0) {\r
+        if (MacAddr[0] == 0x01) {\r
+          //\r
+          // This multicast MAC address is mapped from IPv4 address.\r
+          //\r
+          if (MacAddr[1] != 0x00 || MacAddr[2] != 0x5E || (MacAddr[3] & 0x80) != 0) {\r
+            InvalidMacAddr = TRUE;\r
+          }          \r
+        } else if (MacAddr[0] == 0x33) {\r
+          //\r
+          // This multicast MAC address is mapped from IPv6 address.\r
+          //\r
+          if (MacAddr[1] != 0x33) {\r
+            InvalidMacAddr = TRUE;\r
+          }\r
+        } else {\r
+          InvalidMacAddr = TRUE;\r
+        }\r
+\r
+        if (InvalidMacAddr) {\r
           CdbPtr->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;\r
           CdbPtr->StatCode  = PXE_STATCODE_INVALID_CPB;\r
           return ;\r
           CdbPtr->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;\r
           CdbPtr->StatCode  = PXE_STATCODE_INVALID_CPB;\r
           return ;\r