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

QOS_DIFFSERV

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

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

フィールド

フィールドサイズx64x86説明
ObjectHdrQOS_OBJECT_HDR8+0+0オブジェクト種別と長さを示すQOS_OBJECT_HDR。
DSFieldCountDWORD4+8+8後続のDiffServ規則の数。
DiffservRuleBYTE1+12+12DiffServ規則データの先頭バイト。可変長配列の起点となる。

各言語での定義

#include <windows.h>

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

// QOS_DIFFSERV  (x64 16 / x86 16 バイト)
typedef struct QOS_DIFFSERV {
    QOS_OBJECT_HDR ObjectHdr;
    DWORD DSFieldCount;
    BYTE DiffservRule[1];
} QOS_DIFFSERV;
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 QOS_DIFFSERV
{
    public QOS_OBJECT_HDR ObjectHdr;
    public uint DSFieldCount;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] DiffservRule;
}
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 QOS_DIFFSERV
    Public ObjectHdr As QOS_OBJECT_HDR
    Public DSFieldCount As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public DiffservRule() As Byte
End Structure
import ctypes
from ctypes import wintypes

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

class QOS_DIFFSERV(ctypes.Structure):
    _fields_ = [
        ("ObjectHdr", QOS_OBJECT_HDR),
        ("DSFieldCount", wintypes.DWORD),
        ("DiffservRule", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct QOS_OBJECT_HDR {
    pub ObjectType: u32,
    pub ObjectLength: u32,
}

#[repr(C)]
pub struct QOS_DIFFSERV {
    pub ObjectHdr: QOS_OBJECT_HDR,
    pub DSFieldCount: u32,
    pub DiffservRule: [u8; 1],
}
import "golang.org/x/sys/windows"

type QOS_OBJECT_HDR struct {
	ObjectType uint32
	ObjectLength uint32
}

type QOS_DIFFSERV struct {
	ObjectHdr QOS_OBJECT_HDR
	DSFieldCount uint32
	DiffservRule [1]byte
}
type
  QOS_OBJECT_HDR = record
    ObjectType: DWORD;
    ObjectLength: DWORD;
  end;

  QOS_DIFFSERV = record
    ObjectHdr: QOS_OBJECT_HDR;
    DSFieldCount: DWORD;
    DiffservRule: array[0..0] of Byte;
  end;
const QOS_OBJECT_HDR = extern struct {
    ObjectType: u32,
    ObjectLength: u32,
};

const QOS_DIFFSERV = extern struct {
    ObjectHdr: QOS_OBJECT_HDR,
    DSFieldCount: u32,
    DiffservRule: [1]u8,
};
type
  QOS_OBJECT_HDR {.bycopy.} = object
    ObjectType: uint32
    ObjectLength: uint32

  QOS_DIFFSERV {.bycopy.} = object
    ObjectHdr: QOS_OBJECT_HDR
    DSFieldCount: uint32
    DiffservRule: array[1, uint8]
struct QOS_OBJECT_HDR
{
    uint ObjectType;
    uint ObjectLength;
}

struct QOS_DIFFSERV
{
    QOS_OBJECT_HDR ObjectHdr;
    uint DSFieldCount;
    ubyte[1] DiffservRule;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; QOS_DIFFSERV サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; ObjectHdr : QOS_OBJECT_HDR (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; DSFieldCount : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; DiffservRule : BYTE (+12, 1byte)  varptr(st)+12 を基点に操作(1byte:入れ子/配列)
; ※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 QOS_DIFFSERV
    #field QOS_OBJECT_HDR ObjectHdr
    #field int DSFieldCount
    #field byte DiffservRule 1
#endstruct

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