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

MCAST_LEASE_REQUEST

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

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

フィールド

フィールドサイズx64x86説明
LeaseStartTimeINT4+0+0希望するリース開始時刻(time_t相当のINT)である。
MaxLeaseStartTimeINT4+4+4許容できるリース開始時刻の上限(time_t相当のINT)である。
LeaseDurationDWORD4+8+8希望するリース期間(秒)である。
MinLeaseDurationDWORD4+12+12許容できる最小リース期間(秒)である。
ServerAddressIPNG_ADDRESS16+16+16リースを要求するマルチキャストサーバーのアドレス(IPNG_ADDRESS)である。
MinAddrCountWORD2+32+32要求する最小アドレス数である。
AddrCountWORD2+34+34要求するアドレス数である。
pAddrBufBYTE*8/4+40+36割り当てられたアドレスを格納するバッファを指すポインタである。

各言語での定義

#include <windows.h>

// IPNG_ADDRESS  (x64 16 / x86 16 バイト)
typedef struct IPNG_ADDRESS {
    DWORD IpAddrV4;
    BYTE IpAddrV6[16];
} IPNG_ADDRESS;

// MCAST_LEASE_REQUEST  (x64 48 / x86 40 バイト)
typedef struct MCAST_LEASE_REQUEST {
    INT LeaseStartTime;
    INT MaxLeaseStartTime;
    DWORD LeaseDuration;
    DWORD MinLeaseDuration;
    IPNG_ADDRESS ServerAddress;
    WORD MinAddrCount;
    WORD AddrCount;
    BYTE* pAddrBuf;
} MCAST_LEASE_REQUEST;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IPNG_ADDRESS
{
    public uint IpAddrV4;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] IpAddrV6;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MCAST_LEASE_REQUEST
{
    public int LeaseStartTime;
    public int MaxLeaseStartTime;
    public uint LeaseDuration;
    public uint MinLeaseDuration;
    public IPNG_ADDRESS ServerAddress;
    public ushort MinAddrCount;
    public ushort AddrCount;
    public IntPtr pAddrBuf;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IPNG_ADDRESS
    Public IpAddrV4 As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public IpAddrV6() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MCAST_LEASE_REQUEST
    Public LeaseStartTime As Integer
    Public MaxLeaseStartTime As Integer
    Public LeaseDuration As UInteger
    Public MinLeaseDuration As UInteger
    Public ServerAddress As IPNG_ADDRESS
    Public MinAddrCount As UShort
    Public AddrCount As UShort
    Public pAddrBuf As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class IPNG_ADDRESS(ctypes.Structure):
    _fields_ = [
        ("IpAddrV4", wintypes.DWORD),
        ("IpAddrV6", ctypes.c_ubyte * 16),
    ]

class MCAST_LEASE_REQUEST(ctypes.Structure):
    _fields_ = [
        ("LeaseStartTime", ctypes.c_int),
        ("MaxLeaseStartTime", ctypes.c_int),
        ("LeaseDuration", wintypes.DWORD),
        ("MinLeaseDuration", wintypes.DWORD),
        ("ServerAddress", IPNG_ADDRESS),
        ("MinAddrCount", ctypes.c_ushort),
        ("AddrCount", ctypes.c_ushort),
        ("pAddrBuf", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct IPNG_ADDRESS {
    pub IpAddrV4: u32,
    pub IpAddrV6: [u8; 16],
}

#[repr(C)]
pub struct MCAST_LEASE_REQUEST {
    pub LeaseStartTime: i32,
    pub MaxLeaseStartTime: i32,
    pub LeaseDuration: u32,
    pub MinLeaseDuration: u32,
    pub ServerAddress: IPNG_ADDRESS,
    pub MinAddrCount: u16,
    pub AddrCount: u16,
    pub pAddrBuf: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type IPNG_ADDRESS struct {
	IpAddrV4 uint32
	IpAddrV6 [16]byte
}

type MCAST_LEASE_REQUEST struct {
	LeaseStartTime int32
	MaxLeaseStartTime int32
	LeaseDuration uint32
	MinLeaseDuration uint32
	ServerAddress IPNG_ADDRESS
	MinAddrCount uint16
	AddrCount uint16
	pAddrBuf uintptr
}
type
  IPNG_ADDRESS = record
    IpAddrV4: DWORD;
    IpAddrV6: array[0..15] of Byte;
  end;

  MCAST_LEASE_REQUEST = record
    LeaseStartTime: Integer;
    MaxLeaseStartTime: Integer;
    LeaseDuration: DWORD;
    MinLeaseDuration: DWORD;
    ServerAddress: IPNG_ADDRESS;
    MinAddrCount: Word;
    AddrCount: Word;
    pAddrBuf: Pointer;
  end;
const IPNG_ADDRESS = extern struct {
    IpAddrV4: u32,
    IpAddrV6: [16]u8,
};

const MCAST_LEASE_REQUEST = extern struct {
    LeaseStartTime: i32,
    MaxLeaseStartTime: i32,
    LeaseDuration: u32,
    MinLeaseDuration: u32,
    ServerAddress: IPNG_ADDRESS,
    MinAddrCount: u16,
    AddrCount: u16,
    pAddrBuf: ?*anyopaque,
};
type
  IPNG_ADDRESS {.bycopy.} = object
    IpAddrV4: uint32
    IpAddrV6: array[16, uint8]

  MCAST_LEASE_REQUEST {.bycopy.} = object
    LeaseStartTime: int32
    MaxLeaseStartTime: int32
    LeaseDuration: uint32
    MinLeaseDuration: uint32
    ServerAddress: IPNG_ADDRESS
    MinAddrCount: uint16
    AddrCount: uint16
    pAddrBuf: pointer
struct IPNG_ADDRESS
{
    uint IpAddrV4;
    ubyte[16] IpAddrV6;
}

struct MCAST_LEASE_REQUEST
{
    int LeaseStartTime;
    int MaxLeaseStartTime;
    uint LeaseDuration;
    uint MinLeaseDuration;
    IPNG_ADDRESS ServerAddress;
    ushort MinAddrCount;
    ushort AddrCount;
    void* pAddrBuf;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; MCAST_LEASE_REQUEST サイズ: 40 バイト(x86)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; LeaseStartTime : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; MaxLeaseStartTime : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; LeaseDuration : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; MinLeaseDuration : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ServerAddress : IPNG_ADDRESS (+16, 16byte)  varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; MinAddrCount : WORD (+32, 2byte)  wpoke st,32,値  /  値 = wpeek(st,32)
; AddrCount : WORD (+34, 2byte)  wpoke st,34,値  /  値 = wpeek(st,34)
; pAddrBuf : BYTE* (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MCAST_LEASE_REQUEST サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; LeaseStartTime : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; MaxLeaseStartTime : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; LeaseDuration : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; MinLeaseDuration : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ServerAddress : IPNG_ADDRESS (+16, 16byte)  varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; MinAddrCount : WORD (+32, 2byte)  wpoke st,32,値  /  値 = wpeek(st,32)
; AddrCount : WORD (+34, 2byte)  wpoke st,34,値  /  値 = wpeek(st,34)
; pAddrBuf : BYTE* (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MCAST_LEASE_REQUEST
    #field int LeaseStartTime
    #field int MaxLeaseStartTime
    #field int LeaseDuration
    #field int MinLeaseDuration
    #field byte ServerAddress 16
    #field short MinAddrCount
    #field short AddrCount
    #field intptr pAddrBuf
#endstruct

stdim st, MCAST_LEASE_REQUEST        ; NSTRUCT 変数を確保
st->LeaseStartTime = 100
mes "LeaseStartTime=" + st->LeaseStartTime
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。