summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/IScsiDxe/IScsiProto.c
diff options
context:
space:
mode:
authorZhang Lubo <lubo.zhang@intel.com>2016-10-26 14:21:08 +0800
committerJiaxin Wu <jiaxin.wu@intel.com>2016-10-26 16:43:31 +0800
commit9c3dcd0f5658f2205858994f392b48f425a453d1 (patch)
tree20794d5640570489091ac72562c57ed7506e76d8 /NetworkPkg/IScsiDxe/IScsiProto.c
parent8aa2cdd79f9c75429ae1c23ac0f379d901a251d6 (diff)
downloadedk2-9c3dcd0f5658f2205858994f392b48f425a453d1.tar.gz
edk2-9c3dcd0f5658f2205858994f392b48f425a453d1.tar.bz2
edk2-9c3dcd0f5658f2205858994f392b48f425a453d1.zip
NetworkPkg: Support bracketed IPv6 address during a redirection in iSCSI
According to RFC 3720, the TargetAddress provided in a redirection might be a DNS host name, a dotted-decimal IPv4 address, or a bracketed IPv6 address. Current ISCSI driver in Networkpkg only supports dotted-decimal IPv4 address, so we need add IPv6 address support since it is a combo driver supporting dual stack. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo <lubo.zhang@intel.com> Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Diffstat (limited to 'NetworkPkg/IScsiDxe/IScsiProto.c')
-rw-r--r--NetworkPkg/IScsiDxe/IScsiProto.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c
index eb77d75052..a67bbd5c87 100644
--- a/NetworkPkg/IScsiDxe/IScsiProto.c
+++ b/NetworkPkg/IScsiDxe/IScsiProto.c
@@ -1091,12 +1091,47 @@ IScsiUpdateTargetAddress (
break;
}
- if (!NET_IS_DIGIT (TargetAddress[0])) {
+ //
+ // RFC 3720 defines format of the TargetAddress=domainname[:port][,portal-group-tag]
+ // The domainname can be specified as either a DNS host name, adotted-decimal IPv4 address,
+ // or a bracketed IPv6 address as specified in [RFC2732].
+ //
+ if (NET_IS_DIGIT (TargetAddress[0])) {
+ //
+ // The domainname of the target is presented in a dotted-decimal IPv4 address format.
+ //
+ IpStr = TargetAddress;
+
+ while ((*TargetAddress != '\0') && (*TargetAddress != ':') && (*TargetAddress != ',')) {
+ //
+ // NULL, ':', or ',' ends the IPv4 string.
+ //
+ TargetAddress++;
+ }
+ } else if (*TargetAddress == ISCSI_REDIRECT_ADDR_START_DELIMITER){
//
- // The domainname of the target may be presented in three formats: a DNS host name,
- // a dotted-decimal IPv4 address, or a bracketed IPv6 address. Only accept dotted
- // IPv4 address.
+ // The domainname of the target is presented in a bracketed IPv6 address format.
//
+ TargetAddress ++;
+ IpStr = TargetAddress;
+ while ((*TargetAddress != '\0') && (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER)) {
+ //
+ // ']' ends the IPv6 string.
+ //
+ TargetAddress++;
+ }
+
+ if (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER) {
+ continue;
+ }
+
+ *TargetAddress = '\0';
+ TargetAddress ++;
+
+ } else {
+ //
+ // The domainname of the target is presented in the format of a DNS host name.
+ // Temporary not supported.
continue;
}
@@ -1105,15 +1140,6 @@ IScsiUpdateTargetAddress (
//
NvData->OriginalTargetPort = NvData->TargetPort;
- IpStr = TargetAddress;
-
- while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) {
- //
- // NULL, ':', or ',' ends the IPv4 string.
- //
- TargetAddress++;
- }
-
if (*TargetAddress == ',') {
//
// Comma and the portal group tag MUST be ommitted if the TargetAddress is sent
@@ -1133,7 +1159,7 @@ IScsiUpdateTargetAddress (
}
} else {
//
- // The string only contains the IPv4 address. Use the well-known port.
+ // The string only contains the Target address. Use the well-known port.
//
NvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
}