AddIScsiConnectionA function (iscsidsc.h)

The AddIscsiConnection function adds a new iSCSI connection to an existing session.

Syntax

ISDSC_STATUS ISDSC_API AddIScsiConnectionA(
  [in]            PISCSI_UNIQUE_SESSION_ID    UniqueSessionId,
  [in]            PVOID                       Reserved,
  [in, optional]  ULONG                       InitiatorPortNumber,
  [in]            PISCSI_TARGET_PORTALA       TargetPortal,
  [in, optional]  ISCSI_SECURITY_FLAGS        SecurityFlags,
  [in, optional]  PISCSI_LOGIN_OPTIONS        LoginOptions,
  [in, optional]  ULONG                       KeySize,
  [in, optional]  PCHAR                       Key,
  [out, optional] PISCSI_UNIQUE_CONNECTION_ID ConnectionId
);

Parameters

[in] UniqueSessionId

A pointer to a structure of type ISCSI_UNIQUE_SESSION_ID that, on input, contains the session identifier for the session that was added.

[in] Reserved

This member should be null on input.

[in, optional] InitiatorPortNumber

The number of the port on the initiator that the initiator uses to add the connection. A value of ISCSI_ANY_INITIATOR_PORT indicates that the initiator can use any of its ports to add the connection.

[in] TargetPortal

A pointer to an ISCSI_TARGET_PORTAL-type structure that indicates the target portal to use when adding the connection.

The portal must belong to the same portal group that the initiator used to login to the target, and it must be a portal that the initiator discovered. The iSCSI initiator service does not verify that the target portal meets these requirements.

[in, optional] SecurityFlags

A bitmap that specifies the characteristics of the IPsec connection that the initiator uses to establish the connection. If IPsec security policy between the initiator and the target portal is already configured because of the portal group policy or a previous connection to the portal, the existing configuration takes precedence over the configuration specified in SecurityFlags and the security bitmap is ignored.

If the ISCSI_SECURITY_FLAG_VALID flag is set to 0, the iSCSI initiator service uses default values for the security flags that are defined in the registry.

Value Meaning
ISCSI_SECURITY_FLAG_TUNNEL_MODE_PREFERRED
When set to 1, the initiator should make the connection in IPsec tunnel mode. Caller should set this flag or the ISCSI_SECURITY_FLAG_TRANSPORT_MODE_PREFERRED flag, but not both.
ISCSI_SECURITY_FLAG_TRANSPORT_MODE_PREFERRED
When set to 1, the initiator should make the connection in IPsec transport mode. Caller should set this flag or the ISCSI_SECURITY_FLAG_TUNNEL_MODE_PREFERRED flag, but not both.
ISCSI_SECURITY_FLAG_PFS_ENABLED
When set to 1, the initiator should make the connection with Perfect Forward Secrecy (PFS) mode enabled; otherwise, the initiator should make the connection with PFS mode disabled.
ISCSI_SECURITY_FLAG_AGGRESSIVE_MODE_ENABLED
When set to 1, the initiator should make the connection with aggressive mode enabled. Caller should set this flag or the ISCSI_SECURITY_FLAG_MAIN_MODE_ENABLED flag, but not both.
Note  The Microsoft software initiator driver does not support aggressive mode.
 
ISCSI_SECURITY_FLAG_MAIN_MODE_ENABLED
When set to 1, the initiator should make the connection with main mode enabled. Caller should set this flag or the ISCSI_SECURITY_FLAG_AGGRESSIVE_MODE_ENABLED flag, but not both.
ISCSI_SECURITY_FLAG_IKE_IPSEC_ENABLED
When set to 1, the initiator should make the connection with the IKE/IPsec protocol enabled; otherwise, the IKE/IPsec protocol is disabled.
ISCSI_SECURITY_FLAG_VALID
When set to 1, the other mask values are valid; otherwise, the iSCSI initiator service will use bitmap values that were previously defined for the target portal, or if none are available, the initiator service uses the default values defined in the registry.

[in, optional] LoginOptions

A pointer to a structure of type ISCSI_LOGIN_OPTIONS that contains the options that specify the characteristics of the login session.

[in, optional] KeySize

The size, in bytes, of the preshared key that is passed to the target.

[in, optional] Key

If the IPsec security policy between the initiator and the target portal is already configured as a result of the portal group policy or a previous connection to the portal, the existing key takes precedence over the key currently specified in this member.

[out, optional] ConnectionId

An ISCSI_UNIQUE_CONNECTION_ID-type structure that, on output, receives an opaque value that uniquely identifies the connection that was added to the session.

Return value

Returns ERROR_SUCCESS if the operation succeeds. Otherwise, it returns the appropriate Win32 or iSCSI error code.

Remarks

Note

The iscsidsc.h header defines AddIScsiConnection as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header iscsidsc.h
Library Iscsidsc.lib
DLL Iscsidsc.dll

See also

ISCSI_LOGIN_OPTIONS

ISCSI_TARGET_PORTAL

ISCSI_UNIQUE_SESSION_ID