🦄 refactor(appid api): remove appid module
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
add_subdirectory(appid)
|
|
||||||
add_subdirectory(lpi_plus)
|
add_subdirectory(lpi_plus)
|
||||||
#add_subdirectory(http)
|
#add_subdirectory(http)
|
||||||
#add_subdirectory(socks)
|
#add_subdirectory(socks)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
add_library(appid appid.c)
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#include "appid_internal.h"
|
|
||||||
|
|
||||||
#include "stellar/utils.h"
|
|
||||||
#include "stellar/mq.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void appid_message_free(void *msg, void *msg_free_arg __unused)
|
|
||||||
{
|
|
||||||
if(msg==NULL)return;
|
|
||||||
FREE(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wcast-function-type"
|
|
||||||
|
|
||||||
static void stellar_appid_on_msg_dispatch(int topic_id __unused,
|
|
||||||
void *msg,
|
|
||||||
on_msg_cb_func* on_msg_cb,
|
|
||||||
void *on_msg_cb_arg,
|
|
||||||
void *dispatch_arg __unused)
|
|
||||||
{
|
|
||||||
on_appid_callback *appid_cb = (on_appid_callback *)on_msg_cb;
|
|
||||||
struct appid_message *appid_msg=(struct appid_message *)msg;
|
|
||||||
appid_cb(appid_msg->sess, appid_msg->origin, appid_msg->appid, appid_msg->appid_num, on_msg_cb_arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int stellar_appid_subscribe(struct module_manager *mod_mgr, on_appid_callback *cb, void *args)
|
|
||||||
{
|
|
||||||
if(mod_mgr==NULL)return -1;
|
|
||||||
int appid_topic_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
|
|
||||||
if(appid_topic_id<0)
|
|
||||||
{
|
|
||||||
appid_topic_id=mq_schema_create_topic(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, mod_mgr, appid_message_free, NULL);
|
|
||||||
}
|
|
||||||
return mq_schema_subscribe(module_manager_get_mq_schema(mod_mgr), appid_topic_id, (on_msg_cb_func *)cb, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
int stellar_appid_create_topic(struct module_manager *mod_mgr)
|
|
||||||
{
|
|
||||||
int app_topic_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
|
|
||||||
if(app_topic_id < 0)
|
|
||||||
{
|
|
||||||
app_topic_id=mq_schema_create_topic(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, NULL,appid_message_free, NULL);
|
|
||||||
}
|
|
||||||
return app_topic_id;
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "stellar/appid.h"
|
|
||||||
|
|
||||||
#define MAX_APPID_NUM 8
|
|
||||||
#define APPID_MESSAGE_TOPIC "TOPIC_APPID"
|
|
||||||
|
|
||||||
struct appid_message
|
|
||||||
{
|
|
||||||
struct session *sess;
|
|
||||||
enum APPID_ORIGIN origin;
|
|
||||||
uint32_t appid_num;
|
|
||||||
int32_t appid[MAX_APPID_NUM];
|
|
||||||
uint32_t surrogate_id[MAX_APPID_NUM];
|
|
||||||
uint32_t packet_sequence[MAX_APPID_NUM];
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -5,7 +5,7 @@ add_library(lpi_plus lpip_module.c lpip_extend.c)
|
|||||||
target_include_directories(lpi_plus PUBLIC ${CMAKE_SOURCE_DIR}/deps/)
|
target_include_directories(lpi_plus PUBLIC ${CMAKE_SOURCE_DIR}/deps/)
|
||||||
target_include_directories(lpi_plus PUBLIC ${CMAKE_SOURCE_DIR}/decoders/)
|
target_include_directories(lpi_plus PUBLIC ${CMAKE_SOURCE_DIR}/decoders/)
|
||||||
|
|
||||||
target_link_libraries(lpi_plus libprotoident appid)
|
target_link_libraries(lpi_plus libprotoident)
|
||||||
set_target_properties(lpi_plus PROPERTIES LINK_FLAGS
|
set_target_properties(lpi_plus PROPERTIES LINK_FLAGS
|
||||||
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version.map")
|
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version.map")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "stellar/module.h"
|
|
||||||
#define LPI_PLUS_MODULE_NAME "LPI_PLUS"
|
|
||||||
struct lpi_plus_mapper;
|
|
||||||
struct lpi_plus_mapper *module_to_lpip_mapper(struct module *mod);
|
|
||||||
const char *lpi_plus_appid2name(struct lpi_plus_mapper *mapper, int appid);
|
|
||||||
16
decoders/lpi_plus/lpi_plus_internal.h
Normal file
16
decoders/lpi_plus/lpi_plus_internal.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "stellar/lpi_plus.h"
|
||||||
|
|
||||||
|
#define MAX_APPID_NUM 8
|
||||||
|
#define LPIP_APPID_MESSAGE_TOPIC "TOPIC_LPIP_APPID"
|
||||||
|
|
||||||
|
struct appid_message
|
||||||
|
{
|
||||||
|
struct session *sess;
|
||||||
|
uint32_t appid_num;
|
||||||
|
int32_t appid[MAX_APPID_NUM];
|
||||||
|
uint32_t packet_sequence[MAX_APPID_NUM];
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *lpi_plus_appid2name(struct lpi_plus *lpip, int appid);
|
||||||
@@ -17,9 +17,7 @@
|
|||||||
#include "stellar/packet.h"
|
#include "stellar/packet.h"
|
||||||
#include "stellar/session.h"
|
#include "stellar/session.h"
|
||||||
|
|
||||||
#include "appid/appid_internal.h"
|
#include "lpi_plus_internal.h"
|
||||||
|
|
||||||
#include "lpi_plus.h"
|
|
||||||
#include "lpip_extend.h"
|
#include "lpip_extend.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +38,7 @@ struct lpi_plus_mapper
|
|||||||
struct lpi_plus_appid_info *hash_appid2name;
|
struct lpi_plus_appid_info *hash_appid2name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lpi_plus_env
|
struct lpi_plus
|
||||||
{
|
{
|
||||||
unsigned int max_pkts;
|
unsigned int max_pkts;
|
||||||
int lpip_session_exdata_idx;
|
int lpip_session_exdata_idx;
|
||||||
@@ -93,13 +91,11 @@ static void lpi_plus_get_host_order_port(struct session *sess __unused, unsigned
|
|||||||
static struct appid_message *lpi_plus_message_new(struct session *sess, int *id_array, size_t id_num)
|
static struct appid_message *lpi_plus_message_new(struct session *sess, int *id_array, size_t id_num)
|
||||||
{
|
{
|
||||||
struct appid_message *result=CALLOC(struct appid_message, 1);
|
struct appid_message *result=CALLOC(struct appid_message, 1);
|
||||||
result->origin=ORIGIN_LPI_PLUS;
|
|
||||||
result->sess=sess;
|
result->sess=sess;
|
||||||
result->appid_num=id_num;
|
result->appid_num=id_num;
|
||||||
for(unsigned int i=0; i<result->appid_num; i++)
|
for(unsigned int i=0; i<result->appid_num; i++)
|
||||||
{
|
{
|
||||||
result->appid[i]=(int)(id_array[i]);
|
result->appid[i]=(int)(id_array[i]);
|
||||||
result->surrogate_id[i]=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -136,10 +132,10 @@ static int lpi_plus_name2appid(struct lpi_plus_mapper *mapper, const char *lpi_n
|
|||||||
return out->appid;
|
return out->appid;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *lpi_plus_appid2name(struct lpi_plus_mapper *mapper, int appid)
|
const char *lpi_plus_appid2name(struct lpi_plus *lpip, int appid)
|
||||||
{
|
{
|
||||||
struct lpi_plus_appid_info *out=NULL;
|
struct lpi_plus_appid_info *out=NULL;
|
||||||
HASH_FIND(hh_appid, mapper->hash_appid2name, &appid, sizeof(int), out);
|
HASH_FIND(hh_appid, lpip->mapper->hash_appid2name, &appid, sizeof(int), out);
|
||||||
if(out==NULL)return NULL;
|
if(out==NULL)return NULL;
|
||||||
return out->app_name;
|
return out->app_name;
|
||||||
}
|
}
|
||||||
@@ -293,7 +289,7 @@ static void lpi_plus_on_session(struct session *sess, enum session_state state,
|
|||||||
assert(pkt == NULL);
|
assert(pkt == NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct lpi_plus_env *env=(struct lpi_plus_env *)args;
|
struct lpi_plus *env=(struct lpi_plus *)args;
|
||||||
struct lpi_plus_exdata *exdata = (struct lpi_plus_exdata *)session_get_exdata(sess, env->lpip_session_exdata_idx);
|
struct lpi_plus_exdata *exdata = (struct lpi_plus_exdata *)session_get_exdata(sess, env->lpip_session_exdata_idx);
|
||||||
if(exdata==NULL)
|
if(exdata==NULL)
|
||||||
{
|
{
|
||||||
@@ -331,7 +327,7 @@ void lpi_plus_exit(struct module_manager *mod_mgr, struct module *mod)
|
|||||||
if(mod_mgr==NULL)return;
|
if(mod_mgr==NULL)return;
|
||||||
if(mod)
|
if(mod)
|
||||||
{
|
{
|
||||||
struct lpi_plus_env *env=(struct lpi_plus_env *)module_get_ctx(mod);
|
struct lpi_plus *env=(struct lpi_plus *)module_get_ctx(mod);
|
||||||
lpi_free_library();
|
lpi_free_library();
|
||||||
lpi_plus_mapper_free(env->mapper);
|
lpi_plus_mapper_free(env->mapper);
|
||||||
FREE(env);
|
FREE(env);
|
||||||
@@ -339,11 +335,55 @@ void lpi_plus_exit(struct module_manager *mod_mgr, struct module *mod)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void appid_message_free(void *msg, void *msg_free_arg __unused)
|
||||||
|
{
|
||||||
|
if(msg==NULL)return;
|
||||||
|
FREE(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||||
|
|
||||||
|
static void lpi_plus_appid_on_msg_dispatch(int topic_id __unused,
|
||||||
|
void *msg,
|
||||||
|
on_msg_cb_func* on_msg_cb,
|
||||||
|
void *on_msg_cb_arg,
|
||||||
|
void *dispatch_arg __unused)
|
||||||
|
{
|
||||||
|
on_appid_callback *appid_cb = (on_appid_callback *)on_msg_cb;
|
||||||
|
struct appid_message *appid_msg=(struct appid_message *)msg;
|
||||||
|
appid_cb(appid_msg->sess, appid_msg->appid, appid_msg->appid_num, on_msg_cb_arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lpi_plus_appid_subscribe(struct lpi_plus *lpip, on_appid_callback *cb, void *args)
|
||||||
|
{
|
||||||
|
if(lpip==NULL)return -1;
|
||||||
|
struct module_manager *mod_mgr=lpip->mod_mgr;
|
||||||
|
int appid_topic_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), LPIP_APPID_MESSAGE_TOPIC);
|
||||||
|
if(appid_topic_id<0)
|
||||||
|
{
|
||||||
|
appid_topic_id=mq_schema_create_topic(module_manager_get_mq_schema(mod_mgr), LPIP_APPID_MESSAGE_TOPIC, lpi_plus_appid_on_msg_dispatch, mod_mgr, appid_message_free, NULL);
|
||||||
|
}
|
||||||
|
return mq_schema_subscribe(module_manager_get_mq_schema(mod_mgr), appid_topic_id, (on_msg_cb_func *)cb, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
int lpi_plus_create_appid_topic(struct module_manager *mod_mgr)
|
||||||
|
{
|
||||||
|
int app_topic_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), LPIP_APPID_MESSAGE_TOPIC);
|
||||||
|
if(app_topic_id < 0)
|
||||||
|
{
|
||||||
|
app_topic_id=mq_schema_create_topic(module_manager_get_mq_schema(mod_mgr), LPIP_APPID_MESSAGE_TOPIC, lpi_plus_appid_on_msg_dispatch, NULL,appid_message_free, NULL);
|
||||||
|
}
|
||||||
|
return app_topic_id;
|
||||||
|
}
|
||||||
|
|
||||||
struct module *lpi_plus_init(struct module_manager *mod_mgr)
|
struct module *lpi_plus_init(struct module_manager *mod_mgr)
|
||||||
{
|
{
|
||||||
if(mod_mgr==NULL)return NULL;
|
if(mod_mgr==NULL)return NULL;
|
||||||
|
|
||||||
struct lpi_plus_env *env=CALLOC(struct lpi_plus_env, 1);
|
struct lpi_plus *env=CALLOC(struct lpi_plus, 1);
|
||||||
struct module *mod=module_new("LPI_PLUS", env);
|
struct module *mod=module_new("LPI_PLUS", env);
|
||||||
env->mod_mgr=mod_mgr;
|
env->mod_mgr=mod_mgr;
|
||||||
env->max_pkts=16;//TODO: load from toml
|
env->max_pkts=16;//TODO: load from toml
|
||||||
@@ -370,7 +410,7 @@ struct module *lpi_plus_init(struct module_manager *mod_mgr)
|
|||||||
session_manager_subscribe_udp(sess_mgr, lpi_plus_on_session, env);
|
session_manager_subscribe_udp(sess_mgr, lpi_plus_on_session, env);
|
||||||
|
|
||||||
env->lpip_session_exdata_idx = session_manager_new_session_exdata_index(sess_mgr, "EXDATA_LPI", lpi_plus_exdata_free, NULL);
|
env->lpip_session_exdata_idx = session_manager_new_session_exdata_index(sess_mgr, "EXDATA_LPI", lpi_plus_exdata_free, NULL);
|
||||||
env->topic_appid=stellar_appid_create_topic(mod_mgr);
|
env->topic_appid=lpi_plus_create_appid_topic(mod_mgr);
|
||||||
if(env->topic_appid<0)
|
if(env->topic_appid<0)
|
||||||
{
|
{
|
||||||
goto INIT_ERROR;
|
goto INIT_ERROR;
|
||||||
@@ -385,11 +425,11 @@ INIT_ERROR:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct lpi_plus_mapper *module_to_lpip_mapper(struct module *mod)
|
struct lpi_plus *module_to_lpi_plus(struct module *mod)
|
||||||
{
|
{
|
||||||
if(mod==NULL)return NULL;
|
if(mod==NULL)return NULL;
|
||||||
assert(strcmp(module_get_name(mod), LPI_PLUS_MODULE_NAME) == 0);
|
assert(strcmp(module_get_name(mod), LPI_PLUS_MODULE_NAME) == 0);
|
||||||
struct lpi_plus_env *lpi_p=(struct lpi_plus_env *)module_get_ctx(mod);
|
struct lpi_plus *lpi_p=(struct lpi_plus *)module_get_ctx(mod);
|
||||||
if(lpi_p==NULL)return NULL;
|
if(lpi_p==NULL)return NULL;
|
||||||
return lpi_p->mapper;
|
return lpi_p;
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ global:
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
lpi_plus_init;
|
lpi_plus_init;
|
||||||
lpi_plus_exit;
|
lpi_plus_exit;
|
||||||
stellar_appid_subscribe;
|
lpi_plus_appid_subscribe;
|
||||||
GIT_VERSION_*;
|
GIT_VERSION_*;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "stellar/session.h"
|
|
||||||
#include "stellar/module.h"
|
|
||||||
|
|
||||||
enum APPID_ORIGIN
|
|
||||||
{
|
|
||||||
ORIGIN_LPI_PLUS=0,
|
|
||||||
ORIGIN_APP_SKETCH_USER_DEFINE,
|
|
||||||
ORIGIN_PROTO_ENGINE,
|
|
||||||
ORIGIN_APP_SKETCH_BUILT_IN,
|
|
||||||
ORIGIN_PROTO_DECODED,
|
|
||||||
ORIGIN_EXCEED_PACKET_LIMIT,
|
|
||||||
ORIGIN_TUNNEL,
|
|
||||||
ORIGIN_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void on_appid_callback(struct session *sess, enum APPID_ORIGIN origin, int appid[], size_t appid_num, void *args);
|
|
||||||
int stellar_appid_create_topic(struct module_manager *mod_mgr);
|
|
||||||
int stellar_appid_subscribe(struct module_manager *mod_mgr, on_appid_callback *cb, void *args);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
21
include/stellar/lpi_plus.h
Normal file
21
include/stellar/lpi_plus.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "stellar/module.h"
|
||||||
|
#include "stellar/session.h"
|
||||||
|
|
||||||
|
#define LPI_PLUS_MODULE_NAME "LPI_PLUS"
|
||||||
|
|
||||||
|
struct lpi_plus;
|
||||||
|
struct lpi_plus *module_to_lpi_plus(struct module *mod);
|
||||||
|
|
||||||
|
typedef void on_appid_callback(struct session *sess, int appid[], size_t appid_num, void *args);
|
||||||
|
int lpi_plus_appid_subscribe(struct lpi_plus *lpip, on_appid_callback *cb, void *args);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
set(INFRA exdata mq tuple packet_manager packet_io ip_reassembly tcp_reassembly session_manager module_manager)
|
set(INFRA exdata mq tuple packet_manager packet_io ip_reassembly tcp_reassembly session_manager module_manager)
|
||||||
set(DEPS bitmap dablooms interval_tree logger nmx_pool rbtree timeout toml)
|
set(DEPS bitmap dablooms interval_tree logger nmx_pool rbtree timeout toml)
|
||||||
set(DECODERS appid lpi_plus)
|
set(DECODERS lpi_plus)
|
||||||
set(WHOLE_ARCHIVE ${DEPS} ${INFRA} ${DECODERS})
|
set(WHOLE_ARCHIVE ${DEPS} ${INFRA} ${DECODERS})
|
||||||
set(LIBS fieldstat4)
|
set(LIBS fieldstat4)
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ global:
|
|||||||
stellar_get_logger;
|
stellar_get_logger;
|
||||||
stellar_reload_log_level;
|
stellar_reload_log_level;
|
||||||
|
|
||||||
stellar_appid_subscribe;
|
|
||||||
|
|
||||||
log_print;
|
log_print;
|
||||||
log_check_level;
|
log_check_level;
|
||||||
|
|
||||||
@@ -74,6 +72,7 @@ global:
|
|||||||
|
|
||||||
lpi_plus_init;
|
lpi_plus_init;
|
||||||
lpi_plus_exit;
|
lpi_plus_exit;
|
||||||
|
lpi_plus_appid_subscribe;
|
||||||
|
|
||||||
local: *;
|
local: *;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,20 +6,18 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "stellar/appid.h"
|
|
||||||
#include "stellar/module.h"
|
#include "stellar/module.h"
|
||||||
#include "stellar/session.h"
|
#include "stellar/session.h"
|
||||||
#include "stellar/utils.h"
|
#include "stellar/utils.h"
|
||||||
|
|
||||||
#include "cjson/cJSON.h"
|
#include "cjson/cJSON.h"
|
||||||
|
|
||||||
#include "lpi_plus/lpi_plus.h"
|
#include "lpi_plus/lpi_plus_internal.h"
|
||||||
#include "appid/appid_internal.h"
|
|
||||||
|
|
||||||
struct test_lpip_env
|
struct test_lpip_env
|
||||||
{
|
{
|
||||||
struct module_manager *mod_mgr;
|
struct module_manager *mod_mgr;
|
||||||
struct lpi_plus_mapper *lpi_mapper;
|
struct lpi_plus *lpip;
|
||||||
int l7_exdata_idx;
|
int l7_exdata_idx;
|
||||||
int session_num;
|
int session_num;
|
||||||
};
|
};
|
||||||
@@ -73,7 +71,7 @@ static void gtest_lpip_exdata_free(int idx __attribute__((unused)), void *ex_ptr
|
|||||||
const char *proto_names[MAX_APPID_NUM] = {};
|
const char *proto_names[MAX_APPID_NUM] = {};
|
||||||
for (unsigned int i = 0; i < test_appid_exdata->appid_num; i++)
|
for (unsigned int i = 0; i < test_appid_exdata->appid_num; i++)
|
||||||
{
|
{
|
||||||
proto_names[i] = lpi_plus_appid2name(env->lpi_mapper ,test_appid_exdata->appid[i]);
|
proto_names[i] = lpi_plus_appid2name(env->lpip ,test_appid_exdata->appid[i]);
|
||||||
}
|
}
|
||||||
cJSON *label_ids = cJSON_CreateIntArray(test_appid_exdata->appid, test_appid_exdata->appid_num);
|
cJSON *label_ids = cJSON_CreateIntArray(test_appid_exdata->appid, test_appid_exdata->appid_num);
|
||||||
cJSON_AddItemToObject(ctx, "l7_label_id", label_ids);
|
cJSON_AddItemToObject(ctx, "l7_label_id", label_ids);
|
||||||
@@ -113,7 +111,7 @@ static void gtest_lpip_exdata_free(int idx __attribute__((unused)), void *ex_ptr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void gtest_lpip_on_appid_msg(struct session *sess, enum APPID_ORIGIN origin, int appid[], size_t appid_num, void *args)
|
static void gtest_lpip_on_appid_msg(struct session *sess, int appid[], size_t appid_num, void *args)
|
||||||
{
|
{
|
||||||
if(sess==NULL || appid==NULL || args==NULL)return;
|
if(sess==NULL || appid==NULL || args==NULL)return;
|
||||||
struct test_lpip_env *env = (struct test_lpip_env *)args;
|
struct test_lpip_env *env = (struct test_lpip_env *)args;
|
||||||
@@ -156,7 +154,7 @@ struct module *gtest_lpip_module_init(struct module_manager *mod_mgr)
|
|||||||
{
|
{
|
||||||
struct test_lpip_env *env = (struct test_lpip_env *)calloc(1, sizeof(struct test_lpip_env));
|
struct test_lpip_env *env = (struct test_lpip_env *)calloc(1, sizeof(struct test_lpip_env));
|
||||||
struct module *lpip_mod = module_manager_get_module(mod_mgr, LPI_PLUS_MODULE_NAME);
|
struct module *lpip_mod = module_manager_get_module(mod_mgr, LPI_PLUS_MODULE_NAME);
|
||||||
env->lpi_mapper=module_to_lpip_mapper(lpip_mod);
|
env->lpip=module_to_lpi_plus(lpip_mod);
|
||||||
struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
|
struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
|
||||||
struct session_manager *sess_mgr = module_to_session_manager(sess_mgr_mod);
|
struct session_manager *sess_mgr = module_to_session_manager(sess_mgr_mod);
|
||||||
if(sess_mgr == NULL)
|
if(sess_mgr == NULL)
|
||||||
@@ -170,7 +168,7 @@ struct module *gtest_lpip_module_init(struct module_manager *mod_mgr)
|
|||||||
|
|
||||||
env->l7_exdata_idx = session_manager_new_session_exdata_index(sess_mgr, "EXDATA_L7", gtest_lpip_exdata_free, env);
|
env->l7_exdata_idx = session_manager_new_session_exdata_index(sess_mgr, "EXDATA_L7", gtest_lpip_exdata_free, env);
|
||||||
|
|
||||||
stellar_appid_subscribe(mod_mgr, gtest_lpip_on_appid_msg, env);
|
lpi_plus_appid_subscribe(env->lpip, gtest_lpip_on_appid_msg, env);
|
||||||
printf("gtest_lpip_module_init OK!\n");
|
printf("gtest_lpip_module_init OK!\n");
|
||||||
|
|
||||||
return module_new("TEST_LPIP", env);
|
return module_new("TEST_LPIP", env);
|
||||||
|
|||||||
Reference in New Issue
Block a user