Win32 API 日本語リファレンス
ホームNetworkManagement.WindowsFilteringPlatform › IPSEC_TUNNEL_POLICY0

IPSEC_TUNNEL_POLICY0

構造体
サイズx64: 72 バイト / x86: 60 バイト

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

フィールド

フィールドサイズx64x86説明
flagsIPSEC_POLICY_FLAG4+0+0IPsecトンネルポリシーの動作を制御するフラグ。
numIpsecProposalsDWORD4+4+4ipsecProposals配列の要素数。
ipsecProposalsIPSEC_PROPOSAL0*8/4+8+8IPsecプロポーザルの配列へのポインター。
tunnelEndpointsIPSEC_TUNNEL_ENDPOINTS036+16+12トンネルのローカル/リモートエンドポイント。
saIdleTimeoutIPSEC_SA_IDLE_TIMEOUT08+52+48SAのアイドルタイムアウト設定。
emPolicyIKEEXT_EM_POLICY0*8/4+64+56拡張モードポリシーへのポインター。NULL可。

各言語での定義

#include <windows.h>

// IPSEC_TUNNEL_ENDPOINTS0  (x64 36 / x86 36 バイト)
typedef struct IPSEC_TUNNEL_ENDPOINTS0 {
    FWP_IP_VERSION ipVersion;
    _Anonymous1_e__Union Anonymous1;
    _Anonymous2_e__Union Anonymous2;
} IPSEC_TUNNEL_ENDPOINTS0;

// IPSEC_SA_IDLE_TIMEOUT0  (x64 8 / x86 8 バイト)
typedef struct IPSEC_SA_IDLE_TIMEOUT0 {
    DWORD idleTimeoutSeconds;
    DWORD idleTimeoutSecondsFailOver;
} IPSEC_SA_IDLE_TIMEOUT0;

// IPSEC_TUNNEL_POLICY0  (x64 72 / x86 60 バイト)
typedef struct IPSEC_TUNNEL_POLICY0 {
    IPSEC_POLICY_FLAG flags;
    DWORD numIpsecProposals;
    IPSEC_PROPOSAL0* ipsecProposals;
    IPSEC_TUNNEL_ENDPOINTS0 tunnelEndpoints;
    IPSEC_SA_IDLE_TIMEOUT0 saIdleTimeout;
    IKEEXT_EM_POLICY0* emPolicy;
} IPSEC_TUNNEL_POLICY0;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IPSEC_TUNNEL_ENDPOINTS0
{
    public int ipVersion;
    public _Anonymous1_e__Union Anonymous1;
    public _Anonymous2_e__Union Anonymous2;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IPSEC_SA_IDLE_TIMEOUT0
{
    public uint idleTimeoutSeconds;
    public uint idleTimeoutSecondsFailOver;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IPSEC_TUNNEL_POLICY0
{
    public uint flags;
    public uint numIpsecProposals;
    public IntPtr ipsecProposals;
    public IPSEC_TUNNEL_ENDPOINTS0 tunnelEndpoints;
    public IPSEC_SA_IDLE_TIMEOUT0 saIdleTimeout;
    public IntPtr emPolicy;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IPSEC_TUNNEL_ENDPOINTS0
    Public ipVersion As Integer
    Public Anonymous1 As _Anonymous1_e__Union
    Public Anonymous2 As _Anonymous2_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IPSEC_SA_IDLE_TIMEOUT0
    Public idleTimeoutSeconds As UInteger
    Public idleTimeoutSecondsFailOver As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IPSEC_TUNNEL_POLICY0
    Public flags As UInteger
    Public numIpsecProposals As UInteger
    Public ipsecProposals As IntPtr
    Public tunnelEndpoints As IPSEC_TUNNEL_ENDPOINTS0
    Public saIdleTimeout As IPSEC_SA_IDLE_TIMEOUT0
    Public emPolicy As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class IPSEC_TUNNEL_ENDPOINTS0(ctypes.Structure):
    _fields_ = [
        ("ipVersion", ctypes.c_int),
        ("Anonymous1", _Anonymous1_e__Union),
        ("Anonymous2", _Anonymous2_e__Union),
    ]

class IPSEC_SA_IDLE_TIMEOUT0(ctypes.Structure):
    _fields_ = [
        ("idleTimeoutSeconds", wintypes.DWORD),
        ("idleTimeoutSecondsFailOver", wintypes.DWORD),
    ]

class IPSEC_TUNNEL_POLICY0(ctypes.Structure):
    _fields_ = [
        ("flags", wintypes.DWORD),
        ("numIpsecProposals", wintypes.DWORD),
        ("ipsecProposals", ctypes.c_void_p),
        ("tunnelEndpoints", IPSEC_TUNNEL_ENDPOINTS0),
        ("saIdleTimeout", IPSEC_SA_IDLE_TIMEOUT0),
        ("emPolicy", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct IPSEC_TUNNEL_ENDPOINTS0 {
    pub ipVersion: i32,
    pub Anonymous1: _Anonymous1_e__Union,
    pub Anonymous2: _Anonymous2_e__Union,
}

#[repr(C)]
pub struct IPSEC_SA_IDLE_TIMEOUT0 {
    pub idleTimeoutSeconds: u32,
    pub idleTimeoutSecondsFailOver: u32,
}

#[repr(C)]
pub struct IPSEC_TUNNEL_POLICY0 {
    pub flags: u32,
    pub numIpsecProposals: u32,
    pub ipsecProposals: *mut core::ffi::c_void,
    pub tunnelEndpoints: IPSEC_TUNNEL_ENDPOINTS0,
    pub saIdleTimeout: IPSEC_SA_IDLE_TIMEOUT0,
    pub emPolicy: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type IPSEC_TUNNEL_ENDPOINTS0 struct {
	ipVersion int32
	Anonymous1 _Anonymous1_e__Union
	Anonymous2 _Anonymous2_e__Union
}

type IPSEC_SA_IDLE_TIMEOUT0 struct {
	idleTimeoutSeconds uint32
	idleTimeoutSecondsFailOver uint32
}

type IPSEC_TUNNEL_POLICY0 struct {
	flags uint32
	numIpsecProposals uint32
	ipsecProposals uintptr
	tunnelEndpoints IPSEC_TUNNEL_ENDPOINTS0
	saIdleTimeout IPSEC_SA_IDLE_TIMEOUT0
	emPolicy uintptr
}
type
  IPSEC_TUNNEL_ENDPOINTS0 = record
    ipVersion: Integer;
    Anonymous1: _Anonymous1_e__Union;
    Anonymous2: _Anonymous2_e__Union;
  end;

  IPSEC_SA_IDLE_TIMEOUT0 = record
    idleTimeoutSeconds: DWORD;
    idleTimeoutSecondsFailOver: DWORD;
  end;

  IPSEC_TUNNEL_POLICY0 = record
    flags: DWORD;
    numIpsecProposals: DWORD;
    ipsecProposals: Pointer;
    tunnelEndpoints: IPSEC_TUNNEL_ENDPOINTS0;
    saIdleTimeout: IPSEC_SA_IDLE_TIMEOUT0;
    emPolicy: Pointer;
  end;
const IPSEC_TUNNEL_ENDPOINTS0 = extern struct {
    ipVersion: i32,
    Anonymous1: _Anonymous1_e__Union,
    Anonymous2: _Anonymous2_e__Union,
};

const IPSEC_SA_IDLE_TIMEOUT0 = extern struct {
    idleTimeoutSeconds: u32,
    idleTimeoutSecondsFailOver: u32,
};

const IPSEC_TUNNEL_POLICY0 = extern struct {
    flags: u32,
    numIpsecProposals: u32,
    ipsecProposals: ?*anyopaque,
    tunnelEndpoints: IPSEC_TUNNEL_ENDPOINTS0,
    saIdleTimeout: IPSEC_SA_IDLE_TIMEOUT0,
    emPolicy: ?*anyopaque,
};
type
  IPSEC_TUNNEL_ENDPOINTS0 {.bycopy.} = object
    ipVersion: int32
    Anonymous1: _Anonymous1_e__Union
    Anonymous2: _Anonymous2_e__Union

  IPSEC_SA_IDLE_TIMEOUT0 {.bycopy.} = object
    idleTimeoutSeconds: uint32
    idleTimeoutSecondsFailOver: uint32

  IPSEC_TUNNEL_POLICY0 {.bycopy.} = object
    flags: uint32
    numIpsecProposals: uint32
    ipsecProposals: pointer
    tunnelEndpoints: IPSEC_TUNNEL_ENDPOINTS0
    saIdleTimeout: IPSEC_SA_IDLE_TIMEOUT0
    emPolicy: pointer
struct IPSEC_TUNNEL_ENDPOINTS0
{
    int ipVersion;
    _Anonymous1_e__Union Anonymous1;
    _Anonymous2_e__Union Anonymous2;
}

struct IPSEC_SA_IDLE_TIMEOUT0
{
    uint idleTimeoutSeconds;
    uint idleTimeoutSecondsFailOver;
}

struct IPSEC_TUNNEL_POLICY0
{
    uint flags;
    uint numIpsecProposals;
    void* ipsecProposals;
    IPSEC_TUNNEL_ENDPOINTS0 tunnelEndpoints;
    IPSEC_SA_IDLE_TIMEOUT0 saIdleTimeout;
    void* emPolicy;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; IPSEC_TUNNEL_POLICY0 サイズ: 60 バイト(x86)
dim st, 15    ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; flags : IPSEC_POLICY_FLAG (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; numIpsecProposals : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ipsecProposals : IPSEC_PROPOSAL0* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; tunnelEndpoints : IPSEC_TUNNEL_ENDPOINTS0 (+12, 36byte)  varptr(st)+12 を基点に操作(36byte:入れ子/配列)
; saIdleTimeout : IPSEC_SA_IDLE_TIMEOUT0 (+48, 8byte)  varptr(st)+48 を基点に操作(8byte:入れ子/配列)
; emPolicy : IKEEXT_EM_POLICY0* (+56, 4byte)  varptr(st)+56 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IPSEC_TUNNEL_POLICY0 サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; flags : IPSEC_POLICY_FLAG (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; numIpsecProposals : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ipsecProposals : IPSEC_PROPOSAL0* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; tunnelEndpoints : IPSEC_TUNNEL_ENDPOINTS0 (+16, 36byte)  varptr(st)+16 を基点に操作(36byte:入れ子/配列)
; saIdleTimeout : IPSEC_SA_IDLE_TIMEOUT0 (+52, 8byte)  varptr(st)+52 を基点に操作(8byte:入れ子/配列)
; emPolicy : IKEEXT_EM_POLICY0* (+64, 8byte)  varptr(st)+64 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global IPSEC_TUNNEL_ENDPOINTS0
    #field int ipVersion
    #field byte Anonymous1 16
    #field byte Anonymous2 16
#endstruct

#defstruct global IPSEC_SA_IDLE_TIMEOUT0
    #field int idleTimeoutSeconds
    #field int idleTimeoutSecondsFailOver
#endstruct

#defstruct global IPSEC_TUNNEL_POLICY0
    #field int flags
    #field int numIpsecProposals
    #field intptr ipsecProposals
    #field IPSEC_TUNNEL_ENDPOINTS0 tunnelEndpoints
    #field IPSEC_SA_IDLE_TIMEOUT0 saIdleTimeout
    #field intptr emPolicy
#endstruct

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