2022-07-06 23:18:13 +08:00
|
|
|
#include "session.h"
|
|
|
|
|
#include "packet.h"
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
|
2022-07-27 18:32:22 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
2022-07-06 23:18:13 +08:00
|
|
|
|
2022-07-27 18:32:22 +08:00
|
|
|
static char *g_handler = NULL;
|
2022-07-06 23:18:13 +08:00
|
|
|
|
2022-07-27 18:32:22 +08:00
|
|
|
struct per_session_pme_info
|
2022-07-06 23:18:13 +08:00
|
|
|
{
|
2022-07-27 18:32:22 +08:00
|
|
|
int flag;
|
|
|
|
|
char data[16];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern "C" void http_event_plugin_entry(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme)
|
|
|
|
|
{
|
|
|
|
|
struct per_session_pme_info **per_session_pme = (struct per_session_pme_info **)pme;
|
|
|
|
|
|
|
|
|
|
printf("RUN http_event_plugin_entry, event: %d\n", event);
|
|
|
|
|
|
|
|
|
|
if (event & SESSION_EVENT_OPENING)
|
|
|
|
|
{
|
|
|
|
|
if (*per_session_pme == NULL)
|
|
|
|
|
{
|
|
|
|
|
struct per_session_pme_info *cur_ctx = (struct per_session_pme_info *)malloc(sizeof(struct per_session_pme_info));
|
|
|
|
|
snprintf(cur_ctx->data, 6, "******");
|
|
|
|
|
*per_session_pme = *&cur_ctx;
|
|
|
|
|
printf("http_event_plugin_entry->opening_handler\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event & SESSION_EVENT_RAWPKT)
|
|
|
|
|
{
|
|
|
|
|
printf("http_event_plugin_entry->rawpkt_handler\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event & SESSION_EVENT_ORDPKT)
|
|
|
|
|
{
|
|
|
|
|
printf("http_event_plugin_entry->ordpkt_handler\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event & SESSION_EVENT_META)
|
|
|
|
|
{
|
|
|
|
|
printf("http_event_plugin_entry->meta_handler\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event & SESSION_EVENT_CLOSING)
|
|
|
|
|
{
|
|
|
|
|
if (*per_session_pme)
|
|
|
|
|
{
|
|
|
|
|
printf("http_event_plugin_entry->closing_hanler\n");
|
|
|
|
|
|
|
|
|
|
free(*per_session_pme);
|
|
|
|
|
*per_session_pme = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-06 23:18:13 +08:00
|
|
|
}
|
|
|
|
|
|
2022-07-27 18:32:22 +08:00
|
|
|
extern "C" int http_event_plugin_init(void)
|
2022-07-06 23:18:13 +08:00
|
|
|
{
|
2022-07-27 18:32:22 +08:00
|
|
|
printf("RUN http_event_plugin_init\n");
|
|
|
|
|
|
|
|
|
|
if (g_handler == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_handler = (char *)malloc(1024);
|
|
|
|
|
snprintf(g_handler, 1024, "111111");
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-06 23:18:13 +08:00
|
|
|
return 0;
|
2022-07-20 20:20:31 +08:00
|
|
|
}
|
|
|
|
|
|
2022-07-27 18:32:22 +08:00
|
|
|
extern "C" void http_event_plugin_exit(void)
|
2022-07-20 20:20:31 +08:00
|
|
|
{
|
2022-07-27 18:32:22 +08:00
|
|
|
printf("RUN http_event_plugin_exit\n");
|
|
|
|
|
|
|
|
|
|
if (g_handler)
|
|
|
|
|
{
|
|
|
|
|
free(g_handler);
|
|
|
|
|
g_handler = NULL;
|
|
|
|
|
}
|
2022-07-06 23:18:13 +08:00
|
|
|
}
|