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

MIB_IFROW

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

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

フィールド

フィールドサイズx64x86説明
wszNameWCHAR512+0+0インターフェイスの名前を含む Unicode 文字列へのポインターです。
dwIndexDWORD4+512+512インターフェイスを識別するインデックスです。このインデックス値は、ネットワークアダプターを無効にした後に再度有効にすると変化することがあるため、永続的なものと見なすべきではありません。
dwTypeDWORD4+516+516

Internet Assigned Names Authority (IANA) によって定義されたインターフェイスの種類です。詳細については、http://www.iana.org/assignments/ianaiftype-mib を参照してください。インターフェイスの種類として指定できる値は、Ipifcons.h ヘッダーファイルに記載されています。

次の表は、インターフェイスの種類として一般的な値を示します。ただし、他にも多くの値が使用される可能性があります。

意味
IF_TYPE_OTHER
1
その他の種類のネットワークインターフェイスです。
IF_TYPE_ETHERNET_CSMACD
6
イーサネットのネットワークインターフェイスです。
IF_TYPE_ISO88025_TOKENRING
9
トークンリングのネットワークインターフェイスです。
IF_TYPE_FDDI
15
Fiber Distributed Data Interface (FDDI) のネットワークインターフェイスです。
IF_TYPE_PPP
23
PPP のネットワークインターフェイスです。
IF_TYPE_SOFTWARE_LOOPBACK
24
ソフトウェアループバックのネットワークインターフェイスです。
IF_TYPE_ATM
37
ATM のネットワークインターフェイスです。
IF_TYPE_IEEE80211
71
IEEE 802.11 の無線ネットワークインターフェイスです。
IF_TYPE_TUNNEL
131
トンネル型カプセル化のネットワークインターフェイスです。
IF_TYPE_IEEE1394
144
IEEE 1394 (Firewire) 高性能シリアルバスのネットワークインターフェイスです。
IF_TYPE_IEEE80216_WMAN
237
WiMax デバイス向けのモバイルブロードバンドインターフェイスです。
メモ このインターフェイスの種類は、Windows 7、 Windows Server 2008 R2 以降でサポートされます。
IF_TYPE_WWANPP
243
GSM ベースのデバイス向けのモバイルブロードバンドインターフェイスです。
メモ このインターフェイスの種類は、Windows 7、 Windows Server 2008 R2 以降でサポートされます。
IF_TYPE_WWANPP2
244
CDMA ベースのデバイス向けのモバイルブロードバンドインターフェイスです。
メモ このインターフェイスの種類は、Windows 7、 Windows Server 2008 R2 以降でサポートされます。
dwMtuDWORD4+520+520最大転送単位 (MTU) のサイズ (バイト単位) です。
dwSpeedDWORD4+524+524インターフェイスの速度 (ビット/秒) です。
dwPhysAddrLenDWORD4+528+528bPhysAddr メンバーで指定される物理アドレスの長さ (バイト単位) です。
bPhysAddrBYTE8+532+532このインターフェイスのアダプターの物理アドレスです。
dwAdminStatusDWORD4+540+540インターフェイスが管理上有効か無効かを示します。
dwOperStatusINTERNAL_IF_OPER_STATUS4+544+544

インターフェイスの動作状態です。このメンバーには、Ipifcons.h ヘッダーファイルで定義されている INTERNAL_IF_OPER_STATUS 列挙型の次の値のいずれかを指定できます。

意味
IF_OPER_STATUS_NON_OPERATIONAL
アドレスの競合などの理由により、LAN アダプターが無効になっています。
IF_OPER_STATUS_UNREACHABLE
接続されていない WAN アダプターです。
IF_OPER_STATUS_DISCONNECTED
LAN アダプターの場合: ネットワークケーブルが切断されています。WAN アダプターの場合: キャリアがありません。
IF_OPER_STATUS_CONNECTING
接続処理中の WAN アダプターです。
IF_OPER_STATUS_CONNECTED
リモートピアに接続されている WAN アダプターです。
IF_OPER_STATUS_OPERATIONAL
LAN アダプターの既定の状態です。
dwLastChangeDWORD4+548+548

コンピューターの最後の再起動を起点として、インターフェイスが現在の動作状態になるまでの時間を 100 分の 1 秒 (10^-2 秒) 単位で表した値です。この値は 100 分の 1 秒単位で 2^32 を超えると 0 に戻ります。

dwLastChange メンバーは現在 NDIS ではサポートされていません。Windows Vista 以降では、NDIS はこのメンバーに 0 を返します。それ以前のバージョンの Windows では、NDIS がサポートするインターフェイスについて、このメンバーに任意の値が返されます。他のインターフェイスプロバイダーがサポートするインターフェイスでは、適切な値が返される場合があります。

dwInOctetsDWORD4+552+552このインターフェイスを通じて受信されたデータのオクテット数です。
dwInUcastPktsDWORD4+556+556このインターフェイスを通じて受信されたユニキャストパケットの数です。
dwInNUcastPktsDWORD4+560+560このインターフェイスを通じて受信された非ユニキャストパケットの数です。ブロードキャストパケットとマルチキャストパケットが含まれます。
dwInDiscardsDWORD4+564+564エラーがなかったにもかかわらず破棄された受信パケットの数です。
dwInErrorsDWORD4+568+568エラーが原因で破棄された受信パケットの数です。
dwInUnknownProtosDWORD4+572+572プロトコルが不明であったために破棄された受信パケットの数です。
dwOutOctetsDWORD4+576+576このインターフェイスを通じて送信されたデータのオクテット数です。
dwOutUcastPktsDWORD4+580+580このインターフェイスを通じて送信されたユニキャストパケットの数です。
dwOutNUcastPktsDWORD4+584+584このインターフェイスを通じて送信された非ユニキャストパケットの数です。ブロードキャストパケットとマルチキャストパケットが含まれます。
dwOutDiscardsDWORD4+588+588エラーがなかったにもかかわらず破棄された送信パケットの数です。
dwOutErrorsDWORD4+592+592エラーが原因で破棄された送信パケットの数です。
dwOutQLenDWORD4+596+596送信キューの長さです。このフィールドは現在使用されていません。
dwDescrLenDWORD4+600+600bDescr メンバーの長さ (バイト単位) です。
bDescrBYTE256+604+604インターフェイスの説明です。

公式ドキュメント

MIB_IFROW 構造体は、特定のインターフェイスに関する情報を格納します。

解説(Remarks)

DWORD に格納できる最大値は 4,294,967,295 であるため、非常に高速なネットワークインターフェイス (たとえば 10 Gbit/秒のネットワークアダプター) では、MIB_IFROW 構造体の dwSpeed メンバーの値は正しくありません。非常に高速なネットワークインターフェイスの速度を判定するには、GetIfEntry2 関数および GetIfTable2 関数が返す MIB_IF_ROW2 構造体、または GetAdaptersAddresses 関数が返す IP_ADAPTER_ADDRESSES 構造体を使用してください。

Windows Vista 以降向けにリリースされた Microsoft Windows Software Development Kit (SDK) では、ヘッダーファイルの構成が変更され、MIB_IFROW 構造体は Iprtrmib.h ヘッダーファイルではなく Ifmib.h ヘッダーファイルで定義されています。Ifmib.h ヘッダーファイルは Iprtrmib.h に自動的にインクルードされ、Iprtrmib.hIphlpapi.h ヘッダーファイルに自動的にインクルードされる点に注意してください。Ifmib.h および Iprtrmib.h ヘッダーファイルを直接使用しないでください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// MIB_IFROW  (x64 860 / x86 860 バイト)
typedef struct MIB_IFROW {
    WCHAR wszName[256];
    DWORD dwIndex;
    DWORD dwType;
    DWORD dwMtu;
    DWORD dwSpeed;
    DWORD dwPhysAddrLen;
    BYTE bPhysAddr[8];
    DWORD dwAdminStatus;
    INTERNAL_IF_OPER_STATUS dwOperStatus;
    DWORD dwLastChange;
    DWORD dwInOctets;
    DWORD dwInUcastPkts;
    DWORD dwInNUcastPkts;
    DWORD dwInDiscards;
    DWORD dwInErrors;
    DWORD dwInUnknownProtos;
    DWORD dwOutOctets;
    DWORD dwOutUcastPkts;
    DWORD dwOutNUcastPkts;
    DWORD dwOutDiscards;
    DWORD dwOutErrors;
    DWORD dwOutQLen;
    DWORD dwDescrLen;
    BYTE bDescr[256];
} MIB_IFROW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_IFROW
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string wszName;
    public uint dwIndex;
    public uint dwType;
    public uint dwMtu;
    public uint dwSpeed;
    public uint dwPhysAddrLen;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] bPhysAddr;
    public uint dwAdminStatus;
    public int dwOperStatus;
    public uint dwLastChange;
    public uint dwInOctets;
    public uint dwInUcastPkts;
    public uint dwInNUcastPkts;
    public uint dwInDiscards;
    public uint dwInErrors;
    public uint dwInUnknownProtos;
    public uint dwOutOctets;
    public uint dwOutUcastPkts;
    public uint dwOutNUcastPkts;
    public uint dwOutDiscards;
    public uint dwOutErrors;
    public uint dwOutQLen;
    public uint dwDescrLen;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] bDescr;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_IFROW
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public wszName As String
    Public dwIndex As UInteger
    Public dwType As UInteger
    Public dwMtu As UInteger
    Public dwSpeed As UInteger
    Public dwPhysAddrLen As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public bPhysAddr() As Byte
    Public dwAdminStatus As UInteger
    Public dwOperStatus As Integer
    Public dwLastChange As UInteger
    Public dwInOctets As UInteger
    Public dwInUcastPkts As UInteger
    Public dwInNUcastPkts As UInteger
    Public dwInDiscards As UInteger
    Public dwInErrors As UInteger
    Public dwInUnknownProtos As UInteger
    Public dwOutOctets As UInteger
    Public dwOutUcastPkts As UInteger
    Public dwOutNUcastPkts As UInteger
    Public dwOutDiscards As UInteger
    Public dwOutErrors As UInteger
    Public dwOutQLen As UInteger
    Public dwDescrLen As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Public bDescr() As Byte
End Structure
import ctypes
from ctypes import wintypes

class MIB_IFROW(ctypes.Structure):
    _fields_ = [
        ("wszName", ctypes.c_wchar * 256),
        ("dwIndex", wintypes.DWORD),
        ("dwType", wintypes.DWORD),
        ("dwMtu", wintypes.DWORD),
        ("dwSpeed", wintypes.DWORD),
        ("dwPhysAddrLen", wintypes.DWORD),
        ("bPhysAddr", ctypes.c_ubyte * 8),
        ("dwAdminStatus", wintypes.DWORD),
        ("dwOperStatus", ctypes.c_int),
        ("dwLastChange", wintypes.DWORD),
        ("dwInOctets", wintypes.DWORD),
        ("dwInUcastPkts", wintypes.DWORD),
        ("dwInNUcastPkts", wintypes.DWORD),
        ("dwInDiscards", wintypes.DWORD),
        ("dwInErrors", wintypes.DWORD),
        ("dwInUnknownProtos", wintypes.DWORD),
        ("dwOutOctets", wintypes.DWORD),
        ("dwOutUcastPkts", wintypes.DWORD),
        ("dwOutNUcastPkts", wintypes.DWORD),
        ("dwOutDiscards", wintypes.DWORD),
        ("dwOutErrors", wintypes.DWORD),
        ("dwOutQLen", wintypes.DWORD),
        ("dwDescrLen", wintypes.DWORD),
        ("bDescr", ctypes.c_ubyte * 256),
    ]
#[repr(C)]
pub struct MIB_IFROW {
    pub wszName: [u16; 256],
    pub dwIndex: u32,
    pub dwType: u32,
    pub dwMtu: u32,
    pub dwSpeed: u32,
    pub dwPhysAddrLen: u32,
    pub bPhysAddr: [u8; 8],
    pub dwAdminStatus: u32,
    pub dwOperStatus: i32,
    pub dwLastChange: u32,
    pub dwInOctets: u32,
    pub dwInUcastPkts: u32,
    pub dwInNUcastPkts: u32,
    pub dwInDiscards: u32,
    pub dwInErrors: u32,
    pub dwInUnknownProtos: u32,
    pub dwOutOctets: u32,
    pub dwOutUcastPkts: u32,
    pub dwOutNUcastPkts: u32,
    pub dwOutDiscards: u32,
    pub dwOutErrors: u32,
    pub dwOutQLen: u32,
    pub dwDescrLen: u32,
    pub bDescr: [u8; 256],
}
import "golang.org/x/sys/windows"

type MIB_IFROW struct {
	wszName [256]uint16
	dwIndex uint32
	dwType uint32
	dwMtu uint32
	dwSpeed uint32
	dwPhysAddrLen uint32
	bPhysAddr [8]byte
	dwAdminStatus uint32
	dwOperStatus int32
	dwLastChange uint32
	dwInOctets uint32
	dwInUcastPkts uint32
	dwInNUcastPkts uint32
	dwInDiscards uint32
	dwInErrors uint32
	dwInUnknownProtos uint32
	dwOutOctets uint32
	dwOutUcastPkts uint32
	dwOutNUcastPkts uint32
	dwOutDiscards uint32
	dwOutErrors uint32
	dwOutQLen uint32
	dwDescrLen uint32
	bDescr [256]byte
}
type
  MIB_IFROW = record
    wszName: array[0..255] of WideChar;
    dwIndex: DWORD;
    dwType: DWORD;
    dwMtu: DWORD;
    dwSpeed: DWORD;
    dwPhysAddrLen: DWORD;
    bPhysAddr: array[0..7] of Byte;
    dwAdminStatus: DWORD;
    dwOperStatus: Integer;
    dwLastChange: DWORD;
    dwInOctets: DWORD;
    dwInUcastPkts: DWORD;
    dwInNUcastPkts: DWORD;
    dwInDiscards: DWORD;
    dwInErrors: DWORD;
    dwInUnknownProtos: DWORD;
    dwOutOctets: DWORD;
    dwOutUcastPkts: DWORD;
    dwOutNUcastPkts: DWORD;
    dwOutDiscards: DWORD;
    dwOutErrors: DWORD;
    dwOutQLen: DWORD;
    dwDescrLen: DWORD;
    bDescr: array[0..255] of Byte;
  end;
const MIB_IFROW = extern struct {
    wszName: [256]u16,
    dwIndex: u32,
    dwType: u32,
    dwMtu: u32,
    dwSpeed: u32,
    dwPhysAddrLen: u32,
    bPhysAddr: [8]u8,
    dwAdminStatus: u32,
    dwOperStatus: i32,
    dwLastChange: u32,
    dwInOctets: u32,
    dwInUcastPkts: u32,
    dwInNUcastPkts: u32,
    dwInDiscards: u32,
    dwInErrors: u32,
    dwInUnknownProtos: u32,
    dwOutOctets: u32,
    dwOutUcastPkts: u32,
    dwOutNUcastPkts: u32,
    dwOutDiscards: u32,
    dwOutErrors: u32,
    dwOutQLen: u32,
    dwDescrLen: u32,
    bDescr: [256]u8,
};
type
  MIB_IFROW {.bycopy.} = object
    wszName: array[256, uint16]
    dwIndex: uint32
    dwType: uint32
    dwMtu: uint32
    dwSpeed: uint32
    dwPhysAddrLen: uint32
    bPhysAddr: array[8, uint8]
    dwAdminStatus: uint32
    dwOperStatus: int32
    dwLastChange: uint32
    dwInOctets: uint32
    dwInUcastPkts: uint32
    dwInNUcastPkts: uint32
    dwInDiscards: uint32
    dwInErrors: uint32
    dwInUnknownProtos: uint32
    dwOutOctets: uint32
    dwOutUcastPkts: uint32
    dwOutNUcastPkts: uint32
    dwOutDiscards: uint32
    dwOutErrors: uint32
    dwOutQLen: uint32
    dwDescrLen: uint32
    bDescr: array[256, uint8]
struct MIB_IFROW
{
    wchar[256] wszName;
    uint dwIndex;
    uint dwType;
    uint dwMtu;
    uint dwSpeed;
    uint dwPhysAddrLen;
    ubyte[8] bPhysAddr;
    uint dwAdminStatus;
    int dwOperStatus;
    uint dwLastChange;
    uint dwInOctets;
    uint dwInUcastPkts;
    uint dwInNUcastPkts;
    uint dwInDiscards;
    uint dwInErrors;
    uint dwInUnknownProtos;
    uint dwOutOctets;
    uint dwOutUcastPkts;
    uint dwOutNUcastPkts;
    uint dwOutDiscards;
    uint dwOutErrors;
    uint dwOutQLen;
    uint dwDescrLen;
    ubyte[256] bDescr;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MIB_IFROW サイズ: 860 バイト(x64)
dim st, 215    ; 4byte整数×215(構造体サイズ 860 / 4 切り上げ)
; wszName : WCHAR (+0, 512byte)  varptr(st)+0 を基点に操作(512byte:入れ子/配列)
; dwIndex : DWORD (+512, 4byte)  st.128 = 値  /  値 = st.128   (lpoke/lpeek も可)
; dwType : DWORD (+516, 4byte)  st.129 = 値  /  値 = st.129   (lpoke/lpeek も可)
; dwMtu : DWORD (+520, 4byte)  st.130 = 値  /  値 = st.130   (lpoke/lpeek も可)
; dwSpeed : DWORD (+524, 4byte)  st.131 = 値  /  値 = st.131   (lpoke/lpeek も可)
; dwPhysAddrLen : DWORD (+528, 4byte)  st.132 = 値  /  値 = st.132   (lpoke/lpeek も可)
; bPhysAddr : BYTE (+532, 8byte)  varptr(st)+532 を基点に操作(8byte:入れ子/配列)
; dwAdminStatus : DWORD (+540, 4byte)  st.135 = 値  /  値 = st.135   (lpoke/lpeek も可)
; dwOperStatus : INTERNAL_IF_OPER_STATUS (+544, 4byte)  st.136 = 値  /  値 = st.136   (lpoke/lpeek も可)
; dwLastChange : DWORD (+548, 4byte)  st.137 = 値  /  値 = st.137   (lpoke/lpeek も可)
; dwInOctets : DWORD (+552, 4byte)  st.138 = 値  /  値 = st.138   (lpoke/lpeek も可)
; dwInUcastPkts : DWORD (+556, 4byte)  st.139 = 値  /  値 = st.139   (lpoke/lpeek も可)
; dwInNUcastPkts : DWORD (+560, 4byte)  st.140 = 値  /  値 = st.140   (lpoke/lpeek も可)
; dwInDiscards : DWORD (+564, 4byte)  st.141 = 値  /  値 = st.141   (lpoke/lpeek も可)
; dwInErrors : DWORD (+568, 4byte)  st.142 = 値  /  値 = st.142   (lpoke/lpeek も可)
; dwInUnknownProtos : DWORD (+572, 4byte)  st.143 = 値  /  値 = st.143   (lpoke/lpeek も可)
; dwOutOctets : DWORD (+576, 4byte)  st.144 = 値  /  値 = st.144   (lpoke/lpeek も可)
; dwOutUcastPkts : DWORD (+580, 4byte)  st.145 = 値  /  値 = st.145   (lpoke/lpeek も可)
; dwOutNUcastPkts : DWORD (+584, 4byte)  st.146 = 値  /  値 = st.146   (lpoke/lpeek も可)
; dwOutDiscards : DWORD (+588, 4byte)  st.147 = 値  /  値 = st.147   (lpoke/lpeek も可)
; dwOutErrors : DWORD (+592, 4byte)  st.148 = 値  /  値 = st.148   (lpoke/lpeek も可)
; dwOutQLen : DWORD (+596, 4byte)  st.149 = 値  /  値 = st.149   (lpoke/lpeek も可)
; dwDescrLen : DWORD (+600, 4byte)  st.150 = 値  /  値 = st.150   (lpoke/lpeek も可)
; bDescr : BYTE (+604, 256byte)  varptr(st)+604 を基点に操作(256byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MIB_IFROW
    #field wchar wszName 256
    #field int dwIndex
    #field int dwType
    #field int dwMtu
    #field int dwSpeed
    #field int dwPhysAddrLen
    #field byte bPhysAddr 8
    #field int dwAdminStatus
    #field int dwOperStatus
    #field int dwLastChange
    #field int dwInOctets
    #field int dwInUcastPkts
    #field int dwInNUcastPkts
    #field int dwInDiscards
    #field int dwInErrors
    #field int dwInUnknownProtos
    #field int dwOutOctets
    #field int dwOutUcastPkts
    #field int dwOutNUcastPkts
    #field int dwOutDiscards
    #field int dwOutErrors
    #field int dwOutQLen
    #field int dwDescrLen
    #field byte bDescr 256
#endstruct

stdim st, MIB_IFROW        ; NSTRUCT 変数を確保
st->dwIndex = 100
mes "dwIndex=" + st->dwIndex