refactor: session module (split to define/utils/pool/table/timer/transition/manager)
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#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]
|
||||
|
||||
@@ -7,11 +7,6 @@ extern "C"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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]
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <assert.h>
|
||||
#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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_library(session_manager
|
||||
session.cpp
|
||||
session_utils.cpp
|
||||
session_pool.cpp
|
||||
session_table.cpp
|
||||
session_timer.cpp
|
||||
|
||||
83
src/session/session_def.h
Normal file
83
src/session/session_def.h
Normal file
@@ -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
|
||||
@@ -2,12 +2,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "session_def.h"
|
||||
#include "session_pool.h"
|
||||
|
||||
struct session_pool
|
||||
|
||||
@@ -5,7 +5,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "session_priv.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct session_pool;
|
||||
struct session_pool *session_pool_new(uint64_t count);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "session_def.h"
|
||||
#include "session_timer.h"
|
||||
|
||||
struct session_timer
|
||||
|
||||
@@ -5,7 +5,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "session_priv.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct session_timer;
|
||||
struct session_timer *session_timer_new(uint64_t now);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
#include <assert.h>
|
||||
|
||||
#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]);
|
||||
@@ -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 <stdint.h>
|
||||
|
||||
#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
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include <gtest/gtest.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 = {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include <gtest/gtest.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 "tcp_reassembly.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
struct session_manager_options opts = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "session_def.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_timer.h"
|
||||
|
||||
TEST(SESSION_TIMER, EXPIRE)
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// TCP state machine test: active -> closing
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// TCP state machine test: init -> opening
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// TCP state machine test: init -> opening -> active -> closing -> closed
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// TCP state machine test: opening -> active
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// TCP state machine test: opening -> closing
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// UDP state machine test: init -> opening -> active -> closing
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// UDP state machine test: init -> opening -> closing
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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 = {
|
||||
|
||||
@@ -5,9 +5,6 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
|
||||
/******************************************************************************
|
||||
* test packet: HTTP www.example.com
|
||||
******************************************************************************/
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#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__)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "stellar_priv.h"
|
||||
#include "stellar_utils.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
@@ -1,8 +1,12 @@
|
||||
#include <string.h>
|
||||
|
||||
#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
|
||||
{
|
||||
|
||||
@@ -7,11 +7,6 @@ extern "C"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "stellar_priv.h"
|
||||
#include "stellar_utils.h"
|
||||
#include "packet_inject_main.h"
|
||||
|
||||
struct packet_inject_rule rule = {0};
|
||||
|
||||
Reference in New Issue
Block a user