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

MIB_UDP6TABLE

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

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

フィールド

フィールドサイズx64x86説明
dwNumEntriesDWORD4+0+0テーブル内のエントリ数。
tableMIB_UDP6ROW24+4+4MIB_UDP6ROW 構造体の配列へのポインター。

公式ドキュメント

MIB_UDP6TABLE 構造体は、ローカル コンピューター上の IPv6 用のユーザー データグラム プロトコル (UDP) リスナー テーブルを格納します。

解説(Remarks)

GetUdp6Table 関数は、ローカル コンピューター上のアドレスにバインドされている IPv6 用の UDP エンドポイントを列挙し、その情報を MIB_UDP6TABLE 構造体で返します。

このテーブルには、ローカル コンピューターで UDP データグラムを送受信するためのローカル IPv6 アドレス、スコープ ID、およびポートの情報が含まれます。MIB_UDP6TABLE 構造体には、MIB_UDP6ROW 構造体の配列が含まれます。

MIB_UDP6TABLE 構造体には、dwNumEntries メンバーと table メンバー内の最初の MIB_UDP6ROW 配列エントリとの間に、アラインメントのためのパディングが含まれる場合があります。また、table メンバー内の MIB_UDP6ROW 配列エントリ間にも、アラインメントのためのパディングが存在する場合があります。MIB_UDP6ROW 配列エントリにアクセスする際は、パディングが存在する可能性を前提としてください。

MIB_UDP6TABLE 構造体は、ローカル コンピューター上の IPv6 用の UDP リスナー テーブルを格納します。この名前は、IETF が公開した RFC 2454 におけるこのテーブルの定義に基づいています。詳細については、 http://www.ietf.org/rfc/rfc2454.txt を参照してください。このテーブルには、アドレスにバインドされている IPv6 用の UDP エンドポイントが含まれます。なお、アプリケーションが UDP データグラムを送信することだけを目的として UDP ソケットを作成してアドレスにバインドし、そのソケットを使用してパケットを受信する (リスナーとして機能する) 意図がない場合もある点に注意してください。

MIB_UDP6TABLE_OWNER_MODULE 構造体は MIB_UDP6TABLE_OWNER_PID 構造体の拡張版であり、テーブル内の各 UDP エンドポイントについて利用可能な所有者データを含みます。MIB_UDP6TABLE_OWNER_PIDMIB_UDP6TABLE の拡張版であり、テーブル内の各 UDP エンドポイントについて bind 関数を呼び出したプロセス ID (PID) を含みます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// IN6_ADDR  (x64 16 / x86 16 バイト)
typedef struct IN6_ADDR {
    _u_e__Union u;
} IN6_ADDR;

// MIB_UDP6ROW  (x64 24 / x86 24 バイト)
typedef struct MIB_UDP6ROW {
    IN6_ADDR dwLocalAddr;
    DWORD dwLocalScopeId;
    DWORD dwLocalPort;
} MIB_UDP6ROW;

// MIB_UDP6TABLE  (x64 28 / x86 28 バイト)
typedef struct MIB_UDP6TABLE {
    DWORD dwNumEntries;
    MIB_UDP6ROW table[1];
} MIB_UDP6TABLE;
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_UDP6ROW
{
    public IN6_ADDR dwLocalAddr;
    public uint dwLocalScopeId;
    public uint dwLocalPort;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_UDP6TABLE
{
    public uint dwNumEntries;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public MIB_UDP6ROW[] 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_UDP6ROW
    Public dwLocalAddr As IN6_ADDR
    Public dwLocalScopeId As UInteger
    Public dwLocalPort As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_UDP6TABLE
    Public dwNumEntries As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public table() As MIB_UDP6ROW
End Structure
import ctypes
from ctypes import wintypes

class IN6_ADDR(ctypes.Structure):
    _fields_ = [
        ("u", _u_e__Union),
    ]

class MIB_UDP6ROW(ctypes.Structure):
    _fields_ = [
        ("dwLocalAddr", IN6_ADDR),
        ("dwLocalScopeId", wintypes.DWORD),
        ("dwLocalPort", wintypes.DWORD),
    ]

class MIB_UDP6TABLE(ctypes.Structure):
    _fields_ = [
        ("dwNumEntries", wintypes.DWORD),
        ("table", MIB_UDP6ROW * 1),
    ]
#[repr(C)]
pub struct IN6_ADDR {
    pub u: _u_e__Union,
}

#[repr(C)]
pub struct MIB_UDP6ROW {
    pub dwLocalAddr: IN6_ADDR,
    pub dwLocalScopeId: u32,
    pub dwLocalPort: u32,
}

#[repr(C)]
pub struct MIB_UDP6TABLE {
    pub dwNumEntries: u32,
    pub table: [MIB_UDP6ROW; 1],
}
import "golang.org/x/sys/windows"

type IN6_ADDR struct {
	u _u_e__Union
}

type MIB_UDP6ROW struct {
	dwLocalAddr IN6_ADDR
	dwLocalScopeId uint32
	dwLocalPort uint32
}

type MIB_UDP6TABLE struct {
	dwNumEntries uint32
	table [1]MIB_UDP6ROW
}
type
  IN6_ADDR = record
    u: _u_e__Union;
  end;

  MIB_UDP6ROW = record
    dwLocalAddr: IN6_ADDR;
    dwLocalScopeId: DWORD;
    dwLocalPort: DWORD;
  end;

  MIB_UDP6TABLE = record
    dwNumEntries: DWORD;
    table: array[0..0] of MIB_UDP6ROW;
  end;
const IN6_ADDR = extern struct {
    u: _u_e__Union,
};

const MIB_UDP6ROW = extern struct {
    dwLocalAddr: IN6_ADDR,
    dwLocalScopeId: u32,
    dwLocalPort: u32,
};

const MIB_UDP6TABLE = extern struct {
    dwNumEntries: u32,
    table: [1]MIB_UDP6ROW,
};
type
  IN6_ADDR {.bycopy.} = object
    u: _u_e__Union

  MIB_UDP6ROW {.bycopy.} = object
    dwLocalAddr: IN6_ADDR
    dwLocalScopeId: uint32
    dwLocalPort: uint32

  MIB_UDP6TABLE {.bycopy.} = object
    dwNumEntries: uint32
    table: array[1, MIB_UDP6ROW]
struct IN6_ADDR
{
    _u_e__Union u;
}

struct MIB_UDP6ROW
{
    IN6_ADDR dwLocalAddr;
    uint dwLocalScopeId;
    uint dwLocalPort;
}

struct MIB_UDP6TABLE
{
    uint dwNumEntries;
    MIB_UDP6ROW[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_UDP6TABLE サイズ: 28 バイト(x64)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; dwNumEntries : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; table : MIB_UDP6ROW (+4, 24byte)  varptr(st)+4 を基点に操作(24byte:入れ子/配列)
; ※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_UDP6ROW
    #field IN6_ADDR dwLocalAddr
    #field int dwLocalScopeId
    #field int dwLocalPort
#endstruct

#defstruct global MIB_UDP6TABLE
    #field int dwNumEntries
    #field MIB_UDP6ROW table 1
#endstruct

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