diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-05-21 03:30:09 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-05-21 03:30:09 +0000 |
| commit | fa54bb75ff65b1eca0e36ef2d4d4579dbce4b28e (patch) | |
| tree | ee382de101a4a46f598f2edbb1d868734293ca34 /src | |
| parent | ea28bb1a26afef91fbaac7ef06dc91e4def69477 (diff) | |
| download | tipidee-fa54bb75ff65b1eca0e36ef2d4d4579dbce4b28e.tar.gz | |
Add tipidee/fcgi.h
Diffstat (limited to 'src')
| -rw-r--r-- | src/include/tipidee/fcgi.h | 124 | ||||
| -rw-r--r-- | src/libtipidee/deps-lib/tipidee | 14 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_beginrequest_body_pack.c | 14 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_beginrequest_body_unpack.c | 14 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_beginrequest_record_pack.c | 9 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_beginrequest_record_unpack.c | 9 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_endrequest_body_pack.c | 14 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_endrequest_body_unpack.c | 14 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_endrequest_record_pack.c | 9 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_endrequest_record_unpack.c | 9 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_header_pack.c | 15 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_header_unpack.c | 14 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_unknowntype_body_pack.c | 11 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_unknowntype_body_unpack.c | 11 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_unknowntype_record_pack.c | 9 | ||||
| -rw-r--r-- | src/libtipidee/tipidee_fcgi_unknowntype_record_unpack.c | 9 |
16 files changed, 299 insertions, 0 deletions
diff --git a/src/include/tipidee/fcgi.h b/src/include/tipidee/fcgi.h new file mode 100644 index 0000000..be2f0af --- /dev/null +++ b/src/include/tipidee/fcgi.h @@ -0,0 +1,124 @@ +/* ISC license. */ + +#ifndef TIPIDEE_FCGI_H +#define TIPIDEE_FCGI_H + +#include <stdint.h> + +typedef struct fcgi_header_s fcgi_header, *fcgi_header_ref ; +struct fcgi_header_s +{ + uint8_t version ; + uint8_t type ; + uint16_t requestid ; + uint16_t len ; + uint8_t padlen ; + uint8_t reserved ; +} ; + +typedef enum fcgi_type_e fcgi_type ; +enum fcgi_type_e +{ + FCGI_BEGIN_REQUEST = 1, + FCGI_ABORT_REQUEST, + FCGI_END_REQUEST, + FCGI_PARAMS, + FCGI_STDIN, + FCGI_STDOUT, + FCGI_STDERR, + FCGI_DATA, + FCGI_GET_VALUES, + FCGI_GET_VALUES_RESULT, + FCGI_UNKNOWN_TYPE, + FCGI_MAXTYPE +} ; + +#define FCGI_NULL_REQUEST_ID 0 + +extern void tipidee_fcgi_header_pack (char *, fcgi_header const *) ; +extern void tipidee_fcgi_header_unpack (char const *, fcgi_header *) ; + + +typedef struct fcgi_beginrequest_body_s fcgi_beginrequest_body, *fcgi_beginrequest_body_ref ; +struct fcgi_beginrequest_body_s +{ + uint16_t role ; + uint8_t flags; + unsigned char reserved[5] ; +} ; + +extern void tipidee_fcgi_beginrequest_body_pack (char *, fcgi_beginrequest_body const *) ; +extern void tipidee_fcgi_beginrequest_body_unpack (char const *, fcgi_beginrequest_body *) ; + + +typedef struct fcgi_beginrequest_record_s fcgi_beginrequest_record, *fcgi_beginrequest_record_ref ; +struct fcgi_beginrequest_record_s +{ + fcgi_header header ; + fcgi_beginrequest_body body ; +} ; + +#define FCGI_KEEP_CONN 1 + +#define FCGI_RESPONDER 1 +#define FCGI_AUTHORIZER 2 +#define FCGI_FILTER 3 + +extern void tipidee_fcgi_beginrequest_record_pack (char *, fcgi_beginrequest_record const *) ; +extern void tipidee_fcgi_beginrequest_record_unpack (char const *, fcgi_beginrequest_record *) ; + + +typedef struct fcgi_endrequest_body_s fcgi_endrequest_body, *fcgi_endrequest_body_ref ; +struct fcgi_endrequest_body_s +{ + uint32_t appstatus ; + uint8_t protostatus ; + uint8_t reserved[3] ; +} ; + +extern void tipidee_fcgi_endrequest_body_pack (char *, fcgi_endrequest_body const *) ; +extern void tipidee_fcgi_endrequest_body_unpack (char const *, fcgi_endrequest_body *) ; + + +typedef struct fcgi_endrequest_record_s fcgi_endrequest_record, *fcgi_endrequest_record_ref ; +struct fcgi_endrequest_record_s +{ + fcgi_header header ; + fcgi_endrequest_body body ; +} ; + +#define FCGI_REQUEST_COMPLETE 0 +#define FCGI_CANT_MPX_CONN 1 +#define FCGI_OVERLOADED 2 +#define FCGI_UNKNOWN_ROLE 3 + +#define FCGI_MAX_CONNS "FCGI_MAX_CONNS" +#define FCGI_MAX_REQS "FCGI_MAX_REQS" +#define FCGI_MPXS_CONNS "FCGI_MPXS_CONNS" + +extern void tipidee_fcgi_endrequest_record_pack (char *, fcgi_endrequest_record const *) ; +extern void tipidee_fcgi_endrequest_record_unpack (char const *, fcgi_endrequest_record *) ; + + +typedef struct fcgi_unknowntype_body_s fcgi_unknowntype_body, *fcgi_unknowntype_body_ref ; +struct fcgi_unknowntype_body_s +{ + uint8_t type ; + uint8_t reserved[7] ; +} ; + +extern void tipidee_fcgi_unknowntype_body_pack (char *, fcgi_unknowntype_body const *) ; +extern void tipidee_fcgi_unknowntype_body_unpack (char const *, fcgi_unknowntype_body *) ; + + +typedef struct fcgi_unknowntype_record_s fcgi_unknowntype_record, *fcgi_unknowntype_record_ref ; +struct fcgi_unknowntype_record_s +{ + fcgi_header header ; + fcgi_unknowntype_body body ; +} ; + +extern void tipidee_fcgi_unknowntype_record_pack (char *, fcgi_unknowntype_record const *) ; +extern void tipidee_fcgi_unknowntype_record_unpack (char const *, fcgi_unknowntype_record *) ; + +#endif diff --git a/src/libtipidee/deps-lib/tipidee b/src/libtipidee/deps-lib/tipidee index b0b2c08..1a73f52 100644 --- a/src/libtipidee/deps-lib/tipidee +++ b/src/libtipidee/deps-lib/tipidee @@ -10,6 +10,20 @@ tipidee_conf_get_responseheaders.o tipidee_conf_get_string.o tipidee_conf_get_uint32.o tipidee_conf_init.o +tipidee_fcgi_beginrequest_body_pack.o +tipidee_fcgi_beginrequest_body_unpack.o +tipidee_fcgi_beginrequest_record_pack.o +tipidee_fcgi_beginrequest_record_unpack.o +tipidee_fcgi_endrequest_body_pack.o +tipidee_fcgi_endrequest_body_unpack.o +tipidee_fcgi_endrequest_record_pack.o +tipidee_fcgi_endrequest_record_unpack.o +tipidee_fcgi_header_pack.o +tipidee_fcgi_header_unpack.o +tipidee_fcgi_unknowntype_body_pack.o +tipidee_fcgi_unknowntype_body_unpack.o +tipidee_fcgi_unknowntype_record_pack.o +tipidee_fcgi_unknowntype_record_unpack.o tipidee_headers_get_content_length.o tipidee_headers_init.o tipidee_headers_parse.o diff --git a/src/libtipidee/tipidee_fcgi_beginrequest_body_pack.c b/src/libtipidee/tipidee_fcgi_beginrequest_body_pack.c new file mode 100644 index 0000000..400be69 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_beginrequest_body_pack.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <string.h> + +#include <skalibs/uint16.h> + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_beginrequest_body_pack (char *s, fcgi_beginrequest_body const *bd) +{ + uint16_pack_big(s, bd->role) ; s += 2 ; + *s++ = bd->flags ; + memset(s, 0, 5) ; +} diff --git a/src/libtipidee/tipidee_fcgi_beginrequest_body_unpack.c b/src/libtipidee/tipidee_fcgi_beginrequest_body_unpack.c new file mode 100644 index 0000000..a729b03 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_beginrequest_body_unpack.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <string.h> + +#include <skalibs/uint16.h> + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_beginrequest_body_unpack (char const *s, fcgi_beginrequest_body *bd) +{ + uint16_unpack_big(s, &bd->role) ; s += 2 ; + bd->flags = *s++ ; + memcpy((char *)bd->reserved, s, 5) ; s += 5 ; +} diff --git a/src/libtipidee/tipidee_fcgi_beginrequest_record_pack.c b/src/libtipidee/tipidee_fcgi_beginrequest_record_pack.c new file mode 100644 index 0000000..3329e8d --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_beginrequest_record_pack.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_beginrequest_record_pack (char *s, fcgi_beginrequest_record const *rec) +{ + tipidee_fcgi_header_pack(s, &rec->header) ; s += 8 ; + tipidee_fcgi_beginrequest_body_pack(s, &rec->body) ; +} diff --git a/src/libtipidee/tipidee_fcgi_beginrequest_record_unpack.c b/src/libtipidee/tipidee_fcgi_beginrequest_record_unpack.c new file mode 100644 index 0000000..c68a08f --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_beginrequest_record_unpack.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_beginrequest_record_unpack (char const *s, fcgi_beginrequest_record *rec) +{ + tipidee_fcgi_header_unpack(s, &rec->header) ; s += 8 ; + tipidee_fcgi_beginrequest_body_unpack(s, &rec->body) ; +} diff --git a/src/libtipidee/tipidee_fcgi_endrequest_body_pack.c b/src/libtipidee/tipidee_fcgi_endrequest_body_pack.c new file mode 100644 index 0000000..d289d6d --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_endrequest_body_pack.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <string.h> + +#include <skalibs/uint32.h> + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_endrequest_body_pack (char *s, fcgi_endrequest_body const *bd) +{ + uint32_pack_big(s, bd->appstatus) ; s += 4 ; + *s++ = bd->protostatus ; + memset(s, 0, 3) ; +} diff --git a/src/libtipidee/tipidee_fcgi_endrequest_body_unpack.c b/src/libtipidee/tipidee_fcgi_endrequest_body_unpack.c new file mode 100644 index 0000000..9f52f18 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_endrequest_body_unpack.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <string.h> + +#include <skalibs/uint32.h> + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_endrequest_body_unpack (char const *s, fcgi_endrequest_body *bd) +{ + uint32_unpack_big(s, &bd->appstatus) ; s += 4 ; + bd->protostatus = *s++ ; + memcpy((char *)bd->reserved, s, 3) ; s += 3 ; +} diff --git a/src/libtipidee/tipidee_fcgi_endrequest_record_pack.c b/src/libtipidee/tipidee_fcgi_endrequest_record_pack.c new file mode 100644 index 0000000..46f3ee9 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_endrequest_record_pack.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_endrequest_record_pack (char *s, fcgi_endrequest_record const *rec) +{ + tipidee_fcgi_header_pack(s, &rec->header) ; s += 8 ; + tipidee_fcgi_endrequest_body_pack(s, &rec->body) ; +} diff --git a/src/libtipidee/tipidee_fcgi_endrequest_record_unpack.c b/src/libtipidee/tipidee_fcgi_endrequest_record_unpack.c new file mode 100644 index 0000000..dc0acd5 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_endrequest_record_unpack.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_endrequest_record_unpack (char const *s, fcgi_endrequest_record *rec) +{ + tipidee_fcgi_header_unpack(s, &rec->header) ; s += 8 ; + tipidee_fcgi_endrequest_body_unpack(s, &rec->body) ; +} diff --git a/src/libtipidee/tipidee_fcgi_header_pack.c b/src/libtipidee/tipidee_fcgi_header_pack.c new file mode 100644 index 0000000..2f1a550 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_header_pack.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +#include <skalibs/uint16.h> + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_header_pack (char *s, fcgi_header const *hdr) +{ + *s++ = hdr->version ; + *s++ = hdr->type ; + uint16_pack_big(s, hdr->requestid) ; s += 2 ; + uint16_pack_big(s, hdr->len) ; s += 2 ; + *s++ = hdr->padlen ; + *s++ = 0 ; +} diff --git a/src/libtipidee/tipidee_fcgi_header_unpack.c b/src/libtipidee/tipidee_fcgi_header_unpack.c new file mode 100644 index 0000000..53debd7 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_header_unpack.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <skalibs/uint16.h> + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_header_unpack (char const *s, fcgi_header *hdr) +{ + hdr->version = *s++ ; + hdr->type = *s++ ; + uint16_unpack_big(s, &hdr->requestid) ; s += 2 ; + uint16_unpack_big(s, &hdr->len) ; s += 2 ; + hdr->padlen = *s++ ; +} diff --git a/src/libtipidee/tipidee_fcgi_unknowntype_body_pack.c b/src/libtipidee/tipidee_fcgi_unknowntype_body_pack.c new file mode 100644 index 0000000..f99da8f --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_unknowntype_body_pack.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <string.h> + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_unknowntype_body_pack (char *s, fcgi_unknowntype_body const *bd) +{ + *s++ = bd->type ; + memset(s, 0, 7) ; +} diff --git a/src/libtipidee/tipidee_fcgi_unknowntype_body_unpack.c b/src/libtipidee/tipidee_fcgi_unknowntype_body_unpack.c new file mode 100644 index 0000000..eb0684c --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_unknowntype_body_unpack.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <string.h> + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_unknowntype_body_unpack (char const *s, fcgi_unknowntype_body *bd) +{ + bd->type = *s++ ; + memcpy((char *)bd->reserved, s, 7) ; s += 7 ; +} diff --git a/src/libtipidee/tipidee_fcgi_unknowntype_record_pack.c b/src/libtipidee/tipidee_fcgi_unknowntype_record_pack.c new file mode 100644 index 0000000..9d962e2 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_unknowntype_record_pack.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_unknowntype_record_pack (char *s, fcgi_unknowntype_record const *rec) +{ + tipidee_fcgi_header_pack(s, &rec->header) ; s += 8 ; + tipidee_fcgi_unknowntype_body_pack(s, &rec->body) ; +} diff --git a/src/libtipidee/tipidee_fcgi_unknowntype_record_unpack.c b/src/libtipidee/tipidee_fcgi_unknowntype_record_unpack.c new file mode 100644 index 0000000..24c6631 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_unknowntype_record_unpack.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <tipidee/fcgi.h> + +void tipidee_fcgi_unknowntype_record_unpack (char const *s, fcgi_unknowntype_record *rec) +{ + tipidee_fcgi_header_unpack(s, &rec->header) ; s += 8 ; + tipidee_fcgi_unknowntype_body_unpack(s, &rec->body) ; +} |
