refactor: rename session_utils.cpp to session.cpp
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "utils.h"
|
||||
#include "packet_io.h"
|
||||
#include "packet_private.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "snowflake.h"
|
||||
#include "stellar_stat.h"
|
||||
#include "stellar_core.h"
|
||||
|
||||
@@ -3,6 +3,6 @@ target_include_directories(plugin_manager PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(plugin_manager PUBLIC ${CMAKE_SOURCE_DIR}/include/)
|
||||
target_include_directories(plugin_manager PUBLIC ${CMAKE_SOURCE_DIR}/src/)
|
||||
target_include_directories(plugin_manager PUBLIC ${CMAKE_SOURCE_DIR}/deps/)
|
||||
target_link_libraries(plugin_manager bitmap toml ${CMAKE_DL_LIBS})
|
||||
target_link_libraries(plugin_manager session_manager bitmap toml ${CMAKE_DL_LIBS})
|
||||
|
||||
add_subdirectory(test)
|
||||
@@ -5,9 +5,9 @@
|
||||
#include "uthash/utlist.h"
|
||||
|
||||
#include "core/stellar_core.h"
|
||||
#include "session/session_utils.h"
|
||||
#include "tuple/tuple.h"
|
||||
#include "packet/packet_private.h"
|
||||
#include "session/session_private.h"
|
||||
|
||||
UT_icd plugin_specs_icd = {sizeof(struct plugin_specific), NULL, NULL, NULL};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_library(session_manager
|
||||
session_utils.cpp
|
||||
session.cpp
|
||||
session_pool.cpp
|
||||
session_table.cpp
|
||||
session_timer.cpp
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "session_private.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
|
||||
/******************************************************************************
|
||||
* session set/get
|
||||
******************************************************************************/
|
||||
|
||||
void session_init(struct session *sess)
|
||||
{
|
||||
memset(sess, 0, sizeof(struct session));
|
||||
@@ -257,10 +250,6 @@ void session_free_tcp_segment(struct session *sess, struct tcp_segment *seg)
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* to string
|
||||
******************************************************************************/
|
||||
|
||||
const char *closing_reason_to_str(enum closing_reason reason)
|
||||
{
|
||||
switch (reason)
|
||||
@@ -463,3 +452,10 @@ int session_to_str(const struct session *sess, int bref, char *buff, int size)
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
void session_print(const struct session *sess)
|
||||
{
|
||||
char buff[4096];
|
||||
session_to_str(sess, 0, buff, sizeof(buff));
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "packet_filter.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_private.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_pool.h"
|
||||
#include "session_table.h"
|
||||
#include "session_timer.h"
|
||||
|
||||
@@ -6,7 +6,7 @@ extern "C"
|
||||
#endif
|
||||
|
||||
#include "tuple.h"
|
||||
#include "session_private.h"
|
||||
#include "stellar/session.h"
|
||||
|
||||
struct session_manager_options
|
||||
{
|
||||
|
||||
@@ -75,6 +75,75 @@ struct session
|
||||
struct session_manager_stat *mgr_stat;
|
||||
};
|
||||
|
||||
void session_init(struct session *sess);
|
||||
|
||||
void session_set_id(struct session *sess, uint64_t id);
|
||||
// uint64_t session_get_id(const struct session *sess);
|
||||
|
||||
void session_set_tuple6(struct session *sess, const struct tuple6 *tuple);
|
||||
const struct tuple6 *session_get_tuple6(const struct session *sess);
|
||||
// const char *session_get0_readable_addr(const struct session *sess);
|
||||
|
||||
void session_set_direction(struct session *sess, enum session_direction dir);
|
||||
enum session_direction session_get_direction(const struct session *sess);
|
||||
|
||||
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);
|
||||
|
||||
void session_set_current_state(struct session *sess, enum session_state state);
|
||||
// enum session_state session_get_current_state(const struct session *sess);
|
||||
|
||||
void session_set_type(struct session *sess, enum session_type type);
|
||||
// enum session_type session_get_type(const struct session *sess);
|
||||
|
||||
void session_set_duplicate_traffic(struct session *sess);
|
||||
// int session_has_duplicate_traffic(const struct session *sess);
|
||||
|
||||
void session_set_closing_reason(struct session *sess, enum closing_reason reason);
|
||||
// enum closing_reason session_get_closing_reason(const struct session *sess);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
void session_set_first_packet(struct session *sess, enum flow_direction dir, const struct packet *pkt);
|
||||
// const struct packet *session_get_first_packet(const struct session *sess, enum flow_direction dir);
|
||||
|
||||
void session_set_current_packet(struct session *sess, const struct packet *pkt);
|
||||
// const struct packet *session_get0_current_packet(const struct session *sess);
|
||||
|
||||
// int session_is_symmetric(const struct session *sess, unsigned char *flag);
|
||||
|
||||
void session_set_user_data(struct session *sess, void *user_data);
|
||||
void *session_get_user_data(const struct session *sess);
|
||||
|
||||
struct tcp_segment *session_get_tcp_segment(struct session *sess);
|
||||
void session_free_tcp_segment(struct session *sess, struct tcp_segment *seg);
|
||||
|
||||
/******************************************************************************
|
||||
* to string
|
||||
******************************************************************************/
|
||||
|
||||
const char *closing_reason_to_str(enum closing_reason reason);
|
||||
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);
|
||||
|
||||
// bref : 1, output session bref info
|
||||
// bref : 0, output session detail info
|
||||
int session_to_str(const struct session *sess, int bref, char *buff, int size);
|
||||
void session_print(const struct session *sess);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_transition.h"
|
||||
|
||||
#define SESSION_TRANSITION_LOG_INFO(format, ...) LOG_INFO("session transition", format, ##__VA_ARGS__)
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "stellar/session.h"
|
||||
|
||||
/******************************************************************************
|
||||
* session set/get
|
||||
******************************************************************************/
|
||||
|
||||
void session_init(struct session *sess);
|
||||
|
||||
// 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
|
||||
const char *session_get0_readable_addr(const struct session *sess);
|
||||
|
||||
// session direction
|
||||
void session_set_direction(struct session *sess, enum session_direction dir);
|
||||
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);
|
||||
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);
|
||||
|
||||
// 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);
|
||||
|
||||
/******************************************************************************
|
||||
* to string
|
||||
******************************************************************************/
|
||||
|
||||
const char *closing_reason_to_str(enum closing_reason reason);
|
||||
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);
|
||||
|
||||
// bref : 1, output session bref info
|
||||
// bref : 0, output session detail info
|
||||
int session_to_str(const struct session *sess, int bref, char *buff, int size);
|
||||
|
||||
static inline void session_print(const struct session *sess)
|
||||
{
|
||||
char buff[4096];
|
||||
session_to_str(sess, 0, buff, sizeof(buff));
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "tcp_reassembly.h"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "packet_helper.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "packet_helper.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "packet_helper.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "packet_helper.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "tcp_reassembly.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_pool.h"
|
||||
#include "session_table.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "session_private.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_timer.h"
|
||||
|
||||
TEST(SESSION_TIMER, EXPIRE)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "snowflake.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "tuple.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "tuple.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "tuple.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "tuple.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_private.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "session_utils.h"
|
||||
#include "packet_dump.h"
|
||||
#include "session_private.h"
|
||||
#include "stellar/session.h"
|
||||
#include "stellar/packet.h"
|
||||
#include "stellar/stellar_mq.h"
|
||||
#include "stellar/stellar_exdata.h"
|
||||
|
||||
Reference in New Issue
Block a user