ホーム › Networking.WinSock › IGMPV3_QUERY_HEADER
IGMPV3_QUERY_HEADER
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Type | BYTE | 1 | +0 | +0 | メッセージ種別を示す。IGMPv3クエリでは0x11。 |
| Anonymous1 | _Anonymous1_e__Union | 8/4 | +8 | +4 | 最大応答コードを保持する無名共用体。 |
| Checksum | WORD | 2 | +16 | +8 | メッセージのチェックサムを示す。 |
| MulticastAddress | IN_ADDR | 8/4 | +24 | +12 | 問い合わせ対象のマルチキャストアドレスを保持するIN_ADDR。 |
| _bitfield | BYTE | 1 | +32 | +16 | QRV(クエリア堅牢性変数)等のフラグをまとめたビットフィールド。 |
| Anonymous2 | _Anonymous2_e__Union | 8/4 | +40 | +20 | QQIC(クエリ間隔コード)を保持する無名共用体。 |
| SourceCount | WORD | 2 | +48 | +24 | 後続のソースアドレス数を示す。 |
共用体: _Anonymous1_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| MaxRespCode | BYTE | 1 | +0 | +0 |
| Anonymous | _Anonymous_e__Struct | 8/4 | +0 | +0 |
共用体: _Anonymous2_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| QueriersQueryInterfaceCode | BYTE | 1 | +0 | +0 |
| Anonymous | _Anonymous_e__Struct | 8/4 | +0 | +0 |
各言語での定義
#include <windows.h>
// IN_ADDR (x64 8 / x86 4 バイト)
typedef struct IN_ADDR {
_S_un_e__Union S_un;
} IN_ADDR;
// IGMPV3_QUERY_HEADER (x64 56 / x86 28 バイト)
typedef struct IGMPV3_QUERY_HEADER {
BYTE Type;
_Anonymous1_e__Union Anonymous1;
WORD Checksum;
IN_ADDR MulticastAddress;
BYTE _bitfield;
_Anonymous2_e__Union Anonymous2;
WORD SourceCount;
} IGMPV3_QUERY_HEADER;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IN_ADDR
{
public _S_un_e__Union S_un;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IGMPV3_QUERY_HEADER
{
public byte Type;
public _Anonymous1_e__Union Anonymous1;
public ushort Checksum;
public IN_ADDR MulticastAddress;
public byte _bitfield;
public _Anonymous2_e__Union Anonymous2;
public ushort SourceCount;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IN_ADDR
Public S_un As _S_un_e__Union
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IGMPV3_QUERY_HEADER
Public Type As Byte
Public Anonymous1 As _Anonymous1_e__Union
Public Checksum As UShort
Public MulticastAddress As IN_ADDR
Public _bitfield As Byte
Public Anonymous2 As _Anonymous2_e__Union
Public SourceCount As UShort
End Structureimport ctypes
from ctypes import wintypes
class IN_ADDR(ctypes.Structure):
_fields_ = [
("S_un", _S_un_e__Union),
]
class IGMPV3_QUERY_HEADER(ctypes.Structure):
_fields_ = [
("Type", ctypes.c_ubyte),
("Anonymous1", _Anonymous1_e__Union),
("Checksum", ctypes.c_ushort),
("MulticastAddress", IN_ADDR),
("_bitfield", ctypes.c_ubyte),
("Anonymous2", _Anonymous2_e__Union),
("SourceCount", ctypes.c_ushort),
]#[repr(C)]
pub struct IN_ADDR {
pub S_un: _S_un_e__Union,
}
#[repr(C)]
pub struct IGMPV3_QUERY_HEADER {
pub Type: u8,
pub Anonymous1: _Anonymous1_e__Union,
pub Checksum: u16,
pub MulticastAddress: IN_ADDR,
pub _bitfield: u8,
pub Anonymous2: _Anonymous2_e__Union,
pub SourceCount: u16,
}import "golang.org/x/sys/windows"
type IN_ADDR struct {
S_un _S_un_e__Union
}
type IGMPV3_QUERY_HEADER struct {
Type byte
Anonymous1 _Anonymous1_e__Union
Checksum uint16
MulticastAddress IN_ADDR
_bitfield byte
Anonymous2 _Anonymous2_e__Union
SourceCount uint16
}type
IN_ADDR = record
S_un: _S_un_e__Union;
end;
IGMPV3_QUERY_HEADER = record
Type: Byte;
Anonymous1: _Anonymous1_e__Union;
Checksum: Word;
MulticastAddress: IN_ADDR;
_bitfield: Byte;
Anonymous2: _Anonymous2_e__Union;
SourceCount: Word;
end;const IN_ADDR = extern struct {
S_un: _S_un_e__Union,
};
const IGMPV3_QUERY_HEADER = extern struct {
Type: u8,
Anonymous1: _Anonymous1_e__Union,
Checksum: u16,
MulticastAddress: IN_ADDR,
_bitfield: u8,
Anonymous2: _Anonymous2_e__Union,
SourceCount: u16,
};type
IN_ADDR {.bycopy.} = object
S_un: _S_un_e__Union
IGMPV3_QUERY_HEADER {.bycopy.} = object
Type: uint8
Anonymous1: _Anonymous1_e__Union
Checksum: uint16
MulticastAddress: IN_ADDR
_bitfield: uint8
Anonymous2: _Anonymous2_e__Union
SourceCount: uint16struct IN_ADDR
{
_S_un_e__Union S_un;
}
struct IGMPV3_QUERY_HEADER
{
ubyte Type;
_Anonymous1_e__Union Anonymous1;
ushort Checksum;
IN_ADDR MulticastAddress;
ubyte _bitfield;
_Anonymous2_e__Union Anonymous2;
ushort SourceCount;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; IGMPV3_QUERY_HEADER サイズ: 28 バイト(x86)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; Type : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; Anonymous1 : _Anonymous1_e__Union (+4, 4byte) varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; Checksum : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; MulticastAddress : IN_ADDR (+12, 4byte) varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; _bitfield : BYTE (+16, 1byte) poke st,16,値 / 値 = peek(st,16)
; Anonymous2 : _Anonymous2_e__Union (+20, 4byte) varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; SourceCount : WORD (+24, 2byte) wpoke st,24,値 / 値 = wpeek(st,24)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IGMPV3_QUERY_HEADER サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Type : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; Anonymous1 : _Anonymous1_e__Union (+8, 8byte) varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; Checksum : WORD (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; MulticastAddress : IN_ADDR (+24, 8byte) varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; _bitfield : BYTE (+32, 1byte) poke st,32,値 / 値 = peek(st,32)
; Anonymous2 : _Anonymous2_e__Union (+40, 8byte) varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; SourceCount : WORD (+48, 2byte) wpoke st,48,値 / 値 = wpeek(st,48)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global IN_ADDR
#field byte S_un 8
#endstruct
#defstruct global IGMPV3_QUERY_HEADER
#field byte Type
#field byte Anonymous1 8
#field short Checksum
#field IN_ADDR MulticastAddress
#field byte _bitfield
#field byte Anonymous2 8
#field short SourceCount
#endstruct
stdim st, IGMPV3_QUERY_HEADER ; NSTRUCT 変数を確保
st->Type = 100
mes "Type=" + st->Type
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。