package/busybox: add upstream udhcp hostname truncation fix, bump release number
[openwrt.git] / package / uhttpd / src / uhttpd.h
1 /*
2 * uhttpd - Tiny single-threaded httpd - Main header
3 *
4 * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #ifndef _UHTTPD_
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <unistd.h>
25 #include <signal.h>
26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <sys/select.h>
29 #include <sys/wait.h>
30 #include <netinet/in.h>
31 #include <arpa/inet.h>
32 #include <linux/limits.h>
33 #include <netdb.h>
34 #include <ctype.h>
35 #include <errno.h>
36 #include <dlfcn.h>
37
38
39 #ifdef HAVE_LUA
40 #include <lua.h>
41 #endif
42
43 #ifdef HAVE_TLS
44 #include <openssl/ssl.h>
45 #endif
46
47
48 #define UH_LIMIT_MSGHEAD 4096
49 #define UH_LIMIT_HEADERS 64
50
51 #define UH_LIMIT_LISTENERS 16
52 #define UH_LIMIT_CLIENTS 64
53 #define UH_LIMIT_AUTHREALMS 8
54
55 #define UH_HTTP_MSG_GET 0
56 #define UH_HTTP_MSG_HEAD 1
57 #define UH_HTTP_MSG_POST 2
58
59 struct listener;
60 struct client;
61 struct http_request;
62
63 struct config {
64 char docroot[PATH_MAX];
65 char *realm;
66 char *file;
67 int no_symlinks;
68 int network_timeout;
69 #ifdef HAVE_CGI
70 char *cgi_prefix;
71 #endif
72 #ifdef HAVE_LUA
73 char *lua_prefix;
74 char *lua_handler;
75 lua_State * (*lua_init) (const char *handler);
76 void (*lua_close) (lua_State *L);
77 void (*lua_request) (struct client *cl, struct http_request *req, lua_State *L);
78 #endif
79 #if defined(HAVE_CGI) || defined(HAVE_LUA)
80 int script_timeout;
81 #endif
82 #ifdef HAVE_TLS
83 char *cert;
84 char *key;
85 SSL_CTX *tls;
86 SSL_CTX * (*tls_init) (void);
87 int (*tls_cert) (SSL_CTX *c, const char *file);
88 int (*tls_key) (SSL_CTX *c, const char *file);
89 void (*tls_free) (struct listener *l);
90 void (*tls_accept) (struct client *c);
91 void (*tls_close) (struct client *c);
92 int (*tls_recv) (struct client *c, void *buf, int len);
93 int (*tls_send) (struct client *c, void *buf, int len);
94 #endif
95 };
96
97 struct listener {
98 int socket;
99 struct sockaddr_in6 addr;
100 struct config *conf;
101 #ifdef HAVE_TLS
102 SSL_CTX *tls;
103 #endif
104 };
105
106 struct client {
107 int socket;
108 int peeklen;
109 char peekbuf[UH_LIMIT_MSGHEAD];
110 struct listener *server;
111 struct sockaddr_in6 servaddr;
112 struct sockaddr_in6 peeraddr;
113 #ifdef HAVE_TLS
114 SSL *tls;
115 #endif
116 };
117
118 struct auth_realm {
119 char path[PATH_MAX];
120 char user[32];
121 char pass[128];
122 };
123
124 struct http_request {
125 int method;
126 float version;
127 char *url;
128 char *headers[UH_LIMIT_HEADERS];
129 struct auth_realm *realm;
130 };
131
132 struct http_response {
133 int statuscode;
134 char *statusmsg;
135 char *headers[UH_LIMIT_HEADERS];
136 };
137
138 #endif
139
This page took 0.0573090000000001 seconds and 5 git commands to generate.