Win32 API 日本語リファレンス
ホームNetworking.WinSock › QOS

QOS

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

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

フィールド

フィールドサイズx64x86説明
SendingFlowspecFLOWSPEC32+0+0送信方向のQoSフロー仕様(FLOWSPEC)である。
ReceivingFlowspecFLOWSPEC32+32+32受信方向のQoSフロー仕様(FLOWSPEC)である。
ProviderSpecificWSABUF16/8+64+64プロバイダ固有のQoSデータを保持するWSABUFである。

各言語での定義

#include <windows.h>

// FLOWSPEC  (x64 32 / x86 32 バイト)
typedef struct FLOWSPEC {
    DWORD TokenRate;
    DWORD TokenBucketSize;
    DWORD PeakBandwidth;
    DWORD Latency;
    DWORD DelayVariation;
    DWORD ServiceType;
    DWORD MaxSduSize;
    DWORD MinimumPolicedSize;
} FLOWSPEC;

// WSABUF  (x64 16 / x86 8 バイト)
typedef struct WSABUF {
    DWORD len;
    LPSTR buf;
} WSABUF;

// QOS  (x64 80 / x86 72 バイト)
typedef struct QOS {
    FLOWSPEC SendingFlowspec;
    FLOWSPEC ReceivingFlowspec;
    WSABUF ProviderSpecific;
} QOS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FLOWSPEC
{
    public uint TokenRate;
    public uint TokenBucketSize;
    public uint PeakBandwidth;
    public uint Latency;
    public uint DelayVariation;
    public uint ServiceType;
    public uint MaxSduSize;
    public uint MinimumPolicedSize;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSABUF
{
    public uint len;
    public IntPtr buf;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct QOS
{
    public FLOWSPEC SendingFlowspec;
    public FLOWSPEC ReceivingFlowspec;
    public WSABUF ProviderSpecific;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FLOWSPEC
    Public TokenRate As UInteger
    Public TokenBucketSize As UInteger
    Public PeakBandwidth As UInteger
    Public Latency As UInteger
    Public DelayVariation As UInteger
    Public ServiceType As UInteger
    Public MaxSduSize As UInteger
    Public MinimumPolicedSize As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSABUF
    Public len As UInteger
    Public buf As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure QOS
    Public SendingFlowspec As FLOWSPEC
    Public ReceivingFlowspec As FLOWSPEC
    Public ProviderSpecific As WSABUF
End Structure
import ctypes
from ctypes import wintypes

class FLOWSPEC(ctypes.Structure):
    _fields_ = [
        ("TokenRate", wintypes.DWORD),
        ("TokenBucketSize", wintypes.DWORD),
        ("PeakBandwidth", wintypes.DWORD),
        ("Latency", wintypes.DWORD),
        ("DelayVariation", wintypes.DWORD),
        ("ServiceType", wintypes.DWORD),
        ("MaxSduSize", wintypes.DWORD),
        ("MinimumPolicedSize", wintypes.DWORD),
    ]

class WSABUF(ctypes.Structure):
    _fields_ = [
        ("len", wintypes.DWORD),
        ("buf", ctypes.c_void_p),
    ]

class QOS(ctypes.Structure):
    _fields_ = [
        ("SendingFlowspec", FLOWSPEC),
        ("ReceivingFlowspec", FLOWSPEC),
        ("ProviderSpecific", WSABUF),
    ]
#[repr(C)]
pub struct FLOWSPEC {
    pub TokenRate: u32,
    pub TokenBucketSize: u32,
    pub PeakBandwidth: u32,
    pub Latency: u32,
    pub DelayVariation: u32,
    pub ServiceType: u32,
    pub MaxSduSize: u32,
    pub MinimumPolicedSize: u32,
}

#[repr(C)]
pub struct WSABUF {
    pub len: u32,
    pub buf: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct QOS {
    pub SendingFlowspec: FLOWSPEC,
    pub ReceivingFlowspec: FLOWSPEC,
    pub ProviderSpecific: WSABUF,
}
import "golang.org/x/sys/windows"

type FLOWSPEC struct {
	TokenRate uint32
	TokenBucketSize uint32
	PeakBandwidth uint32
	Latency uint32
	DelayVariation uint32
	ServiceType uint32
	MaxSduSize uint32
	MinimumPolicedSize uint32
}

type WSABUF struct {
	len uint32
	buf uintptr
}

type QOS struct {
	SendingFlowspec FLOWSPEC
	ReceivingFlowspec FLOWSPEC
	ProviderSpecific WSABUF
}
type
  FLOWSPEC = record
    TokenRate: DWORD;
    TokenBucketSize: DWORD;
    PeakBandwidth: DWORD;
    Latency: DWORD;
    DelayVariation: DWORD;
    ServiceType: DWORD;
    MaxSduSize: DWORD;
    MinimumPolicedSize: DWORD;
  end;

  WSABUF = record
    len: DWORD;
    buf: Pointer;
  end;

  QOS = record
    SendingFlowspec: FLOWSPEC;
    ReceivingFlowspec: FLOWSPEC;
    ProviderSpecific: WSABUF;
  end;
const FLOWSPEC = extern struct {
    TokenRate: u32,
    TokenBucketSize: u32,
    PeakBandwidth: u32,
    Latency: u32,
    DelayVariation: u32,
    ServiceType: u32,
    MaxSduSize: u32,
    MinimumPolicedSize: u32,
};

const WSABUF = extern struct {
    len: u32,
    buf: ?*anyopaque,
};

const QOS = extern struct {
    SendingFlowspec: FLOWSPEC,
    ReceivingFlowspec: FLOWSPEC,
    ProviderSpecific: WSABUF,
};
type
  FLOWSPEC {.bycopy.} = object
    TokenRate: uint32
    TokenBucketSize: uint32
    PeakBandwidth: uint32
    Latency: uint32
    DelayVariation: uint32
    ServiceType: uint32
    MaxSduSize: uint32
    MinimumPolicedSize: uint32

  WSABUF {.bycopy.} = object
    len: uint32
    buf: pointer

  QOS {.bycopy.} = object
    SendingFlowspec: FLOWSPEC
    ReceivingFlowspec: FLOWSPEC
    ProviderSpecific: WSABUF
struct FLOWSPEC
{
    uint TokenRate;
    uint TokenBucketSize;
    uint PeakBandwidth;
    uint Latency;
    uint DelayVariation;
    uint ServiceType;
    uint MaxSduSize;
    uint MinimumPolicedSize;
}

struct WSABUF
{
    uint len;
    void* buf;
}

struct QOS
{
    FLOWSPEC SendingFlowspec;
    FLOWSPEC ReceivingFlowspec;
    WSABUF ProviderSpecific;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; QOS サイズ: 72 バイト(x86)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; SendingFlowspec : FLOWSPEC (+0, 32byte)  varptr(st)+0 を基点に操作(32byte:入れ子/配列)
; ReceivingFlowspec : FLOWSPEC (+32, 32byte)  varptr(st)+32 を基点に操作(32byte:入れ子/配列)
; ProviderSpecific : WSABUF (+64, 8byte)  varptr(st)+64 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; QOS サイズ: 80 バイト(x64)
dim st, 20    ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; SendingFlowspec : FLOWSPEC (+0, 32byte)  varptr(st)+0 を基点に操作(32byte:入れ子/配列)
; ReceivingFlowspec : FLOWSPEC (+32, 32byte)  varptr(st)+32 を基点に操作(32byte:入れ子/配列)
; ProviderSpecific : WSABUF (+64, 16byte)  varptr(st)+64 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global FLOWSPEC
    #field int TokenRate
    #field int TokenBucketSize
    #field int PeakBandwidth
    #field int Latency
    #field int DelayVariation
    #field int ServiceType
    #field int MaxSduSize
    #field int MinimumPolicedSize
#endstruct

#defstruct global WSABUF
    #field int len
    #field intptr buf
#endstruct

#defstruct global QOS
    #field FLOWSPEC SendingFlowspec
    #field FLOWSPEC ReceivingFlowspec
    #field WSABUF ProviderSpecific
#endstruct

stdim st, QOS        ; NSTRUCT 変数を確保