Leaked source code of windows server 2003
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.

588 lines
16 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. #ifndef NHPALLOCATEANDGETINTERFACEINFOFROMSTACK_DEFINED
  307. #define NHPALLOCATEANDGETINTERFACEINFOFROMSTACK_DEFINED
  308. DWORD
  309. WINAPI
  310. NhpAllocateAndGetInterfaceInfoFromStack(
  311. OUT IP_INTERFACE_NAME_INFO **ppTable,
  312. OUT PDWORD pdwCount,
  313. IN BOOL bOrder,
  314. IN HANDLE hHeap,
  315. IN DWORD dwFlags
  316. );
  317. #endif
  318. //////////////////////////////////////////////////////////////////////////////
  319. // //
  320. // Gets the "best" outgoing interface for the specified destination address //
  321. // //
  322. //////////////////////////////////////////////////////////////////////////////
  323. DWORD
  324. WINAPI
  325. GetBestInterface(
  326. IN IPAddr dwDestAddr,
  327. OUT PDWORD pdwBestIfIndex
  328. );
  329. #pragma warning(push)
  330. #pragma warning(disable:4115)
  331. DWORD
  332. WINAPI
  333. GetBestInterfaceEx(
  334. IN struct sockaddr *pDestAddr,
  335. OUT PDWORD pdwBestIfIndex
  336. );
  337. #pragma warning(pop)
  338. //////////////////////////////////////////////////////////////////////////////
  339. // //
  340. // Gets the best (longest matching prefix) route for the given destination //
  341. // If the source address is also specified (i.e. is not 0x00000000), and //
  342. // there are multiple "best" routes to the given destination, the returned //
  343. // route will be one that goes out over the interface which has an address //
  344. // that matches the source address //
  345. // //
  346. //////////////////////////////////////////////////////////////////////////////
  347. DWORD
  348. WINAPI
  349. GetBestRoute(
  350. IN DWORD dwDestAddr,
  351. IN DWORD dwSourceAddr, OPTIONAL
  352. OUT PMIB_IPFORWARDROW pBestRoute
  353. );
  354. DWORD
  355. WINAPI
  356. NotifyAddrChange(
  357. OUT PHANDLE Handle,
  358. IN LPOVERLAPPED overlapped
  359. );
  360. DWORD
  361. WINAPI
  362. NotifyRouteChange(
  363. OUT PHANDLE Handle,
  364. IN LPOVERLAPPED overlapped
  365. );
  366. BOOL
  367. WINAPI
  368. CancelIPChangeNotify(
  369. IN LPOVERLAPPED notifyOverlapped
  370. );
  371. DWORD
  372. WINAPI
  373. GetAdapterIndex(
  374. IN LPWSTR AdapterName,
  375. OUT PULONG IfIndex
  376. );
  377. DWORD
  378. WINAPI
  379. AddIPAddress(
  380. IPAddr Address,
  381. IPMask IpMask,
  382. DWORD IfIndex,
  383. PULONG NTEContext,
  384. PULONG NTEInstance
  385. );
  386. DWORD
  387. WINAPI
  388. DeleteIPAddress(
  389. ULONG NTEContext
  390. );
  391. DWORD
  392. WINAPI
  393. GetNetworkParams(
  394. PFIXED_INFO pFixedInfo, PULONG pOutBufLen
  395. );
  396. DWORD
  397. WINAPI
  398. GetAdaptersInfo(
  399. PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen
  400. );
  401. PIP_ADAPTER_ORDER_MAP
  402. WINAPI
  403. GetAdapterOrderMap(
  404. VOID
  405. );
  406. #ifdef _WINSOCK2API_
  407. //
  408. // The following functions require Winsock2.
  409. //
  410. DWORD
  411. WINAPI
  412. GetAdaptersAddresses(
  413. IN ULONG Family,
  414. IN DWORD Flags,
  415. IN PVOID Reserved,
  416. OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses,
  417. IN OUT PULONG pOutBufLen
  418. );
  419. #endif
  420. DWORD
  421. WINAPI
  422. GetPerAdapterInfo(
  423. ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen
  424. );
  425. DWORD
  426. WINAPI
  427. IpReleaseAddress(
  428. PIP_ADAPTER_INDEX_MAP AdapterInfo
  429. );
  430. DWORD
  431. WINAPI
  432. IpRenewAddress(
  433. PIP_ADAPTER_INDEX_MAP AdapterInfo
  434. );
  435. DWORD
  436. WINAPI
  437. SendARP(
  438. IPAddr DestIP,
  439. IPAddr SrcIP,
  440. PULONG pMacAddr,
  441. PULONG PhyAddrLen
  442. );
  443. BOOL
  444. WINAPI
  445. GetRTTAndHopCount(
  446. IPAddr DestIpAddress,
  447. PULONG HopCount,
  448. ULONG MaxHops,
  449. PULONG RTT
  450. );
  451. DWORD
  452. WINAPI
  453. GetFriendlyIfIndex(
  454. DWORD IfIndex
  455. );
  456. DWORD
  457. WINAPI
  458. EnableRouter(
  459. HANDLE* pHandle,
  460. OVERLAPPED* pOverlapped
  461. );
  462. DWORD
  463. WINAPI
  464. UnenableRouter(
  465. OVERLAPPED* pOverlapped,
  466. LPDWORD lpdwEnableCount OPTIONAL
  467. );
  468. DWORD
  469. WINAPI
  470. DisableMediaSense(
  471. HANDLE *pHandle,
  472. OVERLAPPED *pOverLapped
  473. );
  474. DWORD
  475. WINAPI
  476. RestoreMediaSense(
  477. OVERLAPPED* pOverlapped,
  478. LPDWORD lpdwEnableCount OPTIONAL
  479. );
  480. DWORD
  481. WINAPI
  482. GetIpErrorString(
  483. IN IP_STATUS ErrorCode,
  484. OUT PWCHAR Buffer,
  485. IN OUT PDWORD Size
  486. );
  487. #ifdef __cplusplus
  488. }
  489. #endif
  490. #endif //__IPHLPAPI_H__