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

MCAST_LEASE_RESPONSE

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

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

フィールド

フィールドサイズx64x86説明
LeaseStartTimeINT4+0+0実際に付与されたリースの開始時刻(time_t相当のINT)である。
LeaseEndTimeINT4+4+4実際に付与されたリースの終了時刻(time_t相当のINT)である。
ServerAddressIPNG_ADDRESS16+8+8リースを付与したマルチキャストサーバーのアドレス(IPNG_ADDRESS)である。
AddrCountWORD2+24+24実際に割り当てられたアドレス数である。
pAddrBufBYTE*8/4+32+28割り当てられたアドレスが格納されたバッファを指すポインタである。

各言語での定義

#include <windows.h>

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

// MCAST_LEASE_RESPONSE  (x64 40 / x86 32 バイト)
typedef struct MCAST_LEASE_RESPONSE {
    INT LeaseStartTime;
    INT LeaseEndTime;
    IPNG_ADDRESS ServerAddress;
    WORD AddrCount;
    BYTE* pAddrBuf;
} MCAST_LEASE_RESPONSE;
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_RESPONSE
{
    public int LeaseStartTime;
    public int LeaseEndTime;
    public IPNG_ADDRESS ServerAddress;
    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_RESPONSE
    Public LeaseStartTime As Integer
    Public LeaseEndTime As Integer
    Public ServerAddress As IPNG_ADDRESS
    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_RESPONSE(ctypes.Structure):
    _fields_ = [
        ("LeaseStartTime", ctypes.c_int),
        ("LeaseEndTime", ctypes.c_int),
        ("ServerAddress", IPNG_ADDRESS),
        ("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_RESPONSE {
    pub LeaseStartTime: i32,
    pub LeaseEndTime: i32,
    pub ServerAddress: IPNG_ADDRESS,
    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_RESPONSE struct {
	LeaseStartTime int32
	LeaseEndTime int32
	ServerAddress IPNG_ADDRESS
	AddrCount uint16
	pAddrBuf uintptr
}
type
  IPNG_ADDRESS = record
    IpAddrV4: DWORD;
    IpAddrV6: array[0..15] of Byte;
  end;

  MCAST_LEASE_RESPONSE = record
    LeaseStartTime: Integer;
    LeaseEndTime: Integer;
    ServerAddress: IPNG_ADDRESS;
    AddrCount: Word;
    pAddrBuf: Pointer;
  end;
const IPNG_ADDRESS = extern struct {
    IpAddrV4: u32,
    IpAddrV6: [16]u8,
};

const MCAST_LEASE_RESPONSE = extern struct {
    LeaseStartTime: i32,
    LeaseEndTime: i32,
    ServerAddress: IPNG_ADDRESS,
    AddrCount: u16,
    pAddrBuf: ?*anyopaque,
};
type
  IPNG_ADDRESS {.bycopy.} = object
    IpAddrV4: uint32
    IpAddrV6: array[16, uint8]

  MCAST_LEASE_RESPONSE {.bycopy.} = object
    LeaseStartTime: int32
    LeaseEndTime: int32
    ServerAddress: IPNG_ADDRESS
    AddrCount: uint16
    pAddrBuf: pointer
struct IPNG_ADDRESS
{
    uint IpAddrV4;
    ubyte[16] IpAddrV6;
}

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

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