summaryrefslogtreecommitdiff
path: root/src/http_decoder_inc.h
diff options
context:
space:
mode:
authorlijia <[email protected]>2024-05-24 22:47:32 +0800
committerlijia <[email protected]>2024-06-03 11:08:06 +0800
commit1c232f0176c43c93c3e787ac83f3573bf42c58f1 (patch)
tree734c31a97ec38847972b70a18ec075fd415bb5f6 /src/http_decoder_inc.h
parent22d071e23ff423242f51dce2eab1477b5fb9d106 (diff)
Adapt to stellar2.0;update API,add HDR_END,BODY_END,TRANSACTION_NEW,FREE msg.v2.0.2
Diffstat (limited to 'src/http_decoder_inc.h')
-rw-r--r--src/http_decoder_inc.h94
1 files changed, 86 insertions, 8 deletions
diff --git a/src/http_decoder_inc.h b/src/http_decoder_inc.h
index 2d6a5c0..3e2939d 100644
--- a/src/http_decoder_inc.h
+++ b/src/http_decoder_inc.h
@@ -15,36 +15,114 @@
extern "C"
{
#endif
+#include "stellar/stellar.h"
+#include "stellar/utils.h"
+#include "stellar/session.h"
+#include "stellar/session_mq.h"
+#include "stellar/session_exdata.h"
#include "mempool/nmx_palloc.h"
#include "stellar/utils.h"
#include "http_decoder.h"
#include "http_decoder_result_queue.h"
+#include "http_decoder_half.h"
+#include "http_decoder_table.h"
+#include "http_decoder_result_queue.h"
+#include "http_decoder_utils.h"
+#include "http_decoder_stat.h"
+#include "fieldstat/fieldstat_easy.h"
+#include "toml/toml.h"
+#ifndef likely
+#define likely(x) __builtin_expect((x), 1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect((x), 0)
+#endif
#define MEMPOOL_CALLOC(pool, type, number) ((type *)nmx_pcalloc(pool, sizeof(type) * number))
#define MEMPOOL_REALLOC(pool)
#define MEMPOOL_FREE(pool, p) nmx_pfree(pool, p)
+#define ENABLE_MEMPOOL 1
#ifdef ENABLE_MEMPOOL
-
#define HD_CALLOC(pool, type, number) MEMPOOL_CALLOC(pool, number, type)
#define HD_FREE(pool, p) MEMPOOL_FREE(pool, p)
-
#else
-
#define HD_CALLOC(pool, type, number) CALLOC(type, number)
#define HD_FREE(pool, p) FREE(p)
-
#endif
+#define HTTP_IDENTIFY_LEN 16
+#define HD_RESULT_QUEUE_LEN 16
+
+#define DEFAULT_STAT_OUTPUT_INTERVAL 1
+#define DEFAULT_STAT_INTERVAL_PKTS 1000
+#define DEFAULT_MEMPOOL_SIZE (32 * 1024)
+
+#define HTTPD_CFG_FILE "./etc/http/http_decoder.toml"
+#define FILEDSTAT_OUTPUT_FILE "./http_decoder.fs"
+
+struct http_decoder_config
+{
+ int decompress_switch;
+ int stat_interval_pkts; // call fieldstat_incrby every stat_interval_pkts
+ int stat_output_interval;
+ size_t result_queue_len; // per session result queue length
+ size_t mempool_size; // per session mempool size
+};
+
+/**
+ * NOTE: http_message don't have the ownership of data
+ */
+struct http_message
+{
+ uint8_t flow_type;
+ enum http_message_type type;
+ size_t queue_index;
+ struct http_decoder_result_queue *ref_queue;
+};
+
+struct http_decoder
+{
+ struct http_decoder_half *c2s_half;
+ struct http_decoder_half *s2c_half;
+};
+
+struct http_decoder_exdata
+{
+ struct http_decoder_result_queue *queue;
+ struct http_decoder *decoder;
+ nmx_pool_t *mempool;
+};
+
+struct http_decoder_stat
+{
+ long long incoming_bytes;
+ long long incoming_pkts;
+ long long incoming_trans;
+ long long err_pkts;
+ int counter;
+};
+
+struct http_decoder_context
+{
+ int plugin_id;
+ int httpd_msg_topic_id;
+ int ex_data_idx;
+ int fs_incoming_bytes_id;
+ int fs_incoming_pkts_id;
+ int fs_incoming_trans_id;
+ int fs_err_pkts_id;
+ struct stellar *st;
+ struct fieldstat_easy *fse;
+ struct http_decoder_config hd_cfg;
+};
struct http_message;
-struct http_message *
-http_message_new(enum http_message_type type,
- struct http_decoder_result_queue *queue,
- int queue_index);
+struct http_message *http_message_new(enum http_message_type type, struct http_decoder_result_queue *queue,
+ int queue_index, unsigned char flow_type);
#ifdef __cplusplus
}