summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/IScsiDxe/IScsiMisc.c
diff options
context:
space:
mode:
authorfanwang2 <fan.wang@intel.com>2015-07-26 08:03:59 +0000
committerjljusten <jljusten@Edk2>2015-07-26 08:03:59 +0000
commit42f0586d61bc9c7efa47207b71ac52053484c472 (patch)
tree298f3160c7b378a54b81ae71138c5518036f772f /NetworkPkg/IScsiDxe/IScsiMisc.c
parentf18b2162e8c81ed741853e11a4c3134335090946 (diff)
downloadedk2-42f0586d61bc9c7efa47207b71ac52053484c472.tar.gz
edk2-42f0586d61bc9c7efa47207b71ac52053484c472.tar.bz2
edk2-42f0586d61bc9c7efa47207b71ac52053484c472.zip
NetworkPkg: Add old IPv4_DEVICE_PATH and IPv6_DEVICE_PATH support
GatewayIpAddress and SubnetMask do not exist in old IPv4_DEVICE_PATH, IPAddressOrigin, PrefixLength and GatewayIPAddress do not exist in old IPv6_DEVICE_PATH. This will lead new IScsiDxe to error without updating IPv4_DEVICE_PATH and IPv6_DEVICE_PATH in system. Following UEFI2.5 spec of IPv4_DEVICE_PATH do a check before accessing fields only defined in new version's IPv4_DEVICE_PATH, and revise the same issue for IPv6_DEVICE_PATH in Iscsi driver. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: fanwang2 <fan.wang@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> [lersek@redhat.com: rewrapped commit message] Signed-off-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18056 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'NetworkPkg/IScsiDxe/IScsiMisc.c')
-rw-r--r--NetworkPkg/IScsiDxe/IScsiMisc.c62
1 files changed, 50 insertions, 12 deletions
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index aeb99e5f94..010d2a4800 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1,7 +1,7 @@
/** @file
Miscellaneous routines for iSCSI driver.
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
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
@@ -1352,6 +1352,7 @@ IScsiGetTcpConnDevicePath (
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_STATUS Status;
EFI_DEV_PATH *DPathNode;
+ UINTN PathLen;
if (Session->State != SESSION_STATE_LOGGED_IN) {
return NULL;
@@ -1390,21 +1391,58 @@ IScsiGetTcpConnDevicePath (
DPathNode->Ipv4.StaticIpAddress =
(BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
- IP4_COPY_ADDRESS (
- &DPathNode->Ipv4.GatewayIpAddress,
- &Session->ConfigData->SessionConfigData.Gateway
- );
+ //
+ // Add a judgement here to support previous versions of IPv4_DEVICE_PATH.
+ // In previous versions of IPv4_DEVICE_PATH, GatewayIpAddress and SubnetMask
+ // do not exist.
+ // In new version of IPv4_DEVICE_PATH, structcure length is 27.
+ //
- IP4_COPY_ADDRESS (
- &DPathNode->Ipv4.SubnetMask,
- &Session->ConfigData->SessionConfigData.SubnetMask
- );
+ PathLen = DevicePathNodeLength (&DPathNode->Ipv4);
+
+ if (PathLen == IPv4_NODE_LEN_NEW_VERSIONS) {
+
+ IP4_COPY_ADDRESS (
+ &DPathNode->Ipv4.GatewayIpAddress,
+ &Session->ConfigData->SessionConfigData.Gateway
+ );
+
+ IP4_COPY_ADDRESS (
+ &DPathNode->Ipv4.SubnetMask,
+ &Session->ConfigData->SessionConfigData.SubnetMask
+ );
+ }
+
break;
} else if (Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP) {
DPathNode->Ipv6.LocalPort = 0;
- DPathNode->Ipv6.IpAddressOrigin = 0;
- DPathNode->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
- ZeroMem (&DPathNode->Ipv6.GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS));
+
+ //
+ // Add a judgement here to support previous versions of IPv6_DEVICE_PATH.
+ // In previous versions of IPv6_DEVICE_PATH, IpAddressOrigin, PrefixLength
+ // and GatewayIpAddress do not exist.
+ // In new version of IPv6_DEVICE_PATH, structure length is 60, while in
+ // old versions, the length is 43.
+ //
+
+ PathLen = DevicePathNodeLength (&DPathNode->Ipv6);
+
+ if (PathLen == IPv6_NODE_LEN_NEW_VERSIONS ) {
+
+ DPathNode->Ipv6.IpAddressOrigin = 0;
+ DPathNode->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
+ ZeroMem (&DPathNode->Ipv6.GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS));
+ }
+ else if (PathLen == IPv6_NODE_LEN_OLD_VERSIONS) {
+
+ //
+ // StaticIPAddress is a field in old versions of IPv6_DEVICE_PATH, while ignored in new
+ // version. Set StaticIPAddress through its' offset in old IPv6_DEVICE_PATH.
+ //
+ *((UINT8 *)(&DPathNode->Ipv6) + IPv6_OLD_IPADDRESS_OFFSET) =
+ (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
+ }
+
break;
}
}