Win32 API 日本語リファレンス
ホームStorage.IscsiDisc › IKE_AUTHENTICATION_PRESHARED_KEY

IKE_AUTHENTICATION_PRESHARED_KEY

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

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

フィールド

フィールドサイズx64x86説明
SecurityFlagsULONGLONG8+0+0IPsec/IKEのセキュリティ動作を制御するフラグ群(64ビット)。
IdTypeBYTE1+8+8識別子(Id)の種別を示す値(IPアドレス、FQDNなど)。
IdLengthInBytesDWORD4+12+12Idが指すデータのバイト長。
IdBYTE*8/4+16+16ローカル識別子データを指すバイト列ポインタ。
KeyLengthInBytesDWORD4+24+20Keyが指す事前共有鍵のバイト長。
KeyBYTE*8/4+32+24IKE認証に用いる事前共有鍵を指すバイト列ポインタ。

各言語での定義

#include <windows.h>

// IKE_AUTHENTICATION_PRESHARED_KEY  (x64 40 / x86 32 バイト)
typedef struct IKE_AUTHENTICATION_PRESHARED_KEY {
    ULONGLONG SecurityFlags;
    BYTE IdType;
    DWORD IdLengthInBytes;
    BYTE* Id;
    DWORD KeyLengthInBytes;
    BYTE* Key;
} IKE_AUTHENTICATION_PRESHARED_KEY;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IKE_AUTHENTICATION_PRESHARED_KEY
{
    public ulong SecurityFlags;
    public byte IdType;
    public uint IdLengthInBytes;
    public IntPtr Id;
    public uint KeyLengthInBytes;
    public IntPtr Key;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IKE_AUTHENTICATION_PRESHARED_KEY
    Public SecurityFlags As ULong
    Public IdType As Byte
    Public IdLengthInBytes As UInteger
    Public Id As IntPtr
    Public KeyLengthInBytes As UInteger
    Public Key As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class IKE_AUTHENTICATION_PRESHARED_KEY(ctypes.Structure):
    _fields_ = [
        ("SecurityFlags", ctypes.c_ulonglong),
        ("IdType", ctypes.c_ubyte),
        ("IdLengthInBytes", wintypes.DWORD),
        ("Id", ctypes.c_void_p),
        ("KeyLengthInBytes", wintypes.DWORD),
        ("Key", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct IKE_AUTHENTICATION_PRESHARED_KEY {
    pub SecurityFlags: u64,
    pub IdType: u8,
    pub IdLengthInBytes: u32,
    pub Id: *mut core::ffi::c_void,
    pub KeyLengthInBytes: u32,
    pub Key: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type IKE_AUTHENTICATION_PRESHARED_KEY struct {
	SecurityFlags uint64
	IdType byte
	IdLengthInBytes uint32
	Id uintptr
	KeyLengthInBytes uint32
	Key uintptr
}
type
  IKE_AUTHENTICATION_PRESHARED_KEY = record
    SecurityFlags: UInt64;
    IdType: Byte;
    IdLengthInBytes: DWORD;
    Id: Pointer;
    KeyLengthInBytes: DWORD;
    Key: Pointer;
  end;
const IKE_AUTHENTICATION_PRESHARED_KEY = extern struct {
    SecurityFlags: u64,
    IdType: u8,
    IdLengthInBytes: u32,
    Id: ?*anyopaque,
    KeyLengthInBytes: u32,
    Key: ?*anyopaque,
};
type
  IKE_AUTHENTICATION_PRESHARED_KEY {.bycopy.} = object
    SecurityFlags: uint64
    IdType: uint8
    IdLengthInBytes: uint32
    Id: pointer
    KeyLengthInBytes: uint32
    Key: pointer
struct IKE_AUTHENTICATION_PRESHARED_KEY
{
    ulong SecurityFlags;
    ubyte IdType;
    uint IdLengthInBytes;
    void* Id;
    uint KeyLengthInBytes;
    void* Key;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; IKE_AUTHENTICATION_PRESHARED_KEY サイズ: 32 バイト(x86)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; SecurityFlags : ULONGLONG (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; IdType : BYTE (+8, 1byte)  poke st,8,値  /  値 = peek(st,8)
; IdLengthInBytes : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; Id : BYTE* (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; KeyLengthInBytes : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; Key : BYTE* (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IKE_AUTHENTICATION_PRESHARED_KEY サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; SecurityFlags : ULONGLONG (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; IdType : BYTE (+8, 1byte)  poke st,8,値  /  値 = peek(st,8)
; IdLengthInBytes : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; Id : BYTE* (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; KeyLengthInBytes : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; Key : BYTE* (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IKE_AUTHENTICATION_PRESHARED_KEY
    #field int64 SecurityFlags
    #field byte IdType
    #field int IdLengthInBytes
    #field intptr Id
    #field int KeyLengthInBytes
    #field intptr Key
#endstruct

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