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

RSVP_ADSPEC

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

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

フィールド

フィールドサイズx64x86説明
ObjectHdrQOS_OBJECT_HDR8+0+0オブジェクト種別と長さを示すQOS_OBJECT_HDR。
GeneralParamsAD_GENERAL_PARAMS20+8+8ADSPEC全体に適用される一般パラメータ(AD_GENERAL_PARAMS)。
NumberOfServicesDWORD4+28+28後続の制御サービス記述の数。
ServicesCONTROL_SERVICE44+32+32CONTROL_SERVICE群の先頭要素。

各言語での定義

#include <windows.h>

// QOS_OBJECT_HDR  (x64 8 / x86 8 バイト)
typedef struct QOS_OBJECT_HDR {
    DWORD ObjectType;
    DWORD ObjectLength;
} QOS_OBJECT_HDR;

// AD_GENERAL_PARAMS  (x64 20 / x86 20 バイト)
typedef struct AD_GENERAL_PARAMS {
    DWORD IntServAwareHopCount;
    DWORD PathBandwidthEstimate;
    DWORD MinimumLatency;
    DWORD PathMTU;
    DWORD Flags;
} AD_GENERAL_PARAMS;

// CONTROL_SERVICE  (x64 44 / x86 44 バイト)
typedef struct CONTROL_SERVICE {
    DWORD Length;
    DWORD Service;
    AD_GENERAL_PARAMS Overrides;
    _Anonymous_e__Union Anonymous;
} CONTROL_SERVICE;

// RSVP_ADSPEC  (x64 76 / x86 76 バイト)
typedef struct RSVP_ADSPEC {
    QOS_OBJECT_HDR ObjectHdr;
    AD_GENERAL_PARAMS GeneralParams;
    DWORD NumberOfServices;
    CONTROL_SERVICE Services[1];
} RSVP_ADSPEC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct QOS_OBJECT_HDR
{
    public uint ObjectType;
    public uint ObjectLength;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AD_GENERAL_PARAMS
{
    public uint IntServAwareHopCount;
    public uint PathBandwidthEstimate;
    public uint MinimumLatency;
    public uint PathMTU;
    public uint Flags;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CONTROL_SERVICE
{
    public uint Length;
    public uint Service;
    public AD_GENERAL_PARAMS Overrides;
    public _Anonymous_e__Union Anonymous;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RSVP_ADSPEC
{
    public QOS_OBJECT_HDR ObjectHdr;
    public AD_GENERAL_PARAMS GeneralParams;
    public uint NumberOfServices;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public CONTROL_SERVICE[] Services;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure QOS_OBJECT_HDR
    Public ObjectType As UInteger
    Public ObjectLength As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure AD_GENERAL_PARAMS
    Public IntServAwareHopCount As UInteger
    Public PathBandwidthEstimate As UInteger
    Public MinimumLatency As UInteger
    Public PathMTU As UInteger
    Public Flags As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CONTROL_SERVICE
    Public Length As UInteger
    Public Service As UInteger
    Public Overrides As AD_GENERAL_PARAMS
    Public Anonymous As _Anonymous_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RSVP_ADSPEC
    Public ObjectHdr As QOS_OBJECT_HDR
    Public GeneralParams As AD_GENERAL_PARAMS
    Public NumberOfServices As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Services() As CONTROL_SERVICE
End Structure
import ctypes
from ctypes import wintypes

class QOS_OBJECT_HDR(ctypes.Structure):
    _fields_ = [
        ("ObjectType", wintypes.DWORD),
        ("ObjectLength", wintypes.DWORD),
    ]

class AD_GENERAL_PARAMS(ctypes.Structure):
    _fields_ = [
        ("IntServAwareHopCount", wintypes.DWORD),
        ("PathBandwidthEstimate", wintypes.DWORD),
        ("MinimumLatency", wintypes.DWORD),
        ("PathMTU", wintypes.DWORD),
        ("Flags", wintypes.DWORD),
    ]

class CONTROL_SERVICE(ctypes.Structure):
    _fields_ = [
        ("Length", wintypes.DWORD),
        ("Service", wintypes.DWORD),
        ("Overrides", AD_GENERAL_PARAMS),
        ("Anonymous", _Anonymous_e__Union),
    ]

class RSVP_ADSPEC(ctypes.Structure):
    _fields_ = [
        ("ObjectHdr", QOS_OBJECT_HDR),
        ("GeneralParams", AD_GENERAL_PARAMS),
        ("NumberOfServices", wintypes.DWORD),
        ("Services", CONTROL_SERVICE * 1),
    ]
#[repr(C)]
pub struct QOS_OBJECT_HDR {
    pub ObjectType: u32,
    pub ObjectLength: u32,
}

#[repr(C)]
pub struct AD_GENERAL_PARAMS {
    pub IntServAwareHopCount: u32,
    pub PathBandwidthEstimate: u32,
    pub MinimumLatency: u32,
    pub PathMTU: u32,
    pub Flags: u32,
}

#[repr(C)]
pub struct CONTROL_SERVICE {
    pub Length: u32,
    pub Service: u32,
    pub Overrides: AD_GENERAL_PARAMS,
    pub Anonymous: _Anonymous_e__Union,
}

#[repr(C)]
pub struct RSVP_ADSPEC {
    pub ObjectHdr: QOS_OBJECT_HDR,
    pub GeneralParams: AD_GENERAL_PARAMS,
    pub NumberOfServices: u32,
    pub Services: [CONTROL_SERVICE; 1],
}
import "golang.org/x/sys/windows"

type QOS_OBJECT_HDR struct {
	ObjectType uint32
	ObjectLength uint32
}

type AD_GENERAL_PARAMS struct {
	IntServAwareHopCount uint32
	PathBandwidthEstimate uint32
	MinimumLatency uint32
	PathMTU uint32
	Flags uint32
}

type CONTROL_SERVICE struct {
	Length uint32
	Service uint32
	Overrides AD_GENERAL_PARAMS
	Anonymous _Anonymous_e__Union
}

type RSVP_ADSPEC struct {
	ObjectHdr QOS_OBJECT_HDR
	GeneralParams AD_GENERAL_PARAMS
	NumberOfServices uint32
	Services [1]CONTROL_SERVICE
}
type
  QOS_OBJECT_HDR = record
    ObjectType: DWORD;
    ObjectLength: DWORD;
  end;

  AD_GENERAL_PARAMS = record
    IntServAwareHopCount: DWORD;
    PathBandwidthEstimate: DWORD;
    MinimumLatency: DWORD;
    PathMTU: DWORD;
    Flags: DWORD;
  end;

  CONTROL_SERVICE = record
    Length: DWORD;
    Service: DWORD;
    Overrides: AD_GENERAL_PARAMS;
    Anonymous: _Anonymous_e__Union;
  end;

  RSVP_ADSPEC = record
    ObjectHdr: QOS_OBJECT_HDR;
    GeneralParams: AD_GENERAL_PARAMS;
    NumberOfServices: DWORD;
    Services: array[0..0] of CONTROL_SERVICE;
  end;
const QOS_OBJECT_HDR = extern struct {
    ObjectType: u32,
    ObjectLength: u32,
};

const AD_GENERAL_PARAMS = extern struct {
    IntServAwareHopCount: u32,
    PathBandwidthEstimate: u32,
    MinimumLatency: u32,
    PathMTU: u32,
    Flags: u32,
};

const CONTROL_SERVICE = extern struct {
    Length: u32,
    Service: u32,
    Overrides: AD_GENERAL_PARAMS,
    Anonymous: _Anonymous_e__Union,
};

const RSVP_ADSPEC = extern struct {
    ObjectHdr: QOS_OBJECT_HDR,
    GeneralParams: AD_GENERAL_PARAMS,
    NumberOfServices: u32,
    Services: [1]CONTROL_SERVICE,
};
type
  QOS_OBJECT_HDR {.bycopy.} = object
    ObjectType: uint32
    ObjectLength: uint32

  AD_GENERAL_PARAMS {.bycopy.} = object
    IntServAwareHopCount: uint32
    PathBandwidthEstimate: uint32
    MinimumLatency: uint32
    PathMTU: uint32
    Flags: uint32

  CONTROL_SERVICE {.bycopy.} = object
    Length: uint32
    Service: uint32
    Overrides: AD_GENERAL_PARAMS
    Anonymous: _Anonymous_e__Union

  RSVP_ADSPEC {.bycopy.} = object
    ObjectHdr: QOS_OBJECT_HDR
    GeneralParams: AD_GENERAL_PARAMS
    NumberOfServices: uint32
    Services: array[1, CONTROL_SERVICE]
struct QOS_OBJECT_HDR
{
    uint ObjectType;
    uint ObjectLength;
}

struct AD_GENERAL_PARAMS
{
    uint IntServAwareHopCount;
    uint PathBandwidthEstimate;
    uint MinimumLatency;
    uint PathMTU;
    uint Flags;
}

struct CONTROL_SERVICE
{
    uint Length;
    uint Service;
    AD_GENERAL_PARAMS Overrides;
    _Anonymous_e__Union Anonymous;
}

struct RSVP_ADSPEC
{
    QOS_OBJECT_HDR ObjectHdr;
    AD_GENERAL_PARAMS GeneralParams;
    uint NumberOfServices;
    CONTROL_SERVICE[1] Services;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; RSVP_ADSPEC サイズ: 76 バイト(x64)
dim st, 19    ; 4byte整数×19(構造体サイズ 76 / 4 切り上げ)
; ObjectHdr : QOS_OBJECT_HDR (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; GeneralParams : AD_GENERAL_PARAMS (+8, 20byte)  varptr(st)+8 を基点に操作(20byte:入れ子/配列)
; NumberOfServices : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; Services : CONTROL_SERVICE (+32, 44byte)  varptr(st)+32 を基点に操作(44byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global QOS_OBJECT_HDR
    #field int ObjectType
    #field int ObjectLength
#endstruct

#defstruct global AD_GENERAL_PARAMS
    #field int IntServAwareHopCount
    #field int PathBandwidthEstimate
    #field int MinimumLatency
    #field int PathMTU
    #field int Flags
#endstruct

#defstruct global CONTROL_SERVICE
    #field int Length
    #field int Service
    #field AD_GENERAL_PARAMS Overrides
    #field byte Anonymous 16
#endstruct

#defstruct global RSVP_ADSPEC
    #field QOS_OBJECT_HDR ObjectHdr
    #field AD_GENERAL_PARAMS GeneralParams
    #field int NumberOfServices
    #field CONTROL_SERVICE Services 1
#endstruct

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