✨ feat(plugin manager): integrated plugin manager, build success
This commit is contained in:
@@ -123,10 +123,18 @@ enum session_timestamp
|
||||
};
|
||||
|
||||
struct session;
|
||||
#define SESSION_SEEN_C2S_FLOW (1 << 0)
|
||||
#define SESSION_SEEN_S2C_FLOW (1 << 1)
|
||||
int session_is_symmetric(struct session *sess, unsigned char *flag);
|
||||
|
||||
int session_has_duplicate_traffic(const struct session *sess);
|
||||
enum session_type session_get_type(const struct session *sess);
|
||||
enum session_state session_get_state(const struct session *sess);
|
||||
|
||||
enum session_state session_get_current_state(const struct session *sess);
|
||||
const struct packet *session_get0_current_packet(struct session *sess);
|
||||
const char *session_get0_current_payload(struct session *sess, size_t *payload_len);
|
||||
|
||||
enum closing_reason session_get_closing_reason(const struct session *sess);
|
||||
enum session_direction session_get_direction(const struct session *sess);
|
||||
enum flow_direction session_get_current_flow_direction(const struct session *sess);
|
||||
@@ -141,6 +149,8 @@ uint64_t session_get_id(const struct session *sess);
|
||||
uint64_t session_get_timestamp(const struct session *sess, enum session_timestamp type);
|
||||
uint64_t session_get_stat(const struct session *sess, enum flow_direction dir, enum session_stat stat);
|
||||
|
||||
const char *session_get0_readable_addr(struct session *sess);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
17
include/stellar/session_exdata.h
Normal file
17
include/stellar/session_exdata.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "stellar.h"
|
||||
|
||||
typedef void session_exdata_free(struct session *sess, int idx, void *ex_ptr, void *arg);
|
||||
int stellar_session_exdata_new_index(struct stellar *st, const char *name, session_exdata_free *free_func,void *arg);
|
||||
int session_exdata_set(struct session *sess, int idx, void *ex_ptr);
|
||||
void *session_exdata_get(struct session *sess, int idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
33
include/stellar/session_mq.h
Normal file
33
include/stellar/session_mq.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "stellar.h"
|
||||
|
||||
//session mq
|
||||
typedef void msg_free_cb_func(void *msg, void *msg_free_arg);
|
||||
typedef void on_msg_cb_func(struct session *sess, int topic_id, const void *msg, void *per_session_ctx, void *plugin_env);
|
||||
|
||||
//return topic_id
|
||||
int stellar_session_mq_create_topic(struct stellar *st, const char *topic_name, msg_free_cb_func *msg_free_cb, void *msg_free_arg);
|
||||
|
||||
int stellar_session_mq_get_topic_id(struct stellar *st, const char *topic_name);
|
||||
|
||||
int stellar_session_mq_update_topic(struct stellar *st, int topic_id, msg_free_cb_func *msg_free_cb, void *msg_free_arg);
|
||||
|
||||
int stellar_session_mq_destroy_topic(struct stellar *st, int topic_id);
|
||||
|
||||
//return 0 if success, otherwise return -1.
|
||||
int stellar_session_mq_subscribe(struct stellar *st, int topic_id, on_msg_cb_func *plugin_on_msg_cb, int plugin_id);
|
||||
|
||||
int session_mq_publish_message(struct session *sess, int topic_id, void *msg);
|
||||
|
||||
int session_mq_ignore_message(struct session *sess, int topic_id, int plugin_id);
|
||||
int session_mq_unignore_message(struct session *sess, int topic_id, int plugin_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -9,6 +9,48 @@ extern "C"
|
||||
#include <stdint.h>
|
||||
#include "stellar/session.h"
|
||||
|
||||
#include "session.h"
|
||||
|
||||
struct session;
|
||||
struct stellar;
|
||||
|
||||
//return plugin_env
|
||||
typedef void *plugin_on_load_func(struct stellar *st);
|
||||
typedef void plugin_on_unload_func(void *plugin_env);
|
||||
|
||||
//return per_session_ctx
|
||||
typedef void *session_ctx_new_func(struct session *sess, void *plugin_env);
|
||||
typedef void session_ctx_free_func(struct session *sess, void *session_ctx, void *plugin_env);
|
||||
|
||||
#define TOPIC_TCP "TCP"
|
||||
#define TOPIC_TCP_STREAM "TCP_STREAM"
|
||||
#define TOPIC_UDP "UDP"
|
||||
#define TOPIC_EGRESS "EGRESS"
|
||||
#define TOPIC_CONTROL_PACKET "CONTROL_PACKET"
|
||||
|
||||
//return session plugin_id
|
||||
int stellar_session_plugin_register(struct stellar *st,
|
||||
session_ctx_new_func session_ctx_new,
|
||||
session_ctx_free_func session_ctx_free,
|
||||
void *plugin_env);
|
||||
|
||||
void stellar_session_plugin_dettach_current_session(struct session *sess);
|
||||
|
||||
|
||||
|
||||
struct packet;
|
||||
typedef void plugin_on_packet_func(struct packet *pkt, unsigned char ip_protocol, void *plugin_env);
|
||||
|
||||
//return packet plugin_id
|
||||
int stellar_packet_plugin_register(struct stellar *st, unsigned char ip_protocol, plugin_on_packet_func on_packet, void *plugin_env);
|
||||
|
||||
|
||||
//return polling work result, 0: no work, 1: work
|
||||
typedef int plugin_on_polling_func(void *plugin_env);
|
||||
|
||||
//return polling plugin_id
|
||||
int stellar_polling_plugin_register(struct stellar *st, plugin_on_polling_func on_polling, void *plugin_env);
|
||||
|
||||
uint16_t stellar_get_current_thread_index();
|
||||
|
||||
// return inject packet length, return 0 if failed
|
||||
|
||||
36
include/stellar/utils.h
Normal file
36
include/stellar/utils.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h> //calloc
|
||||
#include <stddef.h> //NULL
|
||||
|
||||
#define ALLOC(type, number) ((type *)calloc(sizeof(type), number))
|
||||
#define CALLOC(type, number) ((type *)calloc(sizeof(type), number))
|
||||
|
||||
#define REALLOC(type, ptr, number) ((type *)realloc(ptr, (number) * sizeof(type)))
|
||||
|
||||
#define FREE(p) {free(p); p = NULL;}
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#endif
|
||||
|
||||
#ifndef __unused
|
||||
#define __unused __attribute__((__unused__))
|
||||
#endif
|
||||
Reference in New Issue
Block a user