IP Helper API 関数一覧

ここでは、Windowsでネットワーク設定情報を取得するAPIであるIPHLPAPI(IP Helper API)で使える関数を示します。 IPHLPAPIを使って楽しくネットワークプログラミングしましょう。

必要なヘッダ


#include <winsock2.h>
#include <iphlpapi.h>

必要なライブラリ

  • WS2_32.lib
  • IPHLPAPI.lib

Adapter設定関連


DWORD
GetAdapterIndex(
  LPWSTR AdapterName,
  PULONG IfIndex
);

DWORD WINAPI
GetAdaptersAddresses(
  ULONG Family,
  DWORD Flags,
  PVOID Reserved,
  PIP_ADAPTER_ADDRESSES pAdapterAddresses,
  PULONG pOutBufLen
);

DWORD
GetAdaptersInfo(
  PIP_ADAPTER_INFO pAdapterInfo,
  PULONG pOutBufLen
);

DWORD
GetPerAdapterInfo(
  ULONG IfIndex,
  PIP_PER_ADAPTER_INFO pPerAdapterInfo,
  PULONG pOutBufLen
);

DWORD
GetUniDirectionalAdapterInfo(
  PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo,
  PULONG dwOutBufLen
);

ARP関連


DWORD
CreateIpNetEntry(
  PMIB_IPNETROW pArpEntry
);

DWORD
CreateProxyArpEntry(
  DWORD dwAddress,
  DWORD dwMask,
  DWORD dwIfIndex
);

DWORD
DeleteIpNetEntry(
  PMIB_IPNETROW pArpEntry
);

DWORD
DeleteProxyArpEntry(
  DWORD dwAddress,
  DWORD dwMask,
  DWORD dwIfIndex
);

DWORD
FlushIpNetTable(
  DWORD dwIfIndex
);

DWORD
GetIpNetTable(
  PMIB_IPNETTABLE pIpNetTable,
  PULONG pdwSize,
  BOOL bOrder
);

DWORD
SendARP(
  IPAddr DestIP,
  IPAddr SrcIP,
  PULONG pMacAddr,
  PULONG PhyAddrLen
);

DWORD
SetIpNetEntry(
  PMIB_IPNETROW pArpEntry
);

インターフェース設定関連


DWORD
GetFriendlyIfIndex(
  DWORD IfIndex
);

DWORD
GetIfEntry(
  PMIB_IFROW pIfRow
);

DWORD
GetIfTable(
  PMIB_IFTABLE pIfTable,
  PULONG pdwSize,
  BOOL bOrder
);

DWORD
GetInterfaceInfo(
  PIP_INTERFACE_INFO pIfTable,
  PULONG dwOutBufLen
);

DWORD
GetNumberOfInterfaces(
  PDWORD pdwNumIf
);

DWORD
SetIfEntry(
  PMIB_IFROW pIfRow
);

IP、ICMP関連


DWORD
GetIcmpStatistics(
  PMIB_ICMP pStats
);

DWORD
GetIpStatistics(
  PMIB_IPSTATS pStats
);

BOOL
IcmpCloseHandle(
  HANDLE IcmpHandle
);

HANDLE
IcmpCreateFile(void);

DWORD
IcmpParseReplies(
  LPVOID ReplyBuffer,
  DWORD ReplySize
);

DWORD
IcmpSendEcho(
  HANDLE IcmpHandle,
  IPAddr DestinationAddress,
  LPVOID RequestData,
  WORD RequestSize,
  PIP_OPTION_INFORMATION RequestOptions,
  LPVOID ReplyBuffer,
  DWORD ReplySize,
  DWORD Timeout
);

DWORD
IcmpSendEcho2(
  HANDLE IcmpHandle,
  HANDLE Event,
  FARPROC ApcRoutine,
  PVOID ApcContext,
  IPAddr DestinationAddress,
  LPVOID RequestData,
  WORD RequestSize,
  PIP_OPTION_INFORMATION RequestOptions,
  LPVOID ReplyBuffer,
  DWORD ReplySize,
  DWORD Timeout
);

DWORD
SetIpStatistics(
  PMIB_IPSTATS pIpStats
);

DWORD
SetIpTTL(
  UINT nTTL
);

IPアドレス設定関連


DWORD
AddIPAddress(
  IPAddr Address,
  IPMask IpMask,
  DWORD IfIndex,
  PULONG NTEContext,
  PULONG NTEInstance
);

DWORD
DeleteIPAddress(
  ULONG NTEContext
);

DWORD
GetIpAddrTable(
  PMIB_IPADDRTABLE pIpAddrTable,
  PULONG pdwSize,
  BOOL bOrder
);

DWORD
IpReleaseAddress(
  PIP_ADAPTER_INDEX_MAP AdapterInfo
);

DWORD
IpRenewAddress(
  PIP_ADAPTER_INDEX_MAP AdapterInfo
);

ネットワーク設定


DWORD
GetNetworkParams(
  PFIXED_INFO pFixedInfo,
  PULONG pOutBufLen
);

通知


DWORD
NotifyAddrChange(
  PHANDLE Handle,
  LPOVERLAPPED overlapped
);

DWORD
NotifyRouteChange(
  PHANDLE Handle,
  LPOVERLAPPED overlapped
);

経路制御関連


DWORD
CreateIpForwardEntry(
  PMIB_IPFORWARDROW pRoute
);

DWORD
DeleteIpForwardEntry(
  PMIB_IPFORWARDROW pRoute
);

DWORD WINAPI
EnableRouter(
  HANDLE* pHandle,
  OVERLAPPED* pOverlapped
);

DWORD
GetBestInterface(
  IPAddr dwDestAddr,
  PDWORD pdwBestIfIndex
);

DWORD
GetBestRoute(
  DWORD dwDestAddr,
  DWORD dwSourceAddr,
  PMIB_IPFORWARDROW pBestRoute
);

DWORD
GetIpForwardTable(
  PMIB_IPFORWARDTABLE pIpForwardTable,
  PULONG pdwSize,
  BOOL bOrder
);

BOOL
GetRTTAndHopCount(
  IPAddr DestIpAddress,
  PULONG HopCount,
  ULONG MaxHops,
  PULONG RTT
);

DWORD
SetIpForwardEntry(
  PMIB_IPFORWARDROW pRoute
);

DWORD WINAPI
UnenableRouter(
  OVERLAPPED* pOverlapped,
  LPDWORD lpdwEnableCount
);

TCP、UDP関連


DWORD
GetExtendedTcpTable(
  PVOID pTcpTable,
  PDWORD pdwSize,
  BOOL bOrder,
  ULONG ulAf,
  TCP_TABLE_CLASS TableClass,
  ULONG Reserved
);

DWORD
GetExtendedUdpTable(
  PVOID pUdpTable,
  PDWORD pdwSize,
  BOOL bOrder,
  ULONG ulAf,
  UDP_TABLE_CLASS TableClass,
  ULONG Reserved
);

DWORD
GetOwnerModuleFromTcpEntry(
  PMIB_TCPROW_OWNER_MODULE pTcpEntry,
  TCPIP_OWNER_MODULE_INFO_CLASS Class,
  PVOID Buffer,
  PDWORD pdwSize
);

DWORD
GetOwnerModuleFromTcp6Entry(
  PMIB_TCP6ROW_OWNER_MODULE pTcpEntry,
  TCPIP_OWNER_MODULE_INFO_CLASS Class,
  PVOID Buffer,
  PDWORD pdwSize
);

DWORD
GetOwnerModuleFromUdpEntry(
  PMIB_UDPROW_OWNER_MODULE pUdpEntry,
  TCPIP_OWNER_MODULE_INFO_CLASS Class,
  PVOID Buffer,
  PDWORD pdwSize
);

DWORD
GetOwnerModuleFromUdp6Entry(
  PMIB_UDP6ROW_OWNER_MODULE pUdpEntry,
  TCPIP_OWNER_MODULE_INFO_CLASS Class,
  PVOID Buffer,
  PDWORD pdwSize
);

DWORD
GetTcpStatistics(
  PMIB_TCPSTATS pStats
);

DWORD
GetTcpTable(
  PMIB_TCPTABLE pTcpTable,
  PDWORD pdwSize,
  BOOL bOrder
);

DWORD
SetTcpEntry(
  PMIB_TCPROW pTcpRow
);

DWORD
GetUdpStatistics(
  PMIB_UDPSTATS pStats
);

DWORD
GetUdpTable(
  PMIB_UDPTABLE pUdpTable,
  PDWORD pdwSize,
  BOOL bOrder
);

YouTubeチャンネルやってます!