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