🦄 refactor(appid api): remove appid module

This commit is contained in:
yangwei
2024-11-06 13:53:03 +08:00
parent 8ddef31bb5
commit 526c110868
14 changed files with 102 additions and 143 deletions

View File

@@ -6,20 +6,18 @@
#include <unistd.h>
#include <assert.h>
#include "stellar/appid.h"
#include "stellar/module.h"
#include "stellar/session.h"
#include "stellar/utils.h"
#include "cjson/cJSON.h"
#include "lpi_plus/lpi_plus.h"
#include "appid/appid_internal.h"
#include "lpi_plus/lpi_plus_internal.h"
struct test_lpip_env
{
struct module_manager *mod_mgr;
struct lpi_plus_mapper *lpi_mapper;
struct lpi_plus *lpip;
int l7_exdata_idx;
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] = {};
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_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;
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 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 session_manager *sess_mgr = module_to_session_manager(sess_mgr_mod);
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);
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");
return module_new("TEST_LPIP", env);