变更HTTP业务层回调函数定义,增加session系列操作方法定义及虚接口实现。

* 不提供业务层针对单个数据包(段)的处理函数(返回值),业务层只能对单个session定义操作;
* 通过session的方法(函数)通知解析层对该session的处理方法。
This commit is contained in:
Lu Qiuwen
2018-09-12 15:29:35 +08:00
parent 74a4d38fba
commit 9e59110f8a
8 changed files with 447 additions and 165 deletions

View File

@@ -2,16 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <tfe_http.h>
const char * tfe_http_field_read(const struct tfe_http_half * half, const struct http_field_name * name)
{
return NULL;
}
int tfe_http_field_write(struct tfe_http_half * half, const struct http_field_name * name, const char * value)
{
return 0;
}
#include <tfe_plugin.h>
struct tfe_http_half * tfe_http_request_create(int major_version, int method, const char * uri, const char * host)
{
@@ -22,3 +13,67 @@ struct tfe_http_half * tfe_http_response_create(int major_version, int resp_code
{
return NULL;
}
struct ht_frame_session_ctx
{
void ** pmes;
unsigned int nr_pmes;
struct tfe_plugin * preempt_plugin;
};
struct ht_frame_session_ctx * http_frame_raise_session_begin(const struct tfe_stream * stream,
struct tfe_http_session * ht_session, unsigned int thread_id)
{
struct ht_frame_session_ctx * ss_ctx = ALLOC(struct ht_frame_session_ctx, 1);
ss_ctx->nr_pmes = tfe_plugin_total_counts();
ss_ctx->pmes = ALLOC(void *, ss_ctx->nr_pmes);
unsigned int __for_each_iterator = 0;
unsigned int __plugin_id = 0;
struct tfe_plugin * plugin_info_iter;
TFE_PLUGIN_FOREACH(plugin_info_iter, &__for_each_iterator)
{
if (plugin_info_iter->on_session_begin == NULL) continue;
plugin_info_iter->on_session_begin(stream, ht_session, thread_id, &ss_ctx->pmes[__plugin_id]);
}
return ss_ctx;
};
void http_frame_raise_session_end(struct ht_frame_session_ctx * ss_ctx, struct tfe_stream * stream,
struct tfe_http_session * ht_session, unsigned int thread_id)
{
unsigned int __for_each_iterator = 0;
unsigned int __plugin_id = 0;
struct tfe_plugin * plugin_info_iter;
TFE_PLUGIN_FOREACH(plugin_info_iter, &__for_each_iterator)
{
if (plugin_info_iter->on_session_end == NULL) continue;
plugin_info_iter->on_session_end(stream, ht_session, thread_id, &ss_ctx->pmes[__plugin_id]);
}
free(ss_ctx->pmes);
free(ss_ctx);
}
void http_frame_raise_event(struct ht_frame_session_ctx * ht_frame,
const struct tfe_stream * stream, struct tfe_http_session * ht_session, enum tfe_http_event event,
const unsigned char * data, size_t datalen, unsigned int thread_id)
{
unsigned int __for_each_iterator = 0;
unsigned int __plugin_id = 0;
struct tfe_plugin * plugin_info_iter;
TFE_PLUGIN_FOREACH(plugin_info_iter, &__for_each_iterator)
{
if (plugin_info_iter->on_session_data == NULL)
continue;
plugin_info_iter->on_session_data(stream, ht_session, event, data,
datalen, thread_id, &ht_frame->pmes[__plugin_id]);
}
return;
}