This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar/include/stellar/stellar.h
2024-08-30 15:04:46 +08:00

77 lines
2.7 KiB
C

#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.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);
// INTRINSIC TOPIC
// TOPIC_TCP_STREAM on_msg need convert msg to (const struct tcp_segment *)
// TOPIC_UDP_INPUT/TOPIC_TCP_INPUT/TOPIC_UDP_OUTPUT/TOPIC_TCP_OUTPUT/TOPIC_CONTROL_PACKET on_msg need convert msg to (const struct packet *)
#define TOPIC_TCP_STREAM "TCP_STREAM" //topic message: tcp_segment
#define TOPIC_CONTROL_PACKET "CONTROL_PACKET" //topic message: packet
#define TOPIC_TCP_INPUT "TCP_INPUT" //topic message: packet
#define TOPIC_TCP_OUTPUT "TCP_OUTPUT" //topic message: packet
#define TOPIC_UDP_INPUT "UDP_INPUT" //topic message: packet
#define TOPIC_UDP_OUTPUT "UDP_OUTPUT" //topic message: 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 tcp_segment;
const char *tcp_segment_get_data(const struct tcp_segment *seg);
uint16_t tcp_segment_get_len(const struct tcp_segment *seg);
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);
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_build_packet(struct stellar *st, struct packet *pkt);
struct stellar;
struct stellar *stellar_new(const char *stellar_cfg_file, const char *plugin_cfg_file, const char *log_cfg_file);
void stellar_run(struct stellar *st);
void stellar_free(struct stellar *st);
void stellar_loopbreak(struct stellar *st);
void stellar_reload_log_level(struct stellar *st);
struct logger *stellar_get_logger(struct stellar *st);
#ifdef __cplusplus
}
#endif