Win32 API 日本語リファレンス
ホームStorage.IscsiDisc › ISCSI_TARGET_MAPPINGW

ISCSI_TARGET_MAPPINGW

構造体
サイズx64: 1520 バイト / x86: 1512 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
InitiatorNameWCHAR512+0+0ターゲットへのアクセスに使用される HBA イニシエーターの名前を表す文字列です。
TargetNameWCHAR448+512+512ターゲット名を表す文字列です。
OSDeviceNameWCHAR520+960+960HBA イニシエーターのデバイス名を表す文字列です。たとえば '\device\ScsiPort3' のようになります。
SessionIdISCSI_UNIQUE_SESSION_ID16+1480+1480セッションを一意に識別する情報を格納する ISCSI_UNIQUE_SESSION_ID 構造体です。
OSBusNumberDWORD4+1496+1496ターゲットのローカル SCSI アドレスとしてイニシエーターが使用するバス番号です。
OSTargetNumberDWORD4+1500+1500ターゲットのローカル SCSI アドレスとしてイニシエーターが使用するターゲット番号です。
LUNCountDWORD4+1504+1504ターゲット上の論理ユニット (LUN) の数です。
LUNListSCSI_LUN_LIST*8/4+1512+1508ターゲットに関連付けられた LUN に関する情報を格納する SCSI_LUN_LIST 構造体のリストです。

公式ドキュメント

ISCSI_TARGET_MAPPING 構造体は、ターゲット、およびそのターゲットへの到達に使用されるホストバスアダプター (HBA) とバスに関する情報を格納します。

解説(Remarks)

メモ

iscsidsc.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして ISCSI_TARGET_MAPPING を定義します。エンコード中立のエイリアスを、エンコード中立でないコードと混在させて使用すると、不一致が生じてコンパイルエラーや実行時エラーの原因となることがあります。詳細については、「Conventions for Function Prototypes」を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// ISCSI_UNIQUE_SESSION_ID  (x64 16 / x86 16 バイト)
typedef struct ISCSI_UNIQUE_SESSION_ID {
    ULONGLONG AdapterUnique;
    ULONGLONG AdapterSpecific;
} ISCSI_UNIQUE_SESSION_ID;

// ISCSI_TARGET_MAPPINGW  (x64 1520 / x86 1512 バイト)
typedef struct ISCSI_TARGET_MAPPINGW {
    WCHAR InitiatorName[256];
    WCHAR TargetName[224];
    WCHAR OSDeviceName[260];
    ISCSI_UNIQUE_SESSION_ID SessionId;
    DWORD OSBusNumber;
    DWORD OSTargetNumber;
    DWORD LUNCount;
    SCSI_LUN_LIST* LUNList;
} ISCSI_TARGET_MAPPINGW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ISCSI_UNIQUE_SESSION_ID
{
    public ulong AdapterUnique;
    public ulong AdapterSpecific;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ISCSI_TARGET_MAPPINGW
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string InitiatorName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 224)] public string TargetName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string OSDeviceName;
    public ISCSI_UNIQUE_SESSION_ID SessionId;
    public uint OSBusNumber;
    public uint OSTargetNumber;
    public uint LUNCount;
    public IntPtr LUNList;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ISCSI_UNIQUE_SESSION_ID
    Public AdapterUnique As ULong
    Public AdapterSpecific As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ISCSI_TARGET_MAPPINGW
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public InitiatorName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=224)> Public TargetName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public OSDeviceName As String
    Public SessionId As ISCSI_UNIQUE_SESSION_ID
    Public OSBusNumber As UInteger
    Public OSTargetNumber As UInteger
    Public LUNCount As UInteger
    Public LUNList As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class ISCSI_UNIQUE_SESSION_ID(ctypes.Structure):
    _fields_ = [
        ("AdapterUnique", ctypes.c_ulonglong),
        ("AdapterSpecific", ctypes.c_ulonglong),
    ]

class ISCSI_TARGET_MAPPINGW(ctypes.Structure):
    _fields_ = [
        ("InitiatorName", ctypes.c_wchar * 256),
        ("TargetName", ctypes.c_wchar * 224),
        ("OSDeviceName", ctypes.c_wchar * 260),
        ("SessionId", ISCSI_UNIQUE_SESSION_ID),
        ("OSBusNumber", wintypes.DWORD),
        ("OSTargetNumber", wintypes.DWORD),
        ("LUNCount", wintypes.DWORD),
        ("LUNList", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct ISCSI_UNIQUE_SESSION_ID {
    pub AdapterUnique: u64,
    pub AdapterSpecific: u64,
}

#[repr(C)]
pub struct ISCSI_TARGET_MAPPINGW {
    pub InitiatorName: [u16; 256],
    pub TargetName: [u16; 224],
    pub OSDeviceName: [u16; 260],
    pub SessionId: ISCSI_UNIQUE_SESSION_ID,
    pub OSBusNumber: u32,
    pub OSTargetNumber: u32,
    pub LUNCount: u32,
    pub LUNList: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type ISCSI_UNIQUE_SESSION_ID struct {
	AdapterUnique uint64
	AdapterSpecific uint64
}

type ISCSI_TARGET_MAPPINGW struct {
	InitiatorName [256]uint16
	TargetName [224]uint16
	OSDeviceName [260]uint16
	SessionId ISCSI_UNIQUE_SESSION_ID
	OSBusNumber uint32
	OSTargetNumber uint32
	LUNCount uint32
	LUNList uintptr
}
type
  ISCSI_UNIQUE_SESSION_ID = record
    AdapterUnique: UInt64;
    AdapterSpecific: UInt64;
  end;

  ISCSI_TARGET_MAPPINGW = record
    InitiatorName: array[0..255] of WideChar;
    TargetName: array[0..223] of WideChar;
    OSDeviceName: array[0..259] of WideChar;
    SessionId: ISCSI_UNIQUE_SESSION_ID;
    OSBusNumber: DWORD;
    OSTargetNumber: DWORD;
    LUNCount: DWORD;
    LUNList: Pointer;
  end;
const ISCSI_UNIQUE_SESSION_ID = extern struct {
    AdapterUnique: u64,
    AdapterSpecific: u64,
};

const ISCSI_TARGET_MAPPINGW = extern struct {
    InitiatorName: [256]u16,
    TargetName: [224]u16,
    OSDeviceName: [260]u16,
    SessionId: ISCSI_UNIQUE_SESSION_ID,
    OSBusNumber: u32,
    OSTargetNumber: u32,
    LUNCount: u32,
    LUNList: ?*anyopaque,
};
type
  ISCSI_UNIQUE_SESSION_ID {.bycopy.} = object
    AdapterUnique: uint64
    AdapterSpecific: uint64

  ISCSI_TARGET_MAPPINGW {.bycopy.} = object
    InitiatorName: array[256, uint16]
    TargetName: array[224, uint16]
    OSDeviceName: array[260, uint16]
    SessionId: ISCSI_UNIQUE_SESSION_ID
    OSBusNumber: uint32
    OSTargetNumber: uint32
    LUNCount: uint32
    LUNList: pointer
struct ISCSI_UNIQUE_SESSION_ID
{
    ulong AdapterUnique;
    ulong AdapterSpecific;
}

struct ISCSI_TARGET_MAPPINGW
{
    wchar[256] InitiatorName;
    wchar[224] TargetName;
    wchar[260] OSDeviceName;
    ISCSI_UNIQUE_SESSION_ID SessionId;
    uint OSBusNumber;
    uint OSTargetNumber;
    uint LUNCount;
    void* LUNList;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; ISCSI_TARGET_MAPPINGW サイズ: 1512 バイト(x86)
dim st, 378    ; 4byte整数×378(構造体サイズ 1512 / 4 切り上げ)
; InitiatorName : WCHAR (+0, 512byte)  varptr(st)+0 を基点に操作(512byte:入れ子/配列)
; TargetName : WCHAR (+512, 448byte)  varptr(st)+512 を基点に操作(448byte:入れ子/配列)
; OSDeviceName : WCHAR (+960, 520byte)  varptr(st)+960 を基点に操作(520byte:入れ子/配列)
; SessionId : ISCSI_UNIQUE_SESSION_ID (+1480, 16byte)  varptr(st)+1480 を基点に操作(16byte:入れ子/配列)
; OSBusNumber : DWORD (+1496, 4byte)  st.374 = 値  /  値 = st.374   (lpoke/lpeek も可)
; OSTargetNumber : DWORD (+1500, 4byte)  st.375 = 値  /  値 = st.375   (lpoke/lpeek も可)
; LUNCount : DWORD (+1504, 4byte)  st.376 = 値  /  値 = st.376   (lpoke/lpeek も可)
; LUNList : SCSI_LUN_LIST* (+1508, 4byte)  varptr(st)+1508 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ISCSI_TARGET_MAPPINGW サイズ: 1520 バイト(x64)
dim st, 380    ; 4byte整数×380(構造体サイズ 1520 / 4 切り上げ)
; InitiatorName : WCHAR (+0, 512byte)  varptr(st)+0 を基点に操作(512byte:入れ子/配列)
; TargetName : WCHAR (+512, 448byte)  varptr(st)+512 を基点に操作(448byte:入れ子/配列)
; OSDeviceName : WCHAR (+960, 520byte)  varptr(st)+960 を基点に操作(520byte:入れ子/配列)
; SessionId : ISCSI_UNIQUE_SESSION_ID (+1480, 16byte)  varptr(st)+1480 を基点に操作(16byte:入れ子/配列)
; OSBusNumber : DWORD (+1496, 4byte)  st.374 = 値  /  値 = st.374   (lpoke/lpeek も可)
; OSTargetNumber : DWORD (+1500, 4byte)  st.375 = 値  /  値 = st.375   (lpoke/lpeek も可)
; LUNCount : DWORD (+1504, 4byte)  st.376 = 値  /  値 = st.376   (lpoke/lpeek も可)
; LUNList : SCSI_LUN_LIST* (+1512, 8byte)  varptr(st)+1512 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global ISCSI_UNIQUE_SESSION_ID
    #field int64 AdapterUnique
    #field int64 AdapterSpecific
#endstruct

#defstruct global ISCSI_TARGET_MAPPINGW
    #field wchar InitiatorName 256
    #field wchar TargetName 224
    #field wchar OSDeviceName 260
    #field ISCSI_UNIQUE_SESSION_ID SessionId
    #field int OSBusNumber
    #field int OSTargetNumber
    #field int LUNCount
    #field intptr LUNList
#endstruct

stdim st, ISCSI_TARGET_MAPPINGW        ; NSTRUCT 変数を確保
st->OSBusNumber = 100
mes "OSBusNumber=" + st->OSBusNumber