]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
NetLib:
[mirror_edk2.git] / MdeModulePkg / Library / DxeNetLib / DxeNetLib.c
index f18aa41e34a10e15d1f73535763787382ba7ed51..4c7414acfb0a32d31ac35156096bfcd54c1f528d 100644 (file)
@@ -203,6 +203,46 @@ Ip4IsUnicast (
   return TRUE;\r
 }\r
 \r
+/**\r
+  Check whether the incoming IPv6 address is a valid unicast address.\r
+\r
+  If the address is a multicast address has binary 0xFF at the start, it is not\r
+  a valid unicast address. If the address is unspecified ::, it is not a valid\r
+  unicast address to be assigned to any node. If the address is loopback address\r
+  ::1, it is also not a valid unicast address to be assigned to any physical\r
+  interface. \r
+\r
+  @param[in]  Ip6                   The IPv6 address to check against.\r
+\r
+  @return TRUE if Ip6 is a valid unicast address on the network, otherwise FALSE.\r
+\r
+**/ \r
+BOOLEAN\r
+Ip6IsValidUnicast (\r
+  IN EFI_IPv6_ADDRESS       *Ip6\r
+  ) \r
+{\r
+  UINT8 t;\r
+  UINT8 i;\r
+  \r
+  if (Ip6->Addr[0] == 0xFF) {\r
+    return FALSE;\r
+  }\r
+\r
+  for (i = 0; i < 15; i++) {\r
+    if (Ip6->Addr[i] != 0) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  t = Ip6->Addr[i];\r
+\r
+  if (t == 0x0 || t == 0x1) {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;  \r
+}\r
 \r
 /**\r
   Initialize a random seed using current time.\r