ホーム › NetworkManagement.QoS › IP_PATTERN
IP_PATTERN
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Reserved1 | DWORD | 4 | +0 | +0 | 予約フィールド。0を設定する。 |
| Reserved2 | DWORD | 4 | +4 | +4 | 予約フィールド。0を設定する。 |
| SrcAddr | DWORD | 4 | +8 | +8 | 照合対象の送信元IPv4アドレス。 |
| DstAddr | DWORD | 4 | +12 | +12 | 照合対象の宛先IPv4アドレス。 |
| S_un | _S_un_e__Union | 8/4 | +16 | +16 | 送信元/宛先ポートまたはICMPの種別/コードを保持する共用体。 |
| ProtocolId | BYTE | 1 | +24 | +20 | 照合対象のプロトコルID(TCP/UDP等)。 |
| Reserved3 | BYTE | 3 | +25 | +21 | 予約フィールド。0を設定する。 |
共用体: _S_un_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| S_un_ports | _S_un_ports_e__Struct | 8/4 | +0 | +0 |
| S_un_icmp | _S_un_icmp_e__Struct | 8/4 | +0 | +0 |
| S_Spi | DWORD | 4 | +0 | +0 |
各言語での定義
#include <windows.h>
// IP_PATTERN (x64 32 / x86 24 バイト)
typedef struct IP_PATTERN {
DWORD Reserved1;
DWORD Reserved2;
DWORD SrcAddr;
DWORD DstAddr;
_S_un_e__Union S_un;
BYTE ProtocolId;
BYTE Reserved3[3];
} IP_PATTERN;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IP_PATTERN
{
public uint Reserved1;
public uint Reserved2;
public uint SrcAddr;
public uint DstAddr;
public _S_un_e__Union S_un;
public byte ProtocolId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] Reserved3;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IP_PATTERN
Public Reserved1 As UInteger
Public Reserved2 As UInteger
Public SrcAddr As UInteger
Public DstAddr As UInteger
Public S_un As _S_un_e__Union
Public ProtocolId As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public Reserved3() As Byte
End Structureimport ctypes
from ctypes import wintypes
class IP_PATTERN(ctypes.Structure):
_fields_ = [
("Reserved1", wintypes.DWORD),
("Reserved2", wintypes.DWORD),
("SrcAddr", wintypes.DWORD),
("DstAddr", wintypes.DWORD),
("S_un", _S_un_e__Union),
("ProtocolId", ctypes.c_ubyte),
("Reserved3", ctypes.c_ubyte * 3),
]#[repr(C)]
pub struct IP_PATTERN {
pub Reserved1: u32,
pub Reserved2: u32,
pub SrcAddr: u32,
pub DstAddr: u32,
pub S_un: _S_un_e__Union,
pub ProtocolId: u8,
pub Reserved3: [u8; 3],
}import "golang.org/x/sys/windows"
type IP_PATTERN struct {
Reserved1 uint32
Reserved2 uint32
SrcAddr uint32
DstAddr uint32
S_un _S_un_e__Union
ProtocolId byte
Reserved3 [3]byte
}type
IP_PATTERN = record
Reserved1: DWORD;
Reserved2: DWORD;
SrcAddr: DWORD;
DstAddr: DWORD;
S_un: _S_un_e__Union;
ProtocolId: Byte;
Reserved3: array[0..2] of Byte;
end;const IP_PATTERN = extern struct {
Reserved1: u32,
Reserved2: u32,
SrcAddr: u32,
DstAddr: u32,
S_un: _S_un_e__Union,
ProtocolId: u8,
Reserved3: [3]u8,
};type
IP_PATTERN {.bycopy.} = object
Reserved1: uint32
Reserved2: uint32
SrcAddr: uint32
DstAddr: uint32
S_un: _S_un_e__Union
ProtocolId: uint8
Reserved3: array[3, uint8]struct IP_PATTERN
{
uint Reserved1;
uint Reserved2;
uint SrcAddr;
uint DstAddr;
_S_un_e__Union S_un;
ubyte ProtocolId;
ubyte[3] Reserved3;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; IP_PATTERN サイズ: 24 バイト(x86)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; Reserved1 : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Reserved2 : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; SrcAddr : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; DstAddr : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; S_un : _S_un_e__Union (+16, 4byte) varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; ProtocolId : BYTE (+20, 1byte) poke st,20,値 / 値 = peek(st,20)
; Reserved3 : BYTE (+21, 3byte) varptr(st)+21 を基点に操作(3byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IP_PATTERN サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; Reserved1 : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Reserved2 : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; SrcAddr : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; DstAddr : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; S_un : _S_un_e__Union (+16, 8byte) varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; ProtocolId : BYTE (+24, 1byte) poke st,24,値 / 値 = peek(st,24)
; Reserved3 : BYTE (+25, 3byte) varptr(st)+25 を基点に操作(3byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IP_PATTERN
#field int Reserved1
#field int Reserved2
#field int SrcAddr
#field int DstAddr
#field byte S_un 8
#field byte ProtocolId
#field byte Reserved3 3
#endstruct
stdim st, IP_PATTERN ; NSTRUCT 変数を確保
st->Reserved1 = 100
mes "Reserved1=" + st->Reserved1
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。