feat(stellar_mq subscribe api): replace cb_arg with plugin_id

This commit is contained in:
yangwei
2024-09-09 14:14:59 +08:00
parent a24214cbee
commit 6403e832de
11 changed files with 48 additions and 68 deletions

View File

@@ -171,7 +171,17 @@ enum packet_action
{
PACKET_ACTION_FORWARD = 0,
PACKET_ACTION_DROP = 1,
PACKET_ACTION_FAST_FORWARD = 2,
};
#include <stdbool.h>
void packet_mark_as_drop(struct packet *pkt, bool drop);
void packet_free(struct packet *pkt);
void packet_set_action(struct packet *pkt, enum packet_action action);
enum packet_action packet_get_action(const struct packet *pkt);
@@ -184,6 +194,7 @@ uint16_t packet_get_raw_len(const struct packet *pkt);
const char *packet_get_payload(const struct packet *pkt);
uint16_t packet_get_payload_len(const struct packet *pkt);
#ifdef __cplusplus
}
#endif

View File

@@ -10,7 +10,7 @@ extern "C"
struct stellar;
/**********************************************
* PLUGIN SPEC API *
* PLUGIN API *
**********************************************/
//return plugin_env
@@ -21,15 +21,14 @@ typedef void plugin_on_unload_func(void *plugin_env);
* PLUGIN EVENT API *
**********************************************/
struct packet;
typedef void plugin_on_packet_func(struct packet *pkt, void *plugin_env);
typedef void plugin_on_packet_func(struct packet *pkt, void *on_packet_cb_arg);
//return plugin_id
int stellar_plugin_register(struct stellar *st, plugin_on_packet_func on_packet_input, plugin_on_packet_func on_packet_output, void *plugin_env);
int stellar_on_raw_packet_register(struct stellar *st, plugin_on_packet_func *on_packet_cb, void *on_packet_cb_arg);
//return polling work result, 0: no work, 1: work
typedef int plugin_on_polling_func(void *plugin_env);
typedef int plugin_on_polling_func(void *polling_arg);
//return polling plugin_id
int stellar_polling_plugin_register(struct stellar *st, plugin_on_polling_func on_polling, void *plugin_env);
int stellar_on_polling_register(struct stellar *st, plugin_on_polling_func on_polling, void *polling_arg);
/**********************************************
* STELLAR DEV API *

View File

@@ -16,8 +16,8 @@ inline static void stellar_msg_free_default(void *msg, void *msg_free_arg __unus
if(msg)FREE(msg);
}
typedef void on_msg_cb_func(int topic_id, const void *msg, void *plugin_env);
typedef void on_msg_dispatch_cb_func(int topic_id, const void *msg, on_msg_cb_func* on_msg_cb, void *dispatch_arg, void *sub_plugin_env);
typedef void on_msg_cb_func(int topic_id, const void *msg, void *on_msg_arg);
typedef void on_msg_dispatch_cb_func(int topic_id, const void *msg, on_msg_cb_func* on_msg_cb, void *on_msg_cb_arg, void *dispatch_arg);
//return topic_id
int stellar_mq_create_topic(struct stellar *st, const char *topic_name, on_msg_dispatch_cb_func *on_dispatch_cb, void *on_dispatch_arg, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
@@ -36,7 +36,7 @@ enum stellar_mq_priority
//return 0 if success, otherwise return -1.
int stellar_mq_subscribe(struct stellar *st, int topic_id, on_msg_cb_func *on_msg_cb, int plugin_id);
int stellar_mq_subscribe(struct stellar *st, int topic_id, on_msg_cb_func *on_msg_cb, void * on_msg_cb_arg);
int stellar_mq_publish_message(struct stellar *st, int topic_id, void *msg);
int stellar_mq_publish_message_with_priority(struct stellar *st, int topic_id, void *msg, enum stellar_mq_priority priority);