My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
connection-handler.h
Go to the documentation of this file.
1 /*
2 START OF LICENSE STUB
3  DeDOS: Declarative Dispersion-Oriented Software
4  Copyright (C) 2017 University of Pennsylvania, Georgetown University
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 END OF LICENSE STUB
19 */
20 #ifndef CONNECTION_HANDLER_H_
21 #define CONNECTION_HANDLER_H_
22 
23 #include <openssl/ssl.h>
24 #include "webserver.h"
25 #include "dbops.h"
26 #include "request_parser.h"
27 
28 #define MAX_HEADER_LEN 4096
29 #define MAX_FILEPATH_LEN 512
30 #define MAX_BODY_LEN 4096
31 #define MAX_RECV_LEN 4096
32 
33 struct connection {
34  int fd;
35  SSL *ssl;
37 };
38 
39 struct read_state {
40  struct connection conn;
42  int req_len;
43 };
44 void init_read_state(struct read_state *state, struct connection *conn);
45 
46 struct http_state {
47  struct connection conn;
49  struct db_state db;
50 };
51 void init_http_state(struct http_state *state, struct connection *conn);
52 
54  struct connection conn;
60  int body_len;
61 };
62 void init_response_state(struct response_state *state, struct connection *conn);
63 
64 void init_connection(struct connection *conn, int fd);
65 
66 int accept_connection(struct connection *conn, int use_ssl);
67 int read_request(struct read_state *state);
68 int parse_request(char *req, int req_len, struct http_state *state);
70 int close_connection(struct connection *conn);
71 int access_database(char *url, struct db_state *state);
72 
73 int has_regex(char *url);
74 
75 int craft_error_response(char *url, char *response);
76 int craft_nonregex_response(char *url, char *response);
77 int craft_regex_response(char *url, char *response);
78 
79 
80 #endif
int craft_regex_response(char *url, char *response)
struct connection conn
struct parser_state parser
void init_connection(struct connection *conn, int fd)
struct connection conn
int has_regex(char *url)
int craft_error_response(char *url, char *response)
int close_connection(struct connection *conn)
int write_response(struct response_state *state)
#define MAX_FILEPATH_LEN
int accept_connection(struct connection *conn, int use_ssl)
#define MAX_URL_LEN
void init_read_state(struct read_state *state, struct connection *conn)
#define MAX_BODY_LEN
int read_request(struct read_state *state)
struct db_state db
char req[4096]
int parse_request(char *req, int req_len, struct http_state *state)
int access_database(char *url, struct db_state *state)
Definition: dbops.h:32
#define MAX_RECV_LEN
struct connection conn
void init_http_state(struct http_state *state, struct connection *conn)
webserver_status
Definition: webserver.h:29
int craft_nonregex_response(char *url, char *response)
#define MAX_HEADER_LEN
state
Definition: http_parser.c:298
enum webserver_status status
void init_response_state(struct response_state *state, struct connection *conn)