Smart Home firewall
Profile-based Smart Home firewall
Classes | Macros | Typedefs | Enumerations | Functions
http.h File Reference

HTTP message parser. More...

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for http.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  http_message
 

Macros

#define HTTP_MESSAGE_MIN_LEN   16
 
#define HTTP_METHOD_MAX_LEN   7
 
#define HTTP_URI_DEFAULT_LEN   100
 

Typedefs

typedef struct http_message http_message_t
 

Enumerations

enum  http_method_t {
  HTTP_GET , HTTP_HEAD , HTTP_POST , HTTP_PUT ,
  HTTP_DELETE , HTTP_CONNECT , HTTP_OPTIONS , HTTP_TRACE ,
  HTTP_UNKNOWN
}
 

Functions

bool is_http (uint8_t *data)
 Check if a TCP message is a HTTP message. More...
 
http_message_t http_parse_message (uint8_t *data, uint16_t dst_port)
 Parse the method and URI of HTTP message. More...
 
void http_free_message (http_message_t message)
 Free the memory allocated for a HTTP message. More...
 
char * http_method_to_str (http_method_t method)
 Converts a HTTP method from enum value to character string. More...
 
void http_print_message (http_message_t message)
 Print an HTTP message. More...
 

Detailed Description

HTTP message parser.

Date
2022-09-09

Typedef Documentation

◆ http_message_t

typedef struct http_message http_message_t

Abstraction of a HTTP message

Enumeration Type Documentation

◆ http_method_t

HTTP methods

Function Documentation

◆ http_free_message()

void http_free_message ( http_message_t  message)

Free the memory allocated for a HTTP message.

Parameters
messagethe HTTP message to free

◆ http_method_to_str()

char* http_method_to_str ( http_method_t  method)

Converts a HTTP method from enum value to character string.

Parameters
methodthe HTTP method in enum value
Returns
the same HTTP method as a character string

◆ http_parse_message()

http_message_t http_parse_message ( uint8_t *  data,
uint16_t  dst_port 
)

Parse the method and URI of HTTP message.

Parameters
datapointer to the start of the HTTP message
src_portTCP destination port
Returns
the parsed HTTP message
Parameters
datapointer to the start of the HTTP message
dst_portTCP destination port
Returns
the parsed HTTP message

◆ http_print_message()

void http_print_message ( http_message_t  message)

Print an HTTP message.

Parameters
messagethe HTTP message to print

Print an HTTP message.

Parameters
messagethe message to print

◆ is_http()

bool is_http ( uint8_t *  data)

Check if a TCP message is a HTTP message.

Parameters
datapointer to the start of the TCP payload
dst_portTCP destination port
Returns
true if the message is a HTTP message
false if the message is not a HTTP message