iphlpapi.h
上传用户:zhuzhu0204
上传日期:2020-07-13
资源大小:13165k
文件大小:16k
开发平台:

Visual C++

  1. //
  2. // Copyright (c) Microsoft Corporation.  All rights reserved.
  3. //
  4. //
  5. // Use of this source code is subject to the terms of the Microsoft end-user
  6. // license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
  7. // If you did not accept the terms of the EULA, you are not authorized to use
  8. // this source code. For a copy of the EULA, please see the LICENSE.RTF on your
  9. // install media.
  10. //
  11. /*++
  12. Module Name:
  13.     publicsdkinciphlpapi.h
  14. Abstract:
  15.     Header file for functions to interact with the IP Stack for MIB-II and
  16.     related functionality
  17. --*/
  18. #ifndef __IPHLPAPI_H__
  19. #define __IPHLPAPI_H__
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. //////////////////////////////////////////////////////////////////////////////
  27. //                                                                          //
  28. // IPRTRMIB.H has the definitions of the strcutures used to set and get     //
  29. // information                                                              //
  30. //                                                                          //
  31. //////////////////////////////////////////////////////////////////////////////
  32. #include <iprtrmib.h>
  33. #include "ipexport.h"
  34. #include "iptypes.h"
  35. //
  36. // dwForwardProto types
  37. //
  38. #define PROTO_IP_OTHER         1
  39. #define PROTO_IP_LOCAL         2
  40. #define PROTO_IP_NETMGMT       3
  41. #define PROTO_IP_ICMP          4
  42. //////////////////////////////////////////////////////////////////////////////
  43. //                                                                          //
  44. // The GetXXXTable APIs take a buffer and a size of buffer.  If the buffer  //
  45. // is not large enough, the APIs return ERROR_INSUFFICIENT_BUFFER  and      //
  46. // *pdwSize is the required buffer size                                     //
  47. // The bOrder is a BOOLEAN, which if TRUE sorts the table according to      //
  48. // MIB-II (RFC XXXX)                                                        //
  49. //                                                                          //
  50. //////////////////////////////////////////////////////////////////////////////
  51. //////////////////////////////////////////////////////////////////////////////
  52. //                                                                          //
  53. // Retrieves the number of interfaces in the system. These include LAN and  //
  54. // WAN interfaces                                                           //
  55. //                                                                          //
  56. //////////////////////////////////////////////////////////////////////////////
  57. DWORD
  58. WINAPI
  59. GetNumberOfInterfaces(
  60.     OUT PDWORD  pdwNumIf
  61.     );
  62. //////////////////////////////////////////////////////////////////////////////
  63. //                                                                          //
  64. // Gets the MIB-II ifEntry                                                  //
  65. // The dwIndex field of the MIB_IFROW should be set to the index of the     //
  66. // interface being queried                                                  //
  67. //                                                                          //
  68. //////////////////////////////////////////////////////////////////////////////
  69. DWORD
  70. WINAPI
  71. GetIfEntry(
  72.     IN OUT PMIB_IFROW   pIfRow
  73.     );
  74. //////////////////////////////////////////////////////////////////////////////
  75. //                                                                          //
  76. // Gets the MIB-II IfTable                                                  //
  77. //                                                                          //
  78. //////////////////////////////////////////////////////////////////////////////
  79. DWORD
  80. WINAPI
  81. GetIfTable(
  82.     OUT    PMIB_IFTABLE pIfTable,
  83.     IN OUT PULONG       pdwSize,
  84.     IN     BOOL         bOrder
  85.     );
  86. //////////////////////////////////////////////////////////////////////////////
  87. //                                                                          //
  88. // Gets the Interface to IP Address mapping                                 //
  89. //                                                                          //
  90. //////////////////////////////////////////////////////////////////////////////
  91. DWORD
  92. WINAPI
  93. GetIpAddrTable(
  94.     OUT    PMIB_IPADDRTABLE pIpAddrTable,
  95.     IN OUT PULONG           pdwSize,
  96.     IN     BOOL             bOrder
  97.     );
  98. //////////////////////////////////////////////////////////////////////////////
  99. //                                                                          //
  100. // Gets the current IP Address to Physical Address (ARP) mapping            //
  101. //                                                                          //
  102. //////////////////////////////////////////////////////////////////////////////
  103. DWORD
  104. WINAPI
  105. GetIpNetTable(
  106.     OUT    PMIB_IPNETTABLE pIpNetTable,
  107.     IN OUT PULONG          pdwSize,
  108.     IN     BOOL            bOrder
  109.     );
  110. //////////////////////////////////////////////////////////////////////////////
  111. //                                                                          //
  112. // Gets the IP Routing Table  (RFX XXXX)                                    //
  113. //                                                                          //
  114. //////////////////////////////////////////////////////////////////////////////
  115. DWORD
  116. WINAPI
  117. GetIpForwardTable(
  118.     OUT    PMIB_IPFORWARDTABLE pIpForwardTable,
  119.     IN OUT PULONG              pdwSize,
  120.     IN     BOOL                bOrder
  121.     );
  122. //////////////////////////////////////////////////////////////////////////////
  123. //                                                                          //
  124. // Gets TCP Connection/UDP Listener Table                                   //
  125. //                                                                          //
  126. //////////////////////////////////////////////////////////////////////////////
  127. DWORD
  128. WINAPI
  129. GetTcpTable(
  130.     OUT    PMIB_TCPTABLE pTcpTable,
  131.     IN OUT PDWORD        pdwSize,
  132.     IN     BOOL          bOrder
  133.     );
  134. DWORD
  135. WINAPI
  136. GetUdpTable(
  137.     OUT    PMIB_UDPTABLE pUdpTable,
  138.     IN OUT PDWORD        pdwSize,
  139.     IN     BOOL          bOrder
  140.     );
  141. //////////////////////////////////////////////////////////////////////////////
  142. //                                                                          //
  143. // Gets IP/ICMP/TCP/UDP Statistics                                          //
  144. //                                                                          //
  145. //////////////////////////////////////////////////////////////////////////////
  146. DWORD
  147. WINAPI
  148. GetIpStatistics(
  149.     OUT  PMIB_IPSTATS   pStats
  150.     );
  151. DWORD
  152. WINAPI
  153. GetIpStatisticsEx(
  154.     OUT  PMIB_IPSTATS   pStats,
  155.     IN   DWORD          dwFamily
  156.     );
  157. DWORD
  158. WINAPI
  159. GetIcmpStatistics(
  160.     OUT PMIB_ICMP   pStats
  161.     );
  162. /*
  163. DWORD
  164. WINAPI
  165. GetIcmpStatisticsEx(
  166.     OUT PMIB_ICMP_EX    pStats,
  167.     IN  DWORD           dwFamily
  168.     );
  169. */
  170. DWORD
  171. WINAPI
  172. GetTcpStatistics(
  173.     OUT PMIB_TCPSTATS   pStats
  174.     );
  175. DWORD
  176. WINAPI
  177. GetTcpStatisticsEx(
  178.     OUT PMIB_TCPSTATS   pStats,
  179.     IN  DWORD           dwFamily
  180.     );
  181. DWORD
  182. WINAPI
  183. GetUdpStatistics(
  184.     OUT PMIB_UDPSTATS   pStats
  185.     );
  186. DWORD
  187. WINAPI
  188. GetUdpStatisticsEx(
  189.     OUT PMIB_UDPSTATS   pStats,
  190.     IN  DWORD           dwFamily
  191.     );
  192. //////////////////////////////////////////////////////////////////////////////
  193. //                                                                          //
  194. // Used to set the ifAdminStatus on an interface.  The only fields of the   //
  195. // MIB_IFROW that are relevant are the dwIndex (index of the interface      //
  196. // whose status needs to be set) and the dwAdminStatus which can be either  //
  197. // MIB_IF_ADMIN_STATUS_UP or MIB_IF_ADMIN_STATUS_DOWN                       //
  198. //                                                                          //
  199. //////////////////////////////////////////////////////////////////////////////
  200. DWORD
  201. WINAPI
  202. SetIfEntry(
  203.     IN PMIB_IFROW pIfRow
  204.     );
  205. //////////////////////////////////////////////////////////////////////////////
  206. //                                                                          //
  207. // Used to create, modify or delete a route.  In all cases the              //
  208. // dwForwardIfIndex, dwForwardDest, dwForwardMask, dwForwardNextHop and     //
  209. // dwForwardPolicy MUST BE SPECIFIED. Currently dwForwardPolicy is unused   //
  210. // and MUST BE 0.                                                           //
  211. // For a set, the complete MIB_IPFORWARDROW structure must be specified     //
  212. //                                                                          //
  213. //////////////////////////////////////////////////////////////////////////////
  214. DWORD
  215. WINAPI
  216. CreateIpForwardEntry(
  217.     IN PMIB_IPFORWARDROW pRoute
  218.     );
  219. DWORD
  220. WINAPI
  221. SetIpForwardEntry(
  222.     IN PMIB_IPFORWARDROW pRoute
  223.     );
  224. DWORD
  225. WINAPI
  226. DeleteIpForwardEntry(
  227.     IN PMIB_IPFORWARDROW pRoute
  228.     );
  229. //////////////////////////////////////////////////////////////////////////////
  230. //                                                                          //
  231. // Used to set the ipForwarding to ON or OFF (currently only ON->OFF is     //
  232. // allowed) and to set the defaultTTL.  If only one of the fields needs to  //
  233. // be modified and the other needs to be the same as before the other field //
  234. // needs to be set to MIB_USE_CURRENT_TTL or MIB_USE_CURRENT_FORWARDING as  //
  235. // the case may be                                                          //
  236. //                                                                          //
  237. //////////////////////////////////////////////////////////////////////////////
  238. DWORD
  239. WINAPI
  240. SetIpStatistics(
  241.     IN PMIB_IPSTATS pIpStats
  242.     );
  243. //////////////////////////////////////////////////////////////////////////////
  244. //                                                                          //
  245. // Used to set the defaultTTL.                                              //
  246. //                                                                          //
  247. //////////////////////////////////////////////////////////////////////////////
  248. DWORD
  249. WINAPI
  250. SetIpTTL(
  251.     UINT nTTL
  252.     );
  253. //////////////////////////////////////////////////////////////////////////////
  254. //                                                                          //
  255. // Used to create, modify or delete an ARP entry.  In all cases the dwIndex //
  256. // dwAddr field MUST BE SPECIFIED.                                          //
  257. // For a set, the complete MIB_IPNETROW structure must be specified         //
  258. //                                                                          //
  259. //////////////////////////////////////////////////////////////////////////////
  260. DWORD
  261. WINAPI
  262. CreateIpNetEntry(
  263.     IN PMIB_IPNETROW    pArpEntry
  264.     );
  265. DWORD
  266. WINAPI
  267. SetIpNetEntry(
  268.     IN PMIB_IPNETROW    pArpEntry
  269.     );
  270. DWORD
  271. WINAPI
  272. DeleteIpNetEntry(
  273.     IN PMIB_IPNETROW    pArpEntry
  274.     );
  275. DWORD
  276. WINAPI
  277. FlushIpNetTable(
  278.     IN DWORD   dwIfIndex
  279.     );
  280. //////////////////////////////////////////////////////////////////////////////
  281. //                                                                          //
  282. // Used to create or delete a Proxy ARP entry. The dwIndex is the index of  //
  283. // the interface on which to PARP for the dwAddress.  If the interface is   //
  284. // of a type that doesnt support ARP, e.g. PPP, then the call will fail     //
  285. //                                                                          //
  286. //////////////////////////////////////////////////////////////////////////////
  287. DWORD
  288. WINAPI
  289. CreateProxyArpEntry(
  290.     IN  DWORD   dwAddress,
  291.     IN  DWORD   dwMask,
  292.     IN  DWORD   dwIfIndex
  293.     );
  294. DWORD
  295. WINAPI
  296. DeleteProxyArpEntry(
  297.     IN  DWORD   dwAddress,
  298.     IN  DWORD   dwMask,
  299.     IN  DWORD   dwIfIndex
  300.     );
  301. //////////////////////////////////////////////////////////////////////////////
  302. //                                                                          //
  303. // Used to set the state of a TCP Connection. The only state that it can be //
  304. // set to is MIB_TCP_STATE_DELETE_TCB.  The complete MIB_TCPROW structure   //
  305. // MUST BE SPECIFIED                                                        //
  306. //                                                                          //
  307. //////////////////////////////////////////////////////////////////////////////
  308. DWORD
  309. WINAPI
  310. SetTcpEntry(
  311.     IN PMIB_TCPROW pTcpRow
  312.     );
  313. DWORD
  314. WINAPI
  315. GetInterfaceInfo(
  316.     IN PIP_INTERFACE_INFO pIfTable,
  317.     OUT PULONG            dwOutBufLen
  318.     );
  319. DWORD
  320. WINAPI
  321. GetUniDirectionalAdapterInfo(OUT PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo,
  322.                  OUT PULONG dwOutBufLen
  323.                  );
  324. //////////////////////////////////////////////////////////////////////////////
  325. //                                                                          //
  326. // Gets the "best" outgoing interface for the specified destination address //
  327. //                                                                          //
  328. //////////////////////////////////////////////////////////////////////////////
  329. DWORD
  330. WINAPI
  331. GetBestInterface(
  332.     IN  IPAddr  dwDestAddr,
  333.     OUT PDWORD  pdwBestIfIndex
  334.     );
  335. #pragma warning(push)
  336. #pragma warning(disable:4115)
  337. DWORD
  338. WINAPI
  339. GetBestInterfaceEx(
  340.     IN  struct sockaddr *pDestAddr,
  341.     OUT PDWORD           pdwBestIfIndex
  342.     );
  343. #pragma warning(pop)
  344. //////////////////////////////////////////////////////////////////////////////
  345. //                                                                          //
  346. // Gets the best (longest matching prefix) route for the given destination  //
  347. // If the source address is also specified (i.e. is not 0x00000000), and    //
  348. // there are multiple "best" routes to the given destination, the returned  //
  349. // route will be one that goes out over the interface which has an address  //
  350. // that matches the source address                                          //
  351. //                                                                          //
  352. //////////////////////////////////////////////////////////////////////////////
  353. DWORD
  354. WINAPI
  355. GetBestRoute(
  356.     IN  DWORD               dwDestAddr,
  357.     IN  DWORD               dwSourceAddr, OPTIONAL
  358.     OUT PMIB_IPFORWARDROW   pBestRoute
  359.     );
  360. DWORD
  361. WINAPI
  362. NotifyAddrChange(
  363.     OUT PHANDLE      Handle,
  364.     IN  LPOVERLAPPED overlapped
  365.     );
  366. DWORD
  367. WINAPI
  368. NotifyRouteChange(
  369.     OUT PHANDLE      Handle,
  370.     IN  LPOVERLAPPED overlapped
  371.     );
  372. DWORD
  373. WINAPI
  374. GetAdapterIndex(
  375.     IN LPWSTR  AdapterName,
  376.     OUT PULONG IfIndex
  377.     );
  378. DWORD
  379. WINAPI
  380. AddIPAddress(
  381.     IPAddr  Address,
  382.     IPMask  IpMask,
  383.     DWORD   IfIndex,
  384.     PULONG  NTEContext,
  385.     PULONG  NTEInstance
  386.     );
  387. DWORD
  388. WINAPI
  389. DeleteIPAddress(
  390.     ULONG NTEContext
  391.     );
  392. DWORD
  393. WINAPI
  394. GetNetworkParams(
  395.     PFIXED_INFO pFixedInfo, PULONG pOutBufLen
  396.     );
  397. DWORD
  398. WINAPI
  399. GetAdaptersInfo(
  400.     PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen
  401.     );
  402. #ifdef _WINSOCK2API_
  403. //
  404. // The following functions require Winsock2.
  405. //
  406. DWORD
  407. WINAPI
  408. GetAdaptersAddresses(
  409.     IN     ULONG                 Family,
  410.     IN     DWORD                 Flags,
  411.     IN     PVOID                 Reserved,
  412.     OUT    PIP_ADAPTER_ADDRESSES pAdapterAddresses, 
  413.     IN OUT PULONG                pOutBufLen
  414.     );
  415. #endif
  416. DWORD
  417. WINAPI
  418. GetPerAdapterInfo(
  419.     ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen
  420.     );
  421. DWORD
  422. WINAPI
  423. IpReleaseAddress(
  424.     PIP_ADAPTER_INDEX_MAP  AdapterInfo
  425.     );
  426. DWORD
  427. WINAPI
  428. IpRenewAddress(
  429.     PIP_ADAPTER_INDEX_MAP  AdapterInfo
  430.     );
  431. DWORD
  432. WINAPI
  433. SendARP(
  434.     IPAddr DestIP,
  435.     IPAddr SrcIP,
  436.     PULONG pMacAddr,
  437.     PULONG  PhyAddrLen
  438.     );
  439. BOOL
  440. WINAPI
  441. GetRTTAndHopCount(
  442.     IPAddr DestIpAddress,
  443.     PULONG HopCount,
  444.     ULONG  MaxHops,
  445.     PULONG RTT
  446.     );
  447. DWORD
  448. WINAPI
  449. GetFriendlyIfIndex(
  450.     DWORD IfIndex
  451.     );
  452. DWORD
  453. WINAPI
  454. EnableRouter(
  455.     HANDLE* pHandle,
  456.     OVERLAPPED* pOverlapped
  457.     );
  458. DWORD
  459. WINAPI
  460. UnenableRouter(
  461.     OVERLAPPED* pOverlapped,
  462.     LPDWORD lpdwEnableCount OPTIONAL
  463.     );
  464. #ifndef UNDER_CE
  465. DWORD
  466. WINAPI
  467. DisableMediaSense(
  468.     HANDLE *pHandle,
  469.     OVERLAPPED *pOverLapped
  470.     );
  471. DWORD
  472. WINAPI
  473. RestoreMediaSense(
  474.     OVERLAPPED* pOverlapped,
  475.     LPDWORD lpdwEnableCount OPTIONAL
  476.     );
  477. #endif
  478. DWORD
  479. WINAPI
  480. GetIpErrorString(
  481.     IN IP_STATUS ErrorCode,
  482.     OUT PWCHAR Buffer,
  483.     IN OUT PDWORD Size
  484.     );
  485. #ifdef __cplusplus
  486. }
  487. #endif
  488. #endif //__IPHLPAPI_H__