ホーム › NetworkManagement.Ndis › OFFLOAD_IPSEC_ADD_SA
OFFLOAD_IPSEC_ADD_SA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| SrcAddr | DWORD | 4 | +0 | +0 | 送信元IPv4アドレス。 |
| SrcMask | DWORD | 4 | +4 | +4 | 送信元アドレスのサブネットマスク。 |
| DestAddr | DWORD | 4 | +8 | +8 | 宛先IPv4アドレス。 |
| DestMask | DWORD | 4 | +12 | +12 | 宛先アドレスのサブネットマスク。 |
| Protocol | DWORD | 4 | +16 | +16 | 対象のIPプロトコル番号。 |
| SrcPort | WORD | 2 | +20 | +20 | 送信元ポート番号。 |
| DestPort | WORD | 2 | +22 | +22 | 宛先ポート番号。 |
| SrcTunnelAddr | DWORD | 4 | +24 | +24 | トンネルモード時の送信元トンネルアドレス。 |
| DestTunnelAddr | DWORD | 4 | +28 | +28 | トンネルモード時の宛先トンネルアドレス。 |
| Flags | WORD | 2 | +32 | +32 | SAの種別を示すフラグ(トンネル/トランスポート等)。 |
| NumSAs | SHORT | 2 | +34 | +34 | SecAssoc配列に含まれるSAの数。 |
| SecAssoc | OFFLOAD_SECURITY_ASSOCIATION | 132 | +36 | +36 | セキュリティアソシエーション情報の配列(最大3要素)。 |
| OffloadHandle | HANDLE | 8/4 | +168 | +168 | ドライバが返すSAオフロードハンドル。 |
| KeyLen | DWORD | 4 | +176 | +172 | KeyMatのキーマテリアル長(バイト)。 |
| KeyMat | BYTE | 1 | +180 | +176 | 鍵素材を格納する可変長配列の先頭バイト。 |
各言語での定義
#include <windows.h>
// OFFLOAD_ALGO_INFO (x64 12 / x86 12 バイト)
typedef struct OFFLOAD_ALGO_INFO {
DWORD algoIdentifier;
DWORD algoKeylen;
DWORD algoRounds;
} OFFLOAD_ALGO_INFO;
// OFFLOAD_SECURITY_ASSOCIATION (x64 44 / x86 44 バイト)
typedef struct OFFLOAD_SECURITY_ASSOCIATION {
OFFLOAD_OPERATION_E Operation;
DWORD SPI;
OFFLOAD_ALGO_INFO IntegrityAlgo;
OFFLOAD_ALGO_INFO ConfAlgo;
OFFLOAD_ALGO_INFO Reserved;
} OFFLOAD_SECURITY_ASSOCIATION;
// OFFLOAD_IPSEC_ADD_SA (x64 184 / x86 180 バイト)
typedef struct OFFLOAD_IPSEC_ADD_SA {
DWORD SrcAddr;
DWORD SrcMask;
DWORD DestAddr;
DWORD DestMask;
DWORD Protocol;
WORD SrcPort;
WORD DestPort;
DWORD SrcTunnelAddr;
DWORD DestTunnelAddr;
WORD Flags;
SHORT NumSAs;
OFFLOAD_SECURITY_ASSOCIATION SecAssoc[3];
HANDLE OffloadHandle;
DWORD KeyLen;
BYTE KeyMat[1];
} OFFLOAD_IPSEC_ADD_SA;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OFFLOAD_ALGO_INFO
{
public uint algoIdentifier;
public uint algoKeylen;
public uint algoRounds;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OFFLOAD_SECURITY_ASSOCIATION
{
public int Operation;
public uint SPI;
public OFFLOAD_ALGO_INFO IntegrityAlgo;
public OFFLOAD_ALGO_INFO ConfAlgo;
public OFFLOAD_ALGO_INFO Reserved;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OFFLOAD_IPSEC_ADD_SA
{
public uint SrcAddr;
public uint SrcMask;
public uint DestAddr;
public uint DestMask;
public uint Protocol;
public ushort SrcPort;
public ushort DestPort;
public uint SrcTunnelAddr;
public uint DestTunnelAddr;
public ushort Flags;
public short NumSAs;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public OFFLOAD_SECURITY_ASSOCIATION[] SecAssoc;
public IntPtr OffloadHandle;
public uint KeyLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] KeyMat;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure OFFLOAD_ALGO_INFO
Public algoIdentifier As UInteger
Public algoKeylen As UInteger
Public algoRounds As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure OFFLOAD_SECURITY_ASSOCIATION
Public Operation As Integer
Public SPI As UInteger
Public IntegrityAlgo As OFFLOAD_ALGO_INFO
Public ConfAlgo As OFFLOAD_ALGO_INFO
Public Reserved As OFFLOAD_ALGO_INFO
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure OFFLOAD_IPSEC_ADD_SA
Public SrcAddr As UInteger
Public SrcMask As UInteger
Public DestAddr As UInteger
Public DestMask As UInteger
Public Protocol As UInteger
Public SrcPort As UShort
Public DestPort As UShort
Public SrcTunnelAddr As UInteger
Public DestTunnelAddr As UInteger
Public Flags As UShort
Public NumSAs As Short
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public SecAssoc() As OFFLOAD_SECURITY_ASSOCIATION
Public OffloadHandle As IntPtr
Public KeyLen As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public KeyMat() As Byte
End Structureimport ctypes
from ctypes import wintypes
class OFFLOAD_ALGO_INFO(ctypes.Structure):
_fields_ = [
("algoIdentifier", wintypes.DWORD),
("algoKeylen", wintypes.DWORD),
("algoRounds", wintypes.DWORD),
]
class OFFLOAD_SECURITY_ASSOCIATION(ctypes.Structure):
_fields_ = [
("Operation", ctypes.c_int),
("SPI", wintypes.DWORD),
("IntegrityAlgo", OFFLOAD_ALGO_INFO),
("ConfAlgo", OFFLOAD_ALGO_INFO),
("Reserved", OFFLOAD_ALGO_INFO),
]
class OFFLOAD_IPSEC_ADD_SA(ctypes.Structure):
_fields_ = [
("SrcAddr", wintypes.DWORD),
("SrcMask", wintypes.DWORD),
("DestAddr", wintypes.DWORD),
("DestMask", wintypes.DWORD),
("Protocol", wintypes.DWORD),
("SrcPort", ctypes.c_ushort),
("DestPort", ctypes.c_ushort),
("SrcTunnelAddr", wintypes.DWORD),
("DestTunnelAddr", wintypes.DWORD),
("Flags", ctypes.c_ushort),
("NumSAs", ctypes.c_short),
("SecAssoc", OFFLOAD_SECURITY_ASSOCIATION * 3),
("OffloadHandle", ctypes.c_void_p),
("KeyLen", wintypes.DWORD),
("KeyMat", ctypes.c_ubyte * 1),
]#[repr(C)]
pub struct OFFLOAD_ALGO_INFO {
pub algoIdentifier: u32,
pub algoKeylen: u32,
pub algoRounds: u32,
}
#[repr(C)]
pub struct OFFLOAD_SECURITY_ASSOCIATION {
pub Operation: i32,
pub SPI: u32,
pub IntegrityAlgo: OFFLOAD_ALGO_INFO,
pub ConfAlgo: OFFLOAD_ALGO_INFO,
pub Reserved: OFFLOAD_ALGO_INFO,
}
#[repr(C)]
pub struct OFFLOAD_IPSEC_ADD_SA {
pub SrcAddr: u32,
pub SrcMask: u32,
pub DestAddr: u32,
pub DestMask: u32,
pub Protocol: u32,
pub SrcPort: u16,
pub DestPort: u16,
pub SrcTunnelAddr: u32,
pub DestTunnelAddr: u32,
pub Flags: u16,
pub NumSAs: i16,
pub SecAssoc: [OFFLOAD_SECURITY_ASSOCIATION; 3],
pub OffloadHandle: *mut core::ffi::c_void,
pub KeyLen: u32,
pub KeyMat: [u8; 1],
}import "golang.org/x/sys/windows"
type OFFLOAD_ALGO_INFO struct {
algoIdentifier uint32
algoKeylen uint32
algoRounds uint32
}
type OFFLOAD_SECURITY_ASSOCIATION struct {
Operation int32
SPI uint32
IntegrityAlgo OFFLOAD_ALGO_INFO
ConfAlgo OFFLOAD_ALGO_INFO
Reserved OFFLOAD_ALGO_INFO
}
type OFFLOAD_IPSEC_ADD_SA struct {
SrcAddr uint32
SrcMask uint32
DestAddr uint32
DestMask uint32
Protocol uint32
SrcPort uint16
DestPort uint16
SrcTunnelAddr uint32
DestTunnelAddr uint32
Flags uint16
NumSAs int16
SecAssoc [3]OFFLOAD_SECURITY_ASSOCIATION
OffloadHandle uintptr
KeyLen uint32
KeyMat [1]byte
}type
OFFLOAD_ALGO_INFO = record
algoIdentifier: DWORD;
algoKeylen: DWORD;
algoRounds: DWORD;
end;
OFFLOAD_SECURITY_ASSOCIATION = record
Operation: Integer;
SPI: DWORD;
IntegrityAlgo: OFFLOAD_ALGO_INFO;
ConfAlgo: OFFLOAD_ALGO_INFO;
Reserved: OFFLOAD_ALGO_INFO;
end;
OFFLOAD_IPSEC_ADD_SA = record
SrcAddr: DWORD;
SrcMask: DWORD;
DestAddr: DWORD;
DestMask: DWORD;
Protocol: DWORD;
SrcPort: Word;
DestPort: Word;
SrcTunnelAddr: DWORD;
DestTunnelAddr: DWORD;
Flags: Word;
NumSAs: Smallint;
SecAssoc: array[0..2] of OFFLOAD_SECURITY_ASSOCIATION;
OffloadHandle: Pointer;
KeyLen: DWORD;
KeyMat: array[0..0] of Byte;
end;const OFFLOAD_ALGO_INFO = extern struct {
algoIdentifier: u32,
algoKeylen: u32,
algoRounds: u32,
};
const OFFLOAD_SECURITY_ASSOCIATION = extern struct {
Operation: i32,
SPI: u32,
IntegrityAlgo: OFFLOAD_ALGO_INFO,
ConfAlgo: OFFLOAD_ALGO_INFO,
Reserved: OFFLOAD_ALGO_INFO,
};
const OFFLOAD_IPSEC_ADD_SA = extern struct {
SrcAddr: u32,
SrcMask: u32,
DestAddr: u32,
DestMask: u32,
Protocol: u32,
SrcPort: u16,
DestPort: u16,
SrcTunnelAddr: u32,
DestTunnelAddr: u32,
Flags: u16,
NumSAs: i16,
SecAssoc: [3]OFFLOAD_SECURITY_ASSOCIATION,
OffloadHandle: ?*anyopaque,
KeyLen: u32,
KeyMat: [1]u8,
};type
OFFLOAD_ALGO_INFO {.bycopy.} = object
algoIdentifier: uint32
algoKeylen: uint32
algoRounds: uint32
OFFLOAD_SECURITY_ASSOCIATION {.bycopy.} = object
Operation: int32
SPI: uint32
IntegrityAlgo: OFFLOAD_ALGO_INFO
ConfAlgo: OFFLOAD_ALGO_INFO
Reserved: OFFLOAD_ALGO_INFO
OFFLOAD_IPSEC_ADD_SA {.bycopy.} = object
SrcAddr: uint32
SrcMask: uint32
DestAddr: uint32
DestMask: uint32
Protocol: uint32
SrcPort: uint16
DestPort: uint16
SrcTunnelAddr: uint32
DestTunnelAddr: uint32
Flags: uint16
NumSAs: int16
SecAssoc: array[3, OFFLOAD_SECURITY_ASSOCIATION]
OffloadHandle: pointer
KeyLen: uint32
KeyMat: array[1, uint8]struct OFFLOAD_ALGO_INFO
{
uint algoIdentifier;
uint algoKeylen;
uint algoRounds;
}
struct OFFLOAD_SECURITY_ASSOCIATION
{
int Operation;
uint SPI;
OFFLOAD_ALGO_INFO IntegrityAlgo;
OFFLOAD_ALGO_INFO ConfAlgo;
OFFLOAD_ALGO_INFO Reserved;
}
struct OFFLOAD_IPSEC_ADD_SA
{
uint SrcAddr;
uint SrcMask;
uint DestAddr;
uint DestMask;
uint Protocol;
ushort SrcPort;
ushort DestPort;
uint SrcTunnelAddr;
uint DestTunnelAddr;
ushort Flags;
short NumSAs;
OFFLOAD_SECURITY_ASSOCIATION[3] SecAssoc;
void* OffloadHandle;
uint KeyLen;
ubyte[1] KeyMat;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; OFFLOAD_IPSEC_ADD_SA サイズ: 180 バイト(x86)
dim st, 45 ; 4byte整数×45(構造体サイズ 180 / 4 切り上げ)
; SrcAddr : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; SrcMask : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; DestAddr : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; DestMask : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; Protocol : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; SrcPort : WORD (+20, 2byte) wpoke st,20,値 / 値 = wpeek(st,20)
; DestPort : WORD (+22, 2byte) wpoke st,22,値 / 値 = wpeek(st,22)
; SrcTunnelAddr : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; DestTunnelAddr : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; Flags : WORD (+32, 2byte) wpoke st,32,値 / 値 = wpeek(st,32)
; NumSAs : SHORT (+34, 2byte) wpoke st,34,値 / 値 = wpeek(st,34)
; SecAssoc : OFFLOAD_SECURITY_ASSOCIATION (+36, 132byte) varptr(st)+36 を基点に操作(132byte:入れ子/配列)
; OffloadHandle : HANDLE (+168, 4byte) st.42 = 値 / 値 = st.42 (lpoke/lpeek も可)
; KeyLen : DWORD (+172, 4byte) st.43 = 値 / 値 = st.43 (lpoke/lpeek も可)
; KeyMat : BYTE (+176, 1byte) varptr(st)+176 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; OFFLOAD_IPSEC_ADD_SA サイズ: 184 バイト(x64)
dim st, 46 ; 4byte整数×46(構造体サイズ 184 / 4 切り上げ)
; SrcAddr : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; SrcMask : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; DestAddr : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; DestMask : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; Protocol : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; SrcPort : WORD (+20, 2byte) wpoke st,20,値 / 値 = wpeek(st,20)
; DestPort : WORD (+22, 2byte) wpoke st,22,値 / 値 = wpeek(st,22)
; SrcTunnelAddr : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; DestTunnelAddr : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; Flags : WORD (+32, 2byte) wpoke st,32,値 / 値 = wpeek(st,32)
; NumSAs : SHORT (+34, 2byte) wpoke st,34,値 / 値 = wpeek(st,34)
; SecAssoc : OFFLOAD_SECURITY_ASSOCIATION (+36, 132byte) varptr(st)+36 を基点に操作(132byte:入れ子/配列)
; OffloadHandle : HANDLE (+168, 8byte) qpoke st,168,値 / qpeek(st,168) ※IronHSPのみ。3.7/3.8は lpoke st,168,下位 : lpoke st,172,上位
; KeyLen : DWORD (+176, 4byte) st.44 = 値 / 値 = st.44 (lpoke/lpeek も可)
; KeyMat : BYTE (+180, 1byte) varptr(st)+180 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global OFFLOAD_ALGO_INFO
#field int algoIdentifier
#field int algoKeylen
#field int algoRounds
#endstruct
#defstruct global OFFLOAD_SECURITY_ASSOCIATION
#field int Operation
#field int SPI
#field OFFLOAD_ALGO_INFO IntegrityAlgo
#field OFFLOAD_ALGO_INFO ConfAlgo
#field OFFLOAD_ALGO_INFO Reserved
#endstruct
#defstruct global OFFLOAD_IPSEC_ADD_SA
#field int SrcAddr
#field int SrcMask
#field int DestAddr
#field int DestMask
#field int Protocol
#field short SrcPort
#field short DestPort
#field int SrcTunnelAddr
#field int DestTunnelAddr
#field short Flags
#field short NumSAs
#field OFFLOAD_SECURITY_ASSOCIATION SecAssoc 3
#field intptr OffloadHandle
#field int KeyLen
#field byte KeyMat 1
#endstruct
stdim st, OFFLOAD_IPSEC_ADD_SA ; NSTRUCT 変数を確保
st->SrcAddr = 100
mes "SrcAddr=" + st->SrcAddr