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