#ifndef _STELLAR_PUB_H
#define _STELLAR_PUB_H

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdint.h>
#include "stellar/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
int stellar_inject_tcp_rst(struct stellar *st, const struct session *sess, enum flow_direction inject_dir);
int stellar_inject_tcp_fin(struct stellar *st, const struct session *sess, enum flow_direction inject_dir);
int stellar_inject_tcp_payload(struct stellar *st, const struct session *sess, enum flow_direction inject_dir, const char *payload, uint16_t len);
int stellar_inject_udp_payload(struct stellar *st, const struct session *sess, enum flow_direction inject_dir, const char *payload, uint16_t len);
int stellar_inject_ctrl_msg(struct stellar *st, const struct session *sess, const struct sid_list *sids, const char *msg, uint16_t len);

int stellar_main(int argc, char **argv);

#ifdef __cplusplus
}
#endif

#endif
