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.

477 lines
15 KiB

  1. /*
  2. *============================================================================
  3. * Copyright (c) 1994-95, Microsoft Corp.
  4. *
  5. * File: routetab.h
  6. *
  7. * Contains declarations for the Routing Table functions
  8. * The functions declared here and exported by the Routing Table DLL
  9. * are the following:
  10. *
  11. * AddRoute
  12. * DeleteRoute
  13. * GetRouteTable
  14. * FreeRouteTable
  15. * GetInterfaceTable
  16. * FreeInterfaceTable
  17. * SetAddrChangeNotifyEvent
  18. *
  19. * The structures required by these functions are also declared here:
  20. *
  21. * IPROUTING_ENTRY
  22. * IPINTERFACE_ENTRY
  23. *
  24. * Routes can be added to and deleted from the IP routing table by other
  25. * means. Therefore, it is necessary for any protocol using these functions
  26. * to reload the routing tables periodically.
  27. *============================================================================
  28. */
  29. #ifndef _ROUTETAB_H_
  30. #define _ROUTETAB_H_
  31. /*
  32. *---------------------------------------------------------------
  33. * Any one of these values can be passed as the route entry type
  34. * when calling the AddRoute() function.
  35. *---------------------------------------------------------------
  36. */
  37. #define IRE_TYPE_OTHER 1
  38. #define IRE_TYPE_INVALID 2
  39. #define IRE_TYPE_DIRECT 3
  40. #define IRE_TYPE_INDIRECT 4
  41. /*
  42. *-------------------------------------------------------------
  43. * Any one of these values can be passed as the protocol type
  44. * when calling AddRoute() or DeleteRoute()
  45. *-------------------------------------------------------------
  46. */
  47. #define IRE_PROTO_OTHER 1
  48. #define IRE_PROTO_LOCAL 2
  49. #define IRE_PROTO_NETMGMT 3
  50. #define IRE_PROTO_ICMP 4
  51. #define IRE_PROTO_EGP 5
  52. #define IRE_PROTO_GGP 6
  53. #define IRE_PROTO_HELLO 7
  54. #define IRE_PROTO_RIP 8
  55. #define IRE_PROTO_IS_IS 9
  56. #define IRE_PROTO_ES_IS 10
  57. #define IRE_PROTO_CISCO 11
  58. #define IRE_PROTO_BBN 12
  59. #define IRE_PROTO_OSPF 13
  60. #define IRE_PROTO_BGP 14
  61. /*
  62. *-------------------------------------------------------------
  63. * This value may be passed as the metric to functions which
  64. * require a metric, in cases where the metric is irrelevant
  65. *-------------------------------------------------------------
  66. */
  67. #define IRE_METRIC_UNUSED 0xffffffff
  68. /*
  69. *-------------------------------------------------------------
  70. * These constants are used in the definition of IF_ENTRY
  71. *-------------------------------------------------------------
  72. */
  73. #define MAX_PHYSADDR_SIZE 8
  74. #define MAX_IFDESCR_LEN 256
  75. /*
  76. *-------------------------------------------------------------
  77. * Any of these values may appear in the if_type field of
  78. * the IF_ENTRY structure
  79. *-------------------------------------------------------------
  80. */
  81. #define IF_TYPE_OTHER 1
  82. #define IF_TYPE_ETHERNET 6
  83. #define IF_TYPE_TOKENRING 9
  84. #define IF_TYPE_FDDI 15
  85. #define IF_TYPE_PPP 23
  86. #define IF_TYPE_LOOPBACK 24
  87. #define IF_TYPE_SLIP 28
  88. #define IF_STATUS_UP 1
  89. #define IF_STATUS_DOWN 2
  90. #define IF_STATUS_TESTING 3
  91. /*
  92. *-------------------------------------------------------------
  93. * This structure is used by GetIfTable() to return
  94. * information about the physical network interfaces
  95. * on the system
  96. *-------------------------------------------------------------
  97. */
  98. typedef struct _IF_ENTRY {
  99. DWORD ife_index;
  100. DWORD ife_type;
  101. DWORD ife_mtu;
  102. DWORD ife_speed;
  103. DWORD ife_physaddrlen;
  104. BYTE ife_physaddr[MAX_PHYSADDR_SIZE];
  105. DWORD ife_adminstatus;
  106. DWORD ife_operstatus;
  107. DWORD ife_lastchange;
  108. DWORD ife_inoctets;
  109. DWORD ife_inucastpkts;
  110. DWORD ife_innucastpkts;
  111. DWORD ife_indiscards;
  112. DWORD ife_inerrors;
  113. DWORD ife_inunknownprotos;
  114. DWORD ife_outoctets;
  115. DWORD ife_outucastpkts;
  116. DWORD ife_outnucastpkts;
  117. DWORD ife_outdiscards;
  118. DWORD ife_outerrors;
  119. DWORD ife_outqlen;
  120. DWORD ife_descrlen;
  121. BYTE ife_descr[MAX_IFDESCR_LEN];
  122. } IF_ENTRY, *LPIF_ENTRY;
  123. /*
  124. *-------------------------------------------------------------
  125. * This structure is used by GetIPAddressTable() to return
  126. * information about logical IP interfaces on the system
  127. *-------------------------------------------------------------
  128. */
  129. typedef struct _IPADDRESS_ENTRY {
  130. DWORD iae_address; /* IP address of this entry */
  131. DWORD iae_index; /* index of interface for this entry */
  132. DWORD iae_netmask; /* subnet mask of this entry */
  133. DWORD iae_bcastaddr;
  134. DWORD iae_reasmsize;
  135. USHORT iae_context;
  136. USHORT iae_pad;
  137. } IPADDRESS_ENTRY, *LPIPADDRESS_ENTRY;
  138. /*
  139. *-------------------------------------------------------------
  140. * This structure is used by GetRouteTable() to return
  141. * information about routing table entries.
  142. *-------------------------------------------------------------
  143. */
  144. typedef struct _IPROUTE_ENTRY {
  145. DWORD ire_dest; /* destination IP addr, network order */
  146. DWORD ire_index; /* route entry index */
  147. DWORD ire_metric1; /* destination metric, host order */
  148. DWORD ire_metric2; /* unused */
  149. DWORD ire_metric3; /* unused */
  150. DWORD ire_metric4; /* unused */
  151. DWORD ire_nexthop; /* next hop IP addr, network order */
  152. DWORD ire_type; /* routing type for this entry */
  153. DWORD ire_proto; /* routing protocol for this entry */
  154. DWORD ire_age; /* age of this entry */
  155. DWORD ire_mask; /* network mask, network order */
  156. DWORD ire_metric5; /* unused */
  157. #ifndef CHICAGO
  158. DWORD ire_context; /* unused */
  159. #endif
  160. } IPROUTE_ENTRY, *LPIPROUTE_ENTRY;
  161. /*
  162. *------------------------------------------------------------------
  163. * Function: GetIfEntry
  164. *
  165. * Parameters:
  166. * DWORD dwIfIndex index of interface to retrieve
  167. * LPIF_ENTRY
  168. * lpIfEntry pointer to an IF_ENTRY
  169. * which receives the interface entry
  170. *
  171. * This function fills the supplied interface entry pointer with
  172. * with the interface information corresponding to the physical network
  173. * interface in the system with index dwIfIndex.
  174. *
  175. * It returns 0 if successful and non-zero otherwise
  176. *------------------------------------------------------------------
  177. */
  178. DWORD
  179. APIENTRY
  180. GetIfEntry(
  181. IN DWORD dwIfIndex,
  182. OUT LPIF_ENTRY lpIfEntry
  183. );
  184. /*
  185. *------------------------------------------------------------------
  186. * Function: GetIPAddressTable
  187. *
  188. * Parameters:
  189. * LPIPADDRESS_ENTRY
  190. * *lplpAddrTable pointer to an LPIPADDRESS_ENTRY
  191. * which receives the IP address table
  192. * LPDWORD lpdwAddrCount pointer to a DWORD which receives
  193. * the number of addresses in the table
  194. *
  195. * This function allocates and fills in an array of address entry
  196. * structures corresponding to the logical IP interfaces in
  197. * the system. It also stores the number of entries in the array
  198. * in the DWORD pointed to by lpdwAddrCount.
  199. *
  200. * Call FreeIPAddressTable to free the memory allocated for the
  201. * address table.
  202. *
  203. * If the function fails, it sets *lpdwAddrCount to zero and
  204. * *lplpAddrTable to NULL.
  205. *
  206. * It returns 0 if successful and non-zero otherwise
  207. *------------------------------------------------------------------
  208. */
  209. DWORD
  210. APIENTRY
  211. GetIPAddressTable(
  212. OUT LPIPADDRESS_ENTRY *lplpAddrTable,
  213. OUT LPDWORD lpdwAddrCount
  214. );
  215. /*
  216. *------------------------------------------------------------------
  217. * Function: FreeIPAddressTable
  218. *
  219. * Parameters:
  220. * LPIPADDRESS_ENTRY
  221. * lpAddrTable the address table to be freed.
  222. *
  223. * This function frees the memory allocated for an address table.
  224. * It returns 0 if successful and non-zero otherwise.
  225. *------------------------------------------------------------------
  226. */
  227. DWORD
  228. APIENTRY
  229. FreeIPAddressTable(
  230. IN LPIPADDRESS_ENTRY lpAddrTable
  231. );
  232. /*
  233. *------------------------------------------------------------------
  234. * Function: GetRouteTable
  235. *
  236. * Parameters:
  237. * LPIPROUTE_ENTRY
  238. * *lplpRouteTable pointer to an LPIPROUTE_ENTRY
  239. * which receives the routing table
  240. * DWORD *lpdwRouteCount pointer to a DWORD which receives
  241. * the number of routing entries
  242. *
  243. * This function allocates and fills in an array of routing table
  244. * entries from the Tcpip driver. It also sets the number of
  245. * entries in the array in the DWORD pointed to by lpdwRouteCount.
  246. *
  247. * In the IPROUTE_ENTRY structure, the only metric used by
  248. * the Tcpip stack is IPROUTE_ENTRY.ire_metric1; the other metric
  249. * fields should be ignored.
  250. *
  251. * Call FreeRouteTable to free the memory allocated for the
  252. * routing table.
  253. *
  254. * If the function fails, it sets *lpdwRouteCount to zero and
  255. * *lplpRouteTable to NULL.
  256. *
  257. * It returns 0 if successful and non-zero otherwise
  258. *------------------------------------------------------------------
  259. */
  260. DWORD
  261. APIENTRY
  262. GetRouteTable(
  263. OUT LPIPROUTE_ENTRY *lplpRouteTable,
  264. OUT LPDWORD lpdwRouteCount
  265. );
  266. /*
  267. *------------------------------------------------------------------
  268. * Function: FreeRouteTable
  269. *
  270. * Parameters:
  271. * LPIPROUTE_ENTRY
  272. * lpRouteTable the routing table to be freed.
  273. *
  274. * This function frees the memory allocated for a routing table.
  275. * It returns 0 if successful and non-zero otherwise.
  276. *------------------------------------------------------------------
  277. */
  278. DWORD
  279. APIENTRY
  280. FreeRouteTable(
  281. IN LPIPROUTE_ENTRY lpRouteTable
  282. );
  283. /*
  284. *------------------------------------------------------------------
  285. * Function: AddRoute
  286. *
  287. * Parameters:
  288. * DWORD dwProtocol protocol of specified route
  289. * DWORD dwType type of specified route
  290. * DWORD dwIndex index of interface on which to add
  291. * DWORD dwDestVal destination IP addr (network order)
  292. * DWORD dwMaskVal destination subnet mask, or zero
  293. * if no subnet (network order)
  294. * DWORD dwGateVal next hop IP addr (network order)
  295. * DWORD dwMetric metric
  296. *
  297. * This function adds a new route (or updates an existing route)
  298. * for the specified protocol, on the specified interface.
  299. * (See above for values which can be used as protocol numbers,
  300. * as well as values which can be used as route entry types.)
  301. * If the route identified by dwIndex.dwDestVal.dwMaskVal.dwGateVal
  302. * already exists, it is updated with the specified protocol,
  303. * type, and metric.
  304. * The TCP stack will return an error on an attempt to add a route
  305. * whose destination is destination is longer than its mask.
  306. * In other words, this function fails if (dwDestVal & ~dwMaskVal)
  307. * is non-zero.
  308. *
  309. * Returns 0 if successful, non-zero otherwise.
  310. *------------------------------------------------------------------
  311. */
  312. DWORD
  313. APIENTRY
  314. AddRoute(
  315. IN DWORD dwProtocol,
  316. IN DWORD dwType,
  317. IN DWORD dwIndex,
  318. IN DWORD dwDestVal,
  319. IN DWORD dwMaskVal,
  320. IN DWORD dwGateVal,
  321. IN DWORD dwMetric
  322. );
  323. /*
  324. *------------------------------------------------------------------
  325. * Function: DeleteRoute
  326. *
  327. * Parameters:
  328. * DWORD dwIndex index of interface from which to delete
  329. * DWORD dwDestVal destination IP addr (network order)
  330. * DWORD dwMaskVal subnet mask (network order)
  331. * DWORD dwGateVal next hop IP addr (network order)
  332. *
  333. * This function deletes a route to the specified destination.
  334. *
  335. * Returns 0 if successful, non-zero otherwise.
  336. *------------------------------------------------------------------
  337. */
  338. DWORD
  339. APIENTRY
  340. DeleteRoute(
  341. IN DWORD dwIndex,
  342. IN DWORD dwDestVal,
  343. IN DWORD dwMaskVal,
  344. IN DWORD dwGateVal
  345. );
  346. /*
  347. *------------------------------------------------------------------
  348. * Function: RefreshAddresses
  349. *
  350. * Parameters:
  351. * none
  352. *
  353. * This function queries the TCPIP stack for the current Address table and Interface
  354. * Entry table, updating routetab's local copy of those tables.s
  355. *
  356. * Returns 0 if successful, non-zero otherwise.
  357. *------------------------------------------------------------------
  358. */
  359. DWORD
  360. APIENTRY
  361. RefreshAddresses();
  362. /*
  363. *------------------------------------------------------------------
  364. * Function: SetAddrChangeNotifyEvent
  365. *
  366. * Parameters:
  367. * HANDLE hEvent the event to be signalled if the
  368. * IP address of a local interface changes
  369. *
  370. * This function sets the event to be signalled if any IP address
  371. * for any interfaces is changed either via DHCP client activity
  372. * or manually in the Network Control Panel. This notification is
  373. * optional.
  374. *
  375. * If hEvent is NULL, address change notification is disabled.
  376. *
  377. * Returns 0 if successful, non-zero otherwise.
  378. *------------------------------------------------------------------
  379. */
  380. DWORD
  381. APIENTRY
  382. SetAddrChangeNotifyEvent(
  383. HANDLE hEvent
  384. );
  385. /*
  386. *------------------------------------------------------------------
  387. * Function: ReloadIPAddressTable
  388. *
  389. * Parameters:
  390. * LPIPADDRESS_ENTRY
  391. * *lplpAddrTable pointer to an LPIPADDRESS_ENTRY
  392. * which receives the IP address table
  393. * LPDWORD lpdwAddrCount pointer to a DWORD which receives
  394. * the number of addresses in the table
  395. *
  396. * This function first queries the TCP/IP stack to rebuild its
  397. * IP interface and IP address tables.
  398. * Then this function allocates and fills in an array of address entry
  399. * structures corresponding to the logical IP interfaces in
  400. * the system. It also stores the number of entries in the array
  401. * in the DWORD pointed to by lpdwAddrCount.
  402. *
  403. * Call FreeIPAddressTable to free the memory allocated for the
  404. * address table.
  405. *
  406. * If the function fails, it sets *lpdwAddrCount to zero and
  407. * *lplpAddrTable to NULL.
  408. *
  409. * It returns 0 if successful and non-zero otherwise
  410. *------------------------------------------------------------------
  411. */
  412. DWORD
  413. APIENTRY
  414. ReloadIPAddressTable(
  415. OUT LPIPADDRESS_ENTRY *lplpAddrTable,
  416. OUT LPDWORD lpdwAddrCount
  417. );
  418. #ifdef DBG
  419. #define DEBUG_PRINT(S) printf S
  420. #define TRACE_PRINT(S) if( trace ){ printf S; }else{}
  421. #else
  422. #define DEBUG_PRINT(S) /* nothing */
  423. #define TRACE_PRINT(S) /* nothing */
  424. #endif
  425. #endif /* _ROUTETAB_H_ */