SetPerTcp6ConnectionEStats
関数シグネチャ
// IPHLPAPI.dll
#include <windows.h>
DWORD SetPerTcp6ConnectionEStats(
MIB_TCP6ROW* Row,
TCP_ESTATS_TYPE EstatsType,
BYTE* Rw,
DWORD RwVersion,
DWORD RwSize,
DWORD Offset
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Row | MIB_TCP6ROW* | in | IPv6 TCP 接続を表す MIB_TCP6ROW 構造体へのポインターです。 | ||||||||||||||||||
| EstatsType | TCP_ESTATS_TYPE | in | 設定する TCP 拡張統計の種類です。このパラメーターによって、Rw パラメーターに期待されるデータと情報の形式が決まります。 このパラメーターには、Tcpestats.h ヘッダーファイルで定義されている TCP_ESTATS_TYPE 列挙型の値のいずれか 1 つを指定できます。
| ||||||||||||||||||
| Rw | BYTE* | in | 設定する読み取り/書き込み情報を格納したバッファーへのポインターです。このバッファーには、各構造体メンバーをどのように更新するかを指定する TCP_BOOLEAN_OPTIONAL 列挙型の値を、メンバーごとに格納する必要があります。 | ||||||||||||||||||
| RwVersion | DWORD | in | 設定する読み取り/書き込み情報のバージョンです。Windows Vista、Windows Server 2008、および Windows 7 では、このパラメーターを 0 に設定する必要があります。 | ||||||||||||||||||
| RwSize | DWORD | in | Rw パラメーターが指すバッファーのサイズ (バイト単位) です。 | ||||||||||||||||||
| Offset | DWORD | in | Rw パラメーターが指す構造体内の、設定対象のメンバーへのオフセット (バイト単位) です。このパラメーターは現在使用されておらず、0 に設定する必要があります。 |
戻り値の型: DWORD
公式ドキュメント
IPv6 TCP 接続の読み取り/書き込み情報に値を設定します。この関数は、IPv6 TCP 接続の拡張統計を有効または無効にするために使用します。
戻り値
関数が成功した場合、戻り値は NO_ERROR です。
関数が失敗した場合、戻り値は次のいずれかのエラーコードになります。
| Return code | Description |
|---|---|
| アクセスが拒否されました。このエラーは、次のような複数の条件で返されます。すなわち、ユーザーがローカルコンピューター上で必要な管理者権限を持っていない場合、またはアプリケーションが組み込み Administrator として昇格されたシェル (RunAs administrator) で実行されていない場合です。 | |
| パラメーターが正しくありません。このエラーは、Row パラメーターが NULL ポインターの場合に返されます。 | |
| 指定されたユーザーバッファーが、要求された操作に対して無効です。このエラーは、Row パラメーターが NULL ポインターで、かつ RwSize パラメーターが 0 以外の場合に返されます。 | |
| 要求されたエントリが見つかりませんでした。このエラーは、Row パラメーターで指定された TCP 接続が見つからなかった場合に返されます。 | |
| 要求はサポートされていません。このエラーは、RwVersion または Offset パラメーターが 0 に設定されていない場合に返されます。 | |
|
返されたエラーに対応するメッセージ文字列を取得するには、FormatMessage を使用してください。 |
解説(Remarks)
SetPerTcp6ConnectionEStats 関数は、Windows Vista 以降で定義されています。
SetPerTcp6ConnectionEStats 関数は、Row パラメーターで渡された IPv6 TCP 接続の拡張統計を有効または無効にするために使用します。TCP 接続の拡張統計は、既定では無効になっています。
SetPerTcp6ConnectionEStats 関数は、IPv6 TCP 接続の拡張統計に関する読み取り/書き込み情報内のメンバーの値を設定するために使用します。設定する構造体の型と形式は、EstatsType パラメーターで指定します。Rw パラメーターには、渡される構造体へのポインターが格納されます。この構造体内で設定するメンバーは、Offset パラメーターで指定します。Rw パラメーターが指す構造体内のすべてのメンバーを指定する必要があります。
現在サポートされている TCP 接続統計のバージョンはバージョン 0 のみです。したがって、SetPerTcp6ConnectionEStats に渡す RwVersion パラメーターは 0 に設定する必要があります。
この関数に渡す Rw パラメーターが指す構造体は、EstatsType パラメーターに渡される列挙値によって異なります。次の表は、各 EstatsType パラメーターの型に対して Rw パラメーターで渡すべき構造体の型を示しています。
| EstatsType | Structure pointed to by Rw |
|---|---|
| TcpConnectionEstatsData | TCP_ESTATS_DATA_RW_v0 |
| TcpConnectionEstatsSndCong | TCP_ESTATS_SND_CONG_RW_v0 |
| TcpConnectionEstatsPath | TCP_ESTATS_PATH_RW_v0 |
| TcpConnectionEstatsSendBuff | TCP_ESTATS_SEND_BUFF_RW_v0 |
| TcpConnectionEstatsRec | TCP_ESTATS_REC_RW_v0 |
| TcpConnectionEstatsObsRec | TCP_ESTATS_OBS_REC_RW_v0 |
| TcpConnectionEstatsBandwidth | TCP_ESTATS_BANDWIDTH_RW_v0 |
| TcpConnectionEstatsFineRtt | TCP_ESTATS_FINE_RTT_RW_v0 |
Offset パラメーターは現在使用されていません。Rw パラメーターが指す可能性のある構造体は、TCP_ESTATS_BANDWIDTH_RW_v0 構造体を除いて、いずれも単一のメンバーを持ちます。EstatsType パラメーターが TcpConnectionEstatsBandwidth に設定されている場合、Rw パラメーターが指す TCP_ESTATS_BANDWIDTH_RW_v0 構造体は、SetPerTcp6ConnectionEStats 関数の 1 回の呼び出しで両方の構造体メンバーに優先される値を設定する必要があります。
RwSize パラメーターが 0 に設定されている場合、SetPerTcp6ConnectionEStats 関数は NO_ERROR を返し、拡張統計の状態に変更を加えません。
GetTcp6Table 関数は、ローカルコンピューター上の IPv6 TCP 接続テーブルを取得するために使用します。この関数は、MIB_TCP6ROW エントリの配列を含む MIB_TCP6TABLE 構造体を返します。SetPerTcp6ConnectionEStats 関数に渡す Row パラメーターは、既存の IPv6 TCP 接続のエントリである必要があります。
IPv6 の TCP 接続で拡張統計を有効にした後、アプリケーションは GetPerTcp6ConnectionEStats 関数を呼び出して、その TCP 接続の拡張統計を取得します。
GetPerTcp6ConnectionEStats 関数は、ネットワークとアプリケーションの両方のパフォーマンス問題を診断するために TCP を使用するように設計されています。ネットワークベースのアプリケーションのパフォーマンスが低い場合、TCP はボトルネックが送信側、受信側、またはネットワーク自体のいずれにあるかを判断できます。ボトルネックがネットワークにある場合、TCP はその性質に関する具体的な情報を提供できます。
IPv4 接続における拡張 TCP 統計については、GetPerTcpConnectionEStats 関数および SetPerTcpConnectionEStats 関数を参照してください。
SetPerTcp6ConnectionEStats 関数は、Administrators グループのメンバーとしてログオンしているユーザーのみが呼び出すことができます。Administrators グループのメンバーではないユーザーが SetPerTcp6ConnectionEStats を呼び出した場合、関数呼び出しは失敗し、ERROR_ACCESS_DENIED が返されます。この関数は、Windows Vista および Windows Server 2008 のユーザーアカウント制御 (UAC) が原因で失敗することもあります。この関数を含むアプリケーションを、組み込み Administrator 以外の Administrators グループのメンバーとしてログオンしているユーザーが実行した場合、アプリケーションのマニフェストファイルで requestedExecutionLevel が requireAdministrator に設定されていない限り、この呼び出しは失敗します。Windows Vista または Windows Server 2008 上のアプリケーションにこのマニフェストファイルがない場合、この関数が成功するには、組み込み Administrator 以外の Administrators グループのメンバーとしてログオンしているユーザーが、組み込み Administrator として昇格されたシェル (RunAs administrator) でアプリケーションを実行する必要があります。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// IPHLPAPI.dll
#include <windows.h>
DWORD SetPerTcp6ConnectionEStats(
MIB_TCP6ROW* Row,
TCP_ESTATS_TYPE EstatsType,
BYTE* Rw,
DWORD RwVersion,
DWORD RwSize,
DWORD Offset
);[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint SetPerTcp6ConnectionEStats(
IntPtr Row, // MIB_TCP6ROW*
int EstatsType, // TCP_ESTATS_TYPE
IntPtr Rw, // BYTE*
uint RwVersion, // DWORD
uint RwSize, // DWORD
uint Offset // DWORD
);<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function SetPerTcp6ConnectionEStats(
Row As IntPtr, ' MIB_TCP6ROW*
EstatsType As Integer, ' TCP_ESTATS_TYPE
Rw As IntPtr, ' BYTE*
RwVersion As UInteger, ' DWORD
RwSize As UInteger, ' DWORD
Offset As UInteger ' DWORD
) As UInteger
End Function' Row : MIB_TCP6ROW*
' EstatsType : TCP_ESTATS_TYPE
' Rw : BYTE*
' RwVersion : DWORD
' RwSize : DWORD
' Offset : DWORD
Declare PtrSafe Function SetPerTcp6ConnectionEStats Lib "iphlpapi" ( _
ByVal Row As LongPtr, _
ByVal EstatsType As Long, _
ByVal Rw As LongPtr, _
ByVal RwVersion As Long, _
ByVal RwSize As Long, _
ByVal Offset As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetPerTcp6ConnectionEStats = ctypes.windll.iphlpapi.SetPerTcp6ConnectionEStats
SetPerTcp6ConnectionEStats.restype = wintypes.DWORD
SetPerTcp6ConnectionEStats.argtypes = [
ctypes.c_void_p, # Row : MIB_TCP6ROW*
ctypes.c_int, # EstatsType : TCP_ESTATS_TYPE
ctypes.POINTER(ctypes.c_ubyte), # Rw : BYTE*
wintypes.DWORD, # RwVersion : DWORD
wintypes.DWORD, # RwSize : DWORD
wintypes.DWORD, # Offset : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('IPHLPAPI.dll')
SetPerTcp6ConnectionEStats = Fiddle::Function.new(
lib['SetPerTcp6ConnectionEStats'],
[
Fiddle::TYPE_VOIDP, # Row : MIB_TCP6ROW*
Fiddle::TYPE_INT, # EstatsType : TCP_ESTATS_TYPE
Fiddle::TYPE_VOIDP, # Rw : BYTE*
-Fiddle::TYPE_INT, # RwVersion : DWORD
-Fiddle::TYPE_INT, # RwSize : DWORD
-Fiddle::TYPE_INT, # Offset : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "iphlpapi")]
extern "system" {
fn SetPerTcp6ConnectionEStats(
Row: *mut MIB_TCP6ROW, // MIB_TCP6ROW*
EstatsType: i32, // TCP_ESTATS_TYPE
Rw: *mut u8, // BYTE*
RwVersion: u32, // DWORD
RwSize: u32, // DWORD
Offset: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint SetPerTcp6ConnectionEStats(IntPtr Row, int EstatsType, IntPtr Rw, uint RwVersion, uint RwSize, uint Offset);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_SetPerTcp6ConnectionEStats' -Namespace Win32 -PassThru
# $api::SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset)#uselib "IPHLPAPI.dll"
#func global SetPerTcp6ConnectionEStats "SetPerTcp6ConnectionEStats" sptr, sptr, sptr, sptr, sptr, sptr
; SetPerTcp6ConnectionEStats varptr(Row), EstatsType, varptr(Rw), RwVersion, RwSize, Offset ; 戻り値は stat
; Row : MIB_TCP6ROW* -> "sptr"
; EstatsType : TCP_ESTATS_TYPE -> "sptr"
; Rw : BYTE* -> "sptr"
; RwVersion : DWORD -> "sptr"
; RwSize : DWORD -> "sptr"
; Offset : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "IPHLPAPI.dll" #cfunc global SetPerTcp6ConnectionEStats "SetPerTcp6ConnectionEStats" var, int, var, int, int, int ; res = SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset) ; Row : MIB_TCP6ROW* -> "var" ; EstatsType : TCP_ESTATS_TYPE -> "int" ; Rw : BYTE* -> "var" ; RwVersion : DWORD -> "int" ; RwSize : DWORD -> "int" ; Offset : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "IPHLPAPI.dll" #cfunc global SetPerTcp6ConnectionEStats "SetPerTcp6ConnectionEStats" sptr, int, sptr, int, int, int ; res = SetPerTcp6ConnectionEStats(varptr(Row), EstatsType, varptr(Rw), RwVersion, RwSize, Offset) ; Row : MIB_TCP6ROW* -> "sptr" ; EstatsType : TCP_ESTATS_TYPE -> "int" ; Rw : BYTE* -> "sptr" ; RwVersion : DWORD -> "int" ; RwSize : DWORD -> "int" ; Offset : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; DWORD SetPerTcp6ConnectionEStats(MIB_TCP6ROW* Row, TCP_ESTATS_TYPE EstatsType, BYTE* Rw, DWORD RwVersion, DWORD RwSize, DWORD Offset) #uselib "IPHLPAPI.dll" #cfunc global SetPerTcp6ConnectionEStats "SetPerTcp6ConnectionEStats" var, int, var, int, int, int ; res = SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset) ; Row : MIB_TCP6ROW* -> "var" ; EstatsType : TCP_ESTATS_TYPE -> "int" ; Rw : BYTE* -> "var" ; RwVersion : DWORD -> "int" ; RwSize : DWORD -> "int" ; Offset : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SetPerTcp6ConnectionEStats(MIB_TCP6ROW* Row, TCP_ESTATS_TYPE EstatsType, BYTE* Rw, DWORD RwVersion, DWORD RwSize, DWORD Offset) #uselib "IPHLPAPI.dll" #cfunc global SetPerTcp6ConnectionEStats "SetPerTcp6ConnectionEStats" intptr, int, intptr, int, int, int ; res = SetPerTcp6ConnectionEStats(varptr(Row), EstatsType, varptr(Rw), RwVersion, RwSize, Offset) ; Row : MIB_TCP6ROW* -> "intptr" ; EstatsType : TCP_ESTATS_TYPE -> "int" ; Rw : BYTE* -> "intptr" ; RwVersion : DWORD -> "int" ; RwSize : DWORD -> "int" ; Offset : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
procSetPerTcp6ConnectionEStats = iphlpapi.NewProc("SetPerTcp6ConnectionEStats")
)
// Row (MIB_TCP6ROW*), EstatsType (TCP_ESTATS_TYPE), Rw (BYTE*), RwVersion (DWORD), RwSize (DWORD), Offset (DWORD)
r1, _, err := procSetPerTcp6ConnectionEStats.Call(
uintptr(Row),
uintptr(EstatsType),
uintptr(Rw),
uintptr(RwVersion),
uintptr(RwSize),
uintptr(Offset),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetPerTcp6ConnectionEStats(
Row: Pointer; // MIB_TCP6ROW*
EstatsType: Integer; // TCP_ESTATS_TYPE
Rw: Pointer; // BYTE*
RwVersion: DWORD; // DWORD
RwSize: DWORD; // DWORD
Offset: DWORD // DWORD
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'SetPerTcp6ConnectionEStats';result := DllCall("IPHLPAPI\SetPerTcp6ConnectionEStats"
, "Ptr", Row ; MIB_TCP6ROW*
, "Int", EstatsType ; TCP_ESTATS_TYPE
, "Ptr", Rw ; BYTE*
, "UInt", RwVersion ; DWORD
, "UInt", RwSize ; DWORD
, "UInt", Offset ; DWORD
, "UInt") ; return: DWORD●SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset) = DLL("IPHLPAPI.dll", "dword SetPerTcp6ConnectionEStats(void*, int, void*, dword, dword, dword)")
# 呼び出し: SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset)
# Row : MIB_TCP6ROW* -> "void*"
# EstatsType : TCP_ESTATS_TYPE -> "int"
# Rw : BYTE* -> "void*"
# RwVersion : DWORD -> "dword"
# RwSize : DWORD -> "dword"
# Offset : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "iphlpapi" fn SetPerTcp6ConnectionEStats(
Row: [*c]MIB_TCP6ROW, // MIB_TCP6ROW*
EstatsType: i32, // TCP_ESTATS_TYPE
Rw: [*c]u8, // BYTE*
RwVersion: u32, // DWORD
RwSize: u32, // DWORD
Offset: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc SetPerTcp6ConnectionEStats(
Row: ptr MIB_TCP6ROW, # MIB_TCP6ROW*
EstatsType: int32, # TCP_ESTATS_TYPE
Rw: ptr uint8, # BYTE*
RwVersion: uint32, # DWORD
RwSize: uint32, # DWORD
Offset: uint32 # DWORD
): uint32 {.importc: "SetPerTcp6ConnectionEStats", stdcall, dynlib: "IPHLPAPI.dll".}pragma(lib, "iphlpapi");
extern(Windows)
uint SetPerTcp6ConnectionEStats(
MIB_TCP6ROW* Row, // MIB_TCP6ROW*
int EstatsType, // TCP_ESTATS_TYPE
ubyte* Rw, // BYTE*
uint RwVersion, // DWORD
uint RwSize, // DWORD
uint Offset // DWORD
);ccall((:SetPerTcp6ConnectionEStats, "IPHLPAPI.dll"), stdcall, UInt32,
(Ptr{MIB_TCP6ROW}, Int32, Ptr{UInt8}, UInt32, UInt32, UInt32),
Row, EstatsType, Rw, RwVersion, RwSize, Offset)
# Row : MIB_TCP6ROW* -> Ptr{MIB_TCP6ROW}
# EstatsType : TCP_ESTATS_TYPE -> Int32
# Rw : BYTE* -> Ptr{UInt8}
# RwVersion : DWORD -> UInt32
# RwSize : DWORD -> UInt32
# Offset : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t SetPerTcp6ConnectionEStats(
void* Row,
int32_t EstatsType,
uint8_t* Rw,
uint32_t RwVersion,
uint32_t RwSize,
uint32_t Offset);
]]
local iphlpapi = ffi.load("iphlpapi")
-- iphlpapi.SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset)
-- Row : MIB_TCP6ROW*
-- EstatsType : TCP_ESTATS_TYPE
-- Rw : BYTE*
-- RwVersion : DWORD
-- RwSize : DWORD
-- Offset : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('IPHLPAPI.dll');
const SetPerTcp6ConnectionEStats = lib.func('__stdcall', 'SetPerTcp6ConnectionEStats', 'uint32_t', ['void *', 'int32_t', 'uint8_t *', 'uint32_t', 'uint32_t', 'uint32_t']);
// SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset)
// Row : MIB_TCP6ROW* -> 'void *'
// EstatsType : TCP_ESTATS_TYPE -> 'int32_t'
// Rw : BYTE* -> 'uint8_t *'
// RwVersion : DWORD -> 'uint32_t'
// RwSize : DWORD -> 'uint32_t'
// Offset : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("IPHLPAPI.dll", {
SetPerTcp6ConnectionEStats: { parameters: ["pointer", "i32", "pointer", "u32", "u32", "u32"], result: "u32" },
});
// lib.symbols.SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset)
// Row : MIB_TCP6ROW* -> "pointer"
// EstatsType : TCP_ESTATS_TYPE -> "i32"
// Rw : BYTE* -> "pointer"
// RwVersion : DWORD -> "u32"
// RwSize : DWORD -> "u32"
// Offset : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SetPerTcp6ConnectionEStats(
void* Row,
int32_t EstatsType,
uint8_t* Rw,
uint32_t RwVersion,
uint32_t RwSize,
uint32_t Offset);
C, "IPHLPAPI.dll");
// $ffi->SetPerTcp6ConnectionEStats(Row, EstatsType, Rw, RwVersion, RwSize, Offset);
// Row : MIB_TCP6ROW*
// EstatsType : TCP_ESTATS_TYPE
// Rw : BYTE*
// RwVersion : DWORD
// RwSize : DWORD
// Offset : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Iphlpapi extends StdCallLibrary {
Iphlpapi INSTANCE = Native.load("iphlpapi", Iphlpapi.class);
int SetPerTcp6ConnectionEStats(
Pointer Row, // MIB_TCP6ROW*
int EstatsType, // TCP_ESTATS_TYPE
byte[] Rw, // BYTE*
int RwVersion, // DWORD
int RwSize, // DWORD
int Offset // DWORD
);
}@[Link("iphlpapi")]
lib LibIPHLPAPI
fun SetPerTcp6ConnectionEStats = SetPerTcp6ConnectionEStats(
Row : MIB_TCP6ROW*, # MIB_TCP6ROW*
EstatsType : Int32, # TCP_ESTATS_TYPE
Rw : UInt8*, # BYTE*
RwVersion : UInt32, # DWORD
RwSize : UInt32, # DWORD
Offset : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetPerTcp6ConnectionEStatsNative = Uint32 Function(Pointer<Void>, Int32, Pointer<Uint8>, Uint32, Uint32, Uint32);
typedef SetPerTcp6ConnectionEStatsDart = int Function(Pointer<Void>, int, Pointer<Uint8>, int, int, int);
final SetPerTcp6ConnectionEStats = DynamicLibrary.open('IPHLPAPI.dll')
.lookupFunction<SetPerTcp6ConnectionEStatsNative, SetPerTcp6ConnectionEStatsDart>('SetPerTcp6ConnectionEStats');
// Row : MIB_TCP6ROW* -> Pointer<Void>
// EstatsType : TCP_ESTATS_TYPE -> Int32
// Rw : BYTE* -> Pointer<Uint8>
// RwVersion : DWORD -> Uint32
// RwSize : DWORD -> Uint32
// Offset : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetPerTcp6ConnectionEStats(
Row: Pointer; // MIB_TCP6ROW*
EstatsType: Integer; // TCP_ESTATS_TYPE
Rw: Pointer; // BYTE*
RwVersion: DWORD; // DWORD
RwSize: DWORD; // DWORD
Offset: DWORD // DWORD
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'SetPerTcp6ConnectionEStats';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetPerTcp6ConnectionEStats"
c_SetPerTcp6ConnectionEStats :: Ptr () -> Int32 -> Ptr Word8 -> Word32 -> Word32 -> Word32 -> IO Word32
-- Row : MIB_TCP6ROW* -> Ptr ()
-- EstatsType : TCP_ESTATS_TYPE -> Int32
-- Rw : BYTE* -> Ptr Word8
-- RwVersion : DWORD -> Word32
-- RwSize : DWORD -> Word32
-- Offset : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setpertcp6connectionestats =
foreign "SetPerTcp6ConnectionEStats"
((ptr void) @-> int32_t @-> (ptr uint8_t) @-> uint32_t @-> uint32_t @-> uint32_t @-> returning uint32_t)
(* Row : MIB_TCP6ROW* -> (ptr void) *)
(* EstatsType : TCP_ESTATS_TYPE -> int32_t *)
(* Rw : BYTE* -> (ptr uint8_t) *)
(* RwVersion : DWORD -> uint32_t *)
(* RwSize : DWORD -> uint32_t *)
(* Offset : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library iphlpapi (t "IPHLPAPI.dll"))
(cffi:use-foreign-library iphlpapi)
(cffi:defcfun ("SetPerTcp6ConnectionEStats" set-per-tcp6-connection-estats :convention :stdcall) :uint32
(row :pointer) ; MIB_TCP6ROW*
(estats-type :int32) ; TCP_ESTATS_TYPE
(rw :pointer) ; BYTE*
(rw-version :uint32) ; DWORD
(rw-size :uint32) ; DWORD
(offset :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetPerTcp6ConnectionEStats = Win32::API::More->new('IPHLPAPI',
'DWORD SetPerTcp6ConnectionEStats(LPVOID Row, int EstatsType, LPVOID Rw, DWORD RwVersion, DWORD RwSize, DWORD Offset)');
# my $ret = $SetPerTcp6ConnectionEStats->Call($Row, $EstatsType, $Rw, $RwVersion, $RwSize, $Offset);
# Row : MIB_TCP6ROW* -> LPVOID
# EstatsType : TCP_ESTATS_TYPE -> int
# Rw : BYTE* -> LPVOID
# RwVersion : DWORD -> DWORD
# RwSize : DWORD -> DWORD
# Offset : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f GetPerTcp6ConnectionEStats — 指定IPv6 TCP接続の拡張統計(ESTATS)情報を取得する。
- f GetPerTcpConnectionEStats — 指定IPv4 TCP接続の拡張統計(ESTATS)情報を取得する。
- f GetTcp6Table — 現在のIPv6 TCP接続一覧をMIB_TCP6TABLEとして取得する。
- s MIB_TCP6TABLE
- f SetPerTcpConnectionEStats — 指定IPv4 TCP接続の拡張統計(ESTATS)収集を設定する。
- e TCP_BOOLEAN_OPTIONAL
- s TCP_ESTATS_BANDWIDTH_RW_v0
- s TCP_ESTATS_DATA_RW_v0
- s TCP_ESTATS_FINE_RTT_RW_v0
- s TCP_ESTATS_OBS_REC_RW_v0
- s TCP_ESTATS_PATH_RW_v0
- s TCP_ESTATS_REC_RW_v0