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.

338 lines
11 KiB

  1. /*
  2. *============================================================================
  3. * Copyright (c) 1994-95, Microsoft Corp.
  4. *
  5. * File: map.h
  6. *
  7. * Contains declarations for the functions that map old style routetab
  8. * functions to the iphlpapi functions.
  9. *
  10. * AddRoute
  11. * DeleteRoute
  12. * GetRouteTable
  13. * FreeRouteTable
  14. * GetInterfaceTable
  15. * FreeInterfaceTable
  16. *
  17. * The structures required by these functions are also declared here:
  18. *
  19. * IPROUTING_ENTRY
  20. * IPINTERFACE_ENTRY
  21. *
  22. * Routes can be added to and deleted from the IP routing table by other
  23. * means. Therefore, it is necessary for any protocol using these functions
  24. * to reload the routing tables periodically.
  25. *============================================================================
  26. */
  27. #ifndef _MAP_H_
  28. #define _MAP_H_
  29. /*
  30. *---------------------------------------------------------------
  31. * Any one of these values can be passed as the route entry type
  32. * when calling the AddRoute() function.
  33. *---------------------------------------------------------------
  34. */
  35. #define IRE_TYPE_OTHER 1
  36. #define IRE_TYPE_INVALID 2
  37. #define IRE_TYPE_DIRECT 3
  38. #define IRE_TYPE_INDIRECT 4
  39. /*
  40. *-------------------------------------------------------------
  41. * Any one of these values can be passed as the protocol type
  42. * when calling AddRoute() or DeleteRoute()
  43. *-------------------------------------------------------------
  44. */
  45. #define IRE_PROTO_OTHER 1
  46. #define IRE_PROTO_LOCAL 2
  47. #define IRE_PROTO_NETMGMT 3
  48. #define IRE_PROTO_ICMP 4
  49. #define IRE_PROTO_EGP 5
  50. #define IRE_PROTO_GGP 6
  51. #define IRE_PROTO_HELLO 7
  52. #define IRE_PROTO_RIP 8
  53. #define IRE_PROTO_IS_IS 9
  54. #define IRE_PROTO_ES_IS 10
  55. #define IRE_PROTO_CISCO 11
  56. #define IRE_PROTO_BBN 12
  57. #define IRE_PROTO_OSPF 13
  58. #define IRE_PROTO_BGP 14
  59. /*
  60. *-------------------------------------------------------------
  61. * This value may be passed as the metric to functions which
  62. * require a metric, in cases where the metric is irrelevant
  63. *-------------------------------------------------------------
  64. */
  65. #define IRE_METRIC_UNUSED 0xffffffff
  66. /*
  67. *-------------------------------------------------------------
  68. * These constants are used in the definition of IF_ENTRY
  69. *-------------------------------------------------------------
  70. */
  71. #define MAX_PHYSADDR_SIZE 8
  72. #define MAX_IFDESCR_LEN 256
  73. /*
  74. *-------------------------------------------------------------
  75. * This structure is used by GetIPAddressTable() to return
  76. * information about logical IP interfaces on the system
  77. *-------------------------------------------------------------
  78. */
  79. typedef struct _IPADDRESS_ENTRY {
  80. DWORD iae_address; /* IP address of this entry */
  81. DWORD iae_index; /* index of interface for this entry */
  82. DWORD iae_netmask; /* subnet mask of this entry */
  83. DWORD iae_bcastaddr;
  84. DWORD iae_reasmsize;
  85. USHORT iae_context;
  86. USHORT iae_pad;
  87. } IPADDRESS_ENTRY, *LPIPADDRESS_ENTRY;
  88. /*
  89. *-------------------------------------------------------------
  90. * This structure is used by GetRouteTable() to return
  91. * information about routing table entries.
  92. *-------------------------------------------------------------
  93. */
  94. typedef struct _IPROUTE_ENTRY {
  95. DWORD ire_dest; /* destination IP addr, network order */
  96. DWORD ire_mask; /* network mask, network order */
  97. DWORD ire_policy; /* policy duh(?) */
  98. DWORD ire_nexthop; /* next hop IP addr, network order */
  99. DWORD ire_index; /* route entry index */
  100. DWORD ire_type; /* routing type for this entry */
  101. DWORD ire_proto; /* routing protocol for this entry */
  102. DWORD ire_age; /* age of this entry */
  103. DWORD ire_nexthopas; /* next hop as */
  104. DWORD ire_metric1; /* destination metric, host order */
  105. DWORD ire_metric2; /* unused */
  106. DWORD ire_metric3; /* unused */
  107. DWORD ire_metric4; /* unused */
  108. DWORD ire_metric5; /* unused */
  109. } IPROUTE_ENTRY, *LPIPROUTE_ENTRY;
  110. /*
  111. *------------------------------------------------------------------
  112. * Function: GetIPAddressTable
  113. *
  114. * Parameters:
  115. * LPIPADDRESS_ENTRY
  116. * *lplpAddrTable pointer to an LPIPADDRESS_ENTRY
  117. * which receives the IP address table
  118. * LPDWORD lpdwAddrCount pointer to a DWORD which receives
  119. * the number of addresses in the table
  120. *
  121. * This function allocates and fills in an array of address entry
  122. * structures corresponding to the logical IP interfaces in
  123. * the system. It also stores the number of entries in the array
  124. * in the DWORD pointed to by lpdwAddrCount.
  125. *
  126. * Call FreeIPAddressTable to free the memory allocated for the
  127. * address table.
  128. *
  129. * If the function fails, it sets *lpdwAddrCount to zero and
  130. * *lplpAddrTable to NULL.
  131. *
  132. * It returns 0 if successful and non-zero otherwise
  133. *------------------------------------------------------------------
  134. */
  135. DWORD
  136. GetIPAddressTable(
  137. OUT PMIB_IPADDRROW *lplpAddrTable,
  138. OUT LPDWORD lpdwAddrCount
  139. );
  140. /*
  141. *------------------------------------------------------------------
  142. * Function: FreeIPAddressTable
  143. *
  144. * Parameters:
  145. * LPIPADDRESS_ENTRY
  146. * lpAddrTable the address table to be freed.
  147. *
  148. * This function frees the memory allocated for an address table.
  149. * It returns 0 if successful and non-zero otherwise.
  150. *------------------------------------------------------------------
  151. */
  152. DWORD
  153. FreeIPAddressTable(
  154. IN PMIB_IPADDRROW lpAddrTable
  155. );
  156. /*
  157. *------------------------------------------------------------------
  158. * Function: GetRouteTable
  159. *
  160. * Parameters:
  161. * LPIPROUTE_ENTRY
  162. * *lplpRouteTable pointer to an LPIPROUTE_ENTRY
  163. * which receives the routing table
  164. * DWORD *lpdwRouteCount pointer to a DWORD which receives
  165. * the number of routing entries
  166. *
  167. * This function allocates and fills in an array of routing table
  168. * entries from the Tcpip driver. It also sets the number of
  169. * entries in the array in the DWORD pointed to by lpdwRouteCount.
  170. *
  171. * In the IPROUTE_ENTRY structure, the only metric used by
  172. * the Tcpip stack is IPROUTE_ENTRY.ire_metric1; the other metric
  173. * fields should be ignored.
  174. *
  175. * Call FreeRouteTable to free the memory allocated for the
  176. * routing table.
  177. *
  178. * If the function fails, it sets *lpdwRouteCount to zero and
  179. * *lplpRouteTable to NULL.
  180. *
  181. * It returns 0 if successful and non-zero otherwise
  182. *------------------------------------------------------------------
  183. */
  184. DWORD
  185. GetRouteTable(
  186. OUT LPIPROUTE_ENTRY *lplpRouteTable,
  187. OUT LPDWORD lpdwRouteCount
  188. );
  189. /*
  190. *------------------------------------------------------------------
  191. * Function: FreeRouteTable
  192. *
  193. * Parameters:
  194. * LPIPROUTE_ENTRY
  195. * lpRouteTable the routing table to be freed.
  196. *
  197. * This function frees the memory allocated for a routing table.
  198. * It returns 0 if successful and non-zero otherwise.
  199. *------------------------------------------------------------------
  200. */
  201. DWORD
  202. FreeRouteTable(
  203. IN LPIPROUTE_ENTRY lpRouteTable
  204. );
  205. /*
  206. *------------------------------------------------------------------
  207. * Function: AddRoute
  208. *
  209. * Parameters:
  210. * DWORD dwProtocol protocol of specified route
  211. * DWORD dwType type of specified route
  212. * DWORD dwIndex index of interface on which to add
  213. * DWORD dwDestVal destination IP addr (network order)
  214. * DWORD dwMaskVal destination subnet mask, or zero
  215. * if no subnet (network order)
  216. * DWORD dwGateVal next hop IP addr (network order)
  217. * DWORD dwMetric metric
  218. *
  219. * This function adds a new route (or updates an existing route)
  220. * for the specified protocol, on the specified interface.
  221. * (See above for values which can be used as protocol numbers,
  222. * as well as values which can be used as route entry types.)
  223. * If the route identified by dwIndex.dwDestVal.dwMaskVal.dwGateVal
  224. * already exists, it is updated with the specified protocol,
  225. * type, and metric.
  226. * The TCP stack will return an error on an attempt to add a route
  227. * whose destination is destination is longer than its mask.
  228. * In other words, this function fails if (dwDestVal & ~dwMaskVal)
  229. * is non-zero.
  230. *
  231. * Returns 0 if successful, non-zero otherwise.
  232. *------------------------------------------------------------------
  233. */
  234. DWORD
  235. AddRoute(
  236. IN DWORD dwProtocol,
  237. IN DWORD dwType,
  238. IN DWORD dwIndex,
  239. IN DWORD dwDestVal,
  240. IN DWORD dwMaskVal,
  241. IN DWORD dwGateVal,
  242. IN DWORD dwMetric
  243. );
  244. /*
  245. *------------------------------------------------------------------
  246. * Function: DeleteRoute
  247. *
  248. * Parameters:
  249. * DWORD dwIndex index of interface from which to delete
  250. * DWORD dwDestVal destination IP addr (network order)
  251. * DWORD dwMaskVal subnet mask (network order)
  252. * DWORD dwGateVal next hop IP addr (network order)
  253. *
  254. * This function deletes a route to the specified destination.
  255. *
  256. * Returns 0 if successful, non-zero otherwise.
  257. *------------------------------------------------------------------
  258. */
  259. DWORD
  260. DeleteRoute(
  261. IN DWORD dwIndex,
  262. IN DWORD dwDestVal,
  263. IN DWORD dwMaskVal,
  264. IN DWORD dwGateVal
  265. );
  266. /*
  267. *------------------------------------------------------------------
  268. * Function: ReloadIPAddressTable
  269. *
  270. * Parameters:
  271. * LPIPADDRESS_ENTRY
  272. * *lplpAddrTable pointer to an LPIPADDRESS_ENTRY
  273. * which receives the IP address table
  274. * LPDWORD lpdwAddrCount pointer to a DWORD which receives
  275. * the number of addresses in the table
  276. *
  277. * This function first queries the TCP/IP stack to rebuild its
  278. * IP interface and IP address tables.
  279. * Then this function allocates and fills in an array of address entry
  280. * structures corresponding to the logical IP interfaces in
  281. * the system. It also stores the number of entries in the array
  282. * in the DWORD pointed to by lpdwAddrCount.
  283. *
  284. * Call FreeIPAddressTable to free the memory allocated for the
  285. * address table.
  286. *
  287. * If the function fails, it sets *lpdwAddrCount to zero and
  288. * *lplpAddrTable to NULL.
  289. *
  290. * It returns 0 if successful and non-zero otherwise
  291. *------------------------------------------------------------------
  292. */
  293. DWORD
  294. ReloadIPAddressTable(
  295. OUT PMIB_IPADDRROW *lplpAddrTable,
  296. OUT LPDWORD lpdwAddrCount
  297. );
  298. #endif /* _MAP_H_ */