1 | #ifndef MODULE_WEBIF_LIB_H_
|
---|
2 | #define MODULE_WEBIF_LIB_H_
|
---|
3 |
|
---|
4 | #ifdef WITH_SSL
|
---|
5 | #include <openssl/crypto.h>
|
---|
6 | #include <openssl/ssl.h>
|
---|
7 | #include <openssl/err.h>
|
---|
8 | #endif
|
---|
9 |
|
---|
10 | #include "cscrypt/md5.h"
|
---|
11 |
|
---|
12 | /* The server string in the http header */
|
---|
13 | #define SERVER "webserver/1.0"
|
---|
14 | /* The protocol that gets output. Currently only 1.0 is possible as 1.1 requires many features we don't have. */
|
---|
15 | #define PROTOCOL "HTTP/1.0"
|
---|
16 | /* The RFC1123 time format which is used in http headers. */
|
---|
17 | #define RFC1123FMT "%a, %d %b %Y %H:%M:%S GMT"
|
---|
18 | /* The realm for http digest authentication. Gets displayed to browser. */
|
---|
19 | #define AUTHREALM "Forbidden"
|
---|
20 | /* How long a nonce is valid in seconds after a first request with this nonce has been received. If the nonce isn't valid anymore, the browser gets a "stale=true" message and must resubmit with the current nonce. */
|
---|
21 | #define AUTHNONCEVALIDSECS 15
|
---|
22 | /* When a nonce gets expired after it has been first given to the client. */
|
---|
23 | #define AUTHNONCEEXPIRATION 120
|
---|
24 | /* The amount of hash buckets (based on opaque string) for better performance. */
|
---|
25 | #define AUTHNONCEHASHBUCKETS 4
|
---|
26 | /* The maximum amount of GET parameters the webserver will parse. */
|
---|
27 | #define MAXGETPARAMS 100
|
---|
28 | /* The refresh delay (in seconds) when stopping OSCam via http. */
|
---|
29 | #define SHUTDOWNREFRESH 30
|
---|
30 |
|
---|
31 | #define TOUCH_SUBDIR "touch/"
|
---|
32 |
|
---|
33 | struct s_connection {
|
---|
34 | int32_t socket;
|
---|
35 | struct s_client *cl;
|
---|
36 | IN_ADDR_T remote;
|
---|
37 | #ifdef WITH_SSL
|
---|
38 | SSL *ssl;
|
---|
39 | #endif
|
---|
40 | };
|
---|
41 |
|
---|
42 | struct uriparams {
|
---|
43 | int32_t paramcount;
|
---|
44 | char *params[MAXGETPARAMS];
|
---|
45 | char *values[MAXGETPARAMS];
|
---|
46 | };
|
---|
47 |
|
---|
48 | struct s_nonce{
|
---|
49 | char nonce[(MD5_DIGEST_LENGTH * 2) + 1];
|
---|
50 | char opaque[(MD5_DIGEST_LENGTH * 2) + 1];
|
---|
51 | time_t expirationdate;
|
---|
52 | time_t firstuse;
|
---|
53 | struct s_nonce *next;
|
---|
54 | };
|
---|
55 |
|
---|
56 | extern time_t parse_modifiedsince(char * value);
|
---|
57 | extern void calculate_opaque(IN_ADDR_T addr, char *opaque);
|
---|
58 | extern void init_noncelocks(void);
|
---|
59 | extern void calculate_nonce(char * nonce, char *result, char *opaque);
|
---|
60 | extern int32_t check_auth(char *authstring, char *method, char *path, IN_ADDR_T addr, char *expectednonce, char *opaque);
|
---|
61 | extern int32_t webif_write_raw(char *buf, FILE* f, int32_t len);
|
---|
62 | extern int32_t webif_write(char *buf, FILE* f);
|
---|
63 | extern int32_t webif_read(char *buf, int32_t num, FILE *f);
|
---|
64 | extern void send_headers(FILE *f, int32_t status, char *title, char *extra, char *mime, int32_t cache, int32_t length, char *content, int8_t forcePlain);
|
---|
65 | extern void send_error(FILE *f, int32_t status, char *title, char *extra, char *text, int8_t forcePlain);
|
---|
66 | extern void send_error500(FILE *f);
|
---|
67 | extern void send_header304(FILE *f, char *extraheader);
|
---|
68 | extern void send_file(FILE *f, char *filename, char* subdir, time_t modifiedheader, uint32_t etagheader, char *extraheader);
|
---|
69 | extern void urldecode(char *s);
|
---|
70 | extern void b64prepare(void);
|
---|
71 | extern int32_t b64decode(unsigned char *result);
|
---|
72 | extern void parseParams(struct uriparams *params, char *pch);
|
---|
73 | extern char *getParam(struct uriparams *params, char *name);
|
---|
74 |
|
---|
75 | #ifdef WITH_SSL
|
---|
76 | extern SSL * cur_ssl(void);
|
---|
77 | extern SSL_CTX *SSL_Webif_Init(void);
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | #endif
|
---|