home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / RTLWIN32.PAK / HTTPFILT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  12.6 KB  |  481 lines

  1. /*++
  2.  
  3. Copyright (c) 1995-1996  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     httpfilt.h
  8.  
  9. Abstract:
  10.  
  11.     This module contains the Microsoft HTTP filter extension info
  12.  
  13. Revision History:
  14.  
  15. --*/
  16.  
  17. /* $Copyright: 1997$ */
  18.  
  19. #ifndef _HTTPFILT_H_
  20. #define _HTTPFILT_H_
  21.  
  22. #include <pshpack4.h>
  23.  
  24. #pragma option -b
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30. //
  31. //  Current version of the filter spec is 2.0
  32. //
  33.  
  34. #define HTTP_FILTER_REVISION    MAKELONG( 0, 2);
  35.  
  36. #define SF_MAX_USERNAME         (256+1)
  37. #define SF_MAX_PASSWORD         (256+1)
  38.  
  39. #define SF_MAX_FILTER_DESC_LEN  (256+1)
  40.  
  41. //
  42. //  These values can be used with the pfnSFCallback function supplied in
  43. //  the filter context structure
  44. //
  45.  
  46. enum SF_REQ_TYPE
  47. {
  48.     //
  49.     //  Sends a complete HTTP server response header including
  50.     //  the status, server version, message time and MIME version.
  51.     //
  52.     //  Server extensions should append other information at the end,
  53.     //  such as Content-type, Content-length etc followed by an extra
  54.     //  '\r\n'.
  55.     //
  56.     //  pData - Zero terminated string pointing to optional
  57.     //      status string (i.e., "401 Access Denied") or NULL for
  58.     //      the default response of "200 OK".
  59.     //
  60.     //  ul1 - Zero terminated string pointing to optional data to be
  61.     //      appended and set with the header.  If NULL, the header will
  62.     //      be terminated with an empty line.
  63.     //
  64.  
  65.     SF_REQ_SEND_RESPONSE_HEADER,
  66.  
  67.     //
  68.     //  If the server denies the HTTP request, add the specified headers
  69.     //  to the server error response.
  70.     //
  71.     //  This allows an authentication filter to advertise its services
  72.     //  w/o filtering every request.  Generally the headers will be
  73.     //  WWW-Authenticate headers with custom authentication schemes but
  74.     //  no restriction is placed on what headers may be specified.
  75.     //
  76.     //  pData - Zero terminated string pointing to one or more header lines
  77.     //      with terminating '\r\n'.
  78.     //
  79.  
  80.     SF_REQ_ADD_HEADERS_ON_DENIAL,
  81.  
  82.     //
  83.     //  Only used by raw data filters that return SF_STATUS_READ_NEXT
  84.     //
  85.     //  ul1 - size in bytes for the next read
  86.     //
  87.  
  88.     SF_REQ_SET_NEXT_READ_SIZE,
  89.  
  90.     //
  91.     //  Used to indicate this request is a proxy request
  92.     //
  93.     //  ul1 - The proxy flags to set
  94.     //      0x00000001 - This is a HTTP proxy request
  95.     //
  96.     //
  97.  
  98.     SF_REQ_SET_PROXY_INFO,
  99.  
  100.     //
  101.     //  Returns the connection ID contained in the ConnID field of an
  102.     //  ISAPI Application's Extension Control Block.  This value can be used
  103.     //  as a key to cooridinate shared data between Filters and Applications.
  104.     //
  105.     //  pData - Pointer to DWORD that receives the connection ID.
  106.     //
  107.  
  108.     SF_REQ_GET_CONNID
  109. };
  110.  
  111.  
  112. //
  113. //  These values are returned by the filter entry point when a new request is
  114. //  received indicating their interest in this particular request
  115. //
  116.  
  117. enum SF_STATUS_TYPE
  118. {
  119.     //
  120.     //  The filter has handled the HTTP request.  The server should disconnect
  121.     //  the session.
  122.     //
  123.  
  124.     SF_STATUS_REQ_FINISHED = 0x8000000,
  125.  
  126.     //
  127.     //  Same as SF_STATUS_FINISHED except the server should keep the TCP
  128.     //  session open if the option was negotiated
  129.     //
  130.  
  131.     SF_STATUS_REQ_FINISHED_KEEP_CONN,
  132.  
  133.     //
  134.     //  The next filter in the notification chain should be called
  135.     //
  136.  
  137.     SF_STATUS_REQ_NEXT_NOTIFICATION,
  138.  
  139.     //
  140.     //  This filter handled the notification.  No other handles should be
  141.     //  called for this particular notification type
  142.     //
  143.  
  144.     SF_STATUS_REQ_HANDLED_NOTIFICATION,
  145.  
  146.     //
  147.     //  An error occurred.  The server should use GetLastError() and indicate
  148.     //  the error to the client
  149.     //
  150.  
  151.     SF_STATUS_REQ_ERROR,
  152.  
  153.     //
  154.     //  The filter is an opaque stream filter and we're negotiating the
  155.     //  session parameters.  Only valid for raw read notification.
  156.     //
  157.  
  158.     SF_STATUS_REQ_READ_NEXT
  159. };
  160.  
  161. //
  162. //  pvNotification points to this structure for all request notification types
  163. //
  164.  
  165. typedef struct _HTTP_FILTER_CONTEXT
  166. {
  167.     DWORD          cbSize;
  168.  
  169.     //
  170.     //  This is the structure revision level.
  171.     //
  172.  
  173.     DWORD          Revision;
  174.  
  175.     //
  176.     //  Private context information for the server.
  177.     //
  178.  
  179.     PVOID          ServerContext;
  180.     DWORD          ulReserved;
  181.  
  182.     //
  183.     //  TRUE if this request is coming over a secure port
  184.     //
  185.  
  186.     BOOL           fIsSecurePort;
  187.  
  188.     //
  189.     //  A context that can be used by the filter
  190.     //
  191.  
  192.     PVOID          pFilterContext;
  193.  
  194.     //
  195.     //  Server callbacks
  196.     //
  197.  
  198.     BOOL (WINAPI * GetServerVariable) (
  199.         struct _HTTP_FILTER_CONTEXT * pfc,
  200.         LPSTR                         lpszVariableName,
  201.         LPVOID                        lpvBuffer,
  202.         LPDWORD                       lpdwSize
  203.         );
  204.  
  205.     BOOL (WINAPI * AddResponseHeaders) (
  206.         struct _HTTP_FILTER_CONTEXT * pfc,
  207.         LPSTR                         lpszHeaders,
  208.         DWORD                         dwReserved
  209.         );
  210.  
  211.     BOOL (WINAPI * WriteClient)  (
  212.         struct _HTTP_FILTER_CONTEXT * pfc,
  213.         LPVOID                        Buffer,
  214.         LPDWORD                       lpdwBytes,
  215.         DWORD                         dwReserved
  216.         );
  217.  
  218.     VOID * (WINAPI * AllocMem) (
  219.         struct _HTTP_FILTER_CONTEXT * pfc,
  220.         DWORD                         cbSize,
  221.         DWORD                         dwReserved
  222.         );
  223.  
  224.     BOOL (WINAPI * ServerSupportFunction) (
  225.         struct _HTTP_FILTER_CONTEXT * pfc,
  226.         enum SF_REQ_TYPE              sfReq,
  227.         PVOID                         pData,
  228.         DWORD                         ul1,
  229.         DWORD                         ul2
  230.         );
  231.  
  232. } HTTP_FILTER_CONTEXT, *PHTTP_FILTER_CONTEXT;
  233.  
  234. //
  235. //  This structure is the notification info for the read and send raw data
  236. //  notification types
  237. //
  238.  
  239. typedef struct _HTTP_FILTER_RAW_DATA
  240. {
  241.     //
  242.     //  This is a pointer to the data for the filter to process.
  243.     //
  244.  
  245.     PVOID         pvInData;
  246.     DWORD         cbInData;       // Number of valid data bytes
  247.     DWORD         cbInBuffer;     // Total size of buffer
  248.  
  249.     DWORD         dwReserved;
  250.  
  251. } HTTP_FILTER_RAW_DATA, *PHTTP_FILTER_RAW_DATA;
  252.  
  253. //
  254. //  This structure is the notification info for when the server is about to
  255. //  process the client headers
  256. //
  257.  
  258. typedef struct _HTTP_FILTER_PREPROC_HEADERS
  259. {
  260.     //
  261.     //  Retrieves the specified header value.  Header names should include
  262.     //  the trailing ':'.  The special values 'method', 'url' and 'version'
  263.     //  can be used to retrieve the individual portions of the request line
  264.     //
  265.  
  266.     BOOL (WINAPI * GetHeader) (
  267.         struct _HTTP_FILTER_CONTEXT * pfc,
  268.         LPSTR                         lpszName,
  269.         LPVOID                        lpvBuffer,
  270.         LPDWORD                       lpdwSize
  271.         );
  272.  
  273.     //
  274.     //  Replaces this header value to the specified value.  To delete a header,
  275.     //  specified a value of '\0'.
  276.     //
  277.  
  278.     BOOL (WINAPI * SetHeader) (
  279.         struct _HTTP_FILTER_CONTEXT * pfc,
  280.         LPSTR                         lpszName,
  281.         LPSTR                         lpszValue
  282.         );
  283.  
  284.     //
  285.     //  Adds the specified header and value
  286.     //
  287.  
  288.     BOOL (WINAPI * AddHeader) (
  289.         struct _HTTP_FILTER_CONTEXT * pfc,
  290.         LPSTR                         lpszName,
  291.         LPSTR                         lpszValue
  292.         );
  293.  
  294.     DWORD dwReserved;
  295. } HTTP_FILTER_PREPROC_HEADERS, *PHTTP_FILTER_PREPROC_HEADERS;
  296.  
  297. //
  298. //  Authentication information for this request.
  299. //
  300.  
  301. typedef struct _HTTP_FILTER_AUTHENT
  302. {
  303.     //
  304.     //  Pointer to username and password, empty strings for the anonymous user
  305.     //
  306.     //  Client's can overwrite these buffers which are guaranteed to be at
  307.     //  least SF_MAX_USERNAME and SF_MAX_PASSWORD bytes large.
  308.     //
  309.  
  310.     CHAR * pszUser;
  311.     DWORD  cbUserBuff;
  312.  
  313.     CHAR * pszPassword;
  314.     DWORD  cbPasswordBuff;
  315.  
  316. } HTTP_FILTER_AUTHENT, *PHTTP_FILTER_AUTHENT;
  317.  
  318. //
  319. //  Indicates the server is going to use the specific physical mapping for
  320. //  the specified URL.  Filters can modify the physical path in place.
  321. //
  322.  
  323. typedef struct _HTTP_FILTER_URL_MAP
  324. {
  325.     const CHAR * pszURL;
  326.  
  327.     CHAR *       pszPhysicalPath;
  328.     DWORD        cbPathBuff;
  329.  
  330. } HTTP_FILTER_URL_MAP, *PHTTP_FILTER_URL_MAP;
  331.  
  332. //
  333. //  Bitfield indicating the requested resource has been denied by the server due
  334. //  to a logon failure, an ACL on a resource, an ISAPI Filter or an
  335. //  ISAPI Application/CGI Application.
  336. //
  337. //  SF_DENIED_BY_CONFIG can appear with SF_DENIED_LOGON if the server
  338. //  configuration did not allow the user to logon.
  339. //
  340.  
  341. #define SF_DENIED_LOGON             0x00000001
  342. #define SF_DENIED_RESOURCE          0x00000002
  343. #define SF_DENIED_FILTER            0x00000004
  344. #define SF_DENIED_APPLICATION       0x00000008
  345.  
  346. #define SF_DENIED_BY_CONFIG         0x00010000
  347.  
  348. typedef struct _HTTP_FILTER_ACCESS_DENIED
  349. {
  350.     const CHAR * pszURL;            // Requesting URL
  351.     const CHAR * pszPhysicalPath;   // Physical path of resource
  352.     DWORD        dwReason;          // Bitfield of SF_DENIED flags
  353.  
  354. } HTTP_FILTER_ACCESS_DENIED, *PHTTP_FILTER_ACCESS_DENIED;
  355.  
  356. //
  357. //  The log information about to be written to the server log file.  The
  358. //  string pointers can be replaced but the memory must remain valid until
  359. //  the next notification
  360. //
  361.  
  362. typedef struct _HTTP_FILTER_LOG
  363. {
  364.     const CHAR * pszClientHostName;
  365.     const CHAR * pszClientUserName;
  366.     const CHAR * pszServerName;
  367.     const CHAR * pszOperation;
  368.     const CHAR * pszTarget;
  369.     const CHAR * pszParameters;
  370.  
  371.     DWORD  dwHttpStatus;
  372.     DWORD  dwWin32Status;
  373.  
  374. } HTTP_FILTER_LOG, *PHTTP_FILTER_LOG;
  375.  
  376. //
  377. //  Notification Flags
  378. //
  379. //  SF_NOTIFY_SECURE_PORT
  380. //  SF_NOTIFY_NONSECURE_PORT
  381. //
  382. //      Indicates whether the application wants to be notified for transactions
  383. //      that are happenning on the server port(s) that support data encryption
  384. //      (such as PCT and SSL), on only the non-secure port(s) or both.
  385. //
  386. //  SF_NOTIFY_READ_RAW_DATA
  387. //
  388. //      Applications are notified after the server reads a block of memory
  389. //      from the client but before the server does any processing on the
  390. //      block.  The data block may contain HTTP headers and entity data.
  391. //
  392. //
  393. //
  394.  
  395. #define SF_NOTIFY_SECURE_PORT               0x00000001
  396. #define SF_NOTIFY_NONSECURE_PORT            0x00000002
  397.  
  398. #define SF_NOTIFY_READ_RAW_DATA             0x00008000
  399. #define SF_NOTIFY_PREPROC_HEADERS           0x00004000
  400. #define SF_NOTIFY_AUTHENTICATION            0x00002000
  401. #define SF_NOTIFY_URL_MAP                   0x00001000
  402. #define SF_NOTIFY_ACCESS_DENIED             0x00000800
  403. #define SF_NOTIFY_SEND_RAW_DATA             0x00000400
  404. #define SF_NOTIFY_LOG                       0x00000200
  405. #define SF_NOTIFY_END_OF_NET_SESSION        0x00000100
  406.  
  407. //
  408. //  Filter ordering flags
  409. //
  410. //  Filters will tend to be notified by their specified
  411. //  ordering.  For ties, notification order is determined by load order.
  412. //
  413. //  SF_NOTIFY_ORDER_HIGH - Authentication or data transformation filters
  414. //  SF_NOTIFY_ORDER_MEDIUM
  415. //  SF_NOTIFY_ORDER_LOW  - Logging filters that want the results of any other
  416. //                      filters might specify this order.
  417. //
  418.  
  419. #define SF_NOTIFY_ORDER_HIGH               0x00080000
  420. #define SF_NOTIFY_ORDER_MEDIUM             0x00040000
  421. #define SF_NOTIFY_ORDER_LOW                0x00020000
  422. #define SF_NOTIFY_ORDER_DEFAULT            SF_NOTIFY_ORDER_LOW
  423.  
  424. #define SF_NOTIFY_ORDER_MASK               (SF_NOTIFY_ORDER_HIGH   |    \
  425.                                             SF_NOTIFY_ORDER_MEDIUM |    \
  426.                                             SF_NOTIFY_ORDER_LOW)
  427.  
  428. //
  429. //  Filter version information, passed to GetFilterVersion
  430. //
  431.  
  432. typedef struct _HTTP_FILTER_VERSION
  433. {
  434.     //
  435.     //  Version of the spec the server is using
  436.     //
  437.  
  438.     DWORD  dwServerFilterVersion;
  439.  
  440.     //
  441.     //  Fields specified by the client
  442.     //
  443.  
  444.     DWORD  dwFilterVersion;
  445.     CHAR   lpszFilterDesc[SF_MAX_FILTER_DESC_LEN];
  446.     DWORD  dwFlags;
  447.  
  448.  
  449. } HTTP_FILTER_VERSION, *PHTTP_FILTER_VERSION;
  450.  
  451. //
  452. //  A filter DLL's entry point looks like this.  The return code should be
  453. //  an SF_STATUS_TYPE
  454. //
  455. //  NotificationType - Type of notification
  456. //  pvNotification - Pointer to notification specific data
  457. //
  458.  
  459. DWORD
  460. WINAPI
  461. HttpFilterProc(
  462.     HTTP_FILTER_CONTEXT *      pfc,
  463.     DWORD                      NotificationType,
  464.     VOID *                     pvNotification
  465.     );
  466.  
  467. BOOL
  468. WINAPI
  469. GetFilterVersion(
  470.     HTTP_FILTER_VERSION * pVer
  471.     );
  472.  
  473. #ifdef __cplusplus
  474. }
  475. #endif
  476.  
  477. #include <poppack.h>
  478.  
  479. #pragma option -b.
  480. #endif //_HTTPFILT_H_
  481.