Smart Home firewall
Profile-based Smart Home firewall
http.h
Go to the documentation of this file.
1 
10 #ifndef _PROTOCOL_PARSERS_HTTP_
11 #define _PROTOCOL_PARSERS_HTTP_
12 
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <stdbool.h>
17 
18 #define HTTP_MESSAGE_MIN_LEN 16 // Minimum length of a HTTP message
19 #define HTTP_METHOD_MAX_LEN 7 // Maximum length of a HTTP method
20 #define HTTP_URI_DEFAULT_LEN 100 // Default length of a HTTP URI
21 
22 
26 typedef enum
27 {
28  HTTP_GET,
29  HTTP_HEAD,
30  HTTP_POST,
31  HTTP_PUT,
32  HTTP_DELETE,
33  HTTP_CONNECT,
34  HTTP_OPTIONS,
35  HTTP_TRACE,
36  HTTP_UNKNOWN
38 
42 typedef struct http_message {
43  bool is_request; // True if the message is a request, false if it is a response
44  http_method_t method; // HTTP method (GET, POST, etc.)
45  char *uri; // Message URI
47 
48 
50 
52 
61 bool is_http(uint8_t *data);
62 
70 http_message_t http_parse_message(uint8_t *data, uint16_t dst_port);
71 
72 
74 
80 void http_free_message(http_message_t message);
81 
82 
84 
91 char* http_method_to_str(http_method_t method);
92 
99 
100 
101 #endif /* _PROTOCOL_PARSERS_HTTP_ */
bool is_http(uint8_t *data)
Check if a TCP message is a HTTP message.
Definition: http.c:90
http_method_t
Definition: http.h:27
char * http_method_to_str(http_method_t method)
Converts a HTTP method from enum value to character string.
Definition: http.c:186
void http_free_message(http_message_t message)
Free the memory allocated for a HTTP message.
Definition: http.c:172
struct http_message http_message_t
void http_print_message(http_message_t message)
Print an HTTP message.
Definition: http.c:222
http_message_t http_parse_message(uint8_t *data, uint16_t dst_port)
Parse the method and URI of HTTP message.
Definition: http.c:149
Definition: http.h:42