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

IPsecSaContextAddOutbound1

関数
IPsec SAコンテキストに送信SAバンドルを追加する(バージョン1)。
DLLfwpuclnt.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

// fwpuclnt.dll
#include <windows.h>

DWORD IPsecSaContextAddOutbound1(
    FWPM_ENGINE_HANDLE engineHandle,
    ULONGLONG id,
    const IPSEC_SA_BUNDLE1* outboundBundle
);

パラメーター

名前方向
engineHandleFWPM_ENGINE_HANDLEin
idULONGLONGin
outboundBundleIPSEC_SA_BUNDLE1*in

戻り値の型: DWORD

各言語での呼び出し定義

// fwpuclnt.dll
#include <windows.h>

DWORD IPsecSaContextAddOutbound1(
    FWPM_ENGINE_HANDLE engineHandle,
    ULONGLONG id,
    const IPSEC_SA_BUNDLE1* outboundBundle
);
[DllImport("fwpuclnt.dll", ExactSpelling = true)]
static extern uint IPsecSaContextAddOutbound1(
    FWPM_ENGINE_HANDLE engineHandle,   // FWPM_ENGINE_HANDLE
    ulong id,   // ULONGLONG
    IntPtr outboundBundle   // IPSEC_SA_BUNDLE1*
);
<DllImport("fwpuclnt.dll", ExactSpelling:=True)>
Public Shared Function IPsecSaContextAddOutbound1(
    engineHandle As FWPM_ENGINE_HANDLE,   ' FWPM_ENGINE_HANDLE
    id As ULong,   ' ULONGLONG
    outboundBundle As IntPtr   ' IPSEC_SA_BUNDLE1*
) As UInteger
End Function
' engineHandle : FWPM_ENGINE_HANDLE
' id : ULONGLONG
' outboundBundle : IPSEC_SA_BUNDLE1*
Declare PtrSafe Function IPsecSaContextAddOutbound1 Lib "fwpuclnt" ( _
    ByVal engineHandle As LongPtr, _
    ByVal id As LongLong, _
    ByVal outboundBundle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IPsecSaContextAddOutbound1 = ctypes.windll.fwpuclnt.IPsecSaContextAddOutbound1
IPsecSaContextAddOutbound1.restype = wintypes.DWORD
IPsecSaContextAddOutbound1.argtypes = [
    FWPM_ENGINE_HANDLE,  # engineHandle : FWPM_ENGINE_HANDLE
    ctypes.c_ulonglong,  # id : ULONGLONG
    ctypes.c_void_p,  # outboundBundle : IPSEC_SA_BUNDLE1*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('fwpuclnt.dll')
IPsecSaContextAddOutbound1 = Fiddle::Function.new(
  lib['IPsecSaContextAddOutbound1'],
  [
    Fiddle::TYPE_VOIDP,  # engineHandle : FWPM_ENGINE_HANDLE
    -Fiddle::TYPE_LONG_LONG,  # id : ULONGLONG
    Fiddle::TYPE_VOIDP,  # outboundBundle : IPSEC_SA_BUNDLE1*
  ],
  -Fiddle::TYPE_INT)
#[link(name = "fwpuclnt")]
extern "system" {
    fn IPsecSaContextAddOutbound1(
        engineHandle: FWPM_ENGINE_HANDLE,  // FWPM_ENGINE_HANDLE
        id: u64,  // ULONGLONG
        outboundBundle: *const IPSEC_SA_BUNDLE1  // IPSEC_SA_BUNDLE1*
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("fwpuclnt.dll")]
public static extern uint IPsecSaContextAddOutbound1(FWPM_ENGINE_HANDLE engineHandle, ulong id, IntPtr outboundBundle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'fwpuclnt_IPsecSaContextAddOutbound1' -Namespace Win32 -PassThru
# $api::IPsecSaContextAddOutbound1(engineHandle, id, outboundBundle)
#uselib "fwpuclnt.dll"
#func global IPsecSaContextAddOutbound1 "IPsecSaContextAddOutbound1" sptr, sptr, sptr
; IPsecSaContextAddOutbound1 engineHandle, id, varptr(outboundBundle)   ; 戻り値は stat
; engineHandle : FWPM_ENGINE_HANDLE -> "sptr"
; id : ULONGLONG -> "sptr"
; outboundBundle : IPSEC_SA_BUNDLE1* -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "fwpuclnt.dll"
#cfunc global IPsecSaContextAddOutbound1 "IPsecSaContextAddOutbound1" int, int64, var
; res = IPsecSaContextAddOutbound1(engineHandle, id, outboundBundle)
; engineHandle : FWPM_ENGINE_HANDLE -> "int"
; id : ULONGLONG -> "int64"
; outboundBundle : IPSEC_SA_BUNDLE1* -> "var"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD IPsecSaContextAddOutbound1(FWPM_ENGINE_HANDLE engineHandle, ULONGLONG id, IPSEC_SA_BUNDLE1* outboundBundle)
#uselib "fwpuclnt.dll"
#cfunc global IPsecSaContextAddOutbound1 "IPsecSaContextAddOutbound1" int, int64, var
; res = IPsecSaContextAddOutbound1(engineHandle, id, outboundBundle)
; engineHandle : FWPM_ENGINE_HANDLE -> "int"
; id : ULONGLONG -> "int64"
; outboundBundle : IPSEC_SA_BUNDLE1* -> "var"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	fwpuclnt = windows.NewLazySystemDLL("fwpuclnt.dll")
	procIPsecSaContextAddOutbound1 = fwpuclnt.NewProc("IPsecSaContextAddOutbound1")
)

// engineHandle (FWPM_ENGINE_HANDLE), id (ULONGLONG), outboundBundle (IPSEC_SA_BUNDLE1*)
r1, _, err := procIPsecSaContextAddOutbound1.Call(
	uintptr(engineHandle),
	uintptr(id),
	uintptr(outboundBundle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function IPsecSaContextAddOutbound1(
  engineHandle: FWPM_ENGINE_HANDLE;   // FWPM_ENGINE_HANDLE
  id: UInt64;   // ULONGLONG
  outboundBundle: Pointer   // IPSEC_SA_BUNDLE1*
): DWORD; stdcall;
  external 'fwpuclnt.dll' name 'IPsecSaContextAddOutbound1';
result := DllCall("fwpuclnt\IPsecSaContextAddOutbound1"
    , "Ptr", engineHandle   ; FWPM_ENGINE_HANDLE
    , "Int64", id   ; ULONGLONG
    , "Ptr", outboundBundle   ; IPSEC_SA_BUNDLE1*
    , "UInt")   ; return: DWORD
●IPsecSaContextAddOutbound1(engineHandle, id, outboundBundle) = DLL("fwpuclnt.dll", "dword IPsecSaContextAddOutbound1(void*, qword, void*)")
# 呼び出し: IPsecSaContextAddOutbound1(engineHandle, id, outboundBundle)
# engineHandle : FWPM_ENGINE_HANDLE -> "void*"
# id : ULONGLONG -> "qword"
# outboundBundle : IPSEC_SA_BUNDLE1* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。