Win32 API 日本語リファレンス
ホームNetworking.WinSock › DL_TUNNEL_ADDRESS

DL_TUNNEL_ADDRESS

構造体
サイズx64: 24 バイト / x86: 12 バイト

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

フィールド

フィールドサイズx64x86説明
CompartmentIdCOMPARTMENT_ID4+0+0ネットワークコンパートメントを識別するCOMPARTMENT_ID。
ScopeIdSCOPE_ID8/4+8+4アドレスのスコープを識別するSCOPE_ID。
IpAddressBYTE1+16+8トンネル先のIPアドレスを表すバイト列の先頭。

各言語での定義

#include <windows.h>

// SCOPE_ID  (x64 8 / x86 4 バイト)
typedef struct SCOPE_ID {
    _Anonymous_e__Union Anonymous;
} SCOPE_ID;

// DL_TUNNEL_ADDRESS  (x64 24 / x86 12 バイト)
typedef struct DL_TUNNEL_ADDRESS {
    COMPARTMENT_ID CompartmentId;
    SCOPE_ID ScopeId;
    BYTE IpAddress[1];
} DL_TUNNEL_ADDRESS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SCOPE_ID
{
    public _Anonymous_e__Union Anonymous;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DL_TUNNEL_ADDRESS
{
    public int CompartmentId;
    public SCOPE_ID ScopeId;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] IpAddress;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SCOPE_ID
    Public Anonymous As _Anonymous_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DL_TUNNEL_ADDRESS
    Public CompartmentId As Integer
    Public ScopeId As SCOPE_ID
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public IpAddress() As Byte
End Structure
import ctypes
from ctypes import wintypes

class SCOPE_ID(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Union),
    ]

class DL_TUNNEL_ADDRESS(ctypes.Structure):
    _fields_ = [
        ("CompartmentId", ctypes.c_int),
        ("ScopeId", SCOPE_ID),
        ("IpAddress", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct SCOPE_ID {
    pub Anonymous: _Anonymous_e__Union,
}

#[repr(C)]
pub struct DL_TUNNEL_ADDRESS {
    pub CompartmentId: i32,
    pub ScopeId: SCOPE_ID,
    pub IpAddress: [u8; 1],
}
import "golang.org/x/sys/windows"

type SCOPE_ID struct {
	Anonymous _Anonymous_e__Union
}

type DL_TUNNEL_ADDRESS struct {
	CompartmentId int32
	ScopeId SCOPE_ID
	IpAddress [1]byte
}
type
  SCOPE_ID = record
    Anonymous: _Anonymous_e__Union;
  end;

  DL_TUNNEL_ADDRESS = record
    CompartmentId: Integer;
    ScopeId: SCOPE_ID;
    IpAddress: array[0..0] of Byte;
  end;
const SCOPE_ID = extern struct {
    Anonymous: _Anonymous_e__Union,
};

const DL_TUNNEL_ADDRESS = extern struct {
    CompartmentId: i32,
    ScopeId: SCOPE_ID,
    IpAddress: [1]u8,
};
type
  SCOPE_ID {.bycopy.} = object
    Anonymous: _Anonymous_e__Union

  DL_TUNNEL_ADDRESS {.bycopy.} = object
    CompartmentId: int32
    ScopeId: SCOPE_ID
    IpAddress: array[1, uint8]
struct SCOPE_ID
{
    _Anonymous_e__Union Anonymous;
}

struct DL_TUNNEL_ADDRESS
{
    int CompartmentId;
    SCOPE_ID ScopeId;
    ubyte[1] IpAddress;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DL_TUNNEL_ADDRESS サイズ: 12 バイト(x86)
dim st, 3    ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; CompartmentId : COMPARTMENT_ID (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ScopeId : SCOPE_ID (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; IpAddress : BYTE (+8, 1byte)  varptr(st)+8 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DL_TUNNEL_ADDRESS サイズ: 24 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; CompartmentId : COMPARTMENT_ID (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ScopeId : SCOPE_ID (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; IpAddress : BYTE (+16, 1byte)  varptr(st)+16 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global SCOPE_ID
    #field byte Anonymous 8
#endstruct

#defstruct global DL_TUNNEL_ADDRESS
    #field int CompartmentId
    #field SCOPE_ID ScopeId
    #field byte IpAddress 1
#endstruct

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