ICMPV6_ECHO_REPLY_LH
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Address | IPV6_ADDRESS_EX | 26 | +0 | +0 | 応答した IPv6 アドレスです。IPV6_ADDRESS_EX 構造体の形式で格納されます。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Status | DWORD | 4 | +28 | +28 | エコー要求の状態を IP_STATUS コードの形式で示します。このメンバーに指定できる値は Ipexport.h ヘッダーファイルで定義されています。
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RoundTripTime | DWORD | 4 | +32 | +32 | ラウンドトリップ時間 (ミリ秒単位) です。 |
公式ドキュメント
ICMPV6_ECHO_REPLY 構造体は、IPv6 エコー要求に応答して返されるデータを記述します。
解説(Remarks)
ICMPV6_ECHO_REPLY 構造体は、IPv6 エコー要求への応答を返すために Icmp6ParseReplies 関数で使用されます。ICMPV6 応答のメッセージ本文を含む応答データは、メモリ上で ICMPV6_ECHO_REPLY 構造体の直後に続きます。
IPv6 の場合、Status メンバーに指定できる値の一部は RFC 2163 で規定されています。詳細については、www.ietf.org/rfc/rfc2463.txt を参照してください。
Status メンバーの IP_STATUS エラーコードに対応する IP ヘルパーのエラー文字列を取得するには、GetIpErrorString 関数を使用できます。
ICMPV6_ECHO_REPLY 構造体は Microsoft Windows Software Development Kit (SDK) に含まれる公開ヘッダーファイルで定義されていますが、この構造体が Icmp6ParseReplies 関数で使用されるのは Windows XP 以降です。
Windows SDK では、対象プラットフォームが Windows XP 以降
(NTDDI_VERSION >= NTDDI_XP、
_WIN32_WINNT >= 0x0501、または
WINVER >= 0x0501) の場合にアプリケーションをコンパイルすると、ICMPV6_ECHO_REPLY_LH 構造体が定義されます。ICMPV6_ECHO_REPLY_LH 構造体は ICMPV6_ECHO_REPLY 構造体に typedef されています。対象プラットフォームが Windows XP 以降でない場合にアプリケーションをコンパイルすると、
ICMPV6_ECHO_REPLY 構造体は未定義になります。
この構造体は Ipexport.h ヘッダーファイルで定義されており、このファイルは Iphlpapi.h ヘッダーファイルに自動的にインクルードされます。Ipexport.h ヘッダーファイルを直接使用しないでください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// IPV6_ADDRESS_EX (x64 26 / x86 26 バイト)
#pragma pack(push, 1)
typedef struct IPV6_ADDRESS_EX {
WORD sin6_port;
DWORD sin6_flowinfo;
WORD sin6_addr[8];
DWORD sin6_scope_id;
} IPV6_ADDRESS_EX;
#pragma pack(pop)
// ICMPV6_ECHO_REPLY_LH (x64 36 / x86 36 バイト)
typedef struct ICMPV6_ECHO_REPLY_LH {
IPV6_ADDRESS_EX Address;
DWORD Status;
DWORD RoundTripTime;
} ICMPV6_ECHO_REPLY_LH;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct IPV6_ADDRESS_EX
{
public ushort sin6_port;
public uint sin6_flowinfo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public ushort[] sin6_addr;
public uint sin6_scope_id;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ICMPV6_ECHO_REPLY_LH
{
public IPV6_ADDRESS_EX Address;
public uint Status;
public uint RoundTripTime;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure IPV6_ADDRESS_EX
Public sin6_port As UShort
Public sin6_flowinfo As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public sin6_addr() As UShort
Public sin6_scope_id As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ICMPV6_ECHO_REPLY_LH
Public Address As IPV6_ADDRESS_EX
Public Status As UInteger
Public RoundTripTime As UInteger
End Structureimport ctypes
from ctypes import wintypes
class IPV6_ADDRESS_EX(ctypes.Structure):
_pack_ = 1
_fields_ = [
("sin6_port", ctypes.c_ushort),
("sin6_flowinfo", wintypes.DWORD),
("sin6_addr", ctypes.c_ushort * 8),
("sin6_scope_id", wintypes.DWORD),
]
class ICMPV6_ECHO_REPLY_LH(ctypes.Structure):
_fields_ = [
("Address", IPV6_ADDRESS_EX),
("Status", wintypes.DWORD),
("RoundTripTime", wintypes.DWORD),
]#[repr(C, packed(1))]
pub struct IPV6_ADDRESS_EX {
pub sin6_port: u16,
pub sin6_flowinfo: u32,
pub sin6_addr: [u16; 8],
pub sin6_scope_id: u32,
}
#[repr(C)]
pub struct ICMPV6_ECHO_REPLY_LH {
pub Address: IPV6_ADDRESS_EX,
pub Status: u32,
pub RoundTripTime: u32,
}import "golang.org/x/sys/windows"
type IPV6_ADDRESS_EX struct {
sin6_port uint16
sin6_flowinfo uint32
sin6_addr [8]uint16
sin6_scope_id uint32
}
type ICMPV6_ECHO_REPLY_LH struct {
Address IPV6_ADDRESS_EX
Status uint32
RoundTripTime uint32
}type
IPV6_ADDRESS_EX = packed record
sin6_port: Word;
sin6_flowinfo: DWORD;
sin6_addr: array[0..7] of Word;
sin6_scope_id: DWORD;
end;
ICMPV6_ECHO_REPLY_LH = record
Address: IPV6_ADDRESS_EX;
Status: DWORD;
RoundTripTime: DWORD;
end;const IPV6_ADDRESS_EX = extern struct {
sin6_port: u16,
sin6_flowinfo: u32,
sin6_addr: [8]u16,
sin6_scope_id: u32,
};
const ICMPV6_ECHO_REPLY_LH = extern struct {
Address: IPV6_ADDRESS_EX,
Status: u32,
RoundTripTime: u32,
};type
IPV6_ADDRESS_EX {.packed.} = object
sin6_port: uint16
sin6_flowinfo: uint32
sin6_addr: array[8, uint16]
sin6_scope_id: uint32
ICMPV6_ECHO_REPLY_LH {.bycopy.} = object
Address: IPV6_ADDRESS_EX
Status: uint32
RoundTripTime: uint32align(1)
struct IPV6_ADDRESS_EX
{
ushort sin6_port;
uint sin6_flowinfo;
ushort[8] sin6_addr;
uint sin6_scope_id;
}
struct ICMPV6_ECHO_REPLY_LH
{
IPV6_ADDRESS_EX Address;
uint Status;
uint RoundTripTime;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ICMPV6_ECHO_REPLY_LH サイズ: 36 バイト(x64)
dim st, 9 ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; Address : IPV6_ADDRESS_EX (+0, 26byte) varptr(st)+0 を基点に操作(26byte:入れ子/配列)
; Status : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; RoundTripTime : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global IPV6_ADDRESS_EX, pack=1
#field short sin6_port
#field int sin6_flowinfo
#field short sin6_addr 8
#field int sin6_scope_id
#endstruct
#defstruct global ICMPV6_ECHO_REPLY_LH
#field IPV6_ADDRESS_EX Address
#field int Status
#field int RoundTripTime
#endstruct
stdim st, ICMPV6_ECHO_REPLY_LH ; NSTRUCT 変数を確保
st->Status = 100
mes "Status=" + st->Status