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

ISCSI_CONNECTION_INFOW

構造体
サイズx64: 40 バイト / x86: 32 バイト

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

フィールド

フィールドサイズx64x86説明
ConnectionIdISCSI_UNIQUE_SESSION_ID16+0+0この接続を一意に識別するISCSI_UNIQUE_SESSION_ID。
InitiatorAddressLPWSTR8/4+16+16イニシエータ側のIPアドレス文字列へのポインタ。
TargetAddressLPWSTR8/4+24+20ターゲット側のIPアドレス文字列へのポインタ。
InitiatorSocketWORD2+32+24イニシエータ側のTCPポート番号。
TargetSocketWORD2+34+26ターゲット側のTCPポート番号。
CIDBYTE2+36+28iSCSI接続識別子(Connection ID)。

各言語での定義

#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_CONNECTION_INFOW  (x64 40 / x86 32 バイト)
typedef struct ISCSI_CONNECTION_INFOW {
    ISCSI_UNIQUE_SESSION_ID ConnectionId;
    LPWSTR InitiatorAddress;
    LPWSTR TargetAddress;
    WORD InitiatorSocket;
    WORD TargetSocket;
    BYTE CID[2];
} ISCSI_CONNECTION_INFOW;
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_CONNECTION_INFOW
{
    public ISCSI_UNIQUE_SESSION_ID ConnectionId;
    public IntPtr InitiatorAddress;
    public IntPtr TargetAddress;
    public ushort InitiatorSocket;
    public ushort TargetSocket;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] CID;
}
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_CONNECTION_INFOW
    Public ConnectionId As ISCSI_UNIQUE_SESSION_ID
    Public InitiatorAddress As IntPtr
    Public TargetAddress As IntPtr
    Public InitiatorSocket As UShort
    Public TargetSocket As UShort
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public CID() As Byte
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_CONNECTION_INFOW(ctypes.Structure):
    _fields_ = [
        ("ConnectionId", ISCSI_UNIQUE_SESSION_ID),
        ("InitiatorAddress", ctypes.c_void_p),
        ("TargetAddress", ctypes.c_void_p),
        ("InitiatorSocket", ctypes.c_ushort),
        ("TargetSocket", ctypes.c_ushort),
        ("CID", ctypes.c_ubyte * 2),
    ]
#[repr(C)]
pub struct ISCSI_UNIQUE_SESSION_ID {
    pub AdapterUnique: u64,
    pub AdapterSpecific: u64,
}

#[repr(C)]
pub struct ISCSI_CONNECTION_INFOW {
    pub ConnectionId: ISCSI_UNIQUE_SESSION_ID,
    pub InitiatorAddress: *mut core::ffi::c_void,
    pub TargetAddress: *mut core::ffi::c_void,
    pub InitiatorSocket: u16,
    pub TargetSocket: u16,
    pub CID: [u8; 2],
}
import "golang.org/x/sys/windows"

type ISCSI_UNIQUE_SESSION_ID struct {
	AdapterUnique uint64
	AdapterSpecific uint64
}

type ISCSI_CONNECTION_INFOW struct {
	ConnectionId ISCSI_UNIQUE_SESSION_ID
	InitiatorAddress uintptr
	TargetAddress uintptr
	InitiatorSocket uint16
	TargetSocket uint16
	CID [2]byte
}
type
  ISCSI_UNIQUE_SESSION_ID = record
    AdapterUnique: UInt64;
    AdapterSpecific: UInt64;
  end;

  ISCSI_CONNECTION_INFOW = record
    ConnectionId: ISCSI_UNIQUE_SESSION_ID;
    InitiatorAddress: Pointer;
    TargetAddress: Pointer;
    InitiatorSocket: Word;
    TargetSocket: Word;
    CID: array[0..1] of Byte;
  end;
const ISCSI_UNIQUE_SESSION_ID = extern struct {
    AdapterUnique: u64,
    AdapterSpecific: u64,
};

const ISCSI_CONNECTION_INFOW = extern struct {
    ConnectionId: ISCSI_UNIQUE_SESSION_ID,
    InitiatorAddress: ?*anyopaque,
    TargetAddress: ?*anyopaque,
    InitiatorSocket: u16,
    TargetSocket: u16,
    CID: [2]u8,
};
type
  ISCSI_UNIQUE_SESSION_ID {.bycopy.} = object
    AdapterUnique: uint64
    AdapterSpecific: uint64

  ISCSI_CONNECTION_INFOW {.bycopy.} = object
    ConnectionId: ISCSI_UNIQUE_SESSION_ID
    InitiatorAddress: pointer
    TargetAddress: pointer
    InitiatorSocket: uint16
    TargetSocket: uint16
    CID: array[2, uint8]
struct ISCSI_UNIQUE_SESSION_ID
{
    ulong AdapterUnique;
    ulong AdapterSpecific;
}

struct ISCSI_CONNECTION_INFOW
{
    ISCSI_UNIQUE_SESSION_ID ConnectionId;
    void* InitiatorAddress;
    void* TargetAddress;
    ushort InitiatorSocket;
    ushort TargetSocket;
    ubyte[2] CID;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; ISCSI_CONNECTION_INFOW サイズ: 32 バイト(x86)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; ConnectionId : ISCSI_UNIQUE_SESSION_ID (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; InitiatorAddress : LPWSTR (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; TargetAddress : LPWSTR (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; InitiatorSocket : WORD (+24, 2byte)  wpoke st,24,値  /  値 = wpeek(st,24)
; TargetSocket : WORD (+26, 2byte)  wpoke st,26,値  /  値 = wpeek(st,26)
; CID : BYTE (+28, 2byte)  varptr(st)+28 を基点に操作(2byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ISCSI_CONNECTION_INFOW サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; ConnectionId : ISCSI_UNIQUE_SESSION_ID (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; InitiatorAddress : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; TargetAddress : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; InitiatorSocket : WORD (+32, 2byte)  wpoke st,32,値  /  値 = wpeek(st,32)
; TargetSocket : WORD (+34, 2byte)  wpoke st,34,値  /  値 = wpeek(st,34)
; CID : BYTE (+36, 2byte)  varptr(st)+36 を基点に操作(2byte:入れ子/配列)
; ※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_CONNECTION_INFOW
    #field ISCSI_UNIQUE_SESSION_ID ConnectionId
    #field intptr InitiatorAddress
    #field intptr TargetAddress
    #field short InitiatorSocket
    #field short TargetSocket
    #field byte CID 2
#endstruct

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