annotate src/c/fastcgi.h @ 1512:dcc8abbc6dfd

Change cookie signature comparison to resist timing attacks (based on code suggested by Robin Green and Austin Seipp)
author Adam Chlipala <adam@chlipala.net>
date Tue, 19 Jul 2011 09:18:50 -0400
parents 60240acd15b9
children
rev   line source
adamc@859 1 // This code comes from the FastCGI 1.0 spec at:
adamc@859 2 // http://www.fastcgi.com/drupal/node/6?q=node/22
adamc@859 3
adamc@859 4 /*
adamc@859 5 * Listening socket file number
adamc@859 6 */
adamc@859 7 #define FCGI_LISTENSOCK_FILENO 0
adamc@859 8
adamc@859 9 typedef struct {
adamc@859 10 unsigned char version;
adamc@859 11 unsigned char type;
adamc@859 12 unsigned char requestIdB1;
adamc@859 13 unsigned char requestIdB0;
adamc@859 14 unsigned char contentLengthB1;
adamc@859 15 unsigned char contentLengthB0;
adamc@859 16 unsigned char paddingLength;
adamc@859 17 unsigned char reserved;
adamc@859 18 } FCGI_Header;
adamc@859 19
adamc@859 20 /*
adamc@859 21 * Number of bytes in a FCGI_Header. Future versions of the protocol
adamc@859 22 * will not reduce this number.
adamc@859 23 */
adamc@859 24 #define FCGI_HEADER_LEN 8
adamc@859 25
adamc@859 26 /*
adamc@859 27 * Value for version component of FCGI_Header
adamc@859 28 */
adamc@859 29 #define FCGI_VERSION_1 1
adamc@859 30
adamc@859 31 /*
adamc@859 32 * Values for type component of FCGI_Header
adamc@859 33 */
adamc@859 34 #define FCGI_BEGIN_REQUEST 1
adamc@859 35 #define FCGI_ABORT_REQUEST 2
adamc@859 36 #define FCGI_END_REQUEST 3
adamc@859 37 #define FCGI_PARAMS 4
adamc@859 38 #define FCGI_STDIN 5
adamc@859 39 #define FCGI_STDOUT 6
adamc@859 40 #define FCGI_STDERR 7
adamc@859 41 #define FCGI_DATA 8
adamc@859 42 #define FCGI_GET_VALUES 9
adamc@859 43 #define FCGI_GET_VALUES_RESULT 10
adamc@859 44 #define FCGI_UNKNOWN_TYPE 11
adamc@859 45 #define FCGI_MAXTYPE (FCGI_UNKNOWN_TYPE)
adamc@859 46
adamc@859 47 /*
adamc@859 48 * Value for requestId component of FCGI_Header
adamc@859 49 */
adamc@859 50 #define FCGI_NULL_REQUEST_ID 0
adamc@859 51
adamc@859 52 typedef struct {
adamc@859 53 unsigned char roleB1;
adamc@859 54 unsigned char roleB0;
adamc@859 55 unsigned char flags;
adamc@859 56 unsigned char reserved[5];
adamc@859 57 } FCGI_BeginRequestBody;
adamc@859 58
adamc@859 59 typedef struct {
adamc@859 60 FCGI_Header header;
adamc@859 61 FCGI_BeginRequestBody body;
adamc@859 62 } FCGI_BeginRequestRecord;
adamc@859 63
adamc@859 64 /*
adamc@859 65 * Mask for flags component of FCGI_BeginRequestBody
adamc@859 66 */
adamc@859 67 #define FCGI_KEEP_CONN 1
adamc@859 68
adamc@859 69 /*
adamc@859 70 * Values for role component of FCGI_BeginRequestBody
adamc@859 71 */
adamc@859 72 #define FCGI_RESPONDER 1
adamc@859 73 #define FCGI_AUTHORIZER 2
adamc@859 74 #define FCGI_FILTER 3
adamc@859 75
adamc@859 76 typedef struct {
adamc@859 77 unsigned char appStatusB3;
adamc@859 78 unsigned char appStatusB2;
adamc@859 79 unsigned char appStatusB1;
adamc@859 80 unsigned char appStatusB0;
adamc@859 81 unsigned char protocolStatus;
adamc@859 82 unsigned char reserved[3];
adamc@859 83 } FCGI_EndRequestBody;
adamc@859 84
adamc@859 85 typedef struct {
adamc@859 86 FCGI_Header header;
adamc@859 87 FCGI_EndRequestBody body;
adamc@859 88 } FCGI_EndRequestRecord;
adamc@859 89
adamc@859 90 /*
adamc@859 91 * Values for protocolStatus component of FCGI_EndRequestBody
adamc@859 92 */
adamc@859 93 #define FCGI_REQUEST_COMPLETE 0
adamc@859 94 #define FCGI_CANT_MPX_CONN 1
adamc@859 95 #define FCGI_OVERLOADED 2
adamc@859 96 #define FCGI_UNKNOWN_ROLE 3
adamc@859 97
adamc@859 98 /*
adamc@859 99 * Variable names for FCGI_GET_VALUES / FCGI_GET_VALUES_RESULT records
adamc@859 100 */
adamc@859 101 #define FCGI_MAX_CONNS "FCGI_MAX_CONNS"
adamc@859 102 #define FCGI_MAX_REQS "FCGI_MAX_REQS"
adamc@859 103 #define FCGI_MPXS_CONNS "FCGI_MPXS_CONNS"
adamc@859 104
adamc@859 105 typedef struct {
adamc@859 106 unsigned char type;
adamc@859 107 unsigned char reserved[7];
adamc@859 108 } FCGI_UnknownTypeBody;
adamc@859 109
adamc@859 110 typedef struct {
adamc@859 111 FCGI_Header header;
adamc@859 112 FCGI_UnknownTypeBody body;
adamc@859 113 } FCGI_UnknownTypeRecord;