Plugin Management support C plugin

This commit is contained in:
luwenpeng
2022-07-27 18:32:22 +08:00
parent 649d29e538
commit 50111e7cd0
35 changed files with 4220 additions and 193 deletions

View File

@@ -2,37 +2,57 @@
#include "packet.h"
#include "plugin.h"
struct custom_session_event *_event = nullptr;
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
void *custom_decode(const char *payload, uint32_t len, void **pme)
static char *g_handler = NULL;
static void *custom_decode(const char *payload, uint16_t len, void **pme)
{
return nullptr;
return NULL;
}
int custom_plugin_entry(const struct stellar_session *s, int what, struct stellar_packet *p, const char *payload, uint32_t len, void **pme)
extern "C" void custom_plugin_tcp_entry(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme)
{
struct stellar_session_event_extras *info= (struct stellar_session_event_extras *)custom_decode(payload, len, pme);
struct stellar_session *new_session=session_manager_session_derive(s, "CUSTOM_A");
char **per_session_pme = (char **)pme;
printf("RUN custom_plugin_tcp_entry, event: %d\n", event);
struct stellar_session_event_extras *info = (struct stellar_session_event_extras *)custom_decode(payload, len, pme);
struct stellar_session *new_session = session_manager_session_derive(s, "CUSTOM");
session_manager_trigger_event(new_session, SESSION_EVENT_OPENING, info);
session_manager_trigger_event(new_session, SESSION_EVENT_META, info);
return 0;
}
int custom_event_plugin_entry(const struct stellar_session *s, int what, struct stellar_packet *p, const char *payload, uint32_t len, void **pme)
extern "C" void custom_plugin_custom_entry(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme)
{
return 0;
char **per_session_pme = (char **)pme;
printf("RUN custom_plugin_custom_entry, event: %d\n", event);
}
int custom_plugin_init()
extern "C" int custom_plugin_init(void)
{
//plugin_manager_event_register("TCP", custom_plugin_entry, nullptr);
//plugin_manager_event_register("CUSTOM_A", custom_event_plugin_entry, nullptr);
printf("RUN custom_plugin_init\n");
if (g_handler == NULL)
{
g_handler = (char *)malloc(1024);
snprintf(g_handler, 1024, "222222");
}
return 0;
}
void custom_plugin_destroy()
extern "C" void custom_plugin_exit(void)
{
return ;
printf("RUN custom_plugin_exit\n");
if (g_handler)
{
free(g_handler);
g_handler = NULL;
}
}