✨ feat(plugin manager integration): packet and session exdata&mq
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
#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
|
||||
@@ -1,33 +0,0 @@
|
||||
#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
|
||||
@@ -6,7 +6,6 @@ extern "C"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "stellar/session.h"
|
||||
|
||||
struct session;
|
||||
struct stellar;
|
||||
@@ -48,6 +47,9 @@ 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);
|
||||
|
||||
void stellar_emit_datapath_telemetry(struct packet *pkt, const char * module, const char *str);
|
||||
|
||||
int stellar_get_worker_thread_num(struct stellar *st);
|
||||
uint16_t stellar_get_current_thread_index();
|
||||
// only send user crafted packet, can't send packet which come from network
|
||||
void stellar_send_crafted_packet(struct stellar *st, struct packet *pkt);
|
||||
|
||||
23
include/stellar/stellar_exdata.h
Normal file
23
include/stellar/stellar_exdata.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "stellar.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef void stellar_exdata_free(int idx, void *ex_ptr, void *arg);
|
||||
int stellar_exdata_new_index(struct stellar *st, const char *name, stellar_exdata_free *free_func,void *arg);
|
||||
|
||||
//packet exdata api
|
||||
int packet_exdata_set(struct packet *pkt, int idx, void *ex_ptr);
|
||||
void *packet_exdata_get(struct packet *pkt, int idx);
|
||||
|
||||
//session exdata api
|
||||
int session_exdata_set(struct session *sess, int idx, void *ex_ptr);
|
||||
void *session_exdata_get(struct session *sess, int idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
51
include/stellar/stellar_mq.h
Normal file
51
include/stellar/stellar_mq.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
#include "stellar.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//topic api
|
||||
typedef void stellar_msg_free_cb_func(void *msg, void *msg_free_arg);
|
||||
|
||||
//return topic_id
|
||||
int stellar_mq_create_topic(struct stellar *st, const char *topic_name, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
|
||||
int stellar_mq_get_topic_id(struct stellar *st, const char *topic_name);
|
||||
int stellar_mq_update_topic(struct stellar *st, int topic_id, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
|
||||
int stellar_mq_destroy_topic(struct stellar *st, int topic_id);
|
||||
|
||||
|
||||
enum stellar_mq_priority
|
||||
{
|
||||
STELLAR_MQ_PRIORITY_LOW,
|
||||
STELLAR_MQ_PRIORITY_NORMAL,
|
||||
STELLAR_MQ_PRIORITY_HIGH,
|
||||
STELLAR_MQ_PRIORITY_MAX,
|
||||
};
|
||||
|
||||
//session mq api
|
||||
typedef void on_session_msg_cb_func(struct session *sess, int topic_id, const void *msg, void *per_session_ctx, void *plugin_env);
|
||||
|
||||
//return 0 if success, otherwise return -1.
|
||||
int stellar_session_mq_subscribe(struct stellar *st, int topic_id, on_session_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_publish_message_with_priority(struct session *sess, int topic_id, void *msg, enum stellar_mq_priority priority);
|
||||
|
||||
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);
|
||||
|
||||
int session_mq_topic_is_active(struct session *sess, int topic_id);
|
||||
|
||||
|
||||
//packet mq api
|
||||
|
||||
typedef void on_packet_msg_cb_func(struct packet *pkt, int topic_id, const void *msg, void *plugin_env);
|
||||
//return 0 if success, otherwise return -1.
|
||||
int stellar_packet_mq_subscribe(struct stellar *st, int topic_id, on_packet_msg_cb_func *plugin_on_msg_cb, int plugin_id); //packet plugin only
|
||||
int packet_mq_publish_message(struct packet *pkt, int topic_id, void *msg);
|
||||
int packet_mq_publish_message_with_priority(struct packet *pkt, int topic_id, void *msg, enum stellar_mq_priority priority);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -31,6 +31,14 @@
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#endif
|
||||
|
||||
#ifndef likely
|
||||
#define likely(x) __builtin_expect((x),1)
|
||||
#endif /* likely */
|
||||
|
||||
#ifndef unlikely
|
||||
#define unlikely(x) __builtin_expect((x),0)
|
||||
#endif /* unlikely */
|
||||
|
||||
#ifndef __unused
|
||||
#define __unused __attribute__((__unused__))
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user