tcpflow  1.6.1
About: tcpflow is a TCP/IP packet demultiplexer that captures data transmitted as part of TCP connections (flows), and stores the data in a way that is convenient for protocol analysis and debugging.
  Fossies Dox: tcpflow-1.6.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

http_parser.h File Reference
#include <stddef.h>
#include <stdint.h>
Include dependency graph for http_parser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  http_parser
 
struct  http_parser_settings
 
struct  http_parser_url
 

Macros

#define HTTP_PARSER_VERSION_MAJOR   2
 
#define HTTP_PARSER_VERSION_MINOR   7
 
#define HTTP_PARSER_VERSION_PATCH   1
 
#define HTTP_PARSER_STRICT   1
 
#define HTTP_MAX_HEADER_SIZE   (80*1024)
 
#define HTTP_STATUS_MAP(XX)
 
#define XX(num, name, string)   HTTP_STATUS_##name = num,
 
#define HTTP_METHOD_MAP(XX)
 
#define XX(num, name, string)   HTTP_##name = num,
 
#define HTTP_ERRNO_MAP(XX)
 
#define HTTP_ERRNO_GEN(n, s)   HPE_##n,
 
#define HTTP_PARSER_ERRNO(p)   ((enum http_errno) (p)->http_errno)
 

Typedefs

typedef struct http_parser http_parser
 
typedef struct http_parser_settings http_parser_settings
 
typedef int(* http_data_cb) (http_parser *, const char *at, size_t length)
 
typedef int(* http_cb) (http_parser *)
 

Enumerations

enum  http_status {
  HTTP_STATUS_CONTINUE = 100 , HTTP_STATUS_SWITCHING_PROTOCOLS = 101 , HTTP_STATUS_PROCESSING = 102 , HTTP_STATUS_OK = 200 ,
  HTTP_STATUS_CREATED = 201 , HTTP_STATUS_ACCEPTED = 202 , HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203 , HTTP_STATUS_NO_CONTENT = 204 ,
  HTTP_STATUS_RESET_CONTENT = 205 , HTTP_STATUS_PARTIAL_CONTENT = 206 , HTTP_STATUS_MULTI_STATUS = 207 , HTTP_STATUS_ALREADY_REPORTED = 208 ,
  HTTP_STATUS_IM_USED = 226 , HTTP_STATUS_MULTIPLE_CHOICES = 300 , HTTP_STATUS_MOVED_PERMANENTLY = 301 , HTTP_STATUS_FOUND = 302 ,
  HTTP_STATUS_SEE_OTHER = 303 , HTTP_STATUS_NOT_MODIFIED = 304 , HTTP_STATUS_USE_PROXY = 305 , HTTP_STATUS_TEMPORARY_REDIRECT = 307 ,
  HTTP_STATUS_PERMANENT_REDIRECT = 308 , HTTP_STATUS_BAD_REQUEST = 400 , HTTP_STATUS_UNAUTHORIZED = 401 , HTTP_STATUS_PAYMENT_REQUIRED = 402 ,
  HTTP_STATUS_FORBIDDEN = 403 , HTTP_STATUS_NOT_FOUND = 404 , HTTP_STATUS_METHOD_NOT_ALLOWED = 405 , HTTP_STATUS_NOT_ACCEPTABLE = 406 ,
  HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407 , HTTP_STATUS_REQUEST_TIMEOUT = 408 , HTTP_STATUS_CONFLICT = 409 , HTTP_STATUS_GONE = 410 ,
  HTTP_STATUS_LENGTH_REQUIRED = 411 , HTTP_STATUS_PRECONDITION_FAILED = 412 , HTTP_STATUS_PAYLOAD_TOO_LARGE = 413 , HTTP_STATUS_URI_TOO_LONG = 414 ,
  HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415 , HTTP_STATUS_RANGE_NOT_SATISFIABLE = 416 , HTTP_STATUS_EXPECTATION_FAILED = 417 , HTTP_STATUS_MISDIRECTED_REQUEST = 421 ,
  HTTP_STATUS_UNPROCESSABLE_ENTITY = 422 , HTTP_STATUS_LOCKED = 423 , HTTP_STATUS_FAILED_DEPENDENCY = 424 , HTTP_STATUS_UPGRADE_REQUIRED = 426 ,
  HTTP_STATUS_PRECONDITION_REQUIRED = 428 , HTTP_STATUS_TOO_MANY_REQUESTS = 429 , HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431 , HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS = 451 ,
  HTTP_STATUS_INTERNAL_SERVER_ERROR = 500 , HTTP_STATUS_NOT_IMPLEMENTED = 501 , HTTP_STATUS_BAD_GATEWAY = 502 , HTTP_STATUS_SERVICE_UNAVAILABLE = 503 ,
  HTTP_STATUS_GATEWAY_TIMEOUT = 504 , HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505 , HTTP_STATUS_VARIANT_ALSO_NEGOTIATES = 506 , HTTP_STATUS_INSUFFICIENT_STORAGE = 507 ,
  HTTP_STATUS_LOOP_DETECTED = 508 , HTTP_STATUS_NOT_EXTENDED = 510 , HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511
}
 
enum  http_method {
  HTTP_STATUS_DELETE = 0 , HTTP_STATUS_GET = 1 , HTTP_STATUS_HEAD = 2 , HTTP_STATUS_POST = 3 ,
  HTTP_STATUS_PUT = 4 , HTTP_STATUS_CONNECT = 5 , HTTP_STATUS_OPTIONS = 6 , HTTP_STATUS_TRACE = 7 ,
  HTTP_STATUS_COPY = 8 , HTTP_STATUS_LOCK = 9 , HTTP_STATUS_MKCOL = 10 , HTTP_STATUS_MOVE = 11 ,
  HTTP_STATUS_PROPFIND = 12 , HTTP_STATUS_PROPPATCH = 13 , HTTP_STATUS_SEARCH = 14 , HTTP_STATUS_UNLOCK = 15 ,
  HTTP_STATUS_BIND = 16 , HTTP_STATUS_REBIND = 17 , HTTP_STATUS_UNBIND = 18 , HTTP_STATUS_ACL = 19 ,
  HTTP_STATUS_REPORT = 20 , HTTP_STATUS_MKACTIVITY = 21 , HTTP_STATUS_CHECKOUT = 22 , HTTP_STATUS_MERGE = 23 ,
  HTTP_STATUS_MSEARCH = 24 , HTTP_STATUS_NOTIFY = 25 , HTTP_STATUS_SUBSCRIBE = 26 , HTTP_STATUS_UNSUBSCRIBE = 27 ,
  HTTP_STATUS_PATCH = 28 , HTTP_STATUS_PURGE = 29 , HTTP_STATUS_MKCALENDAR = 30 , HTTP_STATUS_LINK = 31 ,
  HTTP_STATUS_UNLINK = 32
}
 
enum  http_parser_type { HTTP_REQUEST , HTTP_RESPONSE , HTTP_BOTH }
 
enum  flags {
  F_CHUNKED = 1 << 0 , F_CONNECTION_KEEP_ALIVE = 1 << 1 , F_CONNECTION_CLOSE = 1 << 2 , F_CONNECTION_UPGRADE = 1 << 3 ,
  F_TRAILING = 1 << 4 , F_UPGRADE = 1 << 5 , F_SKIPBODY = 1 << 6 , F_CONTENTLENGTH = 1 << 7
}
 
enum  http_errno {
  HPE_OK , HPE_CB_message_begin , HPE_CB_url , HPE_CB_header_field ,
  HPE_CB_header_value , HPE_CB_headers_complete , HPE_CB_body , HPE_CB_message_complete ,
  HPE_CB_status , HPE_CB_chunk_header , HPE_CB_chunk_complete , HPE_INVALID_EOF_STATE ,
  HPE_HEADER_OVERFLOW , HPE_CLOSED_CONNECTION , HPE_INVALID_VERSION , HPE_INVALID_STATUS ,
  HPE_INVALID_METHOD , HPE_INVALID_URL , HPE_INVALID_HOST , HPE_INVALID_PORT ,
  HPE_INVALID_PATH , HPE_INVALID_QUERY_STRING , HPE_INVALID_FRAGMENT , HPE_LF_EXPECTED ,
  HPE_INVALID_HEADER_TOKEN , HPE_INVALID_CONTENT_LENGTH , HPE_UNEXPECTED_CONTENT_LENGTH , HPE_INVALID_CHUNK_SIZE ,
  HPE_INVALID_CONSTANT , HPE_INVALID_INTERNAL_STATE , HPE_STRICT , HPE_PAUSED ,
  HPE_UNKNOWN
}
 
enum  http_parser_url_fields {
  UF_SCHEMA = 0 , UF_HOST = 1 , UF_PORT = 2 , UF_PATH = 3 ,
  UF_QUERY = 4 , UF_FRAGMENT = 5 , UF_USERINFO = 6 , UF_MAX = 7
}
 

Functions

unsigned long http_parser_version (void)
 
void http_parser_init (http_parser *parser, enum http_parser_type type)
 
void http_parser_settings_init (http_parser_settings *settings)
 
size_t http_parser_execute (http_parser *parser, const http_parser_settings *settings, const char *data, size_t len)
 
int http_should_keep_alive (const http_parser *parser)
 
const char * http_method_str (enum http_method m)
 
const char * http_errno_name (enum http_errno err)
 
const char * http_errno_description (enum http_errno err)
 
void http_parser_url_init (struct http_parser_url *u)
 
int http_parser_parse_url (const char *buf, size_t buflen, int is_connect, struct http_parser_url *u)
 
void http_parser_pause (http_parser *parser, int paused)
 
int http_body_is_final (const http_parser *parser)
 

Macro Definition Documentation

◆ HTTP_ERRNO_GEN

#define HTTP_ERRNO_GEN (   n,
 
)    HPE_##n,

Definition at line 278 of file http_parser.h.

◆ HTTP_ERRNO_MAP

#define HTTP_ERRNO_MAP (   XX)

Definition at line 231 of file http_parser.h.

◆ HTTP_MAX_HEADER_SIZE

#define HTTP_MAX_HEADER_SIZE   (80*1024)

Definition at line 63 of file http_parser.h.

◆ HTTP_METHOD_MAP

#define HTTP_METHOD_MAP (   XX)

Definition at line 162 of file http_parser.h.

◆ HTTP_PARSER_ERRNO

#define HTTP_PARSER_ERRNO (   p)    ((enum http_errno) (p)->http_errno)

Definition at line 285 of file http_parser.h.

◆ HTTP_PARSER_STRICT

#define HTTP_PARSER_STRICT   1

Definition at line 52 of file http_parser.h.

◆ HTTP_PARSER_VERSION_MAJOR

#define HTTP_PARSER_VERSION_MAJOR   2

Definition at line 28 of file http_parser.h.

◆ HTTP_PARSER_VERSION_MINOR

#define HTTP_PARSER_VERSION_MINOR   7

Definition at line 29 of file http_parser.h.

◆ HTTP_PARSER_VERSION_PATCH

#define HTTP_PARSER_VERSION_PATCH   1

Definition at line 30 of file http_parser.h.

◆ HTTP_STATUS_MAP

#define HTTP_STATUS_MAP (   XX)

Definition at line 93 of file http_parser.h.

◆ XX [1/2]

#define XX (   num,
  name,
  string 
)    HTTP_STATUS_##name = num,

Definition at line 206 of file http_parser.h.

◆ XX [2/2]

#define XX (   num,
  name,
  string 
)    HTTP_##name = num,

Definition at line 206 of file http_parser.h.

Typedef Documentation

◆ http_cb

typedef int(* http_cb) (http_parser *)

Definition at line 89 of file http_parser.h.

◆ http_data_cb

typedef int(* http_data_cb) (http_parser *, const char *at, size_t length)

Definition at line 88 of file http_parser.h.

◆ http_parser

typedef struct http_parser http_parser

Definition at line 1 of file http_parser.h.

◆ http_parser_settings

Definition at line 1 of file http_parser.h.

Enumeration Type Documentation

◆ flags

enum flags
Enumerator
F_CHUNKED 
F_CONNECTION_KEEP_ALIVE 
F_CONNECTION_CLOSE 
F_CONNECTION_UPGRADE 
F_TRAILING 
F_UPGRADE 
F_SKIPBODY 
F_CONTENTLENGTH 

Definition at line 215 of file http_parser.h.

◆ http_errno

enum http_errno
Enumerator
HPE_OK 
HPE_CB_message_begin 
HPE_CB_url 
HPE_CB_header_field 
HPE_CB_header_value 
HPE_CB_headers_complete 
HPE_CB_body 
HPE_CB_message_complete 
HPE_CB_status 
HPE_CB_chunk_header 
HPE_CB_chunk_complete 
HPE_INVALID_EOF_STATE 
HPE_HEADER_OVERFLOW 
HPE_CLOSED_CONNECTION 
HPE_INVALID_VERSION 
HPE_INVALID_STATUS 
HPE_INVALID_METHOD 
HPE_INVALID_URL 
HPE_INVALID_HOST 
HPE_INVALID_PORT 
HPE_INVALID_PATH 
HPE_INVALID_QUERY_STRING 
HPE_INVALID_FRAGMENT 
HPE_LF_EXPECTED 
HPE_INVALID_HEADER_TOKEN 
HPE_INVALID_CONTENT_LENGTH 
HPE_UNEXPECTED_CONTENT_LENGTH 
HPE_INVALID_CHUNK_SIZE 
HPE_INVALID_CONSTANT 
HPE_INVALID_INTERNAL_STATE 
HPE_STRICT 
HPE_PAUSED 
HPE_UNKNOWN 

Definition at line 279 of file http_parser.h.

◆ http_method

Enumerator
HTTP_STATUS_DELETE 
HTTP_STATUS_GET 
HTTP_STATUS_HEAD 
HTTP_STATUS_POST 
HTTP_STATUS_PUT 
HTTP_STATUS_CONNECT 
HTTP_STATUS_OPTIONS 
HTTP_STATUS_TRACE 
HTTP_STATUS_COPY 
HTTP_STATUS_LOCK 
HTTP_STATUS_MKCOL 
HTTP_STATUS_MOVE 
HTTP_STATUS_PROPFIND 
HTTP_STATUS_PROPPATCH 
HTTP_STATUS_SEARCH 
HTTP_STATUS_UNLOCK 
HTTP_STATUS_BIND 
HTTP_STATUS_REBIND 
HTTP_STATUS_UNBIND 
HTTP_STATUS_ACL 
HTTP_STATUS_REPORT 
HTTP_STATUS_MKACTIVITY 
HTTP_STATUS_CHECKOUT 
HTTP_STATUS_MERGE 
HTTP_STATUS_MSEARCH 
HTTP_STATUS_NOTIFY 
HTTP_STATUS_SUBSCRIBE 
HTTP_STATUS_UNSUBSCRIBE 
HTTP_STATUS_PATCH 
HTTP_STATUS_PURGE 
HTTP_STATUS_MKCALENDAR 
HTTP_STATUS_LINK 
HTTP_STATUS_UNLINK 

Definition at line 204 of file http_parser.h.

◆ http_parser_type

Enumerator
HTTP_REQUEST 
HTTP_RESPONSE 
HTTP_BOTH 

Definition at line 211 of file http_parser.h.

◆ http_parser_url_fields

Enumerator
UF_SCHEMA 
UF_HOST 
UF_PORT 
UF_PATH 
UF_QUERY 
UF_FRAGMENT 
UF_USERINFO 
UF_MAX 

Definition at line 336 of file http_parser.h.

◆ http_status

Enumerator
HTTP_STATUS_CONTINUE 
HTTP_STATUS_SWITCHING_PROTOCOLS 
HTTP_STATUS_PROCESSING 
HTTP_STATUS_OK 
HTTP_STATUS_CREATED 
HTTP_STATUS_ACCEPTED 
HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION 
HTTP_STATUS_NO_CONTENT 
HTTP_STATUS_RESET_CONTENT 
HTTP_STATUS_PARTIAL_CONTENT 
HTTP_STATUS_MULTI_STATUS 
HTTP_STATUS_ALREADY_REPORTED 
HTTP_STATUS_IM_USED 
HTTP_STATUS_MULTIPLE_CHOICES 
HTTP_STATUS_MOVED_PERMANENTLY 
HTTP_STATUS_FOUND 
HTTP_STATUS_SEE_OTHER 
HTTP_STATUS_NOT_MODIFIED 
HTTP_STATUS_USE_PROXY 
HTTP_STATUS_TEMPORARY_REDIRECT 
HTTP_STATUS_PERMANENT_REDIRECT 
HTTP_STATUS_BAD_REQUEST 
HTTP_STATUS_UNAUTHORIZED 
HTTP_STATUS_PAYMENT_REQUIRED 
HTTP_STATUS_FORBIDDEN 
HTTP_STATUS_NOT_FOUND 
HTTP_STATUS_METHOD_NOT_ALLOWED 
HTTP_STATUS_NOT_ACCEPTABLE 
HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED 
HTTP_STATUS_REQUEST_TIMEOUT 
HTTP_STATUS_CONFLICT 
HTTP_STATUS_GONE 
HTTP_STATUS_LENGTH_REQUIRED 
HTTP_STATUS_PRECONDITION_FAILED 
HTTP_STATUS_PAYLOAD_TOO_LARGE 
HTTP_STATUS_URI_TOO_LONG 
HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE 
HTTP_STATUS_RANGE_NOT_SATISFIABLE 
HTTP_STATUS_EXPECTATION_FAILED 
HTTP_STATUS_MISDIRECTED_REQUEST 
HTTP_STATUS_UNPROCESSABLE_ENTITY 
HTTP_STATUS_LOCKED 
HTTP_STATUS_FAILED_DEPENDENCY 
HTTP_STATUS_UPGRADE_REQUIRED 
HTTP_STATUS_PRECONDITION_REQUIRED 
HTTP_STATUS_TOO_MANY_REQUESTS 
HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE 
HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS 
HTTP_STATUS_INTERNAL_SERVER_ERROR 
HTTP_STATUS_NOT_IMPLEMENTED 
HTTP_STATUS_BAD_GATEWAY 
HTTP_STATUS_SERVICE_UNAVAILABLE 
HTTP_STATUS_GATEWAY_TIMEOUT 
HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED 
HTTP_STATUS_VARIANT_ALSO_NEGOTIATES 
HTTP_STATUS_INSUFFICIENT_STORAGE 
HTTP_STATUS_LOOP_DETECTED 
HTTP_STATUS_NOT_EXTENDED 
HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED 

Definition at line 154 of file http_parser.h.

Function Documentation

◆ http_body_is_final()

int http_body_is_final ( const http_parser parser)

◆ http_errno_description()

const char* http_errno_description ( enum http_errno  err)

Definition at line 2107 of file http_parser.c.

References ARRAY_SIZE, err(), and http_strerror_tab.

◆ http_errno_name()

const char* http_errno_name ( enum http_errno  err)

Definition at line 2101 of file http_parser.c.

References ARRAY_SIZE, err(), and http_strerror_tab.

◆ http_method_str()

const char* http_method_str ( enum http_method  m)

Definition at line 2077 of file http_parser.c.

References ELEM_AT, and method_strings.

◆ http_parser_execute()

size_t http_parser_execute ( http_parser parser,
const http_parser_settings settings,
const char *  data,
size_t  len 
)

Definition at line 632 of file http_parser.c.

Referenced by scan_http().

◆ http_parser_init()

void http_parser_init ( http_parser parser,
enum http_parser_type  type 
)

◆ http_parser_parse_url()

◆ http_parser_pause()

void http_parser_pause ( http_parser parser,
int  paused 
)

Definition at line 2386 of file http_parser.c.

References HPE_OK, HPE_PAUSED, HTTP_PARSER_ERRNO, and SET_ERRNO.

◆ http_parser_settings_init()

void http_parser_settings_init ( http_parser_settings settings)

Definition at line 2095 of file http_parser.c.

◆ http_parser_url_init()

void http_parser_url_init ( struct http_parser_url u)

Definition at line 2277 of file http_parser.c.

◆ http_parser_version()

unsigned long http_parser_version ( void  )

◆ http_should_keep_alive()

int http_should_keep_alive ( const http_parser parser)