Win32 API 日本語リファレンス
ホームNetworkManagement.WiFi › DOT11_SECURITY_PACKET_HEADER

DOT11_SECURITY_PACKET_HEADER

構造体
サイズx64: 9 バイト / x86: 9 バイトパッキング1

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

フィールド

フィールドサイズx64x86説明
PeerMacBYTE6+0+0セキュリティパケットの相手側6バイトMACアドレス。
usEtherTypeWORD2+6+6ペイロードのEtherType値(EAPOL等)。ネットワークバイト順。
DataBYTE1+8+8可変長のパケットデータ先頭バイト。実データへのプレースホルダー。

各言語での定義

#include <windows.h>

// DOT11_SECURITY_PACKET_HEADER  (x64 9 / x86 9 バイト)
#pragma pack(push, 1)
typedef struct DOT11_SECURITY_PACKET_HEADER {
    BYTE PeerMac[6];
    WORD usEtherType;
    BYTE Data[1];
} DOT11_SECURITY_PACKET_HEADER;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct DOT11_SECURITY_PACKET_HEADER
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] PeerMac;
    public ushort usEtherType;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Data;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure DOT11_SECURITY_PACKET_HEADER
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=6)> Public PeerMac() As Byte
    Public usEtherType As UShort
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Data() As Byte
End Structure
import ctypes
from ctypes import wintypes

class DOT11_SECURITY_PACKET_HEADER(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("PeerMac", ctypes.c_ubyte * 6),
        ("usEtherType", ctypes.c_ushort),
        ("Data", ctypes.c_ubyte * 1),
    ]
#[repr(C, packed(1))]
pub struct DOT11_SECURITY_PACKET_HEADER {
    pub PeerMac: [u8; 6],
    pub usEtherType: u16,
    pub Data: [u8; 1],
}
import "golang.org/x/sys/windows"

type DOT11_SECURITY_PACKET_HEADER struct {
	PeerMac [6]byte
	usEtherType uint16
	Data [1]byte
}
type
  DOT11_SECURITY_PACKET_HEADER = packed record
    PeerMac: array[0..5] of Byte;
    usEtherType: Word;
    Data: array[0..0] of Byte;
  end;
const DOT11_SECURITY_PACKET_HEADER = extern struct {
    PeerMac: [6]u8,
    usEtherType: u16,
    Data: [1]u8,
};
type
  DOT11_SECURITY_PACKET_HEADER {.packed.} = object
    PeerMac: array[6, uint8]
    usEtherType: uint16
    Data: array[1, uint8]
align(1)
struct DOT11_SECURITY_PACKET_HEADER
{
    ubyte[6] PeerMac;
    ushort usEtherType;
    ubyte[1] Data;
}

HSP用 定義

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

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

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