#include "session.h" #include "packet.h" #include "plugin.h" #include #include static char *g_handler = NULL; struct per_session_pme_info { 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; } } } extern "C" int http_event_plugin_init(void) { printf("RUN http_event_plugin_init\n"); if (g_handler == NULL) { g_handler = (char *)malloc(1024); snprintf(g_handler, 1024, "111111"); } return 0; } extern "C" void http_event_plugin_exit(void) { printf("RUN http_event_plugin_exit\n"); if (g_handler) { free(g_handler); g_handler = NULL; } }