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.

160 lines
7.9 KiB

  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990-1992 **/
  4. /********************************************************************/
  5. /* :ts=4 */
  6. //** IPROUTE.H - IP routing definitions.
  7. //
  8. // This file contains all of the definitions for routing code that are
  9. // visible to modules outside iproute.c
  10. #pragma once
  11. extern struct Interface *LookupNextHop(IPAddr Dest, IPAddr Src,
  12. IPAddr *FirstHop, uint *MTU);
  13. extern struct Interface *LookupNextHopWithBuffer(IPAddr Dest, IPAddr Src,
  14. IPAddr *FirstHop, uint *MTU, uchar Protocol,
  15. uchar *Buffer, uint Length, RouteCacheEntry **FwdRce,
  16. LinkEntry **Link, IPAddr HdrSrc, uint UnicastIf);
  17. extern struct Interface *LookupForwardingNextHop(IPAddr Dest, IPAddr Src,
  18. IPAddr *FirstHop, uint *MTU, uchar Protocol,
  19. uchar *Buffer, uint Length, RouteCacheEntry **FwdRce,
  20. LinkEntry **Link, IPAddr HdrSrc);
  21. extern void AddrTypeCacheFlush(IPAddr Address);
  22. extern uchar GetAddrType(IPAddr Address);
  23. extern uint InvalidSourceAddress(IPAddr Address);
  24. extern uchar GetLocalNTE(IPAddr Address, NetTableEntry **NTE);
  25. extern uchar IsBCastOnNTE(IPAddr Address, NetTableEntry *NTE);
  26. extern void IPForwardPkt(NetTableEntry *SrcNTE,
  27. IPHeader UNALIGNED *Header, uint HeaderLength,
  28. void *Data, uint BufferLength,
  29. NDIS_HANDLE LContext1, uint LContext2,
  30. uchar DestType, uint MAcHdrSize,
  31. PNDIS_BUFFER pNdisBuffer, uint *pClientcnt,
  32. void *LinkCtxt);
  33. extern void SendFWPacket(PNDIS_PACKET Packet, NDIS_STATUS Status,
  34. uint DataLength);
  35. extern uint AttachRCEToRTE(RouteCacheEntry *RCE, uchar Protocol,
  36. uchar *Buffer, uint Length);
  37. extern void Redirect(NetTableEntry *NTE, IPAddr RDSrc,
  38. IPAddr Target, IPAddr Src, IPAddr FirstHop);
  39. extern IP_STATUS AddRoute(IPAddr Destination, IPMask Mask,
  40. IPAddr FirstHop, Interface *OutIF, uint MTU,
  41. uint Metric, uint Proto, uint AType,
  42. ROUTE_CONTEXT Context, uint SetWithRefcnt);
  43. extern IP_STATUS DeleteRoute(IPAddr Destination, IPMask Mask,
  44. IPAddr FirstHop, Interface *OutIF, uint SetWithRefcnt);
  45. extern IP_STATUS DeleteDest(IPAddr Dest, IPMask Mask);
  46. extern ROUTE_CONTEXT GetRouteContext(IPAddr Destination, IPAddr Source);
  47. extern NetTableEntry *BestNTEForIF(IPAddr Dest, Interface *IF, BOOLEAN NoTransientAddr);
  48. extern void RTWalk(uint (*CallFunc)(struct RouteTableEntry *,
  49. void *, void *),
  50. void *Context, void *Context1);
  51. extern uint DeleteRTEOnIF(struct RouteTableEntry *RTE,
  52. void *Context, void *Context1);
  53. extern uint DeleteAllRTEOnIF(struct RouteTableEntry *RTE,
  54. void *Context, void *Context1);
  55. extern uint InvalidateRCEOnIF(struct RouteTableEntry *RTE,
  56. void *Context, void *Context1);
  57. extern uint ConvertRTEType(struct RouteTableEntry *RTE,
  58. void *Context, void *Context1);
  59. extern uint SetMTUOnIF(struct RouteTableEntry *RTE, void *Context,
  60. void *Context1);
  61. extern uint SetMTUToAddr(struct RouteTableEntry *RTE, void *Context,
  62. void *Context1);
  63. extern uint AddNTERoutes(struct NetTableEntry *NTE);
  64. extern uint DelNTERoutes(struct NetTableEntry *NTE);
  65. extern void IPCheckRoute(IPAddr Dest, IPAddr Src,
  66. RouteCacheEntry *RCE, IPOptInfo *OptInfo,
  67. uint CheckRouteFlag);
  68. extern void RouteFragNeeded(IPHeader UNALIGNED *IPH, ushort NewMTU);
  69. extern IP_STATUS IPGetPInfo(IPAddr Dest, IPAddr Src, uint *NewMTU,
  70. uint *MaxPathSpeed, RouteCacheEntry *RCE);
  71. extern int InitRouting(struct IPConfigInfo *ci);
  72. extern uint InitNTERouting(NetTableEntry *NTE, uint NumGWs,
  73. IPAddr *GW, uint *GWMetric);
  74. extern uint InitGateway(struct IPConfigInfo *ci);
  75. extern uint GetIfConstraint(IPAddr Dest, IPAddr Src,
  76. IPOptInfo *OptInfo, BOOLEAN fIpsec);
  77. extern IPAddr OpenRCE(IPAddr Address, IPAddr Src,
  78. RouteCacheEntry **RCE, uchar *Type, ushort *MSS,
  79. IPOptInfo *OptInfo);
  80. extern void CloseRCE(RouteCacheEntry *RCE);
  81. extern uint IsRouteICMP(IPAddr Dest, IPMask Mask, IPAddr FirstHop,
  82. Interface *OutIF);
  83. NTSTATUS GetIFAndLink(void *RCE, ULONG* IFIndex,
  84. IPAddr *NextHop);
  85. extern void RtChangeNotifyCancel(PDEVICE_OBJECT DeviceObject,
  86. PIRP Irp);
  87. extern void RtChangeNotifyCancelEx(PDEVICE_OBJECT DeviceObject,
  88. PIRP Irp);
  89. extern void RtChangeNotify(IPRouteNotifyOutput *RNO);
  90. extern void RtChangeNotifyEx(IPRouteNotifyOutput *RNO);
  91. extern void InvalidateRCELinks(struct RouteTableEntry *RTE);
  92. extern CACHE_LINE_KSPIN_LOCK RouteTableLock;
  93. extern LIST_ENTRY RtChangeNotifyQueue;
  94. extern LIST_ENTRY RtChangeNotifyQueueEx;
  95. extern uint DeadGWDetect;
  96. extern uint PMTUDiscovery;
  97. extern uchar ForwardPackets;
  98. extern uchar RouterConfigured;
  99. // Pointer to callout routine for dial on demand.
  100. extern RefPtr DODRefPtr;
  101. // Pointer to packet filter handler.
  102. extern RefPtr FilterRefPtr;
  103. extern BOOLEAN NotifyFilterOfDiscard(NetTableEntry* NTE,
  104. IPHeader UNALIGNED* IPH,
  105. uchar* Data, uint DataSize);
  106. extern FORWARD_ACTION DummyFilterPtr(struct IPHeader UNALIGNED* PacketHeader,
  107. uchar* Packet, uint PacketLength,
  108. uint RecvInterfaceIndex, uint SendInterfaceIndex,
  109. IPAddr RecvLinkNextHop, IPAddr SendLinkNextHop);
  110. extern void SetDummyFilterPtr(IPPacketFilterPtr FilterPtr);
  111. extern uint RefFirewallQ(Queue** FirewallQ);
  112. extern void DerefFirewallQ(uint Handle);
  113. extern BOOLEAN ProcessFirewallQ(void);
  114. // Pointer to IPSEC handler
  115. extern IPSecHandlerRtn IPSecHandlerPtr;
  116. extern IPSecSendCompleteRtn IPSecSendCmpltPtr;
  117. #define IPADDR_LOCAL 0xffffffff // Indicates that IP address is
  118. // directly connected.
  119. #define IP_LOCAL_BCST 0xffffffff
  120. #define IP_ZERO_BCST 0
  121. #define LOOPBACK_MSS 1500 // back to normal from
  122. // W2K value (32768 - sizeof(IPHeader))
  123. #define LOOPBACK_ADDR 0x0100007f
  124. #define IP_LOOPBACK(x) (((x) & CLASSA_MASK) == 0x7f)
  125. #define ATYPE_PERM 0 // A permanent route.
  126. #define ATYPE_OVERRIDE 1 // Semi-permanent - can be
  127. // overriden.
  128. #define ATYPE_TEMP 2 // A temporary route.
  129. #define MAX_IP_HDR_SIZE 60
  130. #define ICMP_HEADER_SIZE 8