diff --git a/src/id_generator/id_generator.cpp b/src/id_generator/id_generator.cpp index d66bd45..8cc68ab 100644 --- a/src/id_generator/id_generator.cpp +++ b/src/id_generator/id_generator.cpp @@ -1,11 +1,15 @@ #include #include +#include "log.h" #include "macro.h" #include "times.h" -#include "stellar_priv.h" +#include "stellar_utils.h" #include "id_generator.h" +#define ID_GENERATOR_LOG_ERROR(format, ...) LOG_ERROR("id generator", format, ##__VA_ARGS__) +#define ID_GENERATOR_LOG_DEBUG(format, ...) LOG_DEBUG("id generator", format, ##__VA_ARGS__) + struct id_generator { uint8_t device_base; // 5bit [0, 31] diff --git a/src/id_generator/id_generator.h b/src/id_generator/id_generator.h index c100264..1f356ef 100644 --- a/src/id_generator/id_generator.h +++ b/src/id_generator/id_generator.h @@ -7,11 +7,6 @@ extern "C" #include -#include "log.h" - -#define ID_GENERATOR_LOG_ERROR(format, ...) LOG_ERROR("id generator", format, ##__VA_ARGS__) -#define ID_GENERATOR_LOG_DEBUG(format, ...) LOG_DEBUG("id generator", format, ##__VA_ARGS__) - /* * device_base (5bit) : [0, 31] * device_offset (7bit) : [0, 127] diff --git a/src/packet/packet_def.h b/src/packet/packet_def.h index 3e24343..7cb8deb 100644 --- a/src/packet/packet_def.h +++ b/src/packet/packet_def.h @@ -23,7 +23,7 @@ struct metadata struct sids sids; uint64_t session_id; - uint64_t domain_id; + uint64_t domain; uint16_t link_id; int is_ctrl; diff --git a/src/packet/packet_utils.cpp b/src/packet/packet_utils.cpp index 6b249f8..5a07136 100644 --- a/src/packet/packet_utils.cpp +++ b/src/packet/packet_utils.cpp @@ -66,14 +66,14 @@ uint64_t packet_get_session_id(const struct packet *pkt) return pkt->meta.session_id; } -void packet_set_domain_id(struct packet *pkt, uint64_t id) +void packet_set_domain(struct packet *pkt, uint64_t domain) { - pkt->meta.domain_id = id; + pkt->meta.domain = domain; } -uint64_t packet_get_domain_id(const struct packet *pkt) +uint64_t packet_get_domain(const struct packet *pkt) { - return pkt->meta.domain_id; + return pkt->meta.domain; } void packet_set_link_id(struct packet *pkt, uint16_t id) @@ -326,7 +326,6 @@ int packet_get_innermost_tuple6(const struct packet *pkt, struct tuple6 *tuple) const struct raw_layer *layer_l3 = NULL; const struct raw_layer *layer_l4 = NULL; const struct raw_layer *layer = NULL; - uint64_t domain = packet_get_domain_id(pkt); for (int8_t i = pkt->layers_used - 1; i >= 0; i--) { @@ -375,7 +374,7 @@ int packet_get_innermost_tuple6(const struct packet *pkt, struct tuple6 *tuple) if (layer_l3 && layer_l4 && layer_l4 - layer_l3 == 1) { - tuple->domain = packet_get_domain_id(pkt); + tuple->domain = packet_get_domain(pkt); return 0; } else @@ -392,7 +391,6 @@ int packet_get_outermost_tuple6(const struct packet *pkt, struct tuple6 *tuple) const struct raw_layer *layer_l3 = NULL; const struct raw_layer *layer_l4 = NULL; const struct raw_layer *layer = NULL; - uint64_t domain = packet_get_domain_id(pkt); for (int8_t i = 0; i < pkt->layers_used; i++) { @@ -441,7 +439,7 @@ int packet_get_outermost_tuple6(const struct packet *pkt, struct tuple6 *tuple) if (layer_l3 && layer_l4 && layer_l4 - layer_l3 == 1) { - tuple->domain = packet_get_domain_id(pkt); + tuple->domain = packet_get_domain(pkt); return 0; } else diff --git a/src/packet/packet_utils.h b/src/packet/packet_utils.h index 3e4c4f9..fb8d3e7 100644 --- a/src/packet/packet_utils.h +++ b/src/packet/packet_utils.h @@ -22,8 +22,8 @@ void packet_prepend_sids(struct packet *pkt, const struct sids *sids); void packet_set_session_id(struct packet *pkt, uint64_t id); uint64_t packet_get_session_id(const struct packet *pkt); -void packet_set_domain_id(struct packet *pkt, uint64_t id); -uint64_t packet_get_domain_id(const struct packet *pkt); +void packet_set_domain(struct packet *pkt, uint64_t domain); +uint64_t packet_get_domain(const struct packet *pkt); void packet_set_link_id(struct packet *pkt, uint16_t id); uint16_t packet_get_link_id(const struct packet *pkt); diff --git a/src/packet_io/lock_free_queue.cpp b/src/packet_io/lock_free_queue.cpp index a8d03e2..17d1b65 100644 --- a/src/packet_io/lock_free_queue.cpp +++ b/src/packet_io/lock_free_queue.cpp @@ -3,9 +3,13 @@ #include #include +#include "log.h" #include "macro.h" #include "lock_free_queue.h" +#define LOCK_FREE_QUEUE_LOG_ERROR(format, ...) LOG_ERROR("lock free queue", format, ##__VA_ARGS__) +#define LOCK_FREE_QUEUE_LOG_DEBUG(format, ...) LOG_DEBUG("lock free queue", format, ##__VA_ARGS__) + struct lock_free_queue { uint64_t *queue; diff --git a/src/packet_io/lock_free_queue.h b/src/packet_io/lock_free_queue.h index 584f561..7acbc62 100644 --- a/src/packet_io/lock_free_queue.h +++ b/src/packet_io/lock_free_queue.h @@ -5,11 +5,6 @@ extern "C" { #endif -#include "log.h" - -#define LOCK_FREE_QUEUE_LOG_ERROR(format, ...) LOG_ERROR("lock free queue", format, ##__VA_ARGS__) -#define LOCK_FREE_QUEUE_LOG_DEBUG(format, ...) LOG_DEBUG("lock free queue", format, ##__VA_ARGS__) - struct lock_free_queue; struct lock_free_queue *lock_free_queue_new(uint32_t size); diff --git a/src/packet_io/marsio_io.cpp b/src/packet_io/marsio_io.cpp index 7add76b..2850d6d 100644 --- a/src/packet_io/marsio_io.cpp +++ b/src/packet_io/marsio_io.cpp @@ -31,7 +31,7 @@ static void metadata_from_mbuff_to_packet(marsio_buff_t *mbuff, struct packet *p struct route_ctx route_ctx = {0}; struct sids sids = {0}; uint64_t session_id = {0}; - uint64_t domain_id = {0}; + uint64_t domain = {0}; uint16_t link_id = {0}; int is_ctrl = {0}; enum packet_direction direction = PACKET_DIRECTION_OUTGOING; @@ -67,9 +67,9 @@ static void metadata_from_mbuff_to_packet(marsio_buff_t *mbuff, struct packet *p // TODO #if 0 - if (marsio_buff_get_metadata(mbuff, MR_BUFF_DOMAIN_ID, &domain_id, sizeof(domain_id)) == sizeof(domain_id)) + if (marsio_buff_get_metadata(mbuff, MR_BUFF_DOMAIN, &domain, sizeof(domain)) == sizeof(domain)) { - packet_set_domain_id(pkt, domain_id); + packet_set_domain(pkt, domain); } else { @@ -107,7 +107,7 @@ static void metadata_from_packet_to_mbuff(struct packet *pkt, marsio_buff_t *mbu const struct route_ctx *route_ctx = packet_get_route_ctx(pkt); const struct sids *sids = packet_get_sids(pkt); uint64_t session_id = packet_get_session_id(pkt); - uint64_t domain_id = packet_get_domain_id(pkt); + uint64_t domain = packet_get_domain(pkt); uint16_t link_id = packet_get_link_id(pkt); int is_ctrl = packet_is_ctrl(pkt); enum packet_direction direction = packet_get_direction(pkt); @@ -129,7 +129,7 @@ static void metadata_from_packet_to_mbuff(struct packet *pkt, marsio_buff_t *mbu // TODO #if 0 - if (marsio_buff_set_metadata(mbuff, MR_BUFF_DOMAIN_ID, &domain_id, sizeof(domain_id)) != 0) + if (marsio_buff_set_metadata(mbuff, MR_BUFF_DOMAIN, &domain, sizeof(domain)) != 0) { PACKET_IO_LOG_ERROR("failed to set domain id"); } diff --git a/src/plugin/plugin_manager.cpp b/src/plugin/plugin_manager.cpp index 2dfa3cc..2d0cd1d 100644 --- a/src/plugin/plugin_manager.cpp +++ b/src/plugin/plugin_manager.cpp @@ -1,9 +1,9 @@ #include #include "plugin_manager.h" -#include "session_priv.h" -#include "stellar_priv.h" +#include "session_utils.h" +#include "packet_utils.h" +#include "stellar_utils.h" #include "stellar/utils.h" -#include "stellar/session.h" #include "stellar/session_exdata.h" #include "stellar/session_mq.h" #include "tcp_reassembly.h" @@ -212,7 +212,6 @@ PLUGIN_SPEC_LOAD_ERROR: return NULL; } -#include "session_priv.h" static void tcp_stream_msg_free_fn(void *msg, void *msg_free_arg) { struct session *cur_sess = plugin_manager_scratch_session_get(); diff --git a/src/plugin/plugin_manager.h b/src/plugin/plugin_manager.h index b6dd98f..236a1ff 100644 --- a/src/plugin/plugin_manager.h +++ b/src/plugin/plugin_manager.h @@ -5,11 +5,6 @@ extern "C" { #endif -#include "session_priv.h" - -#define PLUGIN_MANAGER_LOG_ERROR(format, ...) LOG_ERROR("plugin manager", format, ##__VA_ARGS__) -#define PLUGIN_MANAGER_LOG_DEBUG(format, ...) LOG_DEBUG("plugin manager", format, ##__VA_ARGS__) - struct plugin_manager_schema; struct plugin_manager_runtime; diff --git a/src/session/CMakeLists.txt b/src/session/CMakeLists.txt index e7c2d0d..1573f66 100644 --- a/src/session/CMakeLists.txt +++ b/src/session/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(session_manager - session.cpp + session_utils.cpp session_pool.cpp session_table.cpp session_timer.cpp diff --git a/src/session/session_def.h b/src/session/session_def.h new file mode 100644 index 0000000..a611f18 --- /dev/null +++ b/src/session/session_def.h @@ -0,0 +1,83 @@ +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "list.h" +#include "tuple.h" +#include "uthash.h" +#include "timeout.h" +#include "packet_def.h" +#include "stellar/session.h" +#include "tcp_reassembly.h" + +#define EX_DATA_MAX_COUNT 4 + +// output format: "${src_addr}:${src_port}-${dst_addr}:${dst_port}-${ip_proto}-${domain}" +// output max len: (46 + 1 + 5) + 1 + (46 + 1 + 5) + 1 + 1 + 1 + 20 = 129 +#define TUPLE6_STR_SIZE 130 + +struct tcp_half +{ + struct tcp_reassembly *assembler; + struct tcp_segment in_order; // current packet in order segment + uint32_t in_order_ref; // reference count of current packet in order segment + + uint32_t inject_inc_seq_offset; // inject packet base on current packet increase seq offset + uint32_t inject_inc_ack_offset; // inject packet base on current packet increase ack offset + + uint32_t seq; // current packet sequence number + uint32_t ack; // current packet ack number + uint16_t len; // current packet payload length + uint8_t flags; // current packet flags + + uint32_t isn; // current direction initial sequence number + uint8_t history; // current direction received flags +}; + +/* + * sizeof(struct session) > 1024 bytes + * max thread number = 128 + * per thread max tcp session number = 50000 + * per thread max udp session number = 50000 + * + * session memory usage = 128 * (50000 + 50000) * 1024 = 13107200000 bytes = 12.2 GB + */ +struct session +{ + uint64_t id; + uint64_t stats[MAX_FLOW_DIRECTION][MAX_STAT]; + uint64_t timestamps[MAX_TIMESTAMP]; // realtime seconds + struct tcp_half tcp_halfs[MAX_FLOW_DIRECTION]; + struct timeout timeout; + struct list_head lru; + struct list_head free; + struct list_head evicte; + UT_hash_handle hh1; + UT_hash_handle hh2; + UT_hash_handle hh3; + struct tuple6 tuple; + char tuple_str[TUPLE6_STR_SIZE]; + struct sids sids[MAX_FLOW_DIRECTION]; + struct route_ctx route_ctx[MAX_FLOW_DIRECTION]; + const struct packet *first_pkt[MAX_FLOW_DIRECTION]; + const struct packet *curr_pkt; + void *ex_data[EX_DATA_MAX_COUNT]; + void *user_data; + int is_symmetric; + int dup; + enum session_direction sess_dir; + enum flow_direction tuple_dir; + enum flow_direction flow_dir; + enum session_type type; + enum session_state state; + enum closing_reason reason; + struct session_manager *mgr; + struct session_manager_stat *mgr_stat; +}; + +#ifdef __cplusplus +} +#endif diff --git a/src/session/session_manager.cpp b/src/session/session_manager.cpp index 1ccd9ec..d9dd5e5 100644 --- a/src/session/session_manager.cpp +++ b/src/session/session_manager.cpp @@ -2,12 +2,16 @@ #include #include +#include "log.h" #include "macro.h" #include "times.h" #include "tcp_utils.h" #include "udp_utils.h" #include "packet_layer.h" +#include "packet_utils.h" #include "id_generator.h" +#include "session_def.h" +#include "session_utils.h" #include "session_pool.h" #include "session_table.h" #include "session_timer.h" @@ -16,6 +20,9 @@ #include "evicted_session_filter.h" #include "duplicated_packet_filter.h" +#define SESSION_LOG_ERROR(format, ...) LOG_ERROR("session", format, ##__VA_ARGS__) +#define SESSION_LOG_DEBUG(format, ...) LOG_DEBUG("session", format, ##__VA_ARGS__) + struct session_manager { struct list_head evicte_queue; @@ -528,7 +535,7 @@ static void session_update(struct session *sess, enum session_state next_state, if (session_get_current_state(sess) == SESSION_STATE_INIT) { session_set_id(sess, id_generator_alloc()); - session_set_tuple(sess, key); + session_set_tuple6(sess, key); session_set_tuple_direction(sess, dir); enum packet_direction pkt_dir = packet_get_direction(pkt); diff --git a/src/session/session_manager.h b/src/session/session_manager.h index 48cf685..f562a80 100644 --- a/src/session/session_manager.h +++ b/src/session/session_manager.h @@ -5,12 +5,6 @@ extern "C" { #endif -#include "session_priv.h" -#include "log.h" - -#define SESSION_LOG_ERROR(format, ...) LOG_ERROR("session", format, ##__VA_ARGS__) -#define SESSION_LOG_DEBUG(format, ...) LOG_DEBUG("session", format, ##__VA_ARGS__) - struct session_manager_options { // max session number diff --git a/src/session/session_pool.cpp b/src/session/session_pool.cpp index 134a752..aff982a 100644 --- a/src/session/session_pool.cpp +++ b/src/session/session_pool.cpp @@ -1,3 +1,6 @@ +#include + +#include "session_def.h" #include "session_pool.h" struct session_pool diff --git a/src/session/session_pool.h b/src/session/session_pool.h index 76433a5..49d035c 100644 --- a/src/session/session_pool.h +++ b/src/session/session_pool.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "session_priv.h" +#include struct session_pool; struct session_pool *session_pool_new(uint64_t count); diff --git a/src/session/session_table.cpp b/src/session/session_table.cpp index bd62db7..24d735a 100644 --- a/src/session/session_table.cpp +++ b/src/session/session_table.cpp @@ -2,6 +2,7 @@ #define HASH_FUNCTION(keyptr, keylen, hashv) HASH_FUNCTION_OVERWRITE(keyptr, keylen, &hashv) #define HASH_KEYCMP(a, b, len) HASH_KEYCMP_OVERWRITE(a, b, len) +#include "session_def.h" #include "session_table.h" struct session_table diff --git a/src/session/session_table.h b/src/session/session_table.h index d543543..205f3e0 100644 --- a/src/session/session_table.h +++ b/src/session/session_table.h @@ -5,8 +5,6 @@ extern "C" { #endif -#include "session_priv.h" - struct session_table; struct session_table *session_table_new(); void session_table_free(struct session_table *table); diff --git a/src/session/session_timer.cpp b/src/session/session_timer.cpp index 07cb3bc..c3ff593 100644 --- a/src/session/session_timer.cpp +++ b/src/session/session_timer.cpp @@ -1,3 +1,4 @@ +#include "session_def.h" #include "session_timer.h" struct session_timer diff --git a/src/session/session_timer.h b/src/session/session_timer.h index 074522a..56b2f79 100644 --- a/src/session/session_timer.h +++ b/src/session/session_timer.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "session_priv.h" +#include struct session_timer; struct session_timer *session_timer_new(uint64_t now); diff --git a/src/session/session_transition.cpp b/src/session/session_transition.cpp index 5a61d0a..cd439eb 100644 --- a/src/session/session_transition.cpp +++ b/src/session/session_transition.cpp @@ -1,8 +1,12 @@ #include #include +#include "log.h" +#include "session_utils.h" #include "session_transition.h" +#define SESSION_TRANSITION_LOG_INFO(format, ...) LOG_INFO("session transition", format, ##__VA_ARGS__) + #define MAX_TRANSITION_PER_STATE 8 struct session_transition diff --git a/src/session/session_transition.h b/src/session/session_transition.h index a23031d..e413f93 100644 --- a/src/session/session_transition.h +++ b/src/session/session_transition.h @@ -5,10 +5,7 @@ extern "C" { #endif -#include "log.h" -#include "session_priv.h" - -#define SESSION_TRANSITION_LOG_INFO(format, ...) LOG_INFO("session transition", format, ##__VA_ARGS__) +#include "stellar/session.h" enum session_inputs { diff --git a/src/session/session.cpp b/src/session/session_utils.cpp similarity index 97% rename from src/session/session.cpp rename to src/session/session_utils.cpp index cb90fee..6d4c007 100644 --- a/src/session/session.cpp +++ b/src/session/session_utils.cpp @@ -1,26 +1,25 @@ #include -#include "packet_def.h" -#include "session_priv.h" -#include "tcp_utils.h" -#include "tcp_reassembly.h" +#include "session_def.h" +#include "session_utils.h" +#include "session_manager.h" #define EX_KEY_MAX_LEN 64 -struct ex_schema +struct session_exdata_schema { char key[EX_KEY_MAX_LEN]; session_ex_free_cb *free_cb; void *args; }; -struct ex_manager +struct session_exdata_manager { - struct ex_schema schemas[EX_DATA_MAX_COUNT]; + struct session_exdata_schema schemas[EX_DATA_MAX_COUNT]; uint8_t count; }; -static struct ex_manager g_ex_manager = {0}; +static struct session_exdata_manager g_ex_manager = {0}; /****************************************************************************** * session set/get @@ -41,7 +40,7 @@ uint64_t session_get_id(const struct session *sess) return sess->id; } -void session_set_tuple(struct session *sess, const struct tuple6 *tuple) +void session_set_tuple6(struct session *sess, const struct tuple6 *tuple) { memcpy(&sess->tuple, tuple, sizeof(struct tuple6)); } @@ -264,6 +263,7 @@ struct tcp_segment *session_get_tcp_segment(struct session *sess) session_inc_stat(sess, dir, STAT_TCP_SEGMENTS_REORDERED, 1); session_inc_stat(sess, dir, STAT_TCP_PAYLOADS_REORDERED, seg->len); + // TODO sess->mgr_stat->nr_tcp_seg_reorded++; } return seg; @@ -326,7 +326,7 @@ uint8_t session_get_ex_new_index(const char *key, session_ex_free_cb *free_cb, v uint8_t idx = g_ex_manager.count; g_ex_manager.count++; - struct ex_schema *schema = &g_ex_manager.schemas[idx]; + struct session_exdata_schema *schema = &g_ex_manager.schemas[idx]; strncpy(schema->key, key, EX_KEY_MAX_LEN); schema->free_cb = free_cb; schema->args = args; @@ -377,7 +377,7 @@ void session_free_ex_data(struct session *sess, uint8_t idx) return; } - struct ex_schema *schema = &g_ex_manager.schemas[idx]; + struct session_exdata_schema *schema = &g_ex_manager.schemas[idx]; if (schema->free_cb != NULL && sess->ex_data[idx] != NULL) { printf("free ex_data, idx: %d, key: %s, val: %p\n", idx, schema->key, sess->ex_data[idx]); diff --git a/src/session/session_priv.h b/src/session/session_utils.h similarity index 61% rename from src/session/session_priv.h rename to src/session/session_utils.h index c53fbeb..cd2811c 100644 --- a/src/session/session_priv.h +++ b/src/session/session_utils.h @@ -5,113 +5,88 @@ extern "C" { #endif -#include "list.h" -#include "tuple.h" -#include "uthash.h" -#include "timeout.h" -#include "packet_def.h" -#include "packet_utils.h" +#include + #include "stellar/session.h" -#include "tcp_reassembly.h" -#include "session_manager.h" -#define EX_DATA_MAX_COUNT 4 - -// output format: "${src_addr}:${src_port}-${dst_addr}:${dst_port}-${ip_proto}-${domain}" -// output max len: (46 + 1 + 5) + 1 + (46 + 1 + 5) + 1 + 1 + 1 + 20 = 129 -#define TUPLE6_STR_SIZE 130 - -struct tcp_half -{ - struct tcp_reassembly *assembler; - struct tcp_segment in_order; // current packet in order segment - uint32_t in_order_ref; // reference count of current packet in order segment - - uint32_t inject_inc_seq_offset; // inject packet base on current packet increase seq offset - uint32_t inject_inc_ack_offset; // inject packet base on current packet increase ack offset - - uint32_t seq; // current packet sequence number - uint32_t ack; // current packet ack number - uint16_t len; // current packet payload length - uint8_t flags; // current packet flags - - uint32_t isn; // current direction initial sequence number - uint8_t history; // current direction received flags -}; - -/* - * sizeof(struct session) > 1024 bytes - * max thread number = 128 - * per thread max tcp session number = 50000 - * per thread max udp session number = 50000 - * - * session memory usage = 128 * (50000 + 50000) * 1024 = 13107200000 bytes = 12.2 GB - */ -struct session -{ - uint64_t id; - uint64_t stats[MAX_FLOW_DIRECTION][MAX_STAT]; - uint64_t timestamps[MAX_TIMESTAMP]; // realtime seconds - struct tcp_half tcp_halfs[MAX_FLOW_DIRECTION]; - struct timeout timeout; - struct list_head lru; - struct list_head free; - struct list_head evicte; - UT_hash_handle hh1; - UT_hash_handle hh2; - UT_hash_handle hh3; - struct tuple6 tuple; - char tuple_str[TUPLE6_STR_SIZE]; - struct sids sids[MAX_FLOW_DIRECTION]; - struct route_ctx route_ctx[MAX_FLOW_DIRECTION]; - const struct packet *first_pkt[MAX_FLOW_DIRECTION]; - const struct packet *curr_pkt; - void *ex_data[EX_DATA_MAX_COUNT]; - void *user_data; - int is_symmetric; - int dup; - enum session_direction sess_dir; - enum flow_direction tuple_dir; - enum flow_direction flow_dir; - enum session_type type; - enum session_state state; - enum closing_reason reason; - struct session_manager *mgr; - struct session_manager_stat *mgr_stat; -}; +/****************************************************************************** + * session set/get + ******************************************************************************/ void session_init(struct session *sess); -void session_set_id(struct session *sess, uint64_t id); -void session_set_tuple(struct session *sess, const struct tuple6 *key); +// session ID +void session_set_id(struct session *sess, uint64_t id); +uint64_t session_get_id(const struct session *sess); + +// session tuple +void session_set_tuple6(struct session *sess, const struct tuple6 *tuple); const struct tuple6 *session_get_tuple6(const struct session *sess); +// session tuple direction void session_set_tuple_direction(struct session *sess, enum flow_direction dir); enum flow_direction session_get_tuple6_direction(const struct session *sess); +const char *session_get0_readable_addr(const struct session *sess); +// session direction void session_set_direction(struct session *sess, enum session_direction dir); -void session_set_current_flow_direction(struct session *sess, enum flow_direction dir); -void session_set_current_state(struct session *sess, enum session_state state); -void session_set_type(struct session *sess, enum session_type type); -void session_set_duplicate_traffic(struct session *sess); -void session_set_closing_reason(struct session *sess, enum closing_reason reason); -void session_inc_stat(struct session *sess, enum flow_direction dir, enum session_stat stat, uint64_t val); -void session_set_timestamp(struct session *sess, enum session_timestamp type, uint64_t value); +enum session_direction session_get_direction(const struct session *sess); +// session flow direction +void session_set_current_flow_direction(struct session *sess, enum flow_direction dir); +enum flow_direction session_get_current_flow_direction(const struct session *sess); + +// session state +void session_set_current_state(struct session *sess, enum session_state state); +enum session_state session_get_current_state(const struct session *sess); + +// session type +void session_set_type(struct session *sess, enum session_type type); +enum session_type session_get_type(const struct session *sess); + +// session seen duplicate traffic +void session_set_duplicate_traffic(struct session *sess); +int session_has_duplicate_traffic(const struct session *sess); + +// session closing reason +void session_set_closing_reason(struct session *sess, enum closing_reason reason); +enum closing_reason session_get_closing_reason(const struct session *sess); + +// session stat +void session_inc_stat(struct session *sess, enum flow_direction dir, enum session_stat stat, uint64_t val); +uint64_t session_get_stat(const struct session *sess, enum flow_direction dir, enum session_stat stat); + +// session timestamp +void session_set_timestamp(struct session *sess, enum session_timestamp type, uint64_t value); +uint64_t session_get_timestamp(const struct session *sess, enum session_timestamp type); + +// session sids void session_clear_sids(struct session *sess, enum flow_direction dir); void session_set_sids(struct session *sess, enum flow_direction dir, const struct sids *sids); const struct sids *session_get_sids(const struct session *sess, enum flow_direction dir); +// session route ctx void session_clear_route_ctx(struct session *sess, enum flow_direction dir); void session_set_route_ctx(struct session *sess, enum flow_direction dir, const struct route_ctx *ctx); const struct route_ctx *session_get_route_ctx(const struct session *sess, enum flow_direction dir); +// session first packet void session_set_first_packet(struct session *sess, enum flow_direction dir, const struct packet *pkt); -void session_set_current_packet(struct session *sess, const struct packet *pkt); +const struct packet *session_get_first_packet(const struct session *sess, enum flow_direction dir); +// session current packet +void session_set_current_packet(struct session *sess, const struct packet *pkt); +const struct packet *session_get0_current_packet(const struct session *sess); +const char *session_get0_current_payload(const struct session *sess, uint16_t *payload_len); + +// session symmetric +int session_is_symmetric(const struct session *sess, unsigned char *flag); + +// session user data void session_set_user_data(struct session *sess, void *user_data); void *session_get_user_data(const struct session *sess); +// session tcp segment struct tcp_segment *session_get_tcp_segment(struct session *sess); void session_free_tcp_segment(struct session *sess, struct tcp_segment *seg); @@ -129,6 +104,7 @@ typedef void session_ex_free_cb(struct session *sess, uint8_t idx, void *ex_ptr, * if key exist, not allow update, return original index. */ uint8_t session_get_ex_new_index(const char *key, session_ex_free_cb *free_cb, void *args); + /* * Support update ex_data. * @@ -147,15 +123,16 @@ void session_free_ex_data(struct session *sess, uint8_t idx); void session_free_all_ex_data(struct session *sess); /****************************************************************************** - * debug + * to string ******************************************************************************/ -const char *session_type_to_str(enum session_type type); -const char *session_state_to_str(enum session_state state); -const char *flow_direction_to_str(enum flow_direction dir); const char *closing_reason_to_str(enum closing_reason reason); -void session_print(struct session *sess); +const char *session_state_to_str(enum session_state state); +const char *session_type_to_str(enum session_type type); +const char *flow_direction_to_str(enum flow_direction dir); + int session_to_json(struct session *sess, char *buff, int size); +void session_print(struct session *sess); #ifdef __cplusplus } diff --git a/src/session/test/gtest_case_tcp_fast_open.cpp b/src/session/test/gtest_case_tcp_fast_open.cpp index 5af9e20..26329a2 100644 --- a/src/session/test/gtest_case_tcp_fast_open.cpp +++ b/src/session/test/gtest_case_tcp_fast_open.cpp @@ -1,9 +1,12 @@ #include +#include "tuple.h" #include "times.h" +#include "packet_def.h" #include "packet_parse.h" -#include "session_priv.h" +#include "session_utils.h" #include "session_manager.h" +#include "tcp_reassembly.h" struct session_manager_options opts = { // max session number diff --git a/src/session/test/gtest_filter_tcp_dupkt.cpp b/src/session/test/gtest_filter_tcp_dupkt.cpp index b16c3a6..e0d30bb 100644 --- a/src/session/test/gtest_filter_tcp_dupkt.cpp +++ b/src/session/test/gtest_filter_tcp_dupkt.cpp @@ -1,9 +1,11 @@ #include -#include "session_priv.h" -#include "session_manager.h" - #include "ipv4_utils.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" +#include "session_manager.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_overload_evict_tcp_sess.cpp b/src/session/test/gtest_overload_evict_tcp_sess.cpp index 942b803..421f189 100644 --- a/src/session/test/gtest_overload_evict_tcp_sess.cpp +++ b/src/session/test/gtest_overload_evict_tcp_sess.cpp @@ -1,10 +1,12 @@ #include -#include "session_priv.h" -#include "session_manager.h" - #include "macro.h" #include "ipv4_utils.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" +#include "session_manager.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_overload_evict_udp_sess.cpp b/src/session/test/gtest_overload_evict_udp_sess.cpp index de10da9..e0713c4 100644 --- a/src/session/test/gtest_overload_evict_udp_sess.cpp +++ b/src/session/test/gtest_overload_evict_udp_sess.cpp @@ -1,10 +1,12 @@ #include -#include "session_priv.h" -#include "session_manager.h" - #include "macro.h" #include "ipv4_utils.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" +#include "session_manager.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_sess_mgr_tcp_reassembly.cpp b/src/session/test/gtest_sess_mgr_tcp_reassembly.cpp index 731c77f..493a8c2 100644 --- a/src/session/test/gtest_sess_mgr_tcp_reassembly.cpp +++ b/src/session/test/gtest_sess_mgr_tcp_reassembly.cpp @@ -1,9 +1,12 @@ #include -#include "session_priv.h" -#include "session_manager.h" - #include "ipv4_utils.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" +#include "session_manager.h" +#include "tcp_reassembly.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_session.cpp b/src/session/test/gtest_session.cpp index 72430b0..afd8625 100644 --- a/src/session/test/gtest_session.cpp +++ b/src/session/test/gtest_session.cpp @@ -1,6 +1,7 @@ #include -#include "session_priv.h" +#include "session_def.h" +#include "session_utils.h" #define SESSION_KEY_IPV4_TCP(name) \ struct tuple6 name; \ @@ -57,7 +58,7 @@ TEST(SESSION, EX_NEW_INDEX) TEST(SESSION, EX_SET_GET) { struct session sess; - memset(&sess, 0, sizeof(sess)); + session_init(&sess); uint8_t idx = session_get_ex_new_index("ex_set_get", NULL, NULL); session_set_ex_data(&sess, idx, (void *)0x1234); EXPECT_TRUE(session_get0_ex_data(&sess, idx) == (void *)0x1234); @@ -66,7 +67,7 @@ TEST(SESSION, EX_SET_GET) TEST(SESSION, EX_FREE_BY_RESET) { struct session sess; - memset(&sess, 0, sizeof(sess)); + session_init(&sess); uint8_t idx = session_get_ex_new_index("ex_free_by_reset", free_ex_data, NULL); char *ptr = strdup("hello"); session_set_ex_data(&sess, idx, ptr); @@ -76,7 +77,7 @@ TEST(SESSION, EX_FREE_BY_RESET) TEST(SESSION, EX_FREE_BY_CB) { struct session sess; - memset(&sess, 0, sizeof(sess)); + session_init(&sess); uint8_t idx = session_get_ex_new_index("ex_free_by_cb", free_ex_data, NULL); char *ptr = strdup("hello"); session_set_ex_data(&sess, idx, ptr); diff --git a/src/session/test/gtest_session_table.cpp b/src/session/test/gtest_session_table.cpp index 477766f..3f7e866 100644 --- a/src/session/test/gtest_session_table.cpp +++ b/src/session/test/gtest_session_table.cpp @@ -1,5 +1,7 @@ #include +#include "tuple.h" +#include "session_utils.h" #include "session_pool.h" #include "session_table.h" @@ -112,17 +114,17 @@ TEST(SESSION_TABLE, OP_SESSION) sess1 = session_pool_pop(sess_pool); EXPECT_TRUE(sess1 != NULL); session_set_id(sess1, 1); - session_set_tuple(sess1, &sess1_tup6); + session_set_tuple6(sess1, &sess1_tup6); sess2 = session_pool_pop(sess_pool); EXPECT_TRUE(sess2 != NULL); session_set_id(sess2, 2); - session_set_tuple(sess2, &sess2_tup6); + session_set_tuple6(sess2, &sess2_tup6); sess3 = session_pool_pop(sess_pool); EXPECT_TRUE(sess3 != NULL); session_set_id(sess3, 3); - session_set_tuple(sess3, &sess3_tup6); + session_set_tuple6(sess3, &sess3_tup6); session_table_add(sess_table, sess1); EXPECT_TRUE(session_table_get_count(sess_table) == 1); @@ -206,21 +208,21 @@ TEST(SESSION_TABLE, FIND_OLDEST_NEWEST) sess1 = session_pool_pop(sess_pool); EXPECT_TRUE(sess1 != NULL); session_set_id(sess1, 1); - session_set_tuple(sess1, &sess1_tup6); + session_set_tuple6(sess1, &sess1_tup6); session_table_add(sess_table, sess1); EXPECT_TRUE(session_table_find_lru(sess_table) == sess1); sess2 = session_pool_pop(sess_pool); EXPECT_TRUE(sess2 != NULL); session_set_id(sess2, 2); - session_set_tuple(sess2, &sess2_tup6); + session_set_tuple6(sess2, &sess2_tup6); session_table_add(sess_table, sess2); EXPECT_TRUE(session_table_find_lru(sess_table) == sess1); sess3 = session_pool_pop(sess_pool); EXPECT_TRUE(sess3 != NULL); session_set_id(sess3, 3); - session_set_tuple(sess3, &sess3_tup6); + session_set_tuple6(sess3, &sess3_tup6); session_table_add(sess_table, sess3); EXPECT_TRUE(session_table_find_lru(sess_table) == sess1); diff --git a/src/session/test/gtest_session_timer.cpp b/src/session/test/gtest_session_timer.cpp index c0b4804..6a5e757 100644 --- a/src/session/test/gtest_session_timer.cpp +++ b/src/session/test/gtest_session_timer.cpp @@ -1,5 +1,7 @@ #include +#include "session_def.h" +#include "session_utils.h" #include "session_timer.h" TEST(SESSION_TIMER, EXPIRE) diff --git a/src/session/test/gtest_state_tcp_active_to_closing.cpp b/src/session/test/gtest_state_tcp_active_to_closing.cpp index dfb36d7..aa0dc8d 100644 --- a/src/session/test/gtest_state_tcp_active_to_closing.cpp +++ b/src/session/test/gtest_state_tcp_active_to_closing.cpp @@ -1,11 +1,14 @@ // TCP state machine test: active -> closing #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" -#include "session_manager.h" - #include "tcp_utils.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" +#include "session_manager.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_state_tcp_init_to_opening.cpp b/src/session/test/gtest_state_tcp_init_to_opening.cpp index 027dae7..a03243b 100644 --- a/src/session/test/gtest_state_tcp_init_to_opening.cpp +++ b/src/session/test/gtest_state_tcp_init_to_opening.cpp @@ -1,11 +1,14 @@ // TCP state machine test: init -> opening #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" -#include "session_manager.h" - #include "ipv4_utils.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" +#include "session_manager.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_state_tcp_init_to_opening_to_active_to_closing_to_closed.cpp b/src/session/test/gtest_state_tcp_init_to_opening_to_active_to_closing_to_closed.cpp index c319049..5562e5d 100644 --- a/src/session/test/gtest_state_tcp_init_to_opening_to_active_to_closing_to_closed.cpp +++ b/src/session/test/gtest_state_tcp_init_to_opening_to_active_to_closing_to_closed.cpp @@ -1,10 +1,13 @@ // TCP state machine test: init -> opening -> active -> closing -> closed #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" #include "session_manager.h" - #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_state_tcp_opening_to_active.cpp b/src/session/test/gtest_state_tcp_opening_to_active.cpp index c086a6b..ede25e5 100644 --- a/src/session/test/gtest_state_tcp_opening_to_active.cpp +++ b/src/session/test/gtest_state_tcp_opening_to_active.cpp @@ -1,10 +1,13 @@ // TCP state machine test: opening -> active #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" #include "session_manager.h" - #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_state_tcp_opening_to_closing.cpp b/src/session/test/gtest_state_tcp_opening_to_closing.cpp index 3b772eb..2e820dc 100644 --- a/src/session/test/gtest_state_tcp_opening_to_closing.cpp +++ b/src/session/test/gtest_state_tcp_opening_to_closing.cpp @@ -1,11 +1,14 @@ // TCP state machine test: opening -> closing #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" -#include "session_manager.h" - #include "tcp_utils.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" +#include "session_manager.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_state_udp_init_to_opening_to_active_to_closing.cpp b/src/session/test/gtest_state_udp_init_to_opening_to_active_to_closing.cpp index 01de7a8..146605a 100644 --- a/src/session/test/gtest_state_udp_init_to_opening_to_active_to_closing.cpp +++ b/src/session/test/gtest_state_udp_init_to_opening_to_active_to_closing.cpp @@ -1,10 +1,13 @@ // UDP state machine test: init -> opening -> active -> closing #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" #include "session_manager.h" - #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_state_udp_init_to_opening_to_closing.cpp b/src/session/test/gtest_state_udp_init_to_opening_to_closing.cpp index f461a86..f7b5cf0 100644 --- a/src/session/test/gtest_state_udp_init_to_opening_to_closing.cpp +++ b/src/session/test/gtest_state_udp_init_to_opening_to_closing.cpp @@ -1,10 +1,13 @@ // UDP state machine test: init -> opening -> closing #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" #include "session_manager.h" - #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_timeout_tcp_data.cpp b/src/session/test/gtest_timeout_tcp_data.cpp index 6e2cd31..ae88c81 100644 --- a/src/session/test/gtest_timeout_tcp_data.cpp +++ b/src/session/test/gtest_timeout_tcp_data.cpp @@ -1,9 +1,12 @@ #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" #include "session_manager.h" - #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_timeout_tcp_handshake.cpp b/src/session/test/gtest_timeout_tcp_handshake.cpp index 598e818..2cc0c20 100644 --- a/src/session/test/gtest_timeout_tcp_handshake.cpp +++ b/src/session/test/gtest_timeout_tcp_handshake.cpp @@ -1,10 +1,12 @@ #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" #include "session_manager.h" - -#include "ipv4_utils.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_timeout_tcp_init.cpp b/src/session/test/gtest_timeout_tcp_init.cpp index 29ae072..2bf3dc8 100644 --- a/src/session/test/gtest_timeout_tcp_init.cpp +++ b/src/session/test/gtest_timeout_tcp_init.cpp @@ -1,10 +1,12 @@ #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" #include "session_manager.h" - -#include "ipv4_utils.h" #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/gtest_timeout_udp_data.cpp b/src/session/test/gtest_timeout_udp_data.cpp index 6debd1a..5cad862 100644 --- a/src/session/test/gtest_timeout_udp_data.cpp +++ b/src/session/test/gtest_timeout_udp_data.cpp @@ -1,9 +1,12 @@ #include +#include "tuple.h" #include "times.h" -#include "session_priv.h" +#include "packet_def.h" +#include "packet_parse.h" +#include "packet_layer.h" +#include "session_utils.h" #include "session_manager.h" - #include "test_packets.h" struct session_manager_options opts = { diff --git a/src/session/test/test_packets.h b/src/session/test/test_packets.h index 12a62ed..e2f0225 100644 --- a/src/session/test/test_packets.h +++ b/src/session/test/test_packets.h @@ -5,9 +5,6 @@ extern "C" { #endif -#include "packet_parse.h" -#include "packet_layer.h" - /****************************************************************************** * test packet: HTTP www.example.com ******************************************************************************/ diff --git a/src/stellar/config.cpp b/src/stellar/config.cpp index 23dbe43..d211257 100644 --- a/src/stellar/config.cpp +++ b/src/stellar/config.cpp @@ -2,8 +2,12 @@ #include #include -#include "config.h" +#include "log.h" #include "toml.h" +#include "config.h" + +#define CONFIG_LOG_ERROR(format, ...) LOG_ERROR("config", format, ##__VA_ARGS__) +#define CONFIG_LOG_DEBUG(format, ...) LOG_DEBUG("config", format, ##__VA_ARGS__) // return 0: success // retuun -1: failed diff --git a/src/stellar/config.h b/src/stellar/config.h index dc7c822..abc61f8 100644 --- a/src/stellar/config.h +++ b/src/stellar/config.h @@ -9,9 +9,6 @@ extern "C" #include "ip_reassembly.h" #include "session_manager.h" -#define CONFIG_LOG_ERROR(format, ...) LOG_ERROR("config", format, ##__VA_ARGS__) -#define CONFIG_LOG_DEBUG(format, ...) LOG_DEBUG("config", format, ##__VA_ARGS__) - struct device_options { uint8_t base; diff --git a/src/stellar/inject.cpp b/src/stellar/inject.cpp index 1fa56e6..2765dd4 100644 --- a/src/stellar/inject.cpp +++ b/src/stellar/inject.cpp @@ -1,12 +1,17 @@ #include #include +#include "log.h" #include "times.h" #include "packet_io.h" #include "packet_def.h" #include "packet_build.h" -#include "session_priv.h" -#include "stellar_priv.h" +#include "packet_utils.h" +#include "session_def.h" +#include "session_utils.h" +#include "stellar_utils.h" +#include "tcp_reassembly.h" +#include "session_manager.h" #define INJECT_PACKET_LOG_ERROR(format, ...) LOG_ERROR("inject packet", format, ##__VA_ARGS__) #define INJECT_PACKE_LOG_DEBUG(format, ...) LOG_DEBUG("inject packet", format, ##__VA_ARGS__) diff --git a/src/stellar/main.cpp b/src/stellar/main.cpp index 3b86339..48a0b79 100644 --- a/src/stellar/main.cpp +++ b/src/stellar/main.cpp @@ -1,4 +1,4 @@ -#include "stellar_priv.h" +#include "stellar_utils.h" int main(int argc, char **argv) { diff --git a/src/stellar/stat.cpp b/src/stellar/stat.cpp index fa20824..3246a88 100644 --- a/src/stellar/stat.cpp +++ b/src/stellar/stat.cpp @@ -1,11 +1,16 @@ #include -#include #include +#include +#include +#include +#include "log.h" #include "stat.h" #include "fieldstat/fieldstat_easy.h" #include "fieldstat/fieldstat_exporter.h" +#define STAT_LOG_ERROR(format, ...) LOG_ERROR("stat", format, ##__VA_ARGS__) + #define IS_FREE 0 #define IS_BUSY 0xf diff --git a/src/stellar/stat.h b/src/stellar/stat.h index c8983c8..c7623f5 100644 --- a/src/stellar/stat.h +++ b/src/stellar/stat.h @@ -9,8 +9,6 @@ extern "C" #include "ip_reassembly.h" #include "session_manager.h" -#define STAT_LOG_ERROR(format, ...) LOG_ERROR("stat", format, ##__VA_ARGS__) - struct thread_stat { struct io_stat *io; diff --git a/src/stellar/stellar.cpp b/src/stellar/stellar.cpp index 5fc9938..b48af57 100644 --- a/src/stellar/stellar.cpp +++ b/src/stellar/stellar.cpp @@ -1,18 +1,28 @@ #include +#include #include #include -#include +#include #include +#include #include +#include "log.h" #include "stat.h" #include "logo.h" #include "times.h" #include "config.h" +#include "packet_def.h" +#include "packet_utils.h" +#include "session_utils.h" #include "id_generator.h" -#include "stellar_priv.h" +#include "stellar_utils.h" #include "plugin_manager.h" +#define STELLAR_LOG_STATE(format, ...) LOG_STATE("stellar", format, ##__VA_ARGS__) +#define STELLAR_LOG_ERROR(format, ...) LOG_ERROR("stellar", format, ##__VA_ARGS__) +#define STELLAR_LOG_DEBUG(format, ...) LOG_DEBUG("stellar", format, ##__VA_ARGS__) + struct stellar_thread { pthread_t tid; @@ -426,7 +436,6 @@ int stellar_main(int argc, char **argv) goto error_out; } stellar_print_config(config); - STELLAR_LOG_DEBUG("sizeof(struct session) = %lu bytes", sizeof(struct session)); if (id_generator_init(config->dev_opts.base, config->dev_opts.offset) != 0) { diff --git a/src/stellar/stellar_priv.h b/src/stellar/stellar_utils.h similarity index 66% rename from src/stellar/stellar_priv.h rename to src/stellar/stellar_utils.h index 3017199..b646e7c 100644 --- a/src/stellar/stellar_priv.h +++ b/src/stellar/stellar_utils.h @@ -7,16 +7,14 @@ extern "C" #include "stellar/stellar.h" -#define STELLAR_LOG_STATE(format, ...) LOG_STATE("stellar", format, ##__VA_ARGS__) -#define STELLAR_LOG_ERROR(format, ...) LOG_ERROR("stellar", format, ##__VA_ARGS__) -#define STELLAR_LOG_DEBUG(format, ...) LOG_DEBUG("stellar", format, ##__VA_ARGS__) - struct packet_io *stellar_get_packet_io(const struct stellar *st); struct session_manager *stellar_get_session_manager(const struct stellar *st); struct plugin_manager_schema *stellar_get_plugin_manager(const struct stellar *st); // TODO fix plugin manager, delete this function void stellar_set_plugin_manger(struct stellar *st, struct plugin_manager_schema *plug_mgr); +int stellar_main(int argc, char **argv); + #ifdef __cplusplus } #endif diff --git a/src/tcp_reassembly/tcp_reassembly.cpp b/src/tcp_reassembly/tcp_reassembly.cpp index 10ef79b..0cf3b3a 100644 --- a/src/tcp_reassembly/tcp_reassembly.cpp +++ b/src/tcp_reassembly/tcp_reassembly.cpp @@ -1,8 +1,12 @@ #include +#include "log.h" #include "list.h" -#include "tcp_reassembly.h" #include "interval_tree.h" +#include "tcp_reassembly.h" + +#define TCP_REASSEMBLY_LOG_DEBUG(format, ...) LOG_DEBUG("tcp_reassembly", format, ##__VA_ARGS__) +#define TCP_REASSEMBLY_LOG_ERROR(format, ...) LOG_ERROR("tcp_reassembly", format, ##__VA_ARGS__) struct tcp_segment_private { diff --git a/src/tcp_reassembly/tcp_reassembly.h b/src/tcp_reassembly/tcp_reassembly.h index f135274..65a7a35 100644 --- a/src/tcp_reassembly/tcp_reassembly.h +++ b/src/tcp_reassembly/tcp_reassembly.h @@ -7,11 +7,6 @@ extern "C" #include -#include "log.h" - -#define TCP_REASSEMBLY_LOG_DEBUG(format, ...) LOG_DEBUG("tcp_reassembly", format, ##__VA_ARGS__) -#define TCP_REASSEMBLY_LOG_ERROR(format, ...) LOG_ERROR("tcp_reassembly", format, ##__VA_ARGS__) - struct tcp_segment { uint32_t len; diff --git a/test/packet_inject/packet_inject_main.cpp b/test/packet_inject/packet_inject_main.cpp index dbb17a2..0b1f591 100644 --- a/test/packet_inject/packet_inject_main.cpp +++ b/test/packet_inject/packet_inject_main.cpp @@ -3,7 +3,7 @@ #include #include -#include "stellar_priv.h" +#include "stellar_utils.h" #include "packet_inject_main.h" struct packet_inject_rule rule = {0};