ホーム › NetworkManagement.Snmp › AsnAny
AsnAny
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| asnType | BYTE | 1 | +0 | +0 | 値の ASN.1 型を示すタグバイト。整数・文字列などの種別を表す。 |
| asnValue | _asnValue_e__Union | 16/12 | +4 | +4 | asnType に応じた実際の値を保持する共用体。 |
共用体: _asnValue_e__Union x64 16B / x86 12B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| number | INT | 4 | +0 | +0 |
| unsigned32 | DWORD | 4 | +0 | +0 |
| counter64 | ULONGLONG | 8 | +0 | +0 |
| string | AsnOctetString | 16/12 | +0 | +0 |
| bits | AsnOctetString | 16/12 | +0 | +0 |
| object | AsnObjectIdentifier | 12/8 | +0 | +0 |
| sequence | AsnOctetString | 16/12 | +0 | +0 |
| address | AsnOctetString | 16/12 | +0 | +0 |
| counter | DWORD | 4 | +0 | +0 |
| gauge | DWORD | 4 | +0 | +0 |
| ticks | DWORD | 4 | +0 | +0 |
| arbitrary | AsnOctetString | 16/12 | +0 | +0 |
各言語での定義
#include <windows.h>
// AsnAny (x64 20 / x86 16 バイト)
#pragma pack(push, 4)
typedef struct AsnAny {
BYTE asnType;
_asnValue_e__Union asnValue;
} AsnAny;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
public struct AsnAny
{
public byte asnType;
public _asnValue_e__Union asnValue;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=4, CharSet:=CharSet.Unicode)>
Public Structure AsnAny
Public asnType As Byte
Public asnValue As _asnValue_e__Union
End Structureimport ctypes
from ctypes import wintypes
class AsnAny(ctypes.Structure):
_pack_ = 4
_fields_ = [
("asnType", ctypes.c_ubyte),
("asnValue", _asnValue_e__Union),
]#[repr(C, packed(4))]
pub struct AsnAny {
pub asnType: u8,
pub asnValue: _asnValue_e__Union,
}import "golang.org/x/sys/windows"
type AsnAny struct {
asnType byte
asnValue _asnValue_e__Union
}type
AsnAny = packed record
asnType: Byte;
asnValue: _asnValue_e__Union;
end;const AsnAny = extern struct {
asnType: u8,
asnValue: _asnValue_e__Union,
};type
AsnAny {.packed.} = object
asnType: uint8
asnValue: _asnValue_e__Unionalign(4)
struct AsnAny
{
ubyte asnType;
_asnValue_e__Union asnValue;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; AsnAny サイズ: 16 バイト(x86)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; asnType : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; asnValue : _asnValue_e__Union (+4, 12byte) varptr(st)+4 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; AsnAny サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; asnType : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; asnValue : _asnValue_e__Union (+4, 16byte) varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global AsnAny, pack=4
#field byte asnType
#field byte asnValue 16
#endstruct
stdim st, AsnAny ; NSTRUCT 変数を確保
st->asnType = 100
mes "asnType=" + st->asnType
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。