【新增】上传当前编译过程中的第三方依赖
This commit is contained in:
8
dependence/include/stellar/packet_exdata.h
Normal file
8
dependence/include/stellar/packet_exdata.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "stellar.h"
|
||||
|
||||
typedef void packet_exdata_free(struct packet *pkt, int idx, void *ex_ptr, void *arg);
|
||||
int stellar_packet_exdata_new_index(struct stellar *st, const char *name, packet_exdata_free *free_func,void *arg);
|
||||
int packet_exdata_set(struct packet *pkt, int idx, void *ex_ptr);
|
||||
void *packet_exdata_get(struct packet *pkt, int idx);
|
||||
22
dependence/include/stellar/packet_mq.h
Normal file
22
dependence/include/stellar/packet_mq.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "stellar.h"
|
||||
|
||||
//session mq
|
||||
typedef void packet_msg_free_cb_func(struct packet *pkt, void *msg, void *msg_free_arg);
|
||||
typedef void on_packet_msg_cb_func(struct packet *pkt, int topic_id, const void *msg, void *plugin_env);
|
||||
|
||||
//return topic_id
|
||||
int stellar_packet_mq_create_topic(struct stellar *st, const char *topic_name, packet_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
|
||||
|
||||
int stellar_packet_mq_get_topic_id(struct stellar *st, const char *topic_name);
|
||||
|
||||
int stellar_packet_mq_update_topic(struct stellar *st, int topic_id, packet_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
|
||||
|
||||
int stellar_packet_mq_destroy_topic(struct stellar *st, int topic_id);
|
||||
|
||||
//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);
|
||||
|
||||
134
dependence/include/stellar/session.h
Normal file
134
dependence/include/stellar/session.h
Normal file
@@ -0,0 +1,134 @@
|
||||
#pragma once
|
||||
|
||||
#include "stellar.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
enum session_type
|
||||
{
|
||||
SESSION_TYPE_TCP,
|
||||
SESSION_TYPE_UDP,
|
||||
__SESSION_TYPE_MAX,
|
||||
};
|
||||
|
||||
enum session_state
|
||||
{
|
||||
SESSION_STATE_INVALID = 0,
|
||||
SESSION_STATE_OPENING = 1 ,
|
||||
SESSION_STATE_ACTIVE = 2,
|
||||
SESSION_STATE_CLOSING = 3,
|
||||
SESSION_STATE_CONTROL = 6,
|
||||
__SESSION_STATE_MAX,
|
||||
};
|
||||
|
||||
enum session_type session_get_type(struct session *sess);
|
||||
|
||||
#define SESSION_SEEN_C2S_FLOW (1 << 0)
|
||||
#define SESSION_SEEN_S2C_FLOW (1 << 1)
|
||||
int session_is_symmetric(struct session *sess, unsigned char *flag);
|
||||
|
||||
long long session_get_client_isn(struct session *sess);
|
||||
long long session_get_server_isn(struct session *sess);
|
||||
|
||||
#define SESSION_IS_TUNNLE_NON (0) /* default is 0, not tunnel; */
|
||||
#define SESSION_IS_TUNNLE_6OVER4 (1 << 0)
|
||||
#define SESSION_IS_TUNNLE_4OVER6 (1 << 1)
|
||||
#define SESSION_IS_TUNNLE_GRE (1 << 2)
|
||||
#define SESSION_IS_TUNNLE_IP_IN_IP (1 << 3)
|
||||
#define SESSION_IS_TUNNLE_PPTP (1 << 4)
|
||||
#define SESSION_IS_TUNNLE_L2TP (1 << 5)
|
||||
#define SESSION_IS_TUNNLE_TEREDO (1 << 6)
|
||||
#define SESSION_IS_TUNNLE_GTP (1 << 7)
|
||||
#define SESSION_IS_TUNNLE_SOCKS (1 << 8)
|
||||
#define SESSION_IS_TUNNLE_HTTP_PROXY (1 << 9)
|
||||
|
||||
int session_is_outmost(struct session *sess, uint64_t *flag);
|
||||
int session_is_innermost(struct session *sess, uint64_t *flag);
|
||||
|
||||
#define SESSION_DIRECTION_IN 0
|
||||
#define SESSION_DIRECTION_OUT 1
|
||||
int session_get_direction(struct session *sess);
|
||||
|
||||
enum session_addr_type
|
||||
{
|
||||
SESSION_ADDR_TYPE_IPV4_TCP,
|
||||
SESSION_ADDR_TYPE_IPV4_UDP,
|
||||
SESSION_ADDR_TYPE_IPV6_TCP,
|
||||
SESSION_ADDR_TYPE_IPV6_UDP,
|
||||
SESSION_ADDR_TYPE_UNKNOWN,
|
||||
__SESSION_ADDR_TYPE_MAX,
|
||||
};
|
||||
struct session_addr_ipv4{
|
||||
uint32_t saddr; /* network order */
|
||||
uint32_t daddr; /* network order */
|
||||
uint16_t sport; /* network order */
|
||||
uint16_t dport; /* network order */
|
||||
};
|
||||
|
||||
#include <netinet/in.h>
|
||||
#ifndef IPV6_ADDR_LEN
|
||||
#define IPV6_ADDR_LEN (sizeof(struct in6_addr))
|
||||
#endif
|
||||
struct session_addr_ipv6
|
||||
{
|
||||
uint8_t saddr[IPV6_ADDR_LEN] ;
|
||||
uint8_t daddr[IPV6_ADDR_LEN] ;
|
||||
uint16_t sport; /* network order */
|
||||
uint16_t dport; /* network order */
|
||||
};
|
||||
|
||||
struct session_addr
|
||||
{
|
||||
union
|
||||
{
|
||||
struct session_addr_ipv4 ipv4;
|
||||
struct session_addr_ipv6 ipv6;
|
||||
};
|
||||
};
|
||||
|
||||
struct session_addr *session_get0_addr(struct session *sess, enum session_addr_type *addr_type);
|
||||
|
||||
const char *session_get0_readable_addr(struct session *sess);
|
||||
const char *session_get0_current_payload(struct session *sess, size_t *payload_len);
|
||||
enum session_state session_get_current_state(struct session *sess);
|
||||
|
||||
int session_get_current_thread_id(struct session *sess);
|
||||
int session_get_current_plugin_id(struct session *sess);
|
||||
|
||||
/* ------------session------------------*/
|
||||
/* |l2|l3|l4|session payload| */
|
||||
const char *session_get0_current_l3_header(struct session *sess);
|
||||
const char *session_get0_current_l4_header(struct session *sess);
|
||||
|
||||
const char *session_get0_l2_l3_hdr(struct session *sess, int session_direction, size_t *l2_l3_hdr_len);
|
||||
|
||||
uint16_t *session_get0_segment_id_list(struct session *sess, int session_direction, size_t *sid_num);
|
||||
const char *session_get0_route_ctx(struct session *sess, int session_direction, size_t *route_ctx_len);
|
||||
|
||||
int session_set_session_id(struct session *sess, uint64_t session_id);
|
||||
int session_set_preappend_segment_id_list(struct session *sess, uint16_t *sid, size_t sid_num);
|
||||
|
||||
const struct packet *session_get0_current_packet(struct session *sess);
|
||||
|
||||
|
||||
//flow direction
|
||||
#define PACKET_DIRECTION_C2S 0
|
||||
#define PACKET_DIRECTION_S2C 1
|
||||
#define PACKET_DIRECTION_UNKNOWN 2
|
||||
int packet_get_direction(const struct packet *pkt);
|
||||
|
||||
//route direction
|
||||
#define PACKET_DIRECTION_INCOMING 0
|
||||
#define PACKET_DIRECTION_OUTGOING 1
|
||||
int packet_get_route_direction(const struct packet *pkt);
|
||||
|
||||
const char *packet_get0_data(const struct packet *pkt, size_t *data_len);
|
||||
int packet_arrive_time(const struct packet *pkt, struct timeval *ts);
|
||||
unsigned char packet_get_ip_protocol(struct packet *pkt);
|
||||
|
||||
void packet_drop(const struct packet *pkt);
|
||||
const char *packet_get0_readable_addr(struct packet *pkt);
|
||||
int packet_get_current_thread_id(struct packet *pkt);
|
||||
|
||||
struct session *packet_get_session(const struct packet *pkt);
|
||||
8
dependence/include/stellar/session_exdata.h
Normal file
8
dependence/include/stellar/session_exdata.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#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);
|
||||
36
dependence/include/stellar/session_mq.h
Normal file
36
dependence/include/stellar/session_mq.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "stellar.h"
|
||||
|
||||
//session mq
|
||||
typedef void session_msg_free_cb_func(struct session *sess, void *msg, void *msg_free_arg);
|
||||
typedef void on_session_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, session_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, session_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_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_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);
|
||||
|
||||
enum session_mq_priority
|
||||
{
|
||||
SESSION_MQ_PRIORITY_LOW,
|
||||
SESSION_MQ_PRIORITY_NORMAL,
|
||||
SESSION_MQ_PRIORITY_HIGH,
|
||||
SESSION_MQ_PRIORITY_MAX,
|
||||
};
|
||||
|
||||
int session_mq_publish_message_with_priority(struct session *sess, int topic_id, void *msg, enum session_mq_priority priority);
|
||||
48
dependence/include/stellar/stellar.h
Normal file
48
dependence/include/stellar/stellar.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
struct session;
|
||||
struct stellar;
|
||||
|
||||
int stellar_get_worker_thread_num(struct stellar *st);
|
||||
int stellar_get_current_thread_id(struct stellar *st);
|
||||
|
||||
//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, publish packet as message
|
||||
#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);
|
||||
|
||||
|
||||
void stellar_emit_datapath_telemetry(struct packet *pkt, const char * module, const char *str);
|
||||
43
dependence/include/stellar/utils.h
Normal file
43
dependence/include/stellar/utils.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h> //calloc
|
||||
#include <stddef.h> //NULL
|
||||
|
||||
#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
|
||||
|
||||
#ifndef likely
|
||||
#define likely(x) __builtin_expect((x),1)
|
||||
#endif /* likely */
|
||||
|
||||
#ifndef unlikely
|
||||
#define unlikely(x) __builtin_expect((x),0)
|
||||
#endif /* unlikely */
|
||||
Reference in New Issue
Block a user