]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IScsiDxe/IScsiDhcp6.c
NetworkPkg: iSCSI should allow to set 6 or 12 length of ISID keyword.
[mirror_edk2.git] / NetworkPkg / IScsiDxe / IScsiDhcp6.c
index 0cd0bd88032fa01f7da81f570a6e8889c6b6370a..06c634c3cda4f6dbe28442535bf6ca09714b836c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   iSCSI DHCP6 related configuration routines.\r
 \r
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2017, 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
@@ -50,7 +50,7 @@ IScsiDhcp6ExtractRootPath (
   UINT8                       IpMode;  \r
 \r
   ConfigNvData = &ConfigData->SessionConfigData;\r
-\r
+  ConfigNvData->DnsMode = FALSE;\r
   //\r
   // "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>\r
   //\r
@@ -82,23 +82,36 @@ IScsiDhcp6ExtractRootPath (
   // Extract SERVERNAME field in the Root Path option.\r
   //\r
   if (TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_START_DELIMITER) {\r
-    Status = EFI_INVALID_PARAMETER;\r
-    goto ON_EXIT;\r
+    //\r
+    // The servername is expressed as domain name.\r
+    //\r
+    ConfigNvData->DnsMode = TRUE;\r
   } else {\r
     Index++;\r
   }\r
 \r
   Fields[RP_FIELD_IDX_SERVERNAME].Str = &TmpStr[Index];\r
 \r
-  while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER) && (Index < Length)) {\r
-    Index++;\r
-  }\r
+  if (!ConfigNvData->DnsMode) {\r
+    while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER)&& (Index < Length)) {\r
+      Index++;\r
+    }\r
 \r
-  //\r
-  // Skip ']' and ':'.\r
-  //\r
-  TmpStr[Index] = '\0';\r
-  Index += 2;\r
+    //\r
+    // Skip ']' and ':'.\r
+    //\r
+    TmpStr[Index] = '\0';\r
+    Index += 2;\r
+  } else {\r
+    while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) {\r
+      Index++;\r
+    }\r
+    //\r
+    // Skip ':'.\r
+    //\r
+    TmpStr[Index] = '\0';\r
+    Index += 1;\r
+  }\r
 \r
   Fields[RP_FIELD_IDX_SERVERNAME].Len = (UINT8) AsciiStrLen (Fields[RP_FIELD_IDX_SERVERNAME].Str);\r
 \r
@@ -150,13 +163,25 @@ IScsiDhcp6ExtractRootPath (
     IpMode = ConfigData->AutoConfigureMode;\r
   }\r
 \r
-  Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);\r
-  CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));\r
-\r
+  //\r
+  // Server name is expressed as domain name, just save it.\r
+  //\r
+  if (ConfigNvData->DnsMode) {\r
+    if (Field->Len > sizeof (ConfigNvData->TargetUrl)) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);\r
+    ConfigNvData->TargetUrl[Field->Len + 1] = '\0';\r
+  } else {\r
+    ZeroMem(&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));\r
+    Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);\r
+    CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_EXIT;\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_EXIT;\r
+    }\r
   }\r
+\r
   //\r
   // Check the protocol type.\r
   //\r