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

DHCP_SUBNET_INFO_V6

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

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

フィールド

フィールドサイズx64x86説明
SubnetAddressDHCP_IPV6_ADDRESS16+0+0IPv6サブネット(スコープ)のアドレスを保持する。
PrefixDWORD4+16+16サブネットのプレフィックス長(ビット数)を示す。
PreferenceWORD2+20+20複数スコープ間の優先度を示す。値が小さいほど優先される。
SubnetNameLPWSTR8/4+24+24サブネットの表示名を示すワイド文字列。NULL可。
SubnetCommentLPWSTR8/4+32+28サブネットの説明コメントを示すワイド文字列。NULL可。
StateDWORD4+40+32サブネットの状態を示す値。有効/無効等を表す。
ScopeIdDWORD4+44+36スコープの識別子を示す。

各言語での定義

#include <windows.h>

// DHCP_IPV6_ADDRESS  (x64 16 / x86 16 バイト)
typedef struct DHCP_IPV6_ADDRESS {
    ULONGLONG HighOrderBits;
    ULONGLONG LowOrderBits;
} DHCP_IPV6_ADDRESS;

// DHCP_SUBNET_INFO_V6  (x64 48 / x86 40 バイト)
typedef struct DHCP_SUBNET_INFO_V6 {
    DHCP_IPV6_ADDRESS SubnetAddress;
    DWORD Prefix;
    WORD Preference;
    LPWSTR SubnetName;
    LPWSTR SubnetComment;
    DWORD State;
    DWORD ScopeId;
} DHCP_SUBNET_INFO_V6;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DHCP_IPV6_ADDRESS
{
    public ulong HighOrderBits;
    public ulong LowOrderBits;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DHCP_SUBNET_INFO_V6
{
    public DHCP_IPV6_ADDRESS SubnetAddress;
    public uint Prefix;
    public ushort Preference;
    public IntPtr SubnetName;
    public IntPtr SubnetComment;
    public uint State;
    public uint ScopeId;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DHCP_IPV6_ADDRESS
    Public HighOrderBits As ULong
    Public LowOrderBits As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DHCP_SUBNET_INFO_V6
    Public SubnetAddress As DHCP_IPV6_ADDRESS
    Public Prefix As UInteger
    Public Preference As UShort
    Public SubnetName As IntPtr
    Public SubnetComment As IntPtr
    Public State As UInteger
    Public ScopeId As UInteger
End Structure
import ctypes
from ctypes import wintypes

class DHCP_IPV6_ADDRESS(ctypes.Structure):
    _fields_ = [
        ("HighOrderBits", ctypes.c_ulonglong),
        ("LowOrderBits", ctypes.c_ulonglong),
    ]

class DHCP_SUBNET_INFO_V6(ctypes.Structure):
    _fields_ = [
        ("SubnetAddress", DHCP_IPV6_ADDRESS),
        ("Prefix", wintypes.DWORD),
        ("Preference", ctypes.c_ushort),
        ("SubnetName", ctypes.c_void_p),
        ("SubnetComment", ctypes.c_void_p),
        ("State", wintypes.DWORD),
        ("ScopeId", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DHCP_IPV6_ADDRESS {
    pub HighOrderBits: u64,
    pub LowOrderBits: u64,
}

#[repr(C)]
pub struct DHCP_SUBNET_INFO_V6 {
    pub SubnetAddress: DHCP_IPV6_ADDRESS,
    pub Prefix: u32,
    pub Preference: u16,
    pub SubnetName: *mut core::ffi::c_void,
    pub SubnetComment: *mut core::ffi::c_void,
    pub State: u32,
    pub ScopeId: u32,
}
import "golang.org/x/sys/windows"

type DHCP_IPV6_ADDRESS struct {
	HighOrderBits uint64
	LowOrderBits uint64
}

type DHCP_SUBNET_INFO_V6 struct {
	SubnetAddress DHCP_IPV6_ADDRESS
	Prefix uint32
	Preference uint16
	SubnetName uintptr
	SubnetComment uintptr
	State uint32
	ScopeId uint32
}
type
  DHCP_IPV6_ADDRESS = record
    HighOrderBits: UInt64;
    LowOrderBits: UInt64;
  end;

  DHCP_SUBNET_INFO_V6 = record
    SubnetAddress: DHCP_IPV6_ADDRESS;
    Prefix: DWORD;
    Preference: Word;
    SubnetName: Pointer;
    SubnetComment: Pointer;
    State: DWORD;
    ScopeId: DWORD;
  end;
const DHCP_IPV6_ADDRESS = extern struct {
    HighOrderBits: u64,
    LowOrderBits: u64,
};

const DHCP_SUBNET_INFO_V6 = extern struct {
    SubnetAddress: DHCP_IPV6_ADDRESS,
    Prefix: u32,
    Preference: u16,
    SubnetName: ?*anyopaque,
    SubnetComment: ?*anyopaque,
    State: u32,
    ScopeId: u32,
};
type
  DHCP_IPV6_ADDRESS {.bycopy.} = object
    HighOrderBits: uint64
    LowOrderBits: uint64

  DHCP_SUBNET_INFO_V6 {.bycopy.} = object
    SubnetAddress: DHCP_IPV6_ADDRESS
    Prefix: uint32
    Preference: uint16
    SubnetName: pointer
    SubnetComment: pointer
    State: uint32
    ScopeId: uint32
struct DHCP_IPV6_ADDRESS
{
    ulong HighOrderBits;
    ulong LowOrderBits;
}

struct DHCP_SUBNET_INFO_V6
{
    DHCP_IPV6_ADDRESS SubnetAddress;
    uint Prefix;
    ushort Preference;
    void* SubnetName;
    void* SubnetComment;
    uint State;
    uint ScopeId;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DHCP_SUBNET_INFO_V6 サイズ: 40 バイト(x86)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; SubnetAddress : DHCP_IPV6_ADDRESS (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; Prefix : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; Preference : WORD (+20, 2byte)  wpoke st,20,値  /  値 = wpeek(st,20)
; SubnetName : LPWSTR (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; SubnetComment : LPWSTR (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; State : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ScopeId : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DHCP_SUBNET_INFO_V6 サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; SubnetAddress : DHCP_IPV6_ADDRESS (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; Prefix : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; Preference : WORD (+20, 2byte)  wpoke st,20,値  /  値 = wpeek(st,20)
; SubnetName : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; SubnetComment : LPWSTR (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; State : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; ScopeId : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DHCP_IPV6_ADDRESS
    #field int64 HighOrderBits
    #field int64 LowOrderBits
#endstruct

#defstruct global DHCP_SUBNET_INFO_V6
    #field DHCP_IPV6_ADDRESS SubnetAddress
    #field int Prefix
    #field short Preference
    #field intptr SubnetName
    #field intptr SubnetComment
    #field int State
    #field int ScopeId
#endstruct

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