rename config -> options

This commit is contained in:
luwenpeng
2024-03-08 14:51:21 +08:00
parent d0914483bb
commit 734f6a5135
32 changed files with 336 additions and 336 deletions

View File

@@ -27,7 +27,7 @@ struct session_manager
struct dupkt_filter *tcp_dupkt_filter;
struct eviction_filter *udp_eviction_filter;
struct session_manager_config config;
struct session_manager_options opts;
/***************************************************************
* session manager status
@@ -66,7 +66,7 @@ static inline void tcp_half_closed_timeout_cb(struct session *sess, void *arg);
static inline void tcp_time_wait_timeout_cb(struct session *sess, void *arg);
static inline void udp_data_timeout_cb(struct session *sess, void *arg);
static inline int session_manager_check_config(struct session_manager_config *config);
static inline int session_manager_check_options(struct session_manager_options *opts);
static inline uint64_t session_manager_alloc_session_id(void);
static inline int session_manager_update_tcp_filter(struct session_manager *mgr, struct session *sess, const struct packet *pkt, enum session_dir curr_dir);
@@ -181,123 +181,123 @@ static inline void udp_data_timeout_cb(struct session *sess, void *arg)
}
// return 0: success
// return -1: invalid config
static inline int session_manager_check_config(struct session_manager_config *config)
// return -1: invalid opts
static inline int session_manager_check_options(struct session_manager_options *opts)
{
if (config == NULL)
if (opts == NULL)
{
SESSION_LOG_ERROR("invalid config");
SESSION_LOG_ERROR("invalid opts");
return -1;
}
// max session number
if (config->max_tcp_session_num < 2)
if (opts->max_tcp_session_num < 2)
{
SESSION_LOG_ERROR("invalid max tcp session number");
return -1;
}
if (config->max_udp_session_num < 2)
if (opts->max_udp_session_num < 2)
{
SESSION_LOG_ERROR("invalid max udp session number");
return -1;
}
// session overload
if (config->tcp_overload_evict_old_sess != 0 && config->tcp_overload_evict_old_sess != 1)
if (opts->tcp_overload_evict_old_sess != 0 && opts->tcp_overload_evict_old_sess != 1)
{
SESSION_LOG_ERROR("invalid tcp overload evict old session, support range: 0-1");
return -1;
}
if (config->udp_overload_evict_old_sess != 0 && config->udp_overload_evict_old_sess != 1)
if (opts->udp_overload_evict_old_sess != 0 && opts->udp_overload_evict_old_sess != 1)
{
SESSION_LOG_ERROR("invalid udp overload evict old session, support range: 0-1");
return -1;
}
// TCP timeout config
if (config->tcp_timeout_init < 1 || config->tcp_timeout_init > 60)
// TCP timeout opts
if (opts->tcp_timeout_init < 1 || opts->tcp_timeout_init > 60)
{
SESSION_LOG_ERROR("invalid tcp timeout init, support range: 1-60");
return -1;
}
if (config->tcp_timeout_handshake < 1 || config->tcp_timeout_handshake > 60)
if (opts->tcp_timeout_handshake < 1 || opts->tcp_timeout_handshake > 60)
{
SESSION_LOG_ERROR("invalid tcp timeout handshake, support range: 1-60");
return -1;
}
if (config->tcp_timeout_data < 1 || config->tcp_timeout_data > 15999999)
if (opts->tcp_timeout_data < 1 || opts->tcp_timeout_data > 15999999)
{
SESSION_LOG_ERROR("invalid tcp timeout data, support range: 1-15,999,999");
return -1;
}
if (config->tcp_timeout_half_closed < 1 || config->tcp_timeout_half_closed > 604800)
if (opts->tcp_timeout_half_closed < 1 || opts->tcp_timeout_half_closed > 604800)
{
SESSION_LOG_ERROR("invalid tcp timeout half closed, support range: 1-604,800");
return -1;
}
if (config->tcp_timeout_time_wait < 1 || config->tcp_timeout_time_wait > 600)
if (opts->tcp_timeout_time_wait < 1 || opts->tcp_timeout_time_wait > 600)
{
SESSION_LOG_ERROR("invalid tcp timeout time wait, support range: 1-600");
return -1;
}
if (config->tcp_timeout_discard < 1 || config->tcp_timeout_discard > 15999999)
if (opts->tcp_timeout_discard < 1 || opts->tcp_timeout_discard > 15999999)
{
SESSION_LOG_ERROR("invalid tcp timeout discard, support range: 1-15,999,999");
return -1;
}
// UDP timeout config
if (config->udp_timeout_data < 1 || config->udp_timeout_data > 15999999)
// UDP timeout opts
if (opts->udp_timeout_data < 1 || opts->udp_timeout_data > 15999999)
{
SESSION_LOG_ERROR("invalid udp timeout data, support range: 1-15,999,999");
return -1;
}
// TCP duplicate packet filter config
if (config->tcp_dupkt_filter_enable != 0 && config->tcp_dupkt_filter_enable != 1)
// TCP duplicate packet filter opts
if (opts->tcp_dupkt_filter_enable != 0 && opts->tcp_dupkt_filter_enable != 1)
{
SESSION_LOG_ERROR("invalid tcp dupkt filter enable, support range: 0-1");
return -1;
}
if (config->tcp_dupkt_filter_enable)
if (opts->tcp_dupkt_filter_enable)
{
if (config->tcp_dupkt_filter_capacity == 0)
if (opts->tcp_dupkt_filter_capacity == 0)
{
SESSION_LOG_ERROR("invalid tcp dupkt filter capacity");
return -1;
}
if (config->tcp_dupkt_filter_timeout < 1 || config->tcp_dupkt_filter_timeout > 60)
if (opts->tcp_dupkt_filter_timeout < 1 || opts->tcp_dupkt_filter_timeout > 60)
{
SESSION_LOG_ERROR("invalid tcp dupkt filter timeout, support range: 1-60");
return -1;
}
if (config->tcp_dupkt_filter_error_rate < 0 || config->tcp_dupkt_filter_error_rate > 1)
if (opts->tcp_dupkt_filter_error_rate < 0 || opts->tcp_dupkt_filter_error_rate > 1)
{
SESSION_LOG_ERROR("invalid tcp dupkt filter error rate, support range: 0-1");
return -1;
}
}
// UDP eviction filter config
if (config->udp_eviction_filter_enable != 0 && config->udp_eviction_filter_enable != 1)
// UDP eviction filter opts
if (opts->udp_eviction_filter_enable != 0 && opts->udp_eviction_filter_enable != 1)
{
SESSION_LOG_ERROR("invalid udp eviction filter enable, support range: 0-1");
return -1;
}
if (config->udp_eviction_filter_enable)
if (opts->udp_eviction_filter_enable)
{
if (config->udp_eviction_filter_capacity == 0)
if (opts->udp_eviction_filter_capacity == 0)
{
SESSION_LOG_ERROR("invalid udp eviction filter capacity");
return -1;
}
if (config->udp_eviction_filter_timeout < 1 || config->udp_eviction_filter_timeout > 60)
if (opts->udp_eviction_filter_timeout < 1 || opts->udp_eviction_filter_timeout > 60)
{
SESSION_LOG_ERROR("invalid udp eviction filter timeout, support range: 1-60");
return -1;
}
if (config->udp_eviction_filter_error_rate < 0 || config->udp_eviction_filter_error_rate > 1)
if (opts->udp_eviction_filter_error_rate < 0 || opts->udp_eviction_filter_error_rate > 1)
{
SESSION_LOG_ERROR("invalid udp eviction filter error rate, support range: 0-1");
return -1;
@@ -633,13 +633,13 @@ static inline void session_manager_update_session_packet(struct session_manager
static inline void session_manager_update_udp_to_opening(struct session_manager *mgr, struct session *sess)
{
session_manager_update_session_state(mgr, sess, SESSION_STATE_OPENING);
session_manager_update_session_timer(mgr, sess, udp_data_timeout_cb, mgr->config.udp_timeout_data);
session_manager_update_session_timer(mgr, sess, udp_data_timeout_cb, mgr->opts.udp_timeout_data);
}
static inline void session_manager_update_udp_to_active(struct session_manager *mgr, struct session *sess)
{
session_manager_update_session_state(mgr, sess, SESSION_STATE_ACTIVE);
session_manager_update_session_timer(mgr, sess, udp_data_timeout_cb, mgr->config.udp_timeout_data);
session_manager_update_session_timer(mgr, sess, udp_data_timeout_cb, mgr->opts.udp_timeout_data);
}
static inline void session_manager_update_udp_to_closing(struct session_manager *mgr, struct session *sess)
@@ -655,18 +655,18 @@ static inline void session_manager_update_tcp_to_opening(struct session_manager
session_manager_update_session_state(mgr, sess, SESSION_STATE_OPENING);
if (opening_by_syn)
{
session_manager_update_session_timer(mgr, sess, tcp_init_timeout_cb, mgr->config.tcp_timeout_init);
session_manager_update_session_timer(mgr, sess, tcp_init_timeout_cb, mgr->opts.tcp_timeout_init);
}
else
{
session_manager_update_session_timer(mgr, sess, tcp_handshake_timeout_cb, mgr->config.tcp_timeout_handshake);
session_manager_update_session_timer(mgr, sess, tcp_handshake_timeout_cb, mgr->opts.tcp_timeout_handshake);
}
}
static inline void session_manager_update_tcp_to_active(struct session_manager *mgr, struct session *sess)
{
session_manager_update_session_state(mgr, sess, SESSION_STATE_ACTIVE);
session_manager_update_session_timer(mgr, sess, tcp_data_timeout_cb, mgr->config.tcp_timeout_data);
session_manager_update_session_timer(mgr, sess, tcp_data_timeout_cb, mgr->opts.tcp_timeout_data);
}
static inline void session_manager_update_tcp_to_closing(struct session_manager *mgr, struct session *sess, int enable_time_wait)
@@ -674,7 +674,7 @@ static inline void session_manager_update_tcp_to_closing(struct session_manager
session_manager_update_session_state(mgr, sess, SESSION_STATE_CLOSING);
if (enable_time_wait)
{
session_manager_update_session_timer(mgr, sess, tcp_time_wait_timeout_cb, mgr->config.tcp_timeout_time_wait);
session_manager_update_session_timer(mgr, sess, tcp_time_wait_timeout_cb, mgr->opts.tcp_timeout_time_wait);
}
else
{
@@ -724,7 +724,7 @@ static inline void session_manager_handle_tcp_on_opening(struct session_manager
SESSION_LOG_DEBUG("TCP %s FIN received, session %lu opening -> opening", (tcp_curr_state & TCP_C2S_FIN_RECVED ? "C2S" : "S2C"), session_get_id(sess));
// still opening, only update timeout
session_set_closing_reason(sess, (tcp_mod_state & TCP_C2S_FIN_RECVED) ? CLOSING_BY_CLIENT_FIN : CLOSING_BY_SERVER_FIN);
session_manager_update_session_timer(mgr, sess, tcp_half_closed_timeout_cb, mgr->config.tcp_timeout_half_closed);
session_manager_update_session_timer(mgr, sess, tcp_half_closed_timeout_cb, mgr->opts.tcp_timeout_half_closed);
return;
}
@@ -732,7 +732,7 @@ static inline void session_manager_handle_tcp_on_opening(struct session_manager
{
SESSION_LOG_DEBUG("TCP %s ACK received, session %lu opening -> opening", (tcp_curr_state & TCP_C2S_ACK_RECVED ? "C2S" : "S2C"), session_get_id(sess));
// still opening, only update timeout
session_manager_update_session_timer(mgr, sess, tcp_data_timeout_cb, mgr->config.tcp_timeout_data);
session_manager_update_session_timer(mgr, sess, tcp_data_timeout_cb, mgr->opts.tcp_timeout_data);
return;
}
@@ -783,7 +783,7 @@ static inline void session_manager_handle_tcp_on_active(struct session_manager *
SESSION_LOG_DEBUG("TCP %s FIN received, session %lu active -> active", (tcp_curr_state & TCP_C2S_FIN_RECVED) ? "C2S" : "S2C", session_get_id(sess));
// still active
session_set_closing_reason(sess, (tcp_curr_state & TCP_C2S_FIN_RECVED) ? CLOSING_BY_CLIENT_FIN : CLOSING_BY_SERVER_FIN);
session_manager_update_session_timer(mgr, sess, tcp_half_closed_timeout_cb, mgr->config.tcp_timeout_half_closed);
session_manager_update_session_timer(mgr, sess, tcp_half_closed_timeout_cb, mgr->opts.tcp_timeout_half_closed);
return;
}
@@ -815,9 +815,9 @@ static inline struct session *session_manager_new_tcp_session(struct session_man
return NULL;
}
if (mgr->tcp_sess_num >= mgr->config.max_tcp_session_num - 1)
if (mgr->tcp_sess_num >= mgr->opts.max_tcp_session_num - 1)
{
if (mgr->config.tcp_overload_evict_old_sess)
if (mgr->opts.tcp_overload_evict_old_sess)
{
struct session *evicted_sess = session_table_find_least_recently_unused_session(mgr->tcp_sess_table);
assert(evicted_sess);
@@ -826,7 +826,7 @@ static inline struct session *session_manager_new_tcp_session(struct session_man
}
else
{
if (mgr->tcp_sess_num >= mgr->config.max_tcp_session_num)
if (mgr->tcp_sess_num >= mgr->opts.max_tcp_session_num)
{
mgr->tcp_overload_evict_new_sess_num++;
return NULL;
@@ -866,9 +866,9 @@ static inline struct session *session_manager_new_udp_session(struct session_man
return NULL;
}
if (mgr->udp_sess_num >= mgr->config.max_udp_session_num - 1)
if (mgr->udp_sess_num >= mgr->opts.max_udp_session_num - 1)
{
if (mgr->config.udp_overload_evict_old_sess)
if (mgr->opts.udp_overload_evict_old_sess)
{
struct session *evicted_sess = session_table_find_least_recently_unused_session(mgr->udp_sess_table);
assert(evicted_sess);
@@ -877,7 +877,7 @@ static inline struct session *session_manager_new_udp_session(struct session_man
}
else
{
if (mgr->udp_sess_num >= mgr->config.max_udp_session_num)
if (mgr->udp_sess_num >= mgr->opts.max_udp_session_num)
{
mgr->udp_overload_evict_new_sess_num++;
return NULL;
@@ -1029,9 +1029,9 @@ static inline void session_manager_evicte_session(struct session_manager *mgr, s
* Public API
******************************************************************************/
struct session_manager *session_manager_new(struct session_manager_config *config)
struct session_manager *session_manager_new(struct session_manager_options *opts)
{
if (session_manager_check_config(config))
if (session_manager_check_options(opts))
{
return NULL;
}
@@ -1042,8 +1042,8 @@ struct session_manager *session_manager_new(struct session_manager_config *confi
return NULL;
}
memcpy(&mgr->config, config, sizeof(struct session_manager_config));
mgr->sess_pool = session_pool_new(mgr->config.max_tcp_session_num + mgr->config.max_udp_session_num);
memcpy(&mgr->opts, opts, sizeof(struct session_manager_options));
mgr->sess_pool = session_pool_new(mgr->opts.max_tcp_session_num + mgr->opts.max_udp_session_num);
if (mgr->sess_pool == NULL)
{
goto error;
@@ -1079,13 +1079,13 @@ struct session_manager *session_manager_new(struct session_manager_config *confi
goto error;
}
mgr->tcp_dupkt_filter = dupkt_filter_new(mgr->config.tcp_dupkt_filter_enable, mgr->config.tcp_dupkt_filter_capacity, mgr->config.tcp_dupkt_filter_error_rate, mgr->config.tcp_dupkt_filter_timeout);
mgr->tcp_dupkt_filter = dupkt_filter_new(mgr->opts.tcp_dupkt_filter_enable, mgr->opts.tcp_dupkt_filter_capacity, mgr->opts.tcp_dupkt_filter_error_rate, mgr->opts.tcp_dupkt_filter_timeout);
if (mgr->tcp_dupkt_filter == NULL)
{
goto error;
}
mgr->udp_eviction_filter = eviction_filter_new(mgr->config.udp_eviction_filter_enable, mgr->config.udp_eviction_filter_capacity, mgr->config.udp_eviction_filter_error_rate, mgr->config.udp_eviction_filter_timeout);
mgr->udp_eviction_filter = eviction_filter_new(mgr->opts.udp_eviction_filter_enable, mgr->opts.udp_eviction_filter_capacity, mgr->opts.udp_eviction_filter_error_rate, mgr->opts.udp_eviction_filter_timeout);
if (mgr->udp_eviction_filter == NULL)
{
goto error;

View File

@@ -12,7 +12,7 @@ extern "C"
#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_config
struct session_manager_options
{
// max session number
uint64_t max_tcp_session_num;
@@ -47,7 +47,7 @@ struct session_manager_config
};
struct session_manager;
struct session_manager *session_manager_new(struct session_manager_config *config);
struct session_manager *session_manager_new(struct session_manager_options *opts);
void session_manager_free(struct session_manager *mgr);
// only use the packet six-tuple to find the session, not update it

View File

@@ -9,7 +9,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, SYN_DUP)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -61,7 +61,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, S2C_DUP)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// S2C SYNACK Packet
@@ -116,7 +116,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, SKIP_FILTER)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -178,13 +178,13 @@ TEST(TCP_DUPKT_FILTER_DISABLE, C2S_DUPKT)
struct packet pkt;
struct session *sess = NULL;
struct session_manager *mgr = NULL;
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.tcp_dupkt_filter_enable = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.tcp_dupkt_filter_enable = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -233,13 +233,13 @@ TEST(TCP_DUPKT_FILTER_DISABLE, S2C_DUP)
struct packet pkt;
struct session *sess = NULL;
struct session_manager *mgr = NULL;
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.tcp_dupkt_filter_enable = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.tcp_dupkt_filter_enable = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
// S2C SYNACK Packet

View File

@@ -9,7 +9,7 @@ TEST(UDP_EVICTION_FILTER_ENABLE, HIT_FILTER_THEN_EVICT_SESS)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -43,13 +43,13 @@ TEST(UDP_EVICTION_FILTER_ENABLE, MISS_FILTER_THEN_NEW_SESS)
struct packet pkt;
struct session *sess = NULL;
struct session_manager *mgr = NULL;
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.udp_eviction_filter_timeout = 2;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.udp_eviction_filter_timeout = 2;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -66,7 +66,7 @@ TEST(UDP_EVICTION_FILTER_ENABLE, MISS_FILTER_THEN_NEW_SESS)
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// wait udp eviction filter timeout
sleep(_config.udp_eviction_filter_timeout);
sleep(_opts.udp_eviction_filter_timeout);
timestamp_update();
// C2S REQ Packet
@@ -91,13 +91,13 @@ TEST(UDP_EVICTION_FILTER_DISABLE, MISS_FILTER_THEN_NEW_SESS)
struct packet pkt;
struct session *sess = NULL;
struct session_manager *mgr = NULL;
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.udp_eviction_filter_enable = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.udp_eviction_filter_enable = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet

View File

@@ -19,10 +19,10 @@ TEST(OVERLOAD, EVICT_TCP_OLD_SESS)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
for (uint64_t i = 0; i < config.max_tcp_session_num; i++)
for (uint64_t i = 0; i < opts.max_tcp_session_num; i++)
{
// C2S SYN Packet
printf("\n====================== new session (%lu) ======================\n\n", i + 1);
@@ -37,7 +37,7 @@ TEST(OVERLOAD, EVICT_TCP_OLD_SESS)
__session_dispatch(sess);
session_manager_print_stat(mgr);
if (i == config.max_tcp_session_num - 1)
if (i == opts.max_tcp_session_num - 1)
{
__session_manager_check_counter(mgr,
i, 0, 1, // tcp_opening_sess_num, tcp_active_sess_num, tcp_closing_sess_num,
@@ -91,16 +91,16 @@ TEST(OVERLOAD, EVICT_TCP_NEW_SESS)
struct session *sess = NULL;
struct session_manager *mgr = NULL;
char buffer[1500] = {0};
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.tcp_overload_evict_old_sess = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.tcp_overload_evict_old_sess = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
for (uint64_t i = 0; i <= _config.max_tcp_session_num; i++)
for (uint64_t i = 0; i <= _opts.max_tcp_session_num; i++)
{
// C2S SYN Packet
printf("\n====================== new session (%lu) ======================\n\n", i + 1);
@@ -111,7 +111,7 @@ TEST(OVERLOAD, EVICT_TCP_NEW_SESS)
printf("<= packet parse\n\n");
sess = session_manager_update_session(mgr, &pkt);
if (i == _config.max_tcp_session_num)
if (i == _opts.max_tcp_session_num)
{
EXPECT_TRUE(sess == NULL);
__session_manager_check_counter(mgr,

View File

@@ -19,10 +19,10 @@ TEST(OVERLOAD, EVICT_UDP_OLD_SESS)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
for (uint64_t i = 0; i < config.max_udp_session_num; i++)
for (uint64_t i = 0; i < opts.max_udp_session_num; i++)
{
// C2S REQ Packet
printf("\n====================== new session (%lu) ======================\n\n", i + 1);
@@ -37,7 +37,7 @@ TEST(OVERLOAD, EVICT_UDP_OLD_SESS)
__session_dispatch(sess);
session_manager_print_stat(mgr);
if (i == config.max_udp_session_num - 1)
if (i == opts.max_udp_session_num - 1)
{
__session_manager_check_counter(mgr,
0, 0, 0, // tcp_opening_sess_num, tcp_active_sess_num, tcp_closing_sess_num,
@@ -91,16 +91,16 @@ TEST(OVERLOAD, EVICT_UDP_NEW_SESS)
struct session *sess = NULL;
struct session_manager *mgr = NULL;
char buffer[1500] = {0};
struct session_manager_config _config;
memcpy(&_config, &config, sizeof(struct session_manager_config));
_config.udp_overload_evict_old_sess = 0;
struct session_manager_options _opts;
memcpy(&_opts, &opts, sizeof(struct session_manager_options));
_opts.udp_overload_evict_old_sess = 0;
timestamp_update();
mgr = session_manager_new(&_config);
mgr = session_manager_new(&_opts);
EXPECT_TRUE(mgr != NULL);
for (uint64_t i = 0; i <= _config.max_udp_session_num; i++)
for (uint64_t i = 0; i <= _opts.max_udp_session_num; i++)
{
// C2S REQ Packet
printf("\n====================== new session (%lu) ======================\n\n", i + 1);
@@ -111,7 +111,7 @@ TEST(OVERLOAD, EVICT_UDP_NEW_SESS)
printf("<= packet parse\n\n");
sess = session_manager_update_session(mgr, &pkt);
if (i == _config.max_udp_session_num)
if (i == _opts.max_udp_session_num)
{
EXPECT_TRUE(sess == NULL);
__session_manager_check_counter(mgr,

View File

@@ -91,7 +91,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_FIN_FIN)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -182,7 +182,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_C2S_RST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -246,7 +246,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_RST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -308,7 +308,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_DATA_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -336,7 +336,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_C2S_HALF_CLOSED_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet
@@ -393,7 +393,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_HALF_CLOSED_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet & C2S DATA Packet

View File

@@ -16,7 +16,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -71,7 +71,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet
@@ -126,7 +126,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_SYNACK)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -216,7 +216,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_SYNACK_ACK)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -342,7 +342,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_RETRANSMISSION)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -440,7 +440,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK_RETRANSMISSION)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet
@@ -536,7 +536,7 @@ TEST(TCP_INIT_TO_OPENING, BY_C2S_ASMMETRIC)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -626,7 +626,7 @@ TEST(TCP_INIT_TO_OPENING, BY_S2C_ASMMETRIC)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet

View File

@@ -12,7 +12,7 @@ TEST(TCP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING_TO_CLOSED, TEST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet

View File

@@ -16,7 +16,7 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYN_C2S_DATA)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -105,7 +105,7 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYNACK_S2C_DATA)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet

View File

@@ -57,7 +57,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_FIN_FIN)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -148,7 +148,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_C2S_RST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -212,7 +212,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_RST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -274,7 +274,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_INIT_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -302,7 +302,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_HANDSHAKE_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -360,7 +360,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_DATA_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -452,7 +452,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_C2S_HALF_CLOSED_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -509,7 +509,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_HALF_CLOSED_TIMEOUT)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet

View File

@@ -20,7 +20,7 @@ TEST(UDP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING, TEST)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet

View File

@@ -18,7 +18,7 @@ TEST(UDP_INIT_TO_OPENING_TO_CLOSING, BY_C2S)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -75,7 +75,7 @@ TEST(UDP_INIT_TO_OPENING_TO_CLOSING, BY_S2C)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// S2C RESP Packet

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_DATA)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -28,8 +28,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_DATA)
__session_manager_check_counter(mgr, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_data(mgr, &config);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_data(mgr, &opts);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_HALF_CLOSED1)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -28,8 +28,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_HALF_CLOSED1)
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_half_closed(mgr, &config, SESSION_STATE_OPENING);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_half_closed(mgr, &opts, SESSION_STATE_OPENING);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -46,7 +46,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_HALF_CLOSED2)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -72,8 +72,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_HALF_CLOSED2)
__session_manager_check_counter(mgr, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_half_closed(mgr, &config, SESSION_STATE_ACTIVE);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_half_closed(mgr, &opts, SESSION_STATE_ACTIVE);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_HANDSHAKE)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// SYNACK Packet
@@ -21,8 +21,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_HANDSHAKE)
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_handshake(mgr, &config);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_handshake(mgr, &opts);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT1)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S SYN Packet
@@ -21,8 +21,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT1)
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_init(mgr, &config);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_init(mgr, &opts);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -39,7 +39,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT2)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// S2C SYNACK Packet
@@ -51,8 +51,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT2)
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
__session_manager_check_tcp_timeout_init(mgr, &config);
__session_manager_check_tcp_timeout_time_wait(mgr, &config);
__session_manager_check_tcp_timeout_init(mgr, &opts);
__session_manager_check_tcp_timeout_time_wait(mgr, &opts);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -9,7 +9,7 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA1)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -21,7 +21,7 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA1)
__session_manager_check_counter(mgr, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0);
__session_manager_check_udp_timeout_data(mgr, &config, SESSION_STATE_OPENING);
__session_manager_check_udp_timeout_data(mgr, &opts, SESSION_STATE_OPENING);
EXPECT_TRUE(session_manager_get_expired_session(mgr) == NULL);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -39,7 +39,7 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA2)
timestamp_update();
mgr = session_manager_new(&config);
mgr = session_manager_new(&opts);
EXPECT_TRUE(mgr != NULL);
// C2S REQ Packet
@@ -58,7 +58,7 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA2)
__session_manager_check_counter(mgr, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0);
__session_manager_check_udp_timeout_data(mgr, &config, SESSION_STATE_ACTIVE);
__session_manager_check_udp_timeout_data(mgr, &opts, SESSION_STATE_ACTIVE);
EXPECT_TRUE(session_manager_get_expired_session(mgr) == NULL);
__session_manager_check_counter(mgr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -15,7 +15,7 @@ extern "C"
#include "ipv4_utils.h"
#include "test_packets.h"
struct session_manager_config config = {
struct session_manager_options opts = {
// max session number
.max_tcp_session_num = 3,
.max_udp_session_num = 3,
@@ -112,20 +112,20 @@ __attribute__((unused)) static void __session_manager_check_counter(struct sessi
EXPECT_TRUE(counter.udp_overload_evict_old_sess_num == udp_overload_evict_old_sess_num);
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_init(struct session_manager *mgr, struct session_manager_config *config)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_init(struct session_manager *mgr, struct session_manager_options *opts)
{
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_init;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_init;
printf("\n=> tcp_timeout_init\n");
for (uint64_t i = 0; i <= config->tcp_timeout_init; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_init; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_init)
if (i == opts->tcp_timeout_init)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -139,7 +139,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_init(str
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_init);
EXPECT_TRUE(interval <= opts->tcp_timeout_init);
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
EXPECT_TRUE(sess == NULL);
}
@@ -148,20 +148,20 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_init(str
printf("<= tcp_timeout_init\n\n");
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_handshake(struct session_manager *mgr, struct session_manager_config *config)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_handshake(struct session_manager *mgr, struct session_manager_options *opts)
{
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_handshake;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_handshake;
printf("\n=> tcp_timeout_handshake\n");
for (uint64_t i = 0; i <= config->tcp_timeout_handshake; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_handshake; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_handshake)
if (i == opts->tcp_timeout_handshake)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -175,7 +175,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_handshak
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_handshake);
EXPECT_TRUE(interval <= opts->tcp_timeout_handshake);
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
EXPECT_TRUE(sess == NULL);
}
@@ -184,20 +184,20 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_handshak
printf("<= tcp_timeout_handshake\n\n");
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_data(struct session_manager *mgr, struct session_manager_config *config)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_data(struct session_manager *mgr, struct session_manager_options *opts)
{
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_data;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_data;
printf("\n=> tcp_timeout_data\n");
for (uint64_t i = 0; i <= config->tcp_timeout_data; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_data; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_data)
if (i == opts->tcp_timeout_data)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -211,7 +211,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_data(str
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_data);
EXPECT_TRUE(interval <= opts->tcp_timeout_data);
__session_manager_check_counter(mgr, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
EXPECT_TRUE(sess == NULL);
}
@@ -220,22 +220,22 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_data(str
printf("<= tcp_timeout_data\n\n");
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_half_closed(struct session_manager *mgr, struct session_manager_config *config, enum session_state curr_state)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_half_closed(struct session_manager *mgr, struct session_manager_options *opts, enum session_state curr_state)
{
EXPECT_TRUE(curr_state == SESSION_STATE_OPENING || curr_state == SESSION_STATE_ACTIVE);
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_half_closed;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_half_closed;
printf("\n=> tcp_timeout_half_closed\n");
for (uint64_t i = 0; i <= config->tcp_timeout_half_closed; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_half_closed; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_half_closed)
if (i == opts->tcp_timeout_half_closed)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -249,7 +249,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_half_clo
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_half_closed);
EXPECT_TRUE(interval <= opts->tcp_timeout_half_closed);
if (curr_state == SESSION_STATE_OPENING)
{
__session_manager_check_counter(mgr, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -265,20 +265,20 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_half_clo
printf("<= tcp_timeout_half_closed\n\n");
}
__attribute__((unused)) static void __session_manager_check_tcp_timeout_time_wait(struct session_manager *mgr, struct session_manager_config *config)
__attribute__((unused)) static void __session_manager_check_tcp_timeout_time_wait(struct session_manager *mgr, struct session_manager_options *opts)
{
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->tcp_timeout_time_wait;
uint64_t timeout_time = timestamp_get_sec() + opts->tcp_timeout_time_wait;
printf("\n=> tcp_timeout_time_wait\n");
for (uint64_t i = 0; i <= config->tcp_timeout_time_wait; i++)
for (uint64_t i = 0; i <= opts->tcp_timeout_time_wait; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->tcp_timeout_time_wait)
if (i == opts->tcp_timeout_time_wait)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -292,7 +292,7 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_time_wai
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->tcp_timeout_init);
EXPECT_TRUE(interval <= opts->tcp_timeout_init);
__session_manager_check_counter(mgr, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
EXPECT_TRUE(sess == NULL);
}
@@ -301,22 +301,22 @@ __attribute__((unused)) static void __session_manager_check_tcp_timeout_time_wai
printf("<= tcp_timeout_time_wait\n\n");
}
__attribute__((unused)) static void __session_manager_check_udp_timeout_data(struct session_manager *mgr, struct session_manager_config *config, enum session_state curr_state)
__attribute__((unused)) static void __session_manager_check_udp_timeout_data(struct session_manager *mgr, struct session_manager_options *opts, enum session_state curr_state)
{
EXPECT_TRUE(curr_state == SESSION_STATE_OPENING || curr_state == SESSION_STATE_ACTIVE);
struct session *sess;
uint64_t interval;
uint64_t timeout_time = timestamp_get_sec() + config->udp_timeout_data;
uint64_t timeout_time = timestamp_get_sec() + opts->udp_timeout_data;
printf("\n=> udp_timeout_data\n");
for (uint64_t i = 0; i <= config->udp_timeout_data; i++)
for (uint64_t i = 0; i <= opts->udp_timeout_data; i++)
{
timestamp_update();
sess = session_manager_get_expired_session(mgr);
interval = session_manager_get_expire_interval(mgr);
if (i == config->udp_timeout_data)
if (i == opts->udp_timeout_data)
{
printf("timeout_time: %lu, curr_time: %lu, session expired\n",
timeout_time, timestamp_get_sec());
@@ -330,7 +330,7 @@ __attribute__((unused)) static void __session_manager_check_udp_timeout_data(str
printf("timeout_time: %lu, curr_time: %lu, interval : %lu, session not expire\n",
timeout_time, timestamp_get_sec(), interval);
EXPECT_TRUE(interval <= config->udp_timeout_data);
EXPECT_TRUE(interval <= opts->udp_timeout_data);
if (curr_state == SESSION_STATE_OPENING)
{
__session_manager_check_counter(mgr, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0);