diff options
Diffstat (limited to 'decoders/http/http_decoder.h')
| -rw-r--r-- | decoders/http/http_decoder.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/decoders/http/http_decoder.h b/decoders/http/http_decoder.h new file mode 100644 index 0000000..06cc72b --- /dev/null +++ b/decoders/http/http_decoder.h @@ -0,0 +1,104 @@ + +#pragma once +#include <stdint.h> +#include <stddef.h> +#include "stellar/session.h" +#include "stellar/http.h" +#include "llhttp.h" +#include "http_decoder_stat.h" +#include "http_decoder_half.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define HTTP_IDENTIFY_LEN 16 +#define HTTP_HEADERS_CACHE_MAX_SIZE 4096 + +#define HTTP_MODULE_NAME "HTTP" +#define HTTP_EXDATA_NAME "HTTP_EXDATA" + +#ifndef likely +#define likely(x) __builtin_expect((x), 1) +#endif +#ifndef unlikely +#define unlikely(x) __builtin_expect((x), 0) +#endif + +#ifndef UNUSED +#define UNUSED __attribute__((unused)) +#endif + + struct http_config + { + int decompress_switch; + // int stat_output_interval; + // size_t mempool_size; // per session mempool size + }; + + enum http_topic_type + { + HTTP_TOPIC_REQ_HEADER = 0, + HTTP_TOPIC_REQ_BODY, + HTTP_TOPIC_RES_HEADER, + HTTP_TOPIC_RES_BODY, + HTTP_TOPIC_MAX, + }; + + struct http_topic_compose + { + const char *topic_name; + int topic_id; + }; + + struct http_topic_manager + { + struct http_topic_compose topic_compose[HTTP_TOPIC_MAX]; + }; + + struct http + { + struct module_manager *mod_mgr_ref; + struct logger *logger_ref; + struct http_topic_manager *http_topic_mgr; + int exdata_id; + int plugin_id; + struct http_config hd_cfg; + struct http_stat stat; + }; + + struct http_half; + struct http_half_data; + struct http_decoder + { + struct http_half *flow_c2s; + struct http_half *flow_s2c; + }; + + struct http_exdata + { + int ignore_session; + struct http *http_env; + struct session *sess; + struct http_decoder *decoder; + }; + + struct http_message + { + struct session *sess_ref; + enum http_topic_type topic_type; + struct http_half_data *flow_data; + enum http_event event; + }; + + void http_on_tcp_stream_cb(struct session *sess, enum session_state state, const char *tcp_payload, uint32_t tcp_payload_len, void *args); + struct http_topic_manager *http_topic_mgr_init(struct module_manager *mod_mgr); + struct http_half *http_flow_get_nx(struct http_exdata *exdata, enum flow_type flow_dir, struct session *sess, struct http *http_env); + void http_message_free_cb(void *msg, void *msg_free_arg); + void http_exdata_free_cb(int idx, void *ex_data, void *plugin_env); + void http_topic_mgr_free(struct http_topic_manager *topic_mgr); + +#ifdef __cplusplus +} +#endif
\ No newline at end of file |
