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

RSVP_FILTERSPEC_V4

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

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

フィールド

フィールドサイズx64x86説明
AddressIN_ADDR_IPV44+0+0IPv4アドレスを示すIN_ADDR_IPV4。
UnusedWORD2+4+4未使用の予約フィールド。
PortWORD2+6+6対象のポート番号。

各言語での定義

#include <windows.h>

// IN_ADDR_IPV4  (x64 4 / x86 4 バイト)
typedef struct IN_ADDR_IPV4 {
    DWORD Addr;
    BYTE AddrBytes[4];
} IN_ADDR_IPV4;

// RSVP_FILTERSPEC_V4  (x64 8 / x86 8 バイト)
typedef struct RSVP_FILTERSPEC_V4 {
    IN_ADDR_IPV4 Address;
    WORD Unused;
    WORD Port;
} RSVP_FILTERSPEC_V4;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IN_ADDR_IPV4
{
    public uint Addr;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] AddrBytes;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RSVP_FILTERSPEC_V4
{
    public IN_ADDR_IPV4 Address;
    public ushort Unused;
    public ushort Port;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IN_ADDR_IPV4
    Public Addr As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public AddrBytes() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RSVP_FILTERSPEC_V4
    Public Address As IN_ADDR_IPV4
    Public Unused As UShort
    Public Port As UShort
End Structure
import ctypes
from ctypes import wintypes

class IN_ADDR_IPV4(ctypes.Structure):
    _fields_ = [
        ("Addr", wintypes.DWORD),
        ("AddrBytes", ctypes.c_ubyte * 4),
    ]

class RSVP_FILTERSPEC_V4(ctypes.Structure):
    _fields_ = [
        ("Address", IN_ADDR_IPV4),
        ("Unused", ctypes.c_ushort),
        ("Port", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct IN_ADDR_IPV4 {
    pub Addr: u32,
    pub AddrBytes: [u8; 4],
}

#[repr(C)]
pub struct RSVP_FILTERSPEC_V4 {
    pub Address: IN_ADDR_IPV4,
    pub Unused: u16,
    pub Port: u16,
}
import "golang.org/x/sys/windows"

type IN_ADDR_IPV4 struct {
	Addr uint32
	AddrBytes [4]byte
}

type RSVP_FILTERSPEC_V4 struct {
	Address IN_ADDR_IPV4
	Unused uint16
	Port uint16
}
type
  IN_ADDR_IPV4 = record
    Addr: DWORD;
    AddrBytes: array[0..3] of Byte;
  end;

  RSVP_FILTERSPEC_V4 = record
    Address: IN_ADDR_IPV4;
    Unused: Word;
    Port: Word;
  end;
const IN_ADDR_IPV4 = extern struct {
    Addr: u32,
    AddrBytes: [4]u8,
};

const RSVP_FILTERSPEC_V4 = extern struct {
    Address: IN_ADDR_IPV4,
    Unused: u16,
    Port: u16,
};
type
  IN_ADDR_IPV4 {.bycopy.} = object
    Addr: uint32
    AddrBytes: array[4, uint8]

  RSVP_FILTERSPEC_V4 {.bycopy.} = object
    Address: IN_ADDR_IPV4
    Unused: uint16
    Port: uint16
struct IN_ADDR_IPV4
{
    uint Addr;
    ubyte[4] AddrBytes;
}

struct RSVP_FILTERSPEC_V4
{
    IN_ADDR_IPV4 Address;
    ushort Unused;
    ushort Port;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; RSVP_FILTERSPEC_V4 サイズ: 8 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; Address : IN_ADDR_IPV4 (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; Unused : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; Port : WORD (+6, 2byte)  wpoke st,6,値  /  値 = wpeek(st,6)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global RSVP_FILTERSPEC_V4
    #field byte Address 4
    #field short Unused
    #field short Port
#endstruct

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