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.

426 lines
11 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. httpfilt.h
  5. Abstract:
  6. This module contains the Microsoft HTTP filter extension info
  7. Revision History:
  8. --*/
  9. #ifndef _HTTPFILT_H_
  10. #define _HTTPFILT_H_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. //
  15. // Current version of the filter spec is 1.0
  16. //
  17. #define HTTP_FILTER_REVISION MAKELONG( 0, 1);
  18. #define SF_MAX_USERNAME (256+1)
  19. #define SF_MAX_PASSWORD (256+1)
  20. #define SF_MAX_FILTER_DESC_LEN (256+1)
  21. //
  22. // These values can be used with the pfnSFCallback function supplied in
  23. // the filter context structure
  24. //
  25. enum SF_REQ_TYPE
  26. {
  27. //
  28. // Sends a complete HTTP server response header including
  29. // the status, server version, message time and MIME version.
  30. //
  31. // Server extensions should append other information at the end,
  32. // such as Content-type, Content-length etc followed by an extra
  33. // '\r\n'.
  34. //
  35. // pData - Zero terminated string pointing to optional
  36. // status string (i.e., "401 Access Denied") or NULL for
  37. // the default response of "200 OK".
  38. //
  39. // ul1 - Zero terminated string pointing to optional data to be
  40. // appended and set with the header. If NULL, the header will
  41. // be terminated with an empty line.
  42. //
  43. SF_REQ_SEND_RESPONSE_HEADER,
  44. //
  45. // If the server denies the HTTP request, add the specified headers
  46. // to the server error response.
  47. //
  48. // This allows an authentication filter to advertise its services
  49. // w/o filtering every request. Generally the headers will be
  50. // WWW-Authenticate headers with custom authentication schemes but
  51. // no restriction is placed on what headers may be specified.
  52. //
  53. // pData - Zero terminated string pointing to one or more header lines
  54. // with terminating '\r\n'.
  55. //
  56. SF_REQ_ADD_HEADERS_ON_DENIAL,
  57. //
  58. // Only used by raw data filters that return SF_STATUS_READ_NEXT
  59. //
  60. // ul1 - size in bytes for the next read
  61. //
  62. SF_REQ_SET_NEXT_READ_SIZE
  63. };
  64. //
  65. // These values are returned by the filter entry point when a new request is
  66. // received indicating their interest in this particular request
  67. //
  68. enum SF_STATUS_TYPE
  69. {
  70. //
  71. // The filter has handled the HTTP request. The server should disconnect
  72. // the session.
  73. //
  74. SF_STATUS_REQ_FINISHED = 0x8000000,
  75. //
  76. // Same as SF_STATUS_FINISHED except the server should keep the TCP
  77. // session open if the option was negotiated
  78. //
  79. SF_STATUS_REQ_FINISHED_KEEP_CONN,
  80. //
  81. // The next filter in the notification chain should be called
  82. //
  83. SF_STATUS_REQ_NEXT_NOTIFICATION,
  84. //
  85. // This filter handled the notification. No other handles should be
  86. // called for this particular notification type
  87. //
  88. SF_STATUS_REQ_HANDLED_NOTIFICATION,
  89. //
  90. // An error occurred. The server should use GetLastError() and indicate
  91. // the error to the client
  92. //
  93. SF_STATUS_REQ_ERROR,
  94. //
  95. // The filter is an opaque stream filter and we're negotiating the
  96. // session parameters. Only valid for raw read notification.
  97. //
  98. SF_STATUS_REQ_READ_NEXT
  99. };
  100. //
  101. // pvNotification points to this structure for all request notification types
  102. //
  103. typedef struct _HTTP_FILTER_CONTEXT
  104. {
  105. DWORD cbSize;
  106. //
  107. // This is the structure revision level.
  108. //
  109. DWORD Revision;
  110. //
  111. // Private context information for the server.
  112. //
  113. PVOID ServerContext;
  114. DWORD ulReserved;
  115. //
  116. // TRUE if this request is coming over a secure port
  117. //
  118. BOOL fIsSecurePort;
  119. //
  120. // A context that can be used by the filter
  121. //
  122. PVOID pFilterContext;
  123. //
  124. // Server callbacks
  125. //
  126. BOOL (WINAPI * GetServerVariable) (
  127. struct _HTTP_FILTER_CONTEXT * pfc,
  128. LPSTR lpszVariableName,
  129. LPVOID lpvBuffer,
  130. LPDWORD lpdwSize
  131. );
  132. BOOL (WINAPI * AddResponseHeaders) (
  133. struct _HTTP_FILTER_CONTEXT * pfc,
  134. LPSTR lpszHeaders,
  135. DWORD dwReserved
  136. );
  137. BOOL (WINAPI * WriteClient) (
  138. struct _HTTP_FILTER_CONTEXT * pfc,
  139. LPVOID Buffer,
  140. LPDWORD lpdwBytes,
  141. DWORD dwReserved
  142. );
  143. VOID * (WINAPI * AllocMem) (
  144. struct _HTTP_FILTER_CONTEXT * pfc,
  145. DWORD cbSize,
  146. DWORD dwReserved
  147. );
  148. BOOL (WINAPI * ServerSupportFunction) (
  149. struct _HTTP_FILTER_CONTEXT * pfc,
  150. enum SF_REQ_TYPE sfReq,
  151. PVOID pData,
  152. DWORD ul1,
  153. DWORD ul2
  154. );
  155. } HTTP_FILTER_CONTEXT, *PHTTP_FILTER_CONTEXT;
  156. //
  157. // This structure is the notification info for the read and send raw data
  158. // notification types
  159. //
  160. typedef struct _HTTP_FILTER_RAW_DATA
  161. {
  162. //
  163. // This is a pointer to the data for the filter to process.
  164. //
  165. PVOID pvInData;
  166. DWORD cbInData; // Number of valid data bytes
  167. DWORD cbInBuffer; // Total size of buffer
  168. DWORD dwReserved;
  169. } HTTP_FILTER_RAW_DATA, *PHTTP_FILTER_RAW_DATA;
  170. //
  171. // This structure is the notification info for when the server is about to
  172. // process the client headers
  173. //
  174. typedef struct _HTTP_FILTER_PREPROC_HEADERS
  175. {
  176. //
  177. // Retrieves the specified header value. Header names should include
  178. // the trailing ':'. The special values 'method', 'url' and 'version'
  179. // can be used to retrieve the individual portions of the request line
  180. //
  181. BOOL (WINAPI * GetHeader) (
  182. struct _HTTP_FILTER_CONTEXT * pfc,
  183. LPSTR lpszName,
  184. LPVOID lpvBuffer,
  185. LPDWORD lpdwSize
  186. );
  187. //
  188. // Replaces this header value to the specified value. To delete a header,
  189. // specified a value of '\0'.
  190. //
  191. BOOL (WINAPI * SetHeader) (
  192. struct _HTTP_FILTER_CONTEXT * pfc,
  193. LPSTR lpszName,
  194. LPSTR lpszValue
  195. );
  196. //
  197. // Adds the specified header and value
  198. //
  199. BOOL (WINAPI * AddHeader) (
  200. struct _HTTP_FILTER_CONTEXT * pfc,
  201. LPSTR lpszName,
  202. LPSTR lpszValue
  203. );
  204. DWORD dwReserved;
  205. } HTTP_FILTER_PREPROC_HEADERS, *PHTTP_FILTER_PREPROC_HEADERS;
  206. //
  207. // Authentication information for this request.
  208. //
  209. typedef struct _HTTP_FILTER_AUTHENT
  210. {
  211. //
  212. // Pointer to username and password, empty strings for the anonymous user
  213. //
  214. // Client's can overwrite these buffers which are guaranteed to be at
  215. // least SF_MAX_USERNAME and SF_MAX_PASSWORD bytes large.
  216. //
  217. CHAR * pszUser;
  218. DWORD cbUserBuff;
  219. CHAR * pszPassword;
  220. DWORD cbPasswordBuff;
  221. } HTTP_FILTER_AUTHENT, *PHTTP_FILTER_AUTHENT;
  222. //
  223. // Indicates the server is going to use the specific physical mapping for
  224. // the specified URL. Filters can modify the physical path in place.
  225. //
  226. typedef struct _HTTP_FILTER_URL_MAP
  227. {
  228. const CHAR * pszURL;
  229. CHAR * pszPhysicalPath;
  230. DWORD cbPathBuff;
  231. } HTTP_FILTER_URL_MAP, *PHTTP_FILTER_URL_MAP;
  232. //
  233. // The log information about to be written to the server log file. The
  234. // string pointers can be replaced but the memory must remain valid until
  235. // the next notification
  236. //
  237. typedef struct _HTTP_FILTER_LOG
  238. {
  239. const CHAR * pszClientHostName;
  240. const CHAR * pszClientUserName;
  241. const CHAR * pszServerName;
  242. const CHAR * pszOperation;
  243. const CHAR * pszTarget;
  244. const CHAR * pszParameters;
  245. DWORD dwHttpStatus;
  246. DWORD dwWin32Status;
  247. } HTTP_FILTER_LOG, *PHTTP_FILTER_LOG;
  248. //
  249. // Notification Flags
  250. //
  251. // SF_NOTIFY_SECURE_PORT
  252. // SF_NOTIFY_NONSECURE_PORT
  253. //
  254. // Indicates whether the application wants to be notified for transactions
  255. // that are happenning on the server port(s) that support data encryption
  256. // (such as PCT and SSL), on only the non-secure port(s) or both.
  257. //
  258. // SF_NOTIFY_READ_RAW_DATA
  259. //
  260. // Applications are notified after the server reads a block of memory
  261. // from the client but before the server does any processing on the
  262. // block. The data block may contain HTTP headers and entity data.
  263. //
  264. //
  265. //
  266. #define SF_NOTIFY_SECURE_PORT 0x00000001
  267. #define SF_NOTIFY_NONSECURE_PORT 0x00000002
  268. #define SF_NOTIFY_READ_RAW_DATA 0x00008000
  269. #define SF_NOTIFY_PREPROC_HEADERS 0x00004000
  270. #define SF_NOTIFY_AUTHENTICATION 0x00002000
  271. #define SF_NOTIFY_URL_MAP 0x00001000
  272. #define SF_NOTIFY_SEND_RAW_DATA 0x00000400
  273. #define SF_NOTIFY_LOG 0x00000200
  274. #define SF_NOTIFY_END_OF_NET_SESSION 0x00000100
  275. //
  276. // Filter ordering flags
  277. //
  278. // Filters will tend to be notified by their specified
  279. // ordering. For ties, notification order is determined by load order.
  280. //
  281. // SF_NOTIFY_ORDER_HIGH - Authentication or data transformation filters
  282. // SF_NOTIFY_ORDER_MEDIUM
  283. // SF_NOTIFY_ORDER_LOW - Logging filters that want the results of any other
  284. // filters might specify this order.
  285. //
  286. #define SF_NOTIFY_ORDER_HIGH 0x00080000
  287. #define SF_NOTIFY_ORDER_MEDIUM 0x00040000
  288. #define SF_NOTIFY_ORDER_LOW 0x00020000
  289. #define SF_NOTIFY_ORDER_DEFAULT SF_NOTIFY_ORDER_LOW
  290. #define SF_NOTIFY_ORDER_MASK (SF_NOTIFY_ORDER_HIGH | \
  291. SF_NOTIFY_ORDER_MEDIUM | \
  292. SF_NOTIFY_ORDER_LOW)
  293. //
  294. // Filter version information, passed to GetFilterVersion
  295. //
  296. typedef struct _HTTP_FILTER_VERSION
  297. {
  298. //
  299. // Version of the spec the server is using
  300. //
  301. DWORD dwServerFilterVersion;
  302. //
  303. // Fields specified by the client
  304. //
  305. DWORD dwFilterVersion;
  306. CHAR lpszFilterDesc[SF_MAX_FILTER_DESC_LEN];
  307. DWORD dwFlags;
  308. } HTTP_FILTER_VERSION, *PHTTP_FILTER_VERSION;
  309. //
  310. // A filter DLL's entry point looks like this. The return code should be
  311. // an SF_STATUS_TYPE
  312. //
  313. // NotificationType - Type of notification
  314. // pvNotification - Pointer to notification specific data
  315. //
  316. DWORD
  317. WINAPI
  318. HttpFilterProc(
  319. HTTP_FILTER_CONTEXT * pfc,
  320. DWORD NotificationType,
  321. VOID * pvNotification
  322. );
  323. BOOL
  324. WINAPI
  325. GetFilterVersion(
  326. HTTP_FILTER_VERSION * pVer
  327. );
  328. #ifdef __cplusplus
  329. }
  330. #endif
  331. #endif //_HTTPFILT_H_
  332.