Fix the issue that the protocol field in IPv4 and IPv6 is does not reflect the RFC1700 real value: In RFC1700, UDP value is 17 while TCP value is 6.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9804 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2010-01-25 03:40:18 +00:00
parent 9b6f044a32
commit 052019e1fa
3 changed files with 79 additions and 10 deletions

View File

@ -110,6 +110,9 @@ typedef struct {
#define USB_SUBCLASS_IRDA_BRIDGE 2 #define USB_SUBCLASS_IRDA_BRIDGE 2
#define USB_SUBCLASS_TEST 3 #define USB_SUBCLASS_TEST 3
#define RFC_1700_UDP_PROTOCOL 17
#define RFC_1700_TCP_PROTOCOL 6
#pragma pack(1) #pragma pack(1)
typedef struct { typedef struct {

View File

@ -1,7 +1,7 @@
/** @file /** @file
DevicePathFromText protocol as defined in the UEFI 2.0 specification. 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 All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 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; 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. Converts a text device path node to IPV4 device path structure.
@ -1676,7 +1702,7 @@ DevPathFromTextIPv4 (
); );
StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress); 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) { if (StrCmp (TypeStr, L"Static") == 0) {
IPv4->StaticIpAddress = TRUE; IPv4->StaticIpAddress = TRUE;
} else { } else {
@ -1721,7 +1747,7 @@ DevPathFromTextIPv6 (
); );
StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress); 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) { if (StrCmp (TypeStr, L"Static") == 0) {
IPv6->StaticIpAddress = TRUE; IPv6->StaticIpAddress = TRUE;
} else { } else {

View File

@ -1,7 +1,7 @@
/** @file /** @file
DevicePathToText protocol as defined in the UEFI 2.0 specification. 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 All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -996,6 +996,28 @@ DevPathToTextMacAddr (
CatPrint (Str, L",0x%x)", (UINTN) MacDevPath->IfType); CatPrint (Str, L",0x%x)", (UINTN) MacDevPath->IfType);
} }
/**
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. Converts a IPv4 device path structure to its string representative.
@ -1034,12 +1056,21 @@ DevPathToTextIPv4 (
CatPrint ( CatPrint (
Str, 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[0],
(UINTN) IPDevPath->RemoteIpAddress.Addr[1], (UINTN) IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IPDevPath->RemoteIpAddress.Addr[2], (UINTN) IPDevPath->RemoteIpAddress.Addr[2],
(UINTN) IPDevPath->RemoteIpAddress.Addr[3], (UINTN) IPDevPath->RemoteIpAddress.Addr[3]
(IPDevPath->Protocol == 1) ? L"TCP" : L"UDP", );
CatNetworkProtocol (
Str,
IPDevPath->Protocol
);
CatPrint (
Str,
L",%s,%d.%d.%d.%d)",
IPDevPath->StaticIpAddress ? L"Static" : L"DHCP", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",
(UINTN) IPDevPath->LocalIpAddress.Addr[0], (UINTN) IPDevPath->LocalIpAddress.Addr[0],
(UINTN) IPDevPath->LocalIpAddress.Addr[1], (UINTN) IPDevPath->LocalIpAddress.Addr[1],
@ -1098,7 +1129,7 @@ DevPathToTextIPv6 (
CatPrint ( CatPrint (
Str, 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[0],
(UINTN) IPDevPath->RemoteIpAddress.Addr[1], (UINTN) IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IPDevPath->RemoteIpAddress.Addr[2], (UINTN) IPDevPath->RemoteIpAddress.Addr[2],
@ -1114,8 +1145,17 @@ DevPathToTextIPv6 (
(UINTN) IPDevPath->RemoteIpAddress.Addr[12], (UINTN) IPDevPath->RemoteIpAddress.Addr[12],
(UINTN) IPDevPath->RemoteIpAddress.Addr[13], (UINTN) IPDevPath->RemoteIpAddress.Addr[13],
(UINTN) IPDevPath->RemoteIpAddress.Addr[14], (UINTN) IPDevPath->RemoteIpAddress.Addr[14],
(UINTN) IPDevPath->RemoteIpAddress.Addr[15], (UINTN) IPDevPath->RemoteIpAddress.Addr[15]
(IPDevPath->Protocol == 1) ? L"TCP" : L"UDP", );
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", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",
(UINTN) IPDevPath->LocalIpAddress.Addr[0], (UINTN) IPDevPath->LocalIpAddress.Addr[0],
(UINTN) IPDevPath->LocalIpAddress.Addr[1], (UINTN) IPDevPath->LocalIpAddress.Addr[1],