diff options
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r-- | MdeModulePkg/Universal/DevicePathDxe/DevicePath.h | 3 | ||||
-rw-r--r-- | MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c | 32 | ||||
-rw-r--r-- | MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c | 54 |
3 files changed, 79 insertions, 10 deletions
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h b/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h index 2acb3b2..b84f2fa 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h @@ -110,6 +110,9 @@ typedef struct { #define USB_SUBCLASS_IRDA_BRIDGE 2
#define USB_SUBCLASS_TEST 3
+#define RFC_1700_UDP_PROTOCOL 17
+#define RFC_1700_TCP_PROTOCOL 6
+
#pragma pack(1)
typedef struct {
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c index 3da549f..37c6da5 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c @@ -1,7 +1,7 @@ /** @file
DevicePathFromText protocol as defined in the UEFI 2.0 specification.
-Copyright (c) 2006 - 2009, Intel Corporation. <BR>
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1646,6 +1646,32 @@ DevPathFromTextMAC ( return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;
}
+
+/**
+ Converts a text format to the network protocol ID.
+
+ @param Text String of protocol field.
+
+ @return Network protocol ID .
+
+**/
+UINTN
+NetworkProtocolFromText (
+ IN CHAR16 *Text
+ )
+{
+ if (StrCmp (Text, L"UDP") == 0) {
+ return RFC_1700_UDP_PROTOCOL;
+ }
+
+ if (StrCmp (Text, L"TCP") == 0) {
+ return RFC_1700_TCP_PROTOCOL;
+ }
+
+ return Strtoi (Text);
+}
+
+
/**
Converts a text device path node to IPV4 device path structure.
@@ -1676,7 +1702,7 @@ DevPathFromTextIPv4 ( );
StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);
- IPv4->Protocol = (UINT16) ((StrCmp (ProtocolStr, L"UDP") == 0) ? 0 : 1);
+ IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
if (StrCmp (TypeStr, L"Static") == 0) {
IPv4->StaticIpAddress = TRUE;
} else {
@@ -1721,7 +1747,7 @@ DevPathFromTextIPv6 ( );
StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);
- IPv6->Protocol = (UINT16) ((StrCmp (ProtocolStr, L"UDP") == 0) ? 0 : 1);
+ IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
if (StrCmp (TypeStr, L"Static") == 0) {
IPv6->StaticIpAddress = TRUE;
} else {
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c index 12caea1..82789c1 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c @@ -1,7 +1,7 @@ /** @file
DevicePathToText protocol as defined in the UEFI 2.0 specification.
-Copyright (c) 2006 - 2009, Intel Corporation. <BR>
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -997,6 +997,28 @@ DevPathToTextMacAddr ( }
/**
+ Converts network protocol string to its text representation.
+
+ @param Str The string representative of input device.
+ @param Protocol The network protocol ID.
+
+**/
+VOID
+CatNetworkProtocol (
+ IN OUT POOL_PRINT *Str,
+ IN UINT16 Protocol
+ )
+{
+ if (Protocol == RFC_1700_TCP_PROTOCOL) {
+ CatPrint (Str, L"TCP");
+ } else if (Protocol == RFC_1700_UDP_PROTOCOL) {
+ CatPrint (Str, L"UDP");
+ } else {
+ CatPrint (Str, L"0x%x", Protocol);
+ }
+}
+
+/**
Converts a IPv4 device path structure to its string representative.
@param Str The string representative of input device.
@@ -1034,12 +1056,21 @@ DevPathToTextIPv4 ( CatPrint (
Str,
- L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",
+ L"IPv4(%d.%d.%d.%d,",
(UINTN) IPDevPath->RemoteIpAddress.Addr[0],
(UINTN) IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IPDevPath->RemoteIpAddress.Addr[2],
- (UINTN) IPDevPath->RemoteIpAddress.Addr[3],
- (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP",
+ (UINTN) IPDevPath->RemoteIpAddress.Addr[3]
+ );
+
+ CatNetworkProtocol (
+ Str,
+ IPDevPath->Protocol
+ );
+
+ CatPrint (
+ Str,
+ L",%s,%d.%d.%d.%d)",
IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",
(UINTN) IPDevPath->LocalIpAddress.Addr[0],
(UINTN) IPDevPath->LocalIpAddress.Addr[1],
@@ -1098,7 +1129,7 @@ DevPathToTextIPv6 ( CatPrint (
Str,
- 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)",
+ L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,",
(UINTN) IPDevPath->RemoteIpAddress.Addr[0],
(UINTN) IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IPDevPath->RemoteIpAddress.Addr[2],
@@ -1114,8 +1145,17 @@ DevPathToTextIPv6 ( (UINTN) IPDevPath->RemoteIpAddress.Addr[12],
(UINTN) IPDevPath->RemoteIpAddress.Addr[13],
(UINTN) IPDevPath->RemoteIpAddress.Addr[14],
- (UINTN) IPDevPath->RemoteIpAddress.Addr[15],
- (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP",
+ (UINTN) IPDevPath->RemoteIpAddress.Addr[15]
+ );
+
+ CatNetworkProtocol (
+ Str,
+ IPDevPath->Protocol
+ );
+
+ CatPrint (
+ Str,
+ L"%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",
(UINTN) IPDevPath->LocalIpAddress.Addr[0],
(UINTN) IPDevPath->LocalIpAddress.Addr[1],
|