SnmpDecodeMsg
関数シグネチャ
// wsnmp32.dll
#include <windows.h>
DWORD SnmpDecodeMsg(
INT_PTR session,
INT_PTR* srcEntity,
INT_PTR* dstEntity,
INT_PTR* context,
INT_PTR* pdu,
smiOCTETS* msgBufDesc
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| session | INT_PTR | in | WinSNMP セッションのハンドル。このパラメーターは必須です。詳細については、後述の「解説」セクションを参照してください。 |
| srcEntity | INT_PTR* | inout | 送信元の管理エンティティのハンドルを受け取る変数へのポインター。詳細については、後述の「解説」セクションを参照してください。 |
| dstEntity | INT_PTR* | inout | 対象の管理エンティティのハンドルを受け取る変数へのポインター。詳細については、後述の「解説」セクションを参照してください。 |
| context | INT_PTR* | inout | 対象の管理エンティティが制御するコンテキスト (管理対象オブジェクトのリソースの集合) のハンドルを受け取る変数へのポインター。 |
| pdu | INT_PTR* | inout | SNMP プロトコルデータユニット (PDU) のハンドルを受け取る変数へのポインター。 |
| msgBufDesc | smiOCTETS* | inout | デコードして構成要素に分解する SNMP メッセージを格納した smiOCTETS 構造体へのポインター。構造体の len メンバーは処理する最大バイト数を指定し、ptr メンバーはエンコードされた SNMP メッセージを指します。 |
戻り値の型: DWORD
公式ドキュメント
WinSNMP の SnmpDecodeMsg 関数は、エンコードされた SNMP メッセージをデコードして各構成要素に分解します。この関数は、WinSNMP の SnmpEncodeMsg 関数とは逆の動作を行います。
戻り値
関数が成功した場合、戻り値はデコードされたバイト数です。この値は、msgBufDesc パラメーターが指す smiOCTETS 構造体の len メンバーと等しいか、それより小さくなります。
関数が失敗した場合、戻り値は SNMPAPI_FAILURE です。拡張エラー情報を取得するには、 SnmpGetLastError を呼び出します。 SnmpGetLastError 関数は、次のいずれかのエラーを返すことがあります。
| 戻り値 | 説明 |
|---|---|
|
SnmpStartup 関数が正常に完了しませんでした。 |
|
| メモリの割り当て中にエラーが発生しました。 | |
| session パラメーターが無効です。 | |
| エンティティを指定するパラメーターの一方または両方が無効です。 | |
| context パラメーターが無効です。 | |
| pdu パラメーターが無効です。 | |
| 出力バッファーの長さが不足しています。出力パラメーターは作成されませんでした。 | |
| msgBufDesc パラメーターで示されるバッファー内の SNMP メッセージの形式が無効です。出力パラメーターは作成されませんでした。 | |
| 不明または未定義のエラーが発生しました。 |
解説(Remarks)
アプリケーションが SNMPv1 または SNMPv2C のメッセージを SnmpDecodeMsg 関数に渡した場合、Microsoft WinSNMP 実装は srcEntity パラメーターと dstEntity パラメーターにゼロを返します。これは、そのメッセージ形式には WinSNMP のエンティティリソースを作成するために必要なアドレス情報が含まれていないためです。
Microsoft WinSNMP 実装は、 SnmpDecodeMsg 関数の呼び出しが成功した結果として、WinSNMP アプリケーションにリソースを割り当てます。WinSNMP アプリケーションでは、各リソースに対応する WinSNMP 関数を使用して個々のリソースを解放することをお勧めします。詳細については、 Freeing WinSNMP Descriptors および WinSNMP Data Management Concepts を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// wsnmp32.dll
#include <windows.h>
DWORD SnmpDecodeMsg(
INT_PTR session,
INT_PTR* srcEntity,
INT_PTR* dstEntity,
INT_PTR* context,
INT_PTR* pdu,
smiOCTETS* msgBufDesc
);[DllImport("wsnmp32.dll", ExactSpelling = true)]
static extern uint SnmpDecodeMsg(
IntPtr session, // INT_PTR
ref IntPtr srcEntity, // INT_PTR* in/out
ref IntPtr dstEntity, // INT_PTR* in/out
ref IntPtr context, // INT_PTR* in/out
ref IntPtr pdu, // INT_PTR* in/out
IntPtr msgBufDesc // smiOCTETS* in/out
);<DllImport("wsnmp32.dll", ExactSpelling:=True)>
Public Shared Function SnmpDecodeMsg(
session As IntPtr, ' INT_PTR
ByRef srcEntity As IntPtr, ' INT_PTR* in/out
ByRef dstEntity As IntPtr, ' INT_PTR* in/out
ByRef context As IntPtr, ' INT_PTR* in/out
ByRef pdu As IntPtr, ' INT_PTR* in/out
msgBufDesc As IntPtr ' smiOCTETS* in/out
) As UInteger
End Function' session : INT_PTR
' srcEntity : INT_PTR* in/out
' dstEntity : INT_PTR* in/out
' context : INT_PTR* in/out
' pdu : INT_PTR* in/out
' msgBufDesc : smiOCTETS* in/out
Declare PtrSafe Function SnmpDecodeMsg Lib "wsnmp32" ( _
ByVal session As LongPtr, _
ByRef srcEntity As LongPtr, _
ByRef dstEntity As LongPtr, _
ByRef context As LongPtr, _
ByRef pdu As LongPtr, _
ByVal msgBufDesc As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SnmpDecodeMsg = ctypes.windll.wsnmp32.SnmpDecodeMsg
SnmpDecodeMsg.restype = wintypes.DWORD
SnmpDecodeMsg.argtypes = [
ctypes.c_ssize_t, # session : INT_PTR
ctypes.POINTER(ctypes.c_ssize_t), # srcEntity : INT_PTR* in/out
ctypes.POINTER(ctypes.c_ssize_t), # dstEntity : INT_PTR* in/out
ctypes.POINTER(ctypes.c_ssize_t), # context : INT_PTR* in/out
ctypes.POINTER(ctypes.c_ssize_t), # pdu : INT_PTR* in/out
ctypes.c_void_p, # msgBufDesc : smiOCTETS* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wsnmp32.dll')
SnmpDecodeMsg = Fiddle::Function.new(
lib['SnmpDecodeMsg'],
[
Fiddle::TYPE_INTPTR_T, # session : INT_PTR
Fiddle::TYPE_VOIDP, # srcEntity : INT_PTR* in/out
Fiddle::TYPE_VOIDP, # dstEntity : INT_PTR* in/out
Fiddle::TYPE_VOIDP, # context : INT_PTR* in/out
Fiddle::TYPE_VOIDP, # pdu : INT_PTR* in/out
Fiddle::TYPE_VOIDP, # msgBufDesc : smiOCTETS* in/out
],
-Fiddle::TYPE_INT)#[link(name = "wsnmp32")]
extern "system" {
fn SnmpDecodeMsg(
session: isize, // INT_PTR
srcEntity: *mut isize, // INT_PTR* in/out
dstEntity: *mut isize, // INT_PTR* in/out
context: *mut isize, // INT_PTR* in/out
pdu: *mut isize, // INT_PTR* in/out
msgBufDesc: *mut smiOCTETS // smiOCTETS* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wsnmp32.dll")]
public static extern uint SnmpDecodeMsg(IntPtr session, ref IntPtr srcEntity, ref IntPtr dstEntity, ref IntPtr context, ref IntPtr pdu, IntPtr msgBufDesc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsnmp32_SnmpDecodeMsg' -Namespace Win32 -PassThru
# $api::SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc)#uselib "wsnmp32.dll"
#func global SnmpDecodeMsg "SnmpDecodeMsg" sptr, sptr, sptr, sptr, sptr, sptr
; SnmpDecodeMsg session, varptr(srcEntity), varptr(dstEntity), varptr(context), varptr(pdu), varptr(msgBufDesc) ; 戻り値は stat
; session : INT_PTR -> "sptr"
; srcEntity : INT_PTR* in/out -> "sptr"
; dstEntity : INT_PTR* in/out -> "sptr"
; context : INT_PTR* in/out -> "sptr"
; pdu : INT_PTR* in/out -> "sptr"
; msgBufDesc : smiOCTETS* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "wsnmp32.dll" #cfunc global SnmpDecodeMsg "SnmpDecodeMsg" sptr, var, var, var, var, var ; res = SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc) ; session : INT_PTR -> "sptr" ; srcEntity : INT_PTR* in/out -> "var" ; dstEntity : INT_PTR* in/out -> "var" ; context : INT_PTR* in/out -> "var" ; pdu : INT_PTR* in/out -> "var" ; msgBufDesc : smiOCTETS* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "wsnmp32.dll" #cfunc global SnmpDecodeMsg "SnmpDecodeMsg" sptr, sptr, sptr, sptr, sptr, sptr ; res = SnmpDecodeMsg(session, varptr(srcEntity), varptr(dstEntity), varptr(context), varptr(pdu), varptr(msgBufDesc)) ; session : INT_PTR -> "sptr" ; srcEntity : INT_PTR* in/out -> "sptr" ; dstEntity : INT_PTR* in/out -> "sptr" ; context : INT_PTR* in/out -> "sptr" ; pdu : INT_PTR* in/out -> "sptr" ; msgBufDesc : smiOCTETS* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; DWORD SnmpDecodeMsg(INT_PTR session, INT_PTR* srcEntity, INT_PTR* dstEntity, INT_PTR* context, INT_PTR* pdu, smiOCTETS* msgBufDesc) #uselib "wsnmp32.dll" #cfunc global SnmpDecodeMsg "SnmpDecodeMsg" intptr, var, var, var, var, var ; res = SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc) ; session : INT_PTR -> "intptr" ; srcEntity : INT_PTR* in/out -> "var" ; dstEntity : INT_PTR* in/out -> "var" ; context : INT_PTR* in/out -> "var" ; pdu : INT_PTR* in/out -> "var" ; msgBufDesc : smiOCTETS* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SnmpDecodeMsg(INT_PTR session, INT_PTR* srcEntity, INT_PTR* dstEntity, INT_PTR* context, INT_PTR* pdu, smiOCTETS* msgBufDesc) #uselib "wsnmp32.dll" #cfunc global SnmpDecodeMsg "SnmpDecodeMsg" intptr, intptr, intptr, intptr, intptr, intptr ; res = SnmpDecodeMsg(session, varptr(srcEntity), varptr(dstEntity), varptr(context), varptr(pdu), varptr(msgBufDesc)) ; session : INT_PTR -> "intptr" ; srcEntity : INT_PTR* in/out -> "intptr" ; dstEntity : INT_PTR* in/out -> "intptr" ; context : INT_PTR* in/out -> "intptr" ; pdu : INT_PTR* in/out -> "intptr" ; msgBufDesc : smiOCTETS* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
procSnmpDecodeMsg = wsnmp32.NewProc("SnmpDecodeMsg")
)
// session (INT_PTR), srcEntity (INT_PTR* in/out), dstEntity (INT_PTR* in/out), context (INT_PTR* in/out), pdu (INT_PTR* in/out), msgBufDesc (smiOCTETS* in/out)
r1, _, err := procSnmpDecodeMsg.Call(
uintptr(session),
uintptr(srcEntity),
uintptr(dstEntity),
uintptr(context),
uintptr(pdu),
uintptr(msgBufDesc),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SnmpDecodeMsg(
session: NativeInt; // INT_PTR
srcEntity: Pointer; // INT_PTR* in/out
dstEntity: Pointer; // INT_PTR* in/out
context: Pointer; // INT_PTR* in/out
pdu: Pointer; // INT_PTR* in/out
msgBufDesc: Pointer // smiOCTETS* in/out
): DWORD; stdcall;
external 'wsnmp32.dll' name 'SnmpDecodeMsg';result := DllCall("wsnmp32\SnmpDecodeMsg"
, "Ptr", session ; INT_PTR
, "Ptr", srcEntity ; INT_PTR* in/out
, "Ptr", dstEntity ; INT_PTR* in/out
, "Ptr", context ; INT_PTR* in/out
, "Ptr", pdu ; INT_PTR* in/out
, "Ptr", msgBufDesc ; smiOCTETS* in/out
, "UInt") ; return: DWORD●SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc) = DLL("wsnmp32.dll", "dword SnmpDecodeMsg(int, void*, void*, void*, void*, void*)")
# 呼び出し: SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc)
# session : INT_PTR -> "int"
# srcEntity : INT_PTR* in/out -> "void*"
# dstEntity : INT_PTR* in/out -> "void*"
# context : INT_PTR* in/out -> "void*"
# pdu : INT_PTR* in/out -> "void*"
# msgBufDesc : smiOCTETS* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wsnmp32" fn SnmpDecodeMsg(
session: isize, // INT_PTR
srcEntity: [*c]isize, // INT_PTR* in/out
dstEntity: [*c]isize, // INT_PTR* in/out
context: [*c]isize, // INT_PTR* in/out
pdu: [*c]isize, // INT_PTR* in/out
msgBufDesc: [*c]smiOCTETS // smiOCTETS* in/out
) callconv(std.os.windows.WINAPI) u32;proc SnmpDecodeMsg(
session: int, # INT_PTR
srcEntity: ptr int, # INT_PTR* in/out
dstEntity: ptr int, # INT_PTR* in/out
context: ptr int, # INT_PTR* in/out
pdu: ptr int, # INT_PTR* in/out
msgBufDesc: ptr smiOCTETS # smiOCTETS* in/out
): uint32 {.importc: "SnmpDecodeMsg", stdcall, dynlib: "wsnmp32.dll".}pragma(lib, "wsnmp32");
extern(Windows)
uint SnmpDecodeMsg(
ptrdiff_t session, // INT_PTR
ptrdiff_t* srcEntity, // INT_PTR* in/out
ptrdiff_t* dstEntity, // INT_PTR* in/out
ptrdiff_t* context, // INT_PTR* in/out
ptrdiff_t* pdu, // INT_PTR* in/out
smiOCTETS* msgBufDesc // smiOCTETS* in/out
);ccall((:SnmpDecodeMsg, "wsnmp32.dll"), stdcall, UInt32,
(Int, Ptr{Int}, Ptr{Int}, Ptr{Int}, Ptr{Int}, Ptr{smiOCTETS}),
session, srcEntity, dstEntity, context, pdu, msgBufDesc)
# session : INT_PTR -> Int
# srcEntity : INT_PTR* in/out -> Ptr{Int}
# dstEntity : INT_PTR* in/out -> Ptr{Int}
# context : INT_PTR* in/out -> Ptr{Int}
# pdu : INT_PTR* in/out -> Ptr{Int}
# msgBufDesc : smiOCTETS* in/out -> Ptr{smiOCTETS}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t SnmpDecodeMsg(
intptr_t session,
intptr_t* srcEntity,
intptr_t* dstEntity,
intptr_t* context,
intptr_t* pdu,
void* msgBufDesc);
]]
local wsnmp32 = ffi.load("wsnmp32")
-- wsnmp32.SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc)
-- session : INT_PTR
-- srcEntity : INT_PTR* in/out
-- dstEntity : INT_PTR* in/out
-- context : INT_PTR* in/out
-- pdu : INT_PTR* in/out
-- msgBufDesc : smiOCTETS* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wsnmp32.dll');
const SnmpDecodeMsg = lib.func('__stdcall', 'SnmpDecodeMsg', 'uint32_t', ['intptr_t', 'intptr_t *', 'intptr_t *', 'intptr_t *', 'intptr_t *', 'void *']);
// SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc)
// session : INT_PTR -> 'intptr_t'
// srcEntity : INT_PTR* in/out -> 'intptr_t *'
// dstEntity : INT_PTR* in/out -> 'intptr_t *'
// context : INT_PTR* in/out -> 'intptr_t *'
// pdu : INT_PTR* in/out -> 'intptr_t *'
// msgBufDesc : smiOCTETS* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wsnmp32.dll", {
SnmpDecodeMsg: { parameters: ["isize", "pointer", "pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc)
// session : INT_PTR -> "isize"
// srcEntity : INT_PTR* in/out -> "pointer"
// dstEntity : INT_PTR* in/out -> "pointer"
// context : INT_PTR* in/out -> "pointer"
// pdu : INT_PTR* in/out -> "pointer"
// msgBufDesc : smiOCTETS* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SnmpDecodeMsg(
intptr_t session,
intptr_t* srcEntity,
intptr_t* dstEntity,
intptr_t* context,
intptr_t* pdu,
void* msgBufDesc);
C, "wsnmp32.dll");
// $ffi->SnmpDecodeMsg(session, srcEntity, dstEntity, context, pdu, msgBufDesc);
// session : INT_PTR
// srcEntity : INT_PTR* in/out
// dstEntity : INT_PTR* in/out
// context : INT_PTR* in/out
// pdu : INT_PTR* in/out
// msgBufDesc : smiOCTETS* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wsnmp32 extends StdCallLibrary {
Wsnmp32 INSTANCE = Native.load("wsnmp32", Wsnmp32.class);
int SnmpDecodeMsg(
long session, // INT_PTR
LongByReference srcEntity, // INT_PTR* in/out
LongByReference dstEntity, // INT_PTR* in/out
LongByReference context, // INT_PTR* in/out
LongByReference pdu, // INT_PTR* in/out
Pointer msgBufDesc // smiOCTETS* in/out
);
}@[Link("wsnmp32")]
lib Libwsnmp32
fun SnmpDecodeMsg = SnmpDecodeMsg(
session : LibC::SSizeT, # INT_PTR
srcEntity : LibC::SSizeT*, # INT_PTR* in/out
dstEntity : LibC::SSizeT*, # INT_PTR* in/out
context : LibC::SSizeT*, # INT_PTR* in/out
pdu : LibC::SSizeT*, # INT_PTR* in/out
msgBufDesc : smiOCTETS* # smiOCTETS* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SnmpDecodeMsgNative = Uint32 Function(IntPtr, Pointer<IntPtr>, Pointer<IntPtr>, Pointer<IntPtr>, Pointer<IntPtr>, Pointer<Void>);
typedef SnmpDecodeMsgDart = int Function(int, Pointer<IntPtr>, Pointer<IntPtr>, Pointer<IntPtr>, Pointer<IntPtr>, Pointer<Void>);
final SnmpDecodeMsg = DynamicLibrary.open('wsnmp32.dll')
.lookupFunction<SnmpDecodeMsgNative, SnmpDecodeMsgDart>('SnmpDecodeMsg');
// session : INT_PTR -> IntPtr
// srcEntity : INT_PTR* in/out -> Pointer<IntPtr>
// dstEntity : INT_PTR* in/out -> Pointer<IntPtr>
// context : INT_PTR* in/out -> Pointer<IntPtr>
// pdu : INT_PTR* in/out -> Pointer<IntPtr>
// msgBufDesc : smiOCTETS* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SnmpDecodeMsg(
session: NativeInt; // INT_PTR
srcEntity: Pointer; // INT_PTR* in/out
dstEntity: Pointer; // INT_PTR* in/out
context: Pointer; // INT_PTR* in/out
pdu: Pointer; // INT_PTR* in/out
msgBufDesc: Pointer // smiOCTETS* in/out
): DWORD; stdcall;
external 'wsnmp32.dll' name 'SnmpDecodeMsg';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SnmpDecodeMsg"
c_SnmpDecodeMsg :: CIntPtr -> Ptr CIntPtr -> Ptr CIntPtr -> Ptr CIntPtr -> Ptr CIntPtr -> Ptr () -> IO Word32
-- session : INT_PTR -> CIntPtr
-- srcEntity : INT_PTR* in/out -> Ptr CIntPtr
-- dstEntity : INT_PTR* in/out -> Ptr CIntPtr
-- context : INT_PTR* in/out -> Ptr CIntPtr
-- pdu : INT_PTR* in/out -> Ptr CIntPtr
-- msgBufDesc : smiOCTETS* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let snmpdecodemsg =
foreign "SnmpDecodeMsg"
(intptr_t @-> (ptr intptr_t) @-> (ptr intptr_t) @-> (ptr intptr_t) @-> (ptr intptr_t) @-> (ptr void) @-> returning uint32_t)
(* session : INT_PTR -> intptr_t *)
(* srcEntity : INT_PTR* in/out -> (ptr intptr_t) *)
(* dstEntity : INT_PTR* in/out -> (ptr intptr_t) *)
(* context : INT_PTR* in/out -> (ptr intptr_t) *)
(* pdu : INT_PTR* in/out -> (ptr intptr_t) *)
(* msgBufDesc : smiOCTETS* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wsnmp32 (t "wsnmp32.dll"))
(cffi:use-foreign-library wsnmp32)
(cffi:defcfun ("SnmpDecodeMsg" snmp-decode-msg :convention :stdcall) :uint32
(session :int64) ; INT_PTR
(src-entity :pointer) ; INT_PTR* in/out
(dst-entity :pointer) ; INT_PTR* in/out
(context :pointer) ; INT_PTR* in/out
(pdu :pointer) ; INT_PTR* in/out
(msg-buf-desc :pointer)) ; smiOCTETS* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SnmpDecodeMsg = Win32::API::More->new('wsnmp32',
'DWORD SnmpDecodeMsg(LPARAM session, LPVOID srcEntity, LPVOID dstEntity, LPVOID context, LPVOID pdu, LPVOID msgBufDesc)');
# my $ret = $SnmpDecodeMsg->Call($session, $srcEntity, $dstEntity, $context, $pdu, $msgBufDesc);
# session : INT_PTR -> LPARAM
# srcEntity : INT_PTR* in/out -> LPVOID
# dstEntity : INT_PTR* in/out -> LPVOID
# context : INT_PTR* in/out -> LPVOID
# pdu : INT_PTR* in/out -> LPVOID
# msgBufDesc : smiOCTETS* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f SnmpEncodeMsg — WinSNMPでメッセージをエンコードしバイト列を生成する。
- f SnmpFreeContext — WinSNMPコンテキストに割り当てたリソースを解放する。
- f SnmpFreeEntity — WinSNMPエンティティに割り当てたリソースを解放する。
- f SnmpFreePdu — WinSNMPのPDUに割り当てたリソースを解放する。
- f SnmpSendMsg — WinSNMPでPDUを含むメッセージを宛先へ送信する。