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.

348 lines
9.6 KiB

  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990-2000 **/
  4. /********************************************************************/
  5. /* :ts=4 */
  6. //*** ipfilter.h - IP filterng and demand dial header file.
  7. //
  8. // Contains definitions for constants and prototypes related to IP filtering and
  9. // dial on demand support.
  10. #pragma once
  11. #ifndef IPFILTER_INCLUDED
  12. #define IPFILTER_INCLUDED
  13. #include <ipexport.h>
  14. #include <ipfltinf.h>
  15. #include <gpcifc.h>
  16. #define RESERVED_IF_INDEX 0xffffffff // The reserved inteface index.
  17. #define INVALID_IF_INDEX 0xffffffff // The invalid inteface index.
  18. #define LOCAL_IF_INDEX 0 // Local inteface index.
  19. typedef ulong ROUTE_CONTEXT; // Context in an unattached route.
  20. //
  21. // Indicates whether it is a transmitted or received packet.
  22. //
  23. typedef enum _IP_DIRECTION_E {
  24. IP_TRANSMIT,
  25. IP_RECEIVE
  26. } DIRECTION_E, *PDIRECTION_E;
  27. typedef struct _FIREWALL_CONTEXT_T {
  28. DIRECTION_E Direction;
  29. void *NTE;
  30. void *LinkCtxt;
  31. NDIS_HANDLE LContext1;
  32. UINT LContext2;
  33. } FIREWALL_CONTEXT_T, *PFIREWALL_CONTEXT_T;
  34. // Definition for pointer to callout that maps a route to an interface.
  35. typedef unsigned int (*IPMapRouteToInterfacePtr)(ROUTE_CONTEXT Context,
  36. IPAddr Destination, IPAddr Source, unsigned char Protocol,
  37. unsigned char *Buffer, unsigned int Length, IPAddr HdrSrc);
  38. // Definiton for a filter routine callout.
  39. typedef FORWARD_ACTION (*IPPacketFilterPtr)(
  40. struct IPHeader UNALIGNED *PacketHeader,
  41. uchar *Packet,
  42. uint PacketLength,
  43. uint RecvInterfaceIndex,
  44. uint SendInterfaceIndex,
  45. IPAddr RecvLinkNextHop,
  46. IPAddr SendLinkNextHop);
  47. // Definiton for a firewall routine callout.
  48. typedef FORWARD_ACTION (*IPPacketFirewallPtr)(
  49. void **pData, //can be pMdl or pRcvBuf
  50. uint RecvInterfaceIndex,
  51. uint *pSendInterfaceIndex,
  52. uchar *pDestinationType,
  53. void *pContext,
  54. UINT ContextLength,
  55. struct IPRcvBuf **pRcvBuf
  56. );
  57. extern
  58. int
  59. IPAllocBuff(
  60. struct IPRcvBuf* pRcvBuf,
  61. UINT Size
  62. );
  63. extern
  64. VOID
  65. IPFreeBuff(
  66. struct IPRcvBuf* pRcvBuf
  67. );
  68. extern
  69. VOID
  70. FreeIprBuff(
  71. struct IPRcvBuf* pRcvBuf
  72. );
  73. extern
  74. VOID
  75. IPFreeHeaders(
  76. struct IPRcvBuf *pRcvBuf
  77. );
  78. typedef enum _IPROUTEINFOCLASS {
  79. IPRouteNoInformation,
  80. IPRouteOutgoingFirewallContext,
  81. IPRouteOutgoingFilterContext,
  82. MaxIPRouteInfoClass
  83. } IPROUTEINFOCLASS;
  84. extern
  85. NTSTATUS
  86. LookupRouteInformation(
  87. IN VOID* RouteLookupData,
  88. OUT VOID* RouteEntry OPTIONAL,
  89. IN IPROUTEINFOCLASS RouteInfoClass OPTIONAL,
  90. OUT VOID* RouteInformation OPTIONAL,
  91. IN OUT UINT* RouteInfoLength OPTIONAL
  92. );
  93. extern
  94. NTSTATUS
  95. LookupRouteInformationWithBuffer(
  96. IN VOID* RouteLookupData,
  97. IN PUCHAR Buffer OPTIONAL,
  98. IN UINT BufferLength OPTIONAL,
  99. OUT VOID* RouteEntry OPTIONAL,
  100. IN IPROUTEINFOCLASS RouteInfoClass OPTIONAL,
  101. OUT VOID* RouteInformation OPTIONAL,
  102. IN OUT UINT* RouteInfoLength OPTIONAL
  103. );
  104. //
  105. // IPSEC stuff - shd this be in a new header??
  106. //
  107. #define IPSEC_RESERVED 110
  108. #define PROTOCOL_AH 51
  109. #define PROTOCOL_ESP 50
  110. #define PROTOCOL_COMP 108
  111. #define PROTOCOL_TCP 6
  112. #define PROTOCOL_UDP 17
  113. #define PROTOCOL_RSVP 46
  114. #define PROTOCOL_ICMP 1
  115. #define IP_IN_IP 4
  116. //
  117. // Context passed to IPSEC on send complete
  118. //
  119. typedef struct _IPSEC_SEND_COMPLETE_CONTEXT {
  120. UCHAR Signature[4]; // contains "ISC?" for debug build
  121. ULONG Flags;
  122. PNDIS_BUFFER OptMdl;
  123. PNDIS_BUFFER OriAHMdl;
  124. PNDIS_BUFFER OriHUMdl;
  125. PNDIS_BUFFER OriTuMdl;
  126. PNDIS_BUFFER PrevMdl;
  127. PNDIS_BUFFER PrevTuMdl;
  128. PNDIS_BUFFER AHMdl;
  129. PNDIS_BUFFER AHTuMdl;
  130. PNDIS_BUFFER PadMdl;
  131. PNDIS_BUFFER PadTuMdl;
  132. PNDIS_BUFFER HUMdl;
  133. PNDIS_BUFFER HUTuMdl;
  134. PNDIS_BUFFER BeforePadMdl;
  135. PNDIS_BUFFER BeforePadTuMdl;
  136. PNDIS_BUFFER HUHdrMdl;
  137. PNDIS_BUFFER OriAHMdl2;
  138. PNDIS_BUFFER PrevAHMdl2;
  139. PNDIS_BUFFER AHMdl2;
  140. PNDIS_BUFFER FlushMdl;
  141. PVOID pSA;
  142. PVOID pNextSA;
  143. PVOID PktExt;
  144. PVOID pMTUContext;
  145. PNDIS_IPSEC_PACKET_INFO PktInfo;
  146. } IPSEC_SEND_COMPLETE_CONTEXT, *PIPSEC_SEND_COMPLETE_CONTEXT;
  147. //
  148. // Flags used on send complete
  149. //
  150. #define SCF_AH 0x00000001
  151. #define SCF_AH_TU 0x00000002
  152. #define SCF_HU_TPT 0x00000004
  153. #define SCF_HU_TU 0x00000008
  154. #define SCF_FLUSH 0x00000010
  155. #define SCF_FRAG 0x00000020
  156. #define SCF_NOE_TPT 0x00000040
  157. #define SCF_NOE_TU 0x00000080
  158. #define SCF_AH_2 0x00000100
  159. #define SCF_PKTINFO 0x00000200
  160. #define SCF_PKTEXT 0x00000400
  161. #define SCF_MTU 0x00000800
  162. #define IPSEC_FLAG_FLUSH 0x00000001
  163. #define IPSEC_FLAG_FRAG_DONE 0x00000002
  164. #define IPSEC_FLAG_LOOPBACK 0x00000004
  165. #define IPSEC_FLAG_SSRR 0x00000008
  166. #define IPSEC_FLAG_FORWARD 0x00000010
  167. #define IPSEC_FLAG_INCOMING 0x00000020
  168. #define IPSEC_FLAG_FASTRCV 0x00000040
  169. #define IPSEC_FLAG_TRANSFORMED 0x00000080
  170. #define IPSEC_FLAG_TCP_CHECKSUM_VALID 0x00000100
  171. #define IPSEC_FLAG_UDP_CHECKSUM_VALID 0x00000200
  172. //
  173. // Definiton for a packet handler routine callout.
  174. //
  175. typedef IPSEC_ACTION
  176. (*IPSecHandlerRtn) (
  177. PUCHAR pIPHeader,
  178. PVOID pData,
  179. PVOID DestIF,
  180. PNDIS_PACKET Packet,
  181. PULONG pExtraBytes,
  182. PULONG pMTU,
  183. PVOID *ppNewData,
  184. PULONG pIpsecFlags,
  185. UCHAR DestType
  186. );
  187. typedef BOOLEAN
  188. (*IPSecQStatusRtn) (
  189. IN CLASSIFICATION_HANDLE GpcHandle
  190. );
  191. typedef VOID
  192. (*IPSecSendCompleteRtn) (
  193. IN PNDIS_PACKET Packet,
  194. IN PVOID pData,
  195. IN PIPSEC_SEND_COMPLETE_CONTEXT pContext,
  196. IN IP_STATUS Status,
  197. OUT PVOID *ppNewData
  198. );
  199. typedef NTSTATUS
  200. (*IPSecNdisStatusRtn) (
  201. IN PVOID IPContext,
  202. IN UINT Status
  203. );
  204. typedef IPSEC_ACTION
  205. (*IPSecRcvFWPacketRtn) (
  206. PCHAR pIPHeader,
  207. PVOID pData,
  208. UINT DataLength,
  209. UCHAR DestType
  210. );
  211. #define IP_IPSEC_BIND_VERSION 1
  212. typedef struct _IPSEC_FUNCTIONS {
  213. ULONG Version;
  214. IPSecHandlerRtn IPSecHandler;
  215. IPSecQStatusRtn IPSecQStatus;
  216. IPSecSendCompleteRtn IPSecSendCmplt;
  217. IPSecNdisStatusRtn IPSecNdisStatus;
  218. IPSecRcvFWPacketRtn IPSecRcvFWPacket;
  219. } IPSEC_FUNCTIONS, *PIPSEC_FUNCTIONS;
  220. extern
  221. IP_STATUS
  222. SetIPSecPtr(PIPSEC_FUNCTIONS IpsecFns);
  223. extern
  224. IP_STATUS
  225. UnSetIPSecPtr(PIPSEC_FUNCTIONS IpsecFns);
  226. extern
  227. IP_STATUS
  228. UnSetIPSecSendPtr(PIPSEC_FUNCTIONS IpsecFns);
  229. extern
  230. IP_STATUS
  231. IPTransmit(void *Context, void *SendContext,
  232. PNDIS_BUFFER Buffer, uint DataSize,
  233. IPAddr Dest, IPAddr Source,
  234. IPOptInfo *OptInfo, RouteCacheEntry *RCE,
  235. uchar Protocol, IRP *Irp);
  236. extern
  237. NDIS_STATUS
  238. IPProxyNdisRequest(
  239. IN PVOID DestIF,
  240. IN NDIS_REQUEST_TYPE RT,
  241. IN NDIS_OID Oid,
  242. IN VOID *Buffer,
  243. IN UINT Length,
  244. IN UINT *Needed
  245. );
  246. extern
  247. NTSTATUS
  248. IPGetBestInterface(
  249. IN IPAddr Address,
  250. OUT PVOID *ppIF
  251. );
  252. extern
  253. NTSTATUS
  254. IPEnableSniffer(
  255. IN PUNICODE_STRING AdapterName,
  256. IN PVOID Context
  257. );
  258. extern
  259. NTSTATUS
  260. IPDisableSniffer(
  261. IN PUNICODE_STRING AdapterName
  262. );
  263. extern
  264. NTSTATUS
  265. IPSetIPSecStatus(
  266. IN BOOLEAN fActivePolicy
  267. );
  268. extern
  269. IP_STATUS
  270. SendICMPErr(
  271. IN IPAddr Src,
  272. IN IPHeader UNALIGNED * Header,
  273. IN uchar Type,
  274. IN uchar Code,
  275. IN ulong Pointer,
  276. IN uchar Length
  277. );
  278. extern
  279. LONG
  280. GetIFAndLink(
  281. IN PVOID RCE,
  282. OUT PULONG IFIndex,
  283. OUT IPAddr *NextHop
  284. );
  285. // Structure passed to the IPSetFilterHook call
  286. typedef struct _IP_SET_FILTER_HOOK_INFO {
  287. IPPacketFilterPtr FilterPtr; // Packet filter callout.
  288. } IP_SET_FILTER_HOOK_INFO, *PIP_SET_FILTER_HOOK_INFO;
  289. // Structure passed to the IPSetFirewallHook call
  290. typedef struct _IP_SET_FIREWALL_HOOK_INFO {
  291. IPPacketFirewallPtr FirewallPtr; // Packet filter callout.
  292. UINT Priority; // Priority of the hook
  293. BOOLEAN Add; // if TRUE then ADD else DELETE
  294. } IP_SET_FIREWALL_HOOK_INFO, *PIP_SET_FIREWALL_HOOK_INFO;
  295. // Structure passed to the IPSetMapRouteHook call.
  296. typedef struct _IP_SET_MAP_ROUTE_HOOK_INFO {
  297. IPMapRouteToInterfacePtr MapRoutePtr; // Map route callout.
  298. } IP_SET_MAP_ROUTE_HOOK_INFO, *PIP_SET_MAP_ROUTE_HOOK_INFO;
  299. #endif