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.

207 lines
8.8 KiB

  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990-2000 **/
  4. /********************************************************************/
  5. /* :ts=4 */
  6. #ifndef __IPRTDEF_H
  7. #define __IPRTDEF_H
  8. #include "ipdef.h"
  9. //** IPRTDEF.H - IP private routing definitions.
  10. //
  11. // This file contains all of the definitions private to the routing
  12. // module.
  13. //* Route table entry.
  14. //
  15. typedef struct RouteTableEntry {
  16. struct RouteTableEntry *rte_next; // Next in hash chain.
  17. IPAddr rte_dest; // Destination of route.
  18. IPMask rte_mask; // Mask to use when examining route.
  19. IPAddr rte_addr; // First hop for this route.
  20. uint rte_priority; // Priority of this route:
  21. // essentially the number of bits
  22. // set in mask.
  23. uint rte_metric; // Metric of route. Lower is better.
  24. uint rte_mtu; // MTU for this route.
  25. struct Interface *rte_if; // Outbound interface.
  26. RouteCacheEntry *rte_rcelist;
  27. ushort rte_type; // Type of route.
  28. ushort rte_flags; // Flags for route.
  29. uint rte_admintype; // Admin type of route.
  30. uint rte_proto; // How we learned about the route.
  31. uint rte_valid; // Up time (in seconds) route was
  32. // last known to be valid.
  33. uint rte_mtuchange; // System up time (in seconds) MTU
  34. // was changed.
  35. ROUTE_CONTEXT rte_context; // Dial-on-demand context for this
  36. // route.
  37. uchar rte_arpcontext[RCE_CONTEXT_SIZE]; // Used in
  38. // forwarding
  39. struct RouteTableEntry *rte_todg; // Points to RTE which is a new
  40. // default gateway
  41. struct RouteTableEntry *rte_fromdg; // Points to RTE which from which
  42. // default gateway is transitioning
  43. uint rte_rces; // number of connected/referenced
  44. // RCEs on this.
  45. struct LinkEntry *rte_link; // Link entry for this route
  46. struct RouteTableEntry *rte_nextlinkrte; // chain of rtes for this link
  47. uint rte_refcnt; // refcount associated with the
  48. // route
  49. } RouteTableEntry;
  50. #define ADDR_FROM_RTE(R, A) \
  51. (IP_ADDR_EQUAL((R)->rte_addr, IPADDR_LOCAL) ? (A) : (R)->rte_addr)
  52. #define IF_FROM_RTE(R) ((R)->rte_if)
  53. #define MTU_FROM_RTE(R) ((R)->rte_mtu)
  54. #define SRC_FROM_RTE(R) ((R)->rte_src)
  55. #define RTE_VALID 1
  56. #define RTE_INCREASE 2 // Set if last MTU change was an
  57. // increase.
  58. #define RTE_IF_VALID 4 // Set to TRUE if rte_if is valid.
  59. #define RTE_DEADGW 8 // This RTE is valid but in DG
  60. // detection process
  61. #define RTE_NEW 16 // This RTE has just been added
  62. #define HOST_MASK 0xffffffff
  63. #define DEFAULT_MASK 0
  64. #define IP_ROUTE_TIMEOUT 5*1000 // Route timer fires once in 5 sec
  65. #define IP_RTABL_TIMEOUT 60L*1000L // & Route table timer once a min.
  66. #define FLUSH_IFLIST_TIMEOUT 60L*1000L // Flush 1 element from freeiflist
  67. // once a min.
  68. #define MTU_INCREASE_TIME 120 // Number of seconds after increase
  69. // to re-increase.
  70. #define MTU_DECREASE_TIME 600 // Number of seconds after decrease
  71. // to re-increase.
  72. #define MAX_ICMP_ROUTE_VALID 600 // Time to timeout an unused ICMP
  73. // derived route, in seconds.
  74. #define MIN_RT_VALID 60 // Minimum time a route is assumed
  75. // to be valid, in seconds.
  76. #define MIN_VALID_MTU 68 // Minimum valid MTU we can have.
  77. #define HOST_ROUTE_PRI 32
  78. #define DEFAULT_ROUTE_PRI 0
  79. //* Forward Q linkage structure.
  80. //
  81. typedef struct FWQ {
  82. struct FWQ *fq_next;
  83. struct FWQ *fq_prev;
  84. } FWQ;
  85. //* Forward context structure, used when TD'ing a packet to be forwarded.
  86. //
  87. typedef struct FWContext {
  88. PacketContext fc_pc; // Dummy packet context for send
  89. // routines.
  90. FWQ fc_q; // Queue structure.
  91. PNDIS_BUFFER fc_hndisbuff; // Pointer to NDIS buffer for
  92. // header.
  93. IPHeader *fc_hbuff; // Header buffer.
  94. PNDIS_BUFFER fc_buffhead; // Head of list of NDIS buffers.
  95. PNDIS_BUFFER fc_bufftail; // Tail of list of NDIS buffers.
  96. uchar *fc_options; // Options,
  97. Interface *fc_if; // Destination interface.
  98. IPAddr fc_outaddr; // IP address of interface.
  99. uint fc_mtu; // Max MTU outgoing.
  100. NetTableEntry *fc_srcnte; // Source NTE.
  101. IPAddr fc_nexthop; // Next hop.
  102. uint fc_datalength; // Length in bytes of data.
  103. OptIndex fc_index; // Index of relevant options.
  104. uchar fc_optlength; // Length of options.
  105. uchar fc_sos; // Send on source indicator.
  106. uchar fc_dtype; // Dest type.
  107. uchar fc_pad;
  108. PNDIS_PACKET fc_bufown; // Incoming ndis packet
  109. uint fc_MacHdrSize; // Media hdr size.
  110. struct LinkEntry *fc_iflink; // link on which the packet is sent
  111. Interface *fc_if2;
  112. } FWContext;
  113. #define PACKET_FROM_FWQ(_fwq_) \
  114. (PNDIS_PACKET) \
  115. ((uchar *)(_fwq_) - (offsetof(struct FWContext, fc_q) + \
  116. offsetof(NDIS_PACKET, ProtocolReserved)))
  117. //* Route send queue structure. This consists of a dummy FWContext for use as
  118. // a queue head, a count of sends pending on the interface, and a count of
  119. // packets in the queue.
  120. //
  121. typedef struct RouteSendQ {
  122. FWQ rsq_qh;
  123. uint rsq_pending;
  124. uint rsq_maxpending;
  125. uint rsq_qlength;
  126. uint rsq_running;
  127. DEFINE_LOCK_STRUCTURE(rsq_lock)
  128. } RouteSendQ;
  129. //* Routing interface, a superset of the ordinary interface when we're
  130. // configured as a router.
  131. //
  132. typedef struct RouteInterface {
  133. Interface ri_if;
  134. RouteSendQ ri_q;
  135. } RouteInterface;
  136. typedef struct RtChangeList {
  137. struct RtChangeList *rt_next;
  138. IPRouteNotifyOutput rt_info;
  139. } RtChangeList;
  140. extern IPMask IPMaskTable[];
  141. #define IPNetMask(a) IPMaskTable[(*(uchar *)&(a)) >> 4]
  142. #if DBG
  143. #define Print DbgPrint
  144. #else
  145. #define Print
  146. #endif
  147. // Route Structures
  148. //
  149. typedef RouteTableEntry Route;
  150. // Dest Definitions
  151. extern USHORT MaxEqualCostRoutes;
  152. #define DEFAULT_MAX_EQUAL_COST_ROUTES 1
  153. #define MAXIMUM_MAX_EQUAL_COST_ROUTES 10
  154. // Destination information structure
  155. //
  156. typedef struct DestinationEntry {
  157. Route *firstRoute; // First route in list of routes on dest
  158. USHORT maxBestRoutes; // Number of best route slots in array
  159. USHORT numBestRoutes; // Actual number of best routes to dest
  160. RouteTableEntry *bestRoutes[1]; // Equal cost best routes to same dest
  161. } DestinationEntry;
  162. typedef DestinationEntry Dest;
  163. #define NULL_DEST(_pDest_) (_pDest_ == NULL)
  164. // Route Macros
  165. //
  166. #define NEXT(_pRoute_) ((_pRoute_)->rte_next)
  167. #define DEST(_pRoute_) ((_pRoute_)->rte_dest)
  168. #define MASK(_pRoute_) ((_pRoute_)->rte_mask)
  169. #define NHOP(_pRoute_) ((_pRoute_)->rte_addr)
  170. #define LEN(_pRoute_) ((_pRoute_)->rte_priority)
  171. #define METRIC(_pRoute_) ((_pRoute_)->rte_metric)
  172. #define IF(_pRoute_) ((_pRoute_)->rte_if)
  173. #define FLAGS(_pRoute_) ((_pRoute_)->rte_flags)
  174. #define PROTO(_pRoute_) ((_pRoute_)->rte_proto)
  175. #define NULL_ROUTE(_pRoute_) (_pRoute_ == NULL)
  176. UINT AddrOnIF(Interface *IF, IPAddr Addr);
  177. #endif // __IPRTDEF_H