ホーム › Networking.WinSock › IN6_PKTINFO
IN6_PKTINFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ipi6_addr | IN6_ADDR | 16 | +0 | +0 | パケットの宛先または送信元IPv6アドレスである。 |
| ipi6_ifindex | DWORD | 4 | +16 | +16 | パケットを送受信したインタフェースのインデックスである。 |
各言語での定義
#include <windows.h>
// IN6_ADDR (x64 16 / x86 16 バイト)
typedef struct IN6_ADDR {
_u_e__Union u;
} IN6_ADDR;
// IN6_PKTINFO (x64 20 / x86 20 バイト)
typedef struct IN6_PKTINFO {
IN6_ADDR ipi6_addr;
DWORD ipi6_ifindex;
} IN6_PKTINFO;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IN6_ADDR
{
public _u_e__Union u;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IN6_PKTINFO
{
public IN6_ADDR ipi6_addr;
public uint ipi6_ifindex;
}Imports System.Runtime.InteropServices
<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 IN6_PKTINFO
Public ipi6_addr As IN6_ADDR
Public ipi6_ifindex As UInteger
End Structureimport ctypes
from ctypes import wintypes
class IN6_ADDR(ctypes.Structure):
_fields_ = [
("u", _u_e__Union),
]
class IN6_PKTINFO(ctypes.Structure):
_fields_ = [
("ipi6_addr", IN6_ADDR),
("ipi6_ifindex", wintypes.DWORD),
]#[repr(C)]
pub struct IN6_ADDR {
pub u: _u_e__Union,
}
#[repr(C)]
pub struct IN6_PKTINFO {
pub ipi6_addr: IN6_ADDR,
pub ipi6_ifindex: u32,
}import "golang.org/x/sys/windows"
type IN6_ADDR struct {
u _u_e__Union
}
type IN6_PKTINFO struct {
ipi6_addr IN6_ADDR
ipi6_ifindex uint32
}type
IN6_ADDR = record
u: _u_e__Union;
end;
IN6_PKTINFO = record
ipi6_addr: IN6_ADDR;
ipi6_ifindex: DWORD;
end;const IN6_ADDR = extern struct {
u: _u_e__Union,
};
const IN6_PKTINFO = extern struct {
ipi6_addr: IN6_ADDR,
ipi6_ifindex: u32,
};type
IN6_ADDR {.bycopy.} = object
u: _u_e__Union
IN6_PKTINFO {.bycopy.} = object
ipi6_addr: IN6_ADDR
ipi6_ifindex: uint32struct IN6_ADDR
{
_u_e__Union u;
}
struct IN6_PKTINFO
{
IN6_ADDR ipi6_addr;
uint ipi6_ifindex;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IN6_PKTINFO サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; ipi6_addr : IN6_ADDR (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; ipi6_ifindex : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global IN6_ADDR
#field byte u 16
#endstruct
#defstruct global IN6_PKTINFO
#field IN6_ADDR ipi6_addr
#field int ipi6_ifindex
#endstruct
stdim st, IN6_PKTINFO ; NSTRUCT 変数を確保
st->ipi6_ifindex = 100
mes "ipi6_ifindex=" + st->ipi6_ifindex