1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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
|