home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / HTTPFILT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  14.0 KB  |  546 lines

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