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

ICMPV4_ADDRESS_MASK_MESSAGE

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

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

フィールド

フィールドサイズx64x86説明
HeaderICMP_MESSAGE8+0+0アドレスマスクメッセージのヘッダーを保持するICMP_MESSAGE。
AddressMaskDWORD4+8+8サブネットアドレスマスクを示す。

各言語での定義

#include <windows.h>

// ICMP_HEADER  (x64 4 / x86 4 バイト)
typedef struct ICMP_HEADER {
    BYTE Type;
    BYTE Code;
    WORD Checksum;
} ICMP_HEADER;

// ICMP_MESSAGE  (x64 8 / x86 8 バイト)
typedef struct ICMP_MESSAGE {
    ICMP_HEADER Header;
    _Data_e__Union Data;
} ICMP_MESSAGE;

// ICMPV4_ADDRESS_MASK_MESSAGE  (x64 12 / x86 12 バイト)
typedef struct ICMPV4_ADDRESS_MASK_MESSAGE {
    ICMP_MESSAGE Header;
    DWORD AddressMask;
} ICMPV4_ADDRESS_MASK_MESSAGE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ICMP_HEADER
{
    public byte Type;
    public byte Code;
    public ushort Checksum;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ICMP_MESSAGE
{
    public ICMP_HEADER Header;
    public _Data_e__Union Data;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ICMPV4_ADDRESS_MASK_MESSAGE
{
    public ICMP_MESSAGE Header;
    public uint AddressMask;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ICMP_HEADER
    Public Type As Byte
    Public Code As Byte
    Public Checksum As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ICMP_MESSAGE
    Public Header As ICMP_HEADER
    Public Data As _Data_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ICMPV4_ADDRESS_MASK_MESSAGE
    Public Header As ICMP_MESSAGE
    Public AddressMask As UInteger
End Structure
import ctypes
from ctypes import wintypes

class ICMP_HEADER(ctypes.Structure):
    _fields_ = [
        ("Type", ctypes.c_ubyte),
        ("Code", ctypes.c_ubyte),
        ("Checksum", ctypes.c_ushort),
    ]

class ICMP_MESSAGE(ctypes.Structure):
    _fields_ = [
        ("Header", ICMP_HEADER),
        ("Data", _Data_e__Union),
    ]

class ICMPV4_ADDRESS_MASK_MESSAGE(ctypes.Structure):
    _fields_ = [
        ("Header", ICMP_MESSAGE),
        ("AddressMask", wintypes.DWORD),
    ]
#[repr(C)]
pub struct ICMP_HEADER {
    pub Type: u8,
    pub Code: u8,
    pub Checksum: u16,
}

#[repr(C)]
pub struct ICMP_MESSAGE {
    pub Header: ICMP_HEADER,
    pub Data: _Data_e__Union,
}

#[repr(C)]
pub struct ICMPV4_ADDRESS_MASK_MESSAGE {
    pub Header: ICMP_MESSAGE,
    pub AddressMask: u32,
}
import "golang.org/x/sys/windows"

type ICMP_HEADER struct {
	Type byte
	Code byte
	Checksum uint16
}

type ICMP_MESSAGE struct {
	Header ICMP_HEADER
	Data _Data_e__Union
}

type ICMPV4_ADDRESS_MASK_MESSAGE struct {
	Header ICMP_MESSAGE
	AddressMask uint32
}
type
  ICMP_HEADER = record
    Type: Byte;
    Code: Byte;
    Checksum: Word;
  end;

  ICMP_MESSAGE = record
    Header: ICMP_HEADER;
    Data: _Data_e__Union;
  end;

  ICMPV4_ADDRESS_MASK_MESSAGE = record
    Header: ICMP_MESSAGE;
    AddressMask: DWORD;
  end;
const ICMP_HEADER = extern struct {
    Type: u8,
    Code: u8,
    Checksum: u16,
};

const ICMP_MESSAGE = extern struct {
    Header: ICMP_HEADER,
    Data: _Data_e__Union,
};

const ICMPV4_ADDRESS_MASK_MESSAGE = extern struct {
    Header: ICMP_MESSAGE,
    AddressMask: u32,
};
type
  ICMP_HEADER {.bycopy.} = object
    Type: uint8
    Code: uint8
    Checksum: uint16

  ICMP_MESSAGE {.bycopy.} = object
    Header: ICMP_HEADER
    Data: _Data_e__Union

  ICMPV4_ADDRESS_MASK_MESSAGE {.bycopy.} = object
    Header: ICMP_MESSAGE
    AddressMask: uint32
struct ICMP_HEADER
{
    ubyte Type;
    ubyte Code;
    ushort Checksum;
}

struct ICMP_MESSAGE
{
    ICMP_HEADER Header;
    _Data_e__Union Data;
}

struct ICMPV4_ADDRESS_MASK_MESSAGE
{
    ICMP_MESSAGE Header;
    uint AddressMask;
}

HSP用 定義

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

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

#defstruct global ICMP_MESSAGE
    #field ICMP_HEADER Header
    #field byte Data 4
#endstruct

#defstruct global ICMPV4_ADDRESS_MASK_MESSAGE
    #field ICMP_MESSAGE Header
    #field int AddressMask
#endstruct

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