]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
Fix the issue that the protocol field in IPv4 and IPv6 is does not reflect the RFC170...
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathToText.c
index afa982afc4e9d4a3c1dee1a885973c5a640d57cb..82789c1d514fa0447db2c3e18d5372271f7c68ef 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\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
@@ -996,6 +996,28 @@ DevPathToTextMacAddr (
   CatPrint (Str, L",0x%x)", (UINTN) MacDevPath->IfType);\r
 }\r
 \r
+/**\r
+  Converts network protocol string to its text representation.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param Protocol        The network protocol ID.\r
+\r
+**/\r
+VOID\r
+CatNetworkProtocol (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN UINT16          Protocol\r
+  )\r
+{\r
+  if (Protocol == RFC_1700_TCP_PROTOCOL) {\r
+    CatPrint (Str, L"TCP");\r
+  } else if (Protocol == RFC_1700_UDP_PROTOCOL) {\r
+    CatPrint (Str, L"UDP");\r
+  } else {\r
+    CatPrint (Str, L"0x%x", Protocol);\r
+  }\r
+}\r
+\r
 /**\r
   Converts a IPv4 device path structure to its string representative.\r
 \r
@@ -1034,12 +1056,21 @@ DevPathToTextIPv4 (
 \r
   CatPrint (\r
     Str,\r
-    L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",\r
+    L"IPv4(%d.%d.%d.%d,",\r
     (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
     (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
     (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
-    (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP",\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[3]\r
+    );\r
+\r
+  CatNetworkProtocol (\r
+    Str,\r
+    IPDevPath->Protocol\r
+    );\r
+\r
+  CatPrint (\r
+    Str,\r
+    L",%s,%d.%d.%d.%d)",\r
     IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
     (UINTN) IPDevPath->LocalIpAddress.Addr[0],\r
     (UINTN) IPDevPath->LocalIpAddress.Addr[1],\r
@@ -1098,7 +1129,7 @@ DevPathToTextIPv6 (
 \r
   CatPrint (\r
     Str,\r
-    L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,%s,%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
+    L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,",\r
     (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
     (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
     (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
@@ -1114,8 +1145,17 @@ DevPathToTextIPv6 (
     (UINTN) IPDevPath->RemoteIpAddress.Addr[12],\r
     (UINTN) IPDevPath->RemoteIpAddress.Addr[13],\r
     (UINTN) IPDevPath->RemoteIpAddress.Addr[14],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[15],\r
-    (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP",\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[15]\r
+    );\r
+    \r
+  CatNetworkProtocol (\r
+    Str,\r
+    IPDevPath->Protocol\r
+    );\r
+\r
+  CatPrint (\r
+    Str,\r
+    L"%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
     IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
     (UINTN) IPDevPath->LocalIpAddress.Addr[0],\r
     (UINTN) IPDevPath->LocalIpAddress.Addr[1],\r
@@ -1291,7 +1331,7 @@ DevPathToTextiSCSI (
   CatPrint (\r
     Str,\r
     L"iSCSI(%a,0x%x,0x%lx,",\r
-    ISCSIDevPath->iSCSITargetName,\r
+    ISCSIDevPath->TargetName,\r
     (UINTN) ISCSIDevPath->TargetPortalGroupTag,\r
     ISCSIDevPath->Lun\r
     );\r
@@ -1311,6 +1351,33 @@ DevPathToTextiSCSI (
   CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
 }\r
 \r
+/**\r
+  Converts a VLAN device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextVlan (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  VLAN_DEVICE_PATH  *Vlan;\r
+\r
+  Vlan = DevPath;\r
+  CatPrint (Str, L"Vlan(%d)", (UINTN) Vlan->VlanId);\r
+}\r
+\r
 /**\r
   Converts a Hard drive device path structure to its string representative.\r
 \r
@@ -1509,6 +1576,38 @@ DevPathToTextFvFile (
   CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
 }\r
 \r
+/**\r
+  Converts a Relative Offset device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathRelativeOffsetRange (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath,\r
+  IN BOOLEAN              DisplayOnly,\r
+  IN BOOLEAN              AllowShortcuts\r
+  )\r
+{\r
+  MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
+\r
+  Offset = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Offset(0x%lx,0x%lx)",\r
+    Offset->StartingOffset,\r
+    Offset->EndingOffset\r
+    );\r
+}\r
+\r
 /**\r
   Converts a BIOS Boot Specification device path structure to its string representative.\r
 \r
@@ -1652,6 +1751,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
   {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r
   {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r
   {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r
+  {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan},\r
   {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r
   {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r
   {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r
@@ -1659,6 +1759,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
   {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
   {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r
   {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r
+  {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange},\r
   {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r
   {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r
   {0, 0, NULL}\r