Win32 API 日本語リファレンス
ホームNetworkManagement.IpHelper › MIB_ICMP

MIB_ICMP

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

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

フィールド

フィールドサイズx64x86説明
statsMIBICMPINFO104+0+0ICMPの送受信統計をまとめて保持するMIBICMPINFO構造体。

各言語での定義

#include <windows.h>

// MIBICMPSTATS  (x64 52 / x86 52 バイト)
typedef struct MIBICMPSTATS {
    DWORD dwMsgs;
    DWORD dwErrors;
    DWORD dwDestUnreachs;
    DWORD dwTimeExcds;
    DWORD dwParmProbs;
    DWORD dwSrcQuenchs;
    DWORD dwRedirects;
    DWORD dwEchos;
    DWORD dwEchoReps;
    DWORD dwTimestamps;
    DWORD dwTimestampReps;
    DWORD dwAddrMasks;
    DWORD dwAddrMaskReps;
} MIBICMPSTATS;

// MIBICMPINFO  (x64 104 / x86 104 バイト)
typedef struct MIBICMPINFO {
    MIBICMPSTATS icmpInStats;
    MIBICMPSTATS icmpOutStats;
} MIBICMPINFO;

// MIB_ICMP  (x64 104 / x86 104 バイト)
typedef struct MIB_ICMP {
    MIBICMPINFO stats;
} MIB_ICMP;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIBICMPSTATS
{
    public uint dwMsgs;
    public uint dwErrors;
    public uint dwDestUnreachs;
    public uint dwTimeExcds;
    public uint dwParmProbs;
    public uint dwSrcQuenchs;
    public uint dwRedirects;
    public uint dwEchos;
    public uint dwEchoReps;
    public uint dwTimestamps;
    public uint dwTimestampReps;
    public uint dwAddrMasks;
    public uint dwAddrMaskReps;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIBICMPINFO
{
    public MIBICMPSTATS icmpInStats;
    public MIBICMPSTATS icmpOutStats;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_ICMP
{
    public MIBICMPINFO stats;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIBICMPSTATS
    Public dwMsgs As UInteger
    Public dwErrors As UInteger
    Public dwDestUnreachs As UInteger
    Public dwTimeExcds As UInteger
    Public dwParmProbs As UInteger
    Public dwSrcQuenchs As UInteger
    Public dwRedirects As UInteger
    Public dwEchos As UInteger
    Public dwEchoReps As UInteger
    Public dwTimestamps As UInteger
    Public dwTimestampReps As UInteger
    Public dwAddrMasks As UInteger
    Public dwAddrMaskReps As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIBICMPINFO
    Public icmpInStats As MIBICMPSTATS
    Public icmpOutStats As MIBICMPSTATS
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_ICMP
    Public stats As MIBICMPINFO
End Structure
import ctypes
from ctypes import wintypes

class MIBICMPSTATS(ctypes.Structure):
    _fields_ = [
        ("dwMsgs", wintypes.DWORD),
        ("dwErrors", wintypes.DWORD),
        ("dwDestUnreachs", wintypes.DWORD),
        ("dwTimeExcds", wintypes.DWORD),
        ("dwParmProbs", wintypes.DWORD),
        ("dwSrcQuenchs", wintypes.DWORD),
        ("dwRedirects", wintypes.DWORD),
        ("dwEchos", wintypes.DWORD),
        ("dwEchoReps", wintypes.DWORD),
        ("dwTimestamps", wintypes.DWORD),
        ("dwTimestampReps", wintypes.DWORD),
        ("dwAddrMasks", wintypes.DWORD),
        ("dwAddrMaskReps", wintypes.DWORD),
    ]

class MIBICMPINFO(ctypes.Structure):
    _fields_ = [
        ("icmpInStats", MIBICMPSTATS),
        ("icmpOutStats", MIBICMPSTATS),
    ]

class MIB_ICMP(ctypes.Structure):
    _fields_ = [
        ("stats", MIBICMPINFO),
    ]
#[repr(C)]
pub struct MIBICMPSTATS {
    pub dwMsgs: u32,
    pub dwErrors: u32,
    pub dwDestUnreachs: u32,
    pub dwTimeExcds: u32,
    pub dwParmProbs: u32,
    pub dwSrcQuenchs: u32,
    pub dwRedirects: u32,
    pub dwEchos: u32,
    pub dwEchoReps: u32,
    pub dwTimestamps: u32,
    pub dwTimestampReps: u32,
    pub dwAddrMasks: u32,
    pub dwAddrMaskReps: u32,
}

#[repr(C)]
pub struct MIBICMPINFO {
    pub icmpInStats: MIBICMPSTATS,
    pub icmpOutStats: MIBICMPSTATS,
}

#[repr(C)]
pub struct MIB_ICMP {
    pub stats: MIBICMPINFO,
}
import "golang.org/x/sys/windows"

type MIBICMPSTATS struct {
	dwMsgs uint32
	dwErrors uint32
	dwDestUnreachs uint32
	dwTimeExcds uint32
	dwParmProbs uint32
	dwSrcQuenchs uint32
	dwRedirects uint32
	dwEchos uint32
	dwEchoReps uint32
	dwTimestamps uint32
	dwTimestampReps uint32
	dwAddrMasks uint32
	dwAddrMaskReps uint32
}

type MIBICMPINFO struct {
	icmpInStats MIBICMPSTATS
	icmpOutStats MIBICMPSTATS
}

type MIB_ICMP struct {
	stats MIBICMPINFO
}
type
  MIBICMPSTATS = record
    dwMsgs: DWORD;
    dwErrors: DWORD;
    dwDestUnreachs: DWORD;
    dwTimeExcds: DWORD;
    dwParmProbs: DWORD;
    dwSrcQuenchs: DWORD;
    dwRedirects: DWORD;
    dwEchos: DWORD;
    dwEchoReps: DWORD;
    dwTimestamps: DWORD;
    dwTimestampReps: DWORD;
    dwAddrMasks: DWORD;
    dwAddrMaskReps: DWORD;
  end;

  MIBICMPINFO = record
    icmpInStats: MIBICMPSTATS;
    icmpOutStats: MIBICMPSTATS;
  end;

  MIB_ICMP = record
    stats: MIBICMPINFO;
  end;
const MIBICMPSTATS = extern struct {
    dwMsgs: u32,
    dwErrors: u32,
    dwDestUnreachs: u32,
    dwTimeExcds: u32,
    dwParmProbs: u32,
    dwSrcQuenchs: u32,
    dwRedirects: u32,
    dwEchos: u32,
    dwEchoReps: u32,
    dwTimestamps: u32,
    dwTimestampReps: u32,
    dwAddrMasks: u32,
    dwAddrMaskReps: u32,
};

const MIBICMPINFO = extern struct {
    icmpInStats: MIBICMPSTATS,
    icmpOutStats: MIBICMPSTATS,
};

const MIB_ICMP = extern struct {
    stats: MIBICMPINFO,
};
type
  MIBICMPSTATS {.bycopy.} = object
    dwMsgs: uint32
    dwErrors: uint32
    dwDestUnreachs: uint32
    dwTimeExcds: uint32
    dwParmProbs: uint32
    dwSrcQuenchs: uint32
    dwRedirects: uint32
    dwEchos: uint32
    dwEchoReps: uint32
    dwTimestamps: uint32
    dwTimestampReps: uint32
    dwAddrMasks: uint32
    dwAddrMaskReps: uint32

  MIBICMPINFO {.bycopy.} = object
    icmpInStats: MIBICMPSTATS
    icmpOutStats: MIBICMPSTATS

  MIB_ICMP {.bycopy.} = object
    stats: MIBICMPINFO
struct MIBICMPSTATS
{
    uint dwMsgs;
    uint dwErrors;
    uint dwDestUnreachs;
    uint dwTimeExcds;
    uint dwParmProbs;
    uint dwSrcQuenchs;
    uint dwRedirects;
    uint dwEchos;
    uint dwEchoReps;
    uint dwTimestamps;
    uint dwTimestampReps;
    uint dwAddrMasks;
    uint dwAddrMaskReps;
}

struct MIBICMPINFO
{
    MIBICMPSTATS icmpInStats;
    MIBICMPSTATS icmpOutStats;
}

struct MIB_ICMP
{
    MIBICMPINFO stats;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MIB_ICMP サイズ: 104 バイト(x64)
dim st, 26    ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; stats : MIBICMPINFO (+0, 104byte)  varptr(st)+0 を基点に操作(104byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global MIBICMPSTATS
    #field int dwMsgs
    #field int dwErrors
    #field int dwDestUnreachs
    #field int dwTimeExcds
    #field int dwParmProbs
    #field int dwSrcQuenchs
    #field int dwRedirects
    #field int dwEchos
    #field int dwEchoReps
    #field int dwTimestamps
    #field int dwTimestampReps
    #field int dwAddrMasks
    #field int dwAddrMaskReps
#endstruct

#defstruct global MIBICMPINFO
    #field MIBICMPSTATS icmpInStats
    #field MIBICMPSTATS icmpOutStats
#endstruct

#defstruct global MIB_ICMP
    #field MIBICMPINFO stats
#endstruct

stdim st, MIB_ICMP        ; NSTRUCT 変数を確保