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

IGMPV3_REPORT_HEADER

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

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

フィールド

フィールドサイズx64x86説明
TypeBYTE1+0+0メッセージ種別を示す。IGMPv3レポートでは0x22。
ReservedBYTE1+1+1予約済みバイト。通常ゼロにする。
ChecksumWORD2+2+2メッセージのチェックサムを示す。
Reserved2WORD2+4+4予約済みワード。通常ゼロにする。
RecordCountWORD2+6+6後続のグループレコード数を示す。

各言語での定義

#include <windows.h>

// IGMPV3_REPORT_HEADER  (x64 8 / x86 8 バイト)
typedef struct IGMPV3_REPORT_HEADER {
    BYTE Type;
    BYTE Reserved;
    WORD Checksum;
    WORD Reserved2;
    WORD RecordCount;
} IGMPV3_REPORT_HEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IGMPV3_REPORT_HEADER
{
    public byte Type;
    public byte Reserved;
    public ushort Checksum;
    public ushort Reserved2;
    public ushort RecordCount;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IGMPV3_REPORT_HEADER
    Public Type As Byte
    Public Reserved As Byte
    Public Checksum As UShort
    Public Reserved2 As UShort
    Public RecordCount As UShort
End Structure
import ctypes
from ctypes import wintypes

class IGMPV3_REPORT_HEADER(ctypes.Structure):
    _fields_ = [
        ("Type", ctypes.c_ubyte),
        ("Reserved", ctypes.c_ubyte),
        ("Checksum", ctypes.c_ushort),
        ("Reserved2", ctypes.c_ushort),
        ("RecordCount", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct IGMPV3_REPORT_HEADER {
    pub Type: u8,
    pub Reserved: u8,
    pub Checksum: u16,
    pub Reserved2: u16,
    pub RecordCount: u16,
}
import "golang.org/x/sys/windows"

type IGMPV3_REPORT_HEADER struct {
	Type byte
	Reserved byte
	Checksum uint16
	Reserved2 uint16
	RecordCount uint16
}
type
  IGMPV3_REPORT_HEADER = record
    Type: Byte;
    Reserved: Byte;
    Checksum: Word;
    Reserved2: Word;
    RecordCount: Word;
  end;
const IGMPV3_REPORT_HEADER = extern struct {
    Type: u8,
    Reserved: u8,
    Checksum: u16,
    Reserved2: u16,
    RecordCount: u16,
};
type
  IGMPV3_REPORT_HEADER {.bycopy.} = object
    Type: uint8
    Reserved: uint8
    Checksum: uint16
    Reserved2: uint16
    RecordCount: uint16
struct IGMPV3_REPORT_HEADER
{
    ubyte Type;
    ubyte Reserved;
    ushort Checksum;
    ushort Reserved2;
    ushort RecordCount;
}

HSP用 定義

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

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

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