Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

562 lines
15 KiB

  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. GetIcmpStatisticsEx(
  149. OUT PMIB_ICMP_EX pStats,
  150. IN DWORD dwFamily
  151. );
  152. DWORD
  153. WINAPI
  154. GetTcpStatistics(
  155. OUT PMIB_TCPSTATS pStats
  156. );
  157. DWORD
  158. WINAPI
  159. GetTcpStatisticsEx(
  160. OUT PMIB_TCPSTATS pStats,
  161. IN DWORD dwFamily
  162. );
  163. DWORD
  164. WINAPI
  165. GetUdpStatistics(
  166. OUT PMIB_UDPSTATS pStats
  167. );
  168. DWORD
  169. WINAPI
  170. GetUdpStatisticsEx(
  171. OUT PMIB_UDPSTATS pStats,
  172. IN DWORD dwFamily
  173. );
  174. //////////////////////////////////////////////////////////////////////////////
  175. // //
  176. // Used to set the ifAdminStatus on an interface. The only fields of the //
  177. // MIB_IFROW that are relevant are the dwIndex (index of the interface //
  178. // whose status needs to be set) and the dwAdminStatus which can be either //
  179. // MIB_IF_ADMIN_STATUS_UP or MIB_IF_ADMIN_STATUS_DOWN //
  180. // //
  181. //////////////////////////////////////////////////////////////////////////////
  182. DWORD
  183. WINAPI
  184. SetIfEntry(
  185. IN PMIB_IFROW pIfRow
  186. );
  187. //////////////////////////////////////////////////////////////////////////////
  188. // //
  189. // Used to create, modify or delete a route. In all cases the //
  190. // dwForwardIfIndex, dwForwardDest, dwForwardMask, dwForwardNextHop and //
  191. // dwForwardPolicy MUST BE SPECIFIED. Currently dwForwardPolicy is unused //
  192. // and MUST BE 0. //
  193. // For a set, the complete MIB_IPFORWARDROW structure must be specified //
  194. // //
  195. //////////////////////////////////////////////////////////////////////////////
  196. DWORD
  197. WINAPI
  198. CreateIpForwardEntry(
  199. IN PMIB_IPFORWARDROW pRoute
  200. );
  201. DWORD
  202. WINAPI
  203. SetIpForwardEntry(
  204. IN PMIB_IPFORWARDROW pRoute
  205. );
  206. DWORD
  207. WINAPI
  208. DeleteIpForwardEntry(
  209. IN PMIB_IPFORWARDROW pRoute
  210. );
  211. //////////////////////////////////////////////////////////////////////////////
  212. // //
  213. // Used to set the ipForwarding to ON or OFF (currently only ON->OFF is //
  214. // allowed) and to set the defaultTTL. If only one of the fields needs to //
  215. // be modified and the other needs to be the same as before the other field //
  216. // needs to be set to MIB_USE_CURRENT_TTL or MIB_USE_CURRENT_FORWARDING as //
  217. // the case may be //
  218. // //
  219. //////////////////////////////////////////////////////////////////////////////
  220. DWORD
  221. WINAPI
  222. SetIpStatistics(
  223. IN PMIB_IPSTATS pIpStats
  224. );
  225. //////////////////////////////////////////////////////////////////////////////
  226. // //
  227. // Used to set the defaultTTL. //
  228. // //
  229. //////////////////////////////////////////////////////////////////////////////
  230. DWORD
  231. WINAPI
  232. SetIpTTL(
  233. UINT nTTL
  234. );
  235. //////////////////////////////////////////////////////////////////////////////
  236. // //
  237. // Used to create, modify or delete an ARP entry. In all cases the dwIndex //
  238. // dwAddr field MUST BE SPECIFIED. //
  239. // For a set, the complete MIB_IPNETROW structure must be specified //
  240. // //
  241. //////////////////////////////////////////////////////////////////////////////
  242. DWORD
  243. WINAPI
  244. CreateIpNetEntry(
  245. IN PMIB_IPNETROW pArpEntry
  246. );
  247. DWORD
  248. WINAPI
  249. SetIpNetEntry(
  250. IN PMIB_IPNETROW pArpEntry
  251. );
  252. DWORD
  253. WINAPI
  254. DeleteIpNetEntry(
  255. IN PMIB_IPNETROW pArpEntry
  256. );
  257. DWORD
  258. WINAPI
  259. FlushIpNetTable(
  260. IN DWORD dwIfIndex
  261. );
  262. //////////////////////////////////////////////////////////////////////////////
  263. // //
  264. // Used to create or delete a Proxy ARP entry. The dwIndex is the index of //
  265. // the interface on which to PARP for the dwAddress. If the interface is //
  266. // of a type that doesnt support ARP, e.g. PPP, then the call will fail //
  267. // //
  268. //////////////////////////////////////////////////////////////////////////////
  269. DWORD
  270. WINAPI
  271. CreateProxyArpEntry(
  272. IN DWORD dwAddress,
  273. IN DWORD dwMask,
  274. IN DWORD dwIfIndex
  275. );
  276. DWORD
  277. WINAPI
  278. DeleteProxyArpEntry(
  279. IN DWORD dwAddress,
  280. IN DWORD dwMask,
  281. IN DWORD dwIfIndex
  282. );
  283. //////////////////////////////////////////////////////////////////////////////
  284. // //
  285. // Used to set the state of a TCP Connection. The only state that it can be //
  286. // set to is MIB_TCP_STATE_DELETE_TCB. The complete MIB_TCPROW structure //
  287. // MUST BE SPECIFIED //
  288. // //
  289. //////////////////////////////////////////////////////////////////////////////
  290. DWORD
  291. WINAPI
  292. SetTcpEntry(
  293. IN PMIB_TCPROW pTcpRow
  294. );
  295. DWORD
  296. WINAPI
  297. GetInterfaceInfo(
  298. IN PIP_INTERFACE_INFO pIfTable,
  299. OUT PULONG dwOutBufLen
  300. );
  301. DWORD
  302. WINAPI
  303. GetUniDirectionalAdapterInfo(OUT PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo,
  304. OUT PULONG dwOutBufLen
  305. );
  306. //////////////////////////////////////////////////////////////////////////////
  307. // //
  308. // Gets the "best" outgoing interface for the specified destination address //
  309. // //
  310. //////////////////////////////////////////////////////////////////////////////
  311. DWORD
  312. WINAPI
  313. GetBestInterface(
  314. IN IPAddr dwDestAddr,
  315. OUT PDWORD pdwBestIfIndex
  316. );
  317. #pragma warning(push)
  318. #pragma warning(disable:4115)
  319. DWORD
  320. WINAPI
  321. GetBestInterfaceEx(
  322. IN struct sockaddr *pDestAddr,
  323. OUT PDWORD pdwBestIfIndex
  324. );
  325. #pragma warning(pop)
  326. //////////////////////////////////////////////////////////////////////////////
  327. // //
  328. // Gets the best (longest matching prefix) route for the given destination //
  329. // If the source address is also specified (i.e. is not 0x00000000), and //
  330. // there are multiple "best" routes to the given destination, the returned //
  331. // route will be one that goes out over the interface which has an address //
  332. // that matches the source address //
  333. // //
  334. //////////////////////////////////////////////////////////////////////////////
  335. DWORD
  336. WINAPI
  337. GetBestRoute(
  338. IN DWORD dwDestAddr,
  339. IN DWORD dwSourceAddr, OPTIONAL
  340. OUT PMIB_IPFORWARDROW pBestRoute
  341. );
  342. DWORD
  343. WINAPI
  344. NotifyAddrChange(
  345. OUT PHANDLE Handle,
  346. IN LPOVERLAPPED overlapped
  347. );
  348. DWORD
  349. WINAPI
  350. NotifyRouteChange(
  351. OUT PHANDLE Handle,
  352. IN LPOVERLAPPED overlapped
  353. );
  354. DWORD
  355. WINAPI
  356. GetAdapterIndex(
  357. IN LPWSTR AdapterName,
  358. OUT PULONG IfIndex
  359. );
  360. DWORD
  361. WINAPI
  362. AddIPAddress(
  363. IPAddr Address,
  364. IPMask IpMask,
  365. DWORD IfIndex,
  366. PULONG NTEContext,
  367. PULONG NTEInstance
  368. );
  369. DWORD
  370. WINAPI
  371. DeleteIPAddress(
  372. ULONG NTEContext
  373. );
  374. DWORD
  375. WINAPI
  376. GetNetworkParams(
  377. PFIXED_INFO pFixedInfo, PULONG pOutBufLen
  378. );
  379. DWORD
  380. WINAPI
  381. GetAdaptersInfo(
  382. PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen
  383. );
  384. #ifdef _WINSOCK2API_
  385. //
  386. // The following functions require Winsock2.
  387. //
  388. DWORD
  389. WINAPI
  390. GetAdaptersAddresses(
  391. IN ULONG Family,
  392. IN DWORD Flags,
  393. IN PVOID Reserved,
  394. OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses,
  395. IN OUT PULONG pOutBufLen
  396. );
  397. #endif
  398. DWORD
  399. WINAPI
  400. GetPerAdapterInfo(
  401. ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen
  402. );
  403. DWORD
  404. WINAPI
  405. IpReleaseAddress(
  406. PIP_ADAPTER_INDEX_MAP AdapterInfo
  407. );
  408. DWORD
  409. WINAPI
  410. IpRenewAddress(
  411. PIP_ADAPTER_INDEX_MAP AdapterInfo
  412. );
  413. DWORD
  414. WINAPI
  415. SendARP(
  416. IPAddr DestIP,
  417. IPAddr SrcIP,
  418. PULONG pMacAddr,
  419. PULONG PhyAddrLen
  420. );
  421. BOOL
  422. WINAPI
  423. GetRTTAndHopCount(
  424. IPAddr DestIpAddress,
  425. PULONG HopCount,
  426. ULONG MaxHops,
  427. PULONG RTT
  428. );
  429. DWORD
  430. WINAPI
  431. GetFriendlyIfIndex(
  432. DWORD IfIndex
  433. );
  434. DWORD
  435. WINAPI
  436. EnableRouter(
  437. HANDLE* pHandle,
  438. OVERLAPPED* pOverlapped
  439. );
  440. DWORD
  441. WINAPI
  442. UnenableRouter(
  443. OVERLAPPED* pOverlapped,
  444. LPDWORD lpdwEnableCount OPTIONAL
  445. );
  446. DWORD
  447. WINAPI
  448. DisableMediaSense(
  449. HANDLE *pHandle,
  450. OVERLAPPED *pOverLapped
  451. );
  452. DWORD
  453. WINAPI
  454. RestoreMediaSense(
  455. OVERLAPPED* pOverlapped,
  456. LPDWORD lpdwEnableCount OPTIONAL
  457. );
  458. DWORD
  459. WINAPI
  460. GetIpErrorString(
  461. IN IP_STATUS ErrorCode,
  462. OUT PWCHAR Buffer,
  463. IN OUT PDWORD Size
  464. );
  465. #ifdef __cplusplus
  466. }
  467. #endif
  468. #endif //__IPHLPAPI_H__