Source code of Windows XP (NT5)
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.8 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);
  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 SetMTUOnIF(struct RouteTableEntry *RTE, void *Context,
  58. void *Context1);
  59. extern uint SetMTUToAddr(struct RouteTableEntry *RTE, void *Context,
  60. void *Context1);
  61. extern uint AddNTERoutes(struct NetTableEntry *NTE);
  62. extern uint DelNTERoutes(struct NetTableEntry *NTE);
  63. extern void IPCheckRoute(IPAddr Dest, IPAddr Src,
  64. RouteCacheEntry *RCE, IPOptInfo *OptInfo,
  65. uint CheckRouteFlag);
  66. extern void RouteFragNeeded(IPHeader UNALIGNED *IPH, ushort NewMTU);
  67. extern IP_STATUS IPGetPInfo(IPAddr Dest, IPAddr Src, uint *NewMTU,
  68. uint *MaxPathSpeed, RouteCacheEntry *RCE);
  69. extern int InitRouting(struct IPConfigInfo *ci);
  70. extern uint InitNTERouting(NetTableEntry *NTE, uint NumGWs,
  71. IPAddr *GW, uint *GWMetric);
  72. extern uint InitGateway(struct IPConfigInfo *ci);
  73. extern uint GetIfConstraint(IPAddr Dest, IPAddr Src,
  74. IPOptInfo *OptInfo, BOOLEAN fIpsec);
  75. extern IPAddr OpenRCE(IPAddr Address, IPAddr Src,
  76. RouteCacheEntry **RCE, uchar *Type, ushort *MSS,
  77. IPOptInfo *OptInfo);
  78. extern void CloseRCE(RouteCacheEntry *RCE);
  79. extern uint IsRouteICMP(IPAddr Dest, IPMask Mask, IPAddr FirstHop,
  80. Interface *OutIF);
  81. NTSTATUS GetIFAndLink(void *RCE, uint* IFIndex,
  82. IPAddr *NextHop);
  83. extern void RtChangeNotifyCancel(PDEVICE_OBJECT DeviceObject,
  84. PIRP Irp);
  85. extern void RtChangeNotifyCancelEx(PDEVICE_OBJECT DeviceObject,
  86. PIRP Irp);
  87. extern void RtChangeNotify(IPRouteNotifyOutput *RNO);
  88. extern void RtChangeNotifyEx(IPRouteNotifyOutput *RNO);
  89. extern void InvalidateRCELinks(struct RouteTableEntry *RTE);
  90. extern CACHE_LINE_KSPIN_LOCK RouteTableLock;
  91. extern LIST_ENTRY RtChangeNotifyQueue;
  92. extern LIST_ENTRY RtChangeNotifyQueueEx;
  93. extern uint DeadGWDetect;
  94. extern uint PMTUDiscovery;
  95. extern uchar ForwardPackets;
  96. extern uchar RouterConfigured;
  97. // Pointer to callout routine for dial on demand.
  98. extern IPMapRouteToInterfacePtr DODCallout;
  99. // Pointer to packet filter handler.
  100. extern IPPacketFilterPtr ForwardFilterPtr;
  101. extern BOOLEAN ForwardFilterEnabled;
  102. extern uint ForwardFilterRefCount;
  103. extern CTEBlockStruc ForwardFilterBlock;
  104. extern void DerefFilterPtr(void);
  105. extern BOOLEAN NotifyFilterOfDiscard(NetTableEntry* NTE,
  106. IPHeader UNALIGNED* IPH,
  107. uchar* Data, uint DataSize);
  108. extern FORWARD_ACTION DummyFilterPtr(struct IPHeader UNALIGNED* PacketHeader,
  109. uchar* Packet, uint PacketLength,
  110. uint RecvInterfaceIndex, uint SendInterfaceIndex,
  111. IPAddr RecvLinkNextHop, IPAddr SendLinkNextHop);
  112. extern void SetDummyFilterPtr(IPPacketFilterPtr FilterPtr);
  113. extern uint RefFirewallQ(Queue** FirewallQ);
  114. extern void DerefFirewallQ(uint Handle);
  115. extern BOOLEAN ProcessFirewallQ(void);
  116. // Pointer to IPSEC handler
  117. extern IPSecHandlerRtn IPSecHandlerPtr;
  118. extern IPSecSendCompleteRtn IPSecSendCmpltPtr;
  119. #define IPADDR_LOCAL 0xffffffff // Indicates that IP address is
  120. // directly connected.
  121. #define IP_LOCAL_BCST 0xffffffff
  122. #define IP_ZERO_BCST 0
  123. #define LOOPBACK_MSS 1500 // back to normal from
  124. // W2K value (32768 - sizeof(IPHeader))
  125. #define LOOPBACK_ADDR 0x0100007f
  126. #define IP_LOOPBACK(x) (((x) & CLASSA_MASK) == 0x7f)
  127. #define ATYPE_PERM 0 // A permanent route.
  128. #define ATYPE_OVERRIDE 1 // Semi-permanent - can be
  129. // overriden.
  130. #define ATYPE_TEMP 2 // A temporary route.
  131. #define MAX_IP_HDR_SIZE 60
  132. #define ICMP_HEADER_SIZE 8