ホーム › NetworkManagement.IpHelper › MIB_TCP6TABLE
MIB_TCP6TABLE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwNumEntries | DWORD | 4 | +0 | +0 | table配列に格納されたIPv6 TCP接続行数を示す。 |
| table | MIB_TCP6ROW | 52 | +4 | +4 | MIB_TCP6ROW要素を格納する可変長配列の先頭。 |
各言語での定義
#include <windows.h>
// IN6_ADDR (x64 16 / x86 16 バイト)
typedef struct IN6_ADDR {
_u_e__Union u;
} IN6_ADDR;
// MIB_TCP6ROW (x64 52 / x86 52 バイト)
typedef struct MIB_TCP6ROW {
MIB_TCP_STATE State;
IN6_ADDR LocalAddr;
DWORD dwLocalScopeId;
DWORD dwLocalPort;
IN6_ADDR RemoteAddr;
DWORD dwRemoteScopeId;
DWORD dwRemotePort;
} MIB_TCP6ROW;
// MIB_TCP6TABLE (x64 56 / x86 56 バイト)
typedef struct MIB_TCP6TABLE {
DWORD dwNumEntries;
MIB_TCP6ROW table[1];
} MIB_TCP6TABLE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IN6_ADDR
{
public _u_e__Union u;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_TCP6ROW
{
public int State;
public IN6_ADDR LocalAddr;
public uint dwLocalScopeId;
public uint dwLocalPort;
public IN6_ADDR RemoteAddr;
public uint dwRemoteScopeId;
public uint dwRemotePort;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_TCP6TABLE
{
public uint dwNumEntries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public MIB_TCP6ROW[] table;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IN6_ADDR
Public u As _u_e__Union
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_TCP6ROW
Public State As Integer
Public LocalAddr As IN6_ADDR
Public dwLocalScopeId As UInteger
Public dwLocalPort As UInteger
Public RemoteAddr As IN6_ADDR
Public dwRemoteScopeId As UInteger
Public dwRemotePort As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_TCP6TABLE
Public dwNumEntries As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public table() As MIB_TCP6ROW
End Structureimport ctypes
from ctypes import wintypes
class IN6_ADDR(ctypes.Structure):
_fields_ = [
("u", _u_e__Union),
]
class MIB_TCP6ROW(ctypes.Structure):
_fields_ = [
("State", ctypes.c_int),
("LocalAddr", IN6_ADDR),
("dwLocalScopeId", wintypes.DWORD),
("dwLocalPort", wintypes.DWORD),
("RemoteAddr", IN6_ADDR),
("dwRemoteScopeId", wintypes.DWORD),
("dwRemotePort", wintypes.DWORD),
]
class MIB_TCP6TABLE(ctypes.Structure):
_fields_ = [
("dwNumEntries", wintypes.DWORD),
("table", MIB_TCP6ROW * 1),
]#[repr(C)]
pub struct IN6_ADDR {
pub u: _u_e__Union,
}
#[repr(C)]
pub struct MIB_TCP6ROW {
pub State: i32,
pub LocalAddr: IN6_ADDR,
pub dwLocalScopeId: u32,
pub dwLocalPort: u32,
pub RemoteAddr: IN6_ADDR,
pub dwRemoteScopeId: u32,
pub dwRemotePort: u32,
}
#[repr(C)]
pub struct MIB_TCP6TABLE {
pub dwNumEntries: u32,
pub table: [MIB_TCP6ROW; 1],
}import "golang.org/x/sys/windows"
type IN6_ADDR struct {
u _u_e__Union
}
type MIB_TCP6ROW struct {
State int32
LocalAddr IN6_ADDR
dwLocalScopeId uint32
dwLocalPort uint32
RemoteAddr IN6_ADDR
dwRemoteScopeId uint32
dwRemotePort uint32
}
type MIB_TCP6TABLE struct {
dwNumEntries uint32
table [1]MIB_TCP6ROW
}type
IN6_ADDR = record
u: _u_e__Union;
end;
MIB_TCP6ROW = record
State: Integer;
LocalAddr: IN6_ADDR;
dwLocalScopeId: DWORD;
dwLocalPort: DWORD;
RemoteAddr: IN6_ADDR;
dwRemoteScopeId: DWORD;
dwRemotePort: DWORD;
end;
MIB_TCP6TABLE = record
dwNumEntries: DWORD;
table: array[0..0] of MIB_TCP6ROW;
end;const IN6_ADDR = extern struct {
u: _u_e__Union,
};
const MIB_TCP6ROW = extern struct {
State: i32,
LocalAddr: IN6_ADDR,
dwLocalScopeId: u32,
dwLocalPort: u32,
RemoteAddr: IN6_ADDR,
dwRemoteScopeId: u32,
dwRemotePort: u32,
};
const MIB_TCP6TABLE = extern struct {
dwNumEntries: u32,
table: [1]MIB_TCP6ROW,
};type
IN6_ADDR {.bycopy.} = object
u: _u_e__Union
MIB_TCP6ROW {.bycopy.} = object
State: int32
LocalAddr: IN6_ADDR
dwLocalScopeId: uint32
dwLocalPort: uint32
RemoteAddr: IN6_ADDR
dwRemoteScopeId: uint32
dwRemotePort: uint32
MIB_TCP6TABLE {.bycopy.} = object
dwNumEntries: uint32
table: array[1, MIB_TCP6ROW]struct IN6_ADDR
{
_u_e__Union u;
}
struct MIB_TCP6ROW
{
int State;
IN6_ADDR LocalAddr;
uint dwLocalScopeId;
uint dwLocalPort;
IN6_ADDR RemoteAddr;
uint dwRemoteScopeId;
uint dwRemotePort;
}
struct MIB_TCP6TABLE
{
uint dwNumEntries;
MIB_TCP6ROW[1] table;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MIB_TCP6TABLE サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; dwNumEntries : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; table : MIB_TCP6ROW (+4, 52byte) varptr(st)+4 を基点に操作(52byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global IN6_ADDR
#field byte u 16
#endstruct
#defstruct global MIB_TCP6ROW
#field int State
#field IN6_ADDR LocalAddr
#field int dwLocalScopeId
#field int dwLocalPort
#field IN6_ADDR RemoteAddr
#field int dwRemoteScopeId
#field int dwRemotePort
#endstruct
#defstruct global MIB_TCP6TABLE
#field int dwNumEntries
#field MIB_TCP6ROW table 1
#endstruct
stdim st, MIB_TCP6TABLE ; NSTRUCT 変数を確保
st->dwNumEntries = 100
mes "dwNumEntries=" + st->dwNumEntries