feat(plugin register): remove ip_proto in parameter

This commit is contained in:
yangwei
2024-09-06 13:22:02 +08:00
parent 9c12523c9d
commit 442586ef52
4 changed files with 57 additions and 56 deletions

View File

@@ -7,7 +7,6 @@
#include <stdbool.h>
#include "stellar_core.h"
#include "tuple.h"
#include "packet_private.h"
#include "session_private.h"
@@ -613,7 +612,7 @@ void session_exdata_runtime_free(struct stellar_exdata *exdata_rt)
*********************************************/
UT_icd registered_plugin_array_icd = {sizeof(struct registered_plugin_schema), NULL, NULL, NULL};
int stellar_plugin_register(struct stellar *st, unsigned char ip_proto, plugin_on_packet_func on_packet_input, plugin_on_packet_func on_packet_output, void *plugin_env)
int stellar_plugin_register(struct stellar *st, plugin_on_packet_func on_packet_input, plugin_on_packet_func on_packet_output, void *plugin_env)
{
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
if(plug_mgr->registered_packet_plugin_array == NULL)
@@ -622,7 +621,6 @@ int stellar_plugin_register(struct stellar *st, unsigned char ip_proto, plugin_o
}
struct registered_plugin_schema packet_plugin_schema;
memset(&packet_plugin_schema, 0, sizeof(packet_plugin_schema));
packet_plugin_schema.ip_protocol = ip_proto;
packet_plugin_schema.on_packet[PACKET_STAGE_INPUT] = on_packet_input;
packet_plugin_schema.on_packet[PACKET_STAGE_OUTPUT] = on_packet_output;
packet_plugin_schema.plugin_env = plugin_env;
@@ -635,19 +633,14 @@ static void plugin_manager_on_packet(struct plugin_manager_schema *plug_mgr, str
if(plug_mgr==NULL || plug_mgr->registered_packet_plugin_array == NULL || pkt == NULL)return;
struct registered_plugin_schema *p=NULL;
//TODO: get innermost layer ip protocol by packet api
struct tuple6 t6;
packet_get_innermost_tuple6(pkt, &t6);
unsigned char ip_proto=t6.ip_proto;
int tid=stellar_get_current_thread_index();
//TODO : provide public api to reset pub_msg_cnt
plug_mgr->per_thread_data[tid].pub_packet_msg_cnt=0;//reset pub_msg_cnt
while ((p = (struct registered_plugin_schema *)utarray_next(plug_mgr->registered_packet_plugin_array, p)))
{
if(p->ip_protocol == ip_proto && p->on_packet[in_out])
if(p->on_packet[in_out])
{
p->on_packet[in_out](pkt, ip_proto, p->plugin_env);
p->on_packet[in_out](pkt, p->plugin_env);
}
}
stellar_mq_dispatch(plug_mgr->per_thread_data[tid].priority_mq, &plug_mgr->per_thread_data[tid].dealth_letter_queue);