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

IPV6_ROUTING_HEADER

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

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

フィールド

フィールドサイズx64x86説明
NextHeaderBYTE1+0+0ルーティングヘッダー後の次ヘッダー種別を示す。
LengthBYTE1+1+1このヘッダーの長さを示す(8オクテット単位)。
RoutingTypeBYTE1+2+2ルーティングヘッダーの種別を示す。
SegmentsLeftBYTE1+3+3残りの経由セグメント数を示す。
ReservedBYTE4+4+4予約済みバイト。通常ゼロにする。

各言語での定義

#include <windows.h>

// IPV6_ROUTING_HEADER  (x64 8 / x86 8 バイト)
typedef struct IPV6_ROUTING_HEADER {
    BYTE NextHeader;
    BYTE Length;
    BYTE RoutingType;
    BYTE SegmentsLeft;
    BYTE Reserved[4];
} IPV6_ROUTING_HEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IPV6_ROUTING_HEADER
{
    public byte NextHeader;
    public byte Length;
    public byte RoutingType;
    public byte SegmentsLeft;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] Reserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IPV6_ROUTING_HEADER
    Public NextHeader As Byte
    Public Length As Byte
    Public RoutingType As Byte
    Public SegmentsLeft As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public Reserved() As Byte
End Structure
import ctypes
from ctypes import wintypes

class IPV6_ROUTING_HEADER(ctypes.Structure):
    _fields_ = [
        ("NextHeader", ctypes.c_ubyte),
        ("Length", ctypes.c_ubyte),
        ("RoutingType", ctypes.c_ubyte),
        ("SegmentsLeft", ctypes.c_ubyte),
        ("Reserved", ctypes.c_ubyte * 4),
    ]
#[repr(C)]
pub struct IPV6_ROUTING_HEADER {
    pub NextHeader: u8,
    pub Length: u8,
    pub RoutingType: u8,
    pub SegmentsLeft: u8,
    pub Reserved: [u8; 4],
}
import "golang.org/x/sys/windows"

type IPV6_ROUTING_HEADER struct {
	NextHeader byte
	Length byte
	RoutingType byte
	SegmentsLeft byte
	Reserved [4]byte
}
type
  IPV6_ROUTING_HEADER = record
    NextHeader: Byte;
    Length: Byte;
    RoutingType: Byte;
    SegmentsLeft: Byte;
    Reserved: array[0..3] of Byte;
  end;
const IPV6_ROUTING_HEADER = extern struct {
    NextHeader: u8,
    Length: u8,
    RoutingType: u8,
    SegmentsLeft: u8,
    Reserved: [4]u8,
};
type
  IPV6_ROUTING_HEADER {.bycopy.} = object
    NextHeader: uint8
    Length: uint8
    RoutingType: uint8
    SegmentsLeft: uint8
    Reserved: array[4, uint8]
struct IPV6_ROUTING_HEADER
{
    ubyte NextHeader;
    ubyte Length;
    ubyte RoutingType;
    ubyte SegmentsLeft;
    ubyte[4] Reserved;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IPV6_ROUTING_HEADER サイズ: 8 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; NextHeader : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; Length : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; RoutingType : BYTE (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; SegmentsLeft : BYTE (+3, 1byte)  poke st,3,値  /  値 = peek(st,3)
; Reserved : BYTE (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IPV6_ROUTING_HEADER
    #field byte NextHeader
    #field byte Length
    #field byte RoutingType
    #field byte SegmentsLeft
    #field byte Reserved 4
#endstruct

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