ホーム › Networking.WinSock › ICMPV4_ROUTER_SOLICIT
ICMPV4_ROUTER_SOLICIT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| RsHeader | ICMP_MESSAGE | 8 | +0 | +0 | ルータ要請メッセージのヘッダーを保持するICMP_MESSAGE。 |
各言語での定義
#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_ROUTER_SOLICIT (x64 8 / x86 8 バイト)
typedef struct ICMPV4_ROUTER_SOLICIT {
ICMP_MESSAGE RsHeader;
} ICMPV4_ROUTER_SOLICIT;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_ROUTER_SOLICIT
{
public ICMP_MESSAGE RsHeader;
}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_ROUTER_SOLICIT
Public RsHeader As ICMP_MESSAGE
End Structureimport 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_ROUTER_SOLICIT(ctypes.Structure):
_fields_ = [
("RsHeader", ICMP_MESSAGE),
]#[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_ROUTER_SOLICIT {
pub RsHeader: ICMP_MESSAGE,
}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_ROUTER_SOLICIT struct {
RsHeader ICMP_MESSAGE
}type
ICMP_HEADER = record
Type: Byte;
Code: Byte;
Checksum: Word;
end;
ICMP_MESSAGE = record
Header: ICMP_HEADER;
Data: _Data_e__Union;
end;
ICMPV4_ROUTER_SOLICIT = record
RsHeader: ICMP_MESSAGE;
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_ROUTER_SOLICIT = extern struct {
RsHeader: ICMP_MESSAGE,
};type
ICMP_HEADER {.bycopy.} = object
Type: uint8
Code: uint8
Checksum: uint16
ICMP_MESSAGE {.bycopy.} = object
Header: ICMP_HEADER
Data: _Data_e__Union
ICMPV4_ROUTER_SOLICIT {.bycopy.} = object
RsHeader: ICMP_MESSAGEstruct ICMP_HEADER
{
ubyte Type;
ubyte Code;
ushort Checksum;
}
struct ICMP_MESSAGE
{
ICMP_HEADER Header;
_Data_e__Union Data;
}
struct ICMPV4_ROUTER_SOLICIT
{
ICMP_MESSAGE RsHeader;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ICMPV4_ROUTER_SOLICIT サイズ: 8 バイト(x64)
dim st, 2 ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; RsHeader : ICMP_MESSAGE (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; ※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_ROUTER_SOLICIT
#field ICMP_MESSAGE RsHeader
#endstruct
stdim st, ICMPV4_ROUTER_SOLICIT ; NSTRUCT 変数を確保