]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issue that the protocol field in IPv4 and IPv6 is does not reflect the RFC170...
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 25 Jan 2010 03:40:18 +0000 (03:40 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 25 Jan 2010 03:40:18 +0000 (03:40 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9804 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/DevicePathDxe/DevicePath.h
MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c

index 2acb3b21fbc43320997ee88243ab9147a9ba41f9..b84f2fa1603e105be5c6ff776262570fe7ba6e4a 100644 (file)
@@ -110,6 +110,9 @@ typedef struct {
 #define USB_SUBCLASS_IRDA_BRIDGE   2\r
 #define USB_SUBCLASS_TEST          3\r
 \r
+#define RFC_1700_UDP_PROTOCOL      17\r
+#define RFC_1700_TCP_PROTOCOL      6\r
+\r
 #pragma pack(1)\r
 \r
 typedef struct {\r
index 3da549f156e5f9d9331e972899b8399fa29e3bb7..37c6da58a62f8297bff9445899648e7e72db6bc2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
 \r
-Copyright (c) 2006 - 2009, 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
@@ -1646,6 +1646,32 @@ DevPathFromTextMAC (
   return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r
 }\r
 \r
+\r
+/**\r
+  Converts a text format to the network protocol ID.\r
+\r
+  @param Text  String of protocol field.\r
+\r
+  @return Network protocol ID .\r
+\r
+**/\r
+UINTN\r
+NetworkProtocolFromText (\r
+  IN CHAR16 *Text\r
+  )\r
+{\r
+  if (StrCmp (Text, L"UDP") == 0) {\r
+    return RFC_1700_UDP_PROTOCOL;\r
+  }\r
+\r
+  if (StrCmp (Text, L"TCP") == 0) {\r
+    return RFC_1700_TCP_PROTOCOL;\r
+  }\r
+\r
+  return Strtoi (Text);\r
+}\r
+\r
+\r
 /**\r
   Converts a text device path node to IPV4 device path structure.\r
 \r
@@ -1676,7 +1702,7 @@ DevPathFromTextIPv4 (
                                                  );\r
 \r
   StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);\r
-  IPv4->Protocol = (UINT16) ((StrCmp (ProtocolStr, L"UDP") == 0) ? 0 : 1);\r
+  IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
   if (StrCmp (TypeStr, L"Static") == 0) {\r
     IPv4->StaticIpAddress = TRUE;\r
   } else {\r
@@ -1721,7 +1747,7 @@ DevPathFromTextIPv6 (
                                                  );\r
 \r
   StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);\r
-  IPv6->Protocol        = (UINT16) ((StrCmp (ProtocolStr, L"UDP") == 0) ? 0 : 1);\r
+  IPv6->Protocol        = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
   if (StrCmp (TypeStr, L"Static") == 0) {\r
     IPv6->StaticIpAddress = TRUE;\r
   } else {\r
index 12caea19baf7bb073da616833d6fadbcf1b08756..82789c1d514fa0447db2c3e18d5372271f7c68ef 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
 \r
-Copyright (c) 2006 - 2009, 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