Iphlpapi.h
上传用户:shouhua
上传日期:2014-12-06
资源大小:5685k
文件大小:16k
源码类别:

杀毒

开发平台:

Visual C++

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