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

ISCSI_TARGET_MAPPINGA

構造体
サイズx64: 784 バイト / x86: 776 バイト

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

フィールド

フィールドサイズx64x86説明
InitiatorNameCHAR256+0+0イニシエータ名(iSCSI修飾名)を保持する固定長CHAR配列(ANSI)。
TargetNameCHAR224+256+256接続先ターゲット名(iSCSI修飾名)を保持する固定長CHAR配列(ANSI)。
OSDeviceNameCHAR260+480+480OS上のデバイス名を保持する固定長CHAR配列(ANSI)。
SessionIdISCSI_UNIQUE_SESSION_ID16+744+744このマッピングが属するセッションの一意識別子。
OSBusNumberDWORD4+760+760OSがこのデバイスに割り当てたSCSIバス番号。
OSTargetNumberDWORD4+764+764OSがこのデバイスに割り当てたSCSIターゲット番号。
LUNCountDWORD4+768+768LUNList配列に含まれるLUNエントリ数。
LUNListSCSI_LUN_LIST*8/4+776+772OS LUNとターゲットLUNの対応を並べたSCSI_LUN_LIST配列へのポインタ。

各言語での定義

#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_MAPPINGA  (x64 784 / x86 776 バイト)
typedef struct ISCSI_TARGET_MAPPINGA {
    CHAR InitiatorName[256];
    CHAR TargetName[224];
    CHAR OSDeviceName[260];
    ISCSI_UNIQUE_SESSION_ID SessionId;
    DWORD OSBusNumber;
    DWORD OSTargetNumber;
    DWORD LUNCount;
    SCSI_LUN_LIST* LUNList;
} ISCSI_TARGET_MAPPINGA;
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_MAPPINGA
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public sbyte[] InitiatorName;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 224)] public sbyte[] TargetName;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)] public sbyte[] 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_MAPPINGA
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Public InitiatorName() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=224)> Public TargetName() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=260)> Public OSDeviceName() As SByte
    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_MAPPINGA(ctypes.Structure):
    _fields_ = [
        ("InitiatorName", ctypes.c_byte * 256),
        ("TargetName", ctypes.c_byte * 224),
        ("OSDeviceName", ctypes.c_byte * 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_MAPPINGA {
    pub InitiatorName: [i8; 256],
    pub TargetName: [i8; 224],
    pub OSDeviceName: [i8; 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_MAPPINGA struct {
	InitiatorName [256]int8
	TargetName [224]int8
	OSDeviceName [260]int8
	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_MAPPINGA = record
    InitiatorName: array[0..255] of Shortint;
    TargetName: array[0..223] of Shortint;
    OSDeviceName: array[0..259] of Shortint;
    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_MAPPINGA = extern struct {
    InitiatorName: [256]i8,
    TargetName: [224]i8,
    OSDeviceName: [260]i8,
    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_MAPPINGA {.bycopy.} = object
    InitiatorName: array[256, int8]
    TargetName: array[224, int8]
    OSDeviceName: array[260, int8]
    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_MAPPINGA
{
    byte[256] InitiatorName;
    byte[224] TargetName;
    byte[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_MAPPINGA サイズ: 776 バイト(x86)
dim st, 194    ; 4byte整数×194(構造体サイズ 776 / 4 切り上げ)
; InitiatorName : CHAR (+0, 256byte)  varptr(st)+0 を基点に操作(256byte:入れ子/配列)
; TargetName : CHAR (+256, 224byte)  varptr(st)+256 を基点に操作(224byte:入れ子/配列)
; OSDeviceName : CHAR (+480, 260byte)  varptr(st)+480 を基点に操作(260byte:入れ子/配列)
; SessionId : ISCSI_UNIQUE_SESSION_ID (+744, 16byte)  varptr(st)+744 を基点に操作(16byte:入れ子/配列)
; OSBusNumber : DWORD (+760, 4byte)  st.190 = 値  /  値 = st.190   (lpoke/lpeek も可)
; OSTargetNumber : DWORD (+764, 4byte)  st.191 = 値  /  値 = st.191   (lpoke/lpeek も可)
; LUNCount : DWORD (+768, 4byte)  st.192 = 値  /  値 = st.192   (lpoke/lpeek も可)
; LUNList : SCSI_LUN_LIST* (+772, 4byte)  varptr(st)+772 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ISCSI_TARGET_MAPPINGA サイズ: 784 バイト(x64)
dim st, 196    ; 4byte整数×196(構造体サイズ 784 / 4 切り上げ)
; InitiatorName : CHAR (+0, 256byte)  varptr(st)+0 を基点に操作(256byte:入れ子/配列)
; TargetName : CHAR (+256, 224byte)  varptr(st)+256 を基点に操作(224byte:入れ子/配列)
; OSDeviceName : CHAR (+480, 260byte)  varptr(st)+480 を基点に操作(260byte:入れ子/配列)
; SessionId : ISCSI_UNIQUE_SESSION_ID (+744, 16byte)  varptr(st)+744 を基点に操作(16byte:入れ子/配列)
; OSBusNumber : DWORD (+760, 4byte)  st.190 = 値  /  値 = st.190   (lpoke/lpeek も可)
; OSTargetNumber : DWORD (+764, 4byte)  st.191 = 値  /  値 = st.191   (lpoke/lpeek も可)
; LUNCount : DWORD (+768, 4byte)  st.192 = 値  /  値 = st.192   (lpoke/lpeek も可)
; LUNList : SCSI_LUN_LIST* (+776, 8byte)  varptr(st)+776 を基点に操作(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_MAPPINGA
    #field byte InitiatorName 256
    #field byte TargetName 224
    #field byte 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_MAPPINGA        ; NSTRUCT 変数を確保
st->OSBusNumber = 100
mes "OSBusNumber=" + st->OSBusNumber