mirror of
https://github.com/rtbrick/bngblaster.git
synced 2024-05-06 15:54:57 +00:00
monkey test start/stop command
This commit is contained in:
@@ -24,6 +24,7 @@ bool g_interactive = false; /* interactive mode using ncurses */
|
||||
bool g_init_phase = true;
|
||||
bool g_traffic = true;
|
||||
bool g_banner = true;
|
||||
bool g_monkey = true;
|
||||
|
||||
extern char *g_log_file;
|
||||
volatile bool g_teardown = false;
|
||||
@@ -541,6 +542,7 @@ main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
g_monkey = ctx->config.monkey_autostart;
|
||||
|
||||
if(username) ctx->config.username = username;
|
||||
if(password) ctx->config.password = password;
|
||||
|
||||
@@ -1354,6 +1354,10 @@ json_parse_config(json_t *root, bbl_ctx_s *ctx) {
|
||||
if (json_is_boolean(value)) {
|
||||
ctx->config.sessions_autostart = json_boolean_value(value);
|
||||
}
|
||||
value = json_object_get(section, "monkey-autostart");
|
||||
if (json_is_boolean(value)) {
|
||||
ctx->config.monkey_autostart = json_boolean_value(value);
|
||||
}
|
||||
}
|
||||
|
||||
/* IPoE Configuration */
|
||||
@@ -2230,6 +2234,7 @@ bbl_config_init_defaults (bbl_ctx_s *ctx) {
|
||||
ctx->config.sessions_start_rate = 400;
|
||||
ctx->config.sessions_stop_rate = 400;
|
||||
ctx->config.sessions_autostart = true;
|
||||
ctx->config.monkey_autostart = true;
|
||||
ctx->config.pppoe_discovery_timeout = 5;
|
||||
ctx->config.pppoe_discovery_retry = 10;
|
||||
ctx->config.ppp_mru = 1492;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
extern volatile bool g_teardown;
|
||||
extern volatile bool g_teardown_request;
|
||||
extern volatile bool g_monkey;
|
||||
|
||||
typedef ssize_t callback_function(int fd, bbl_ctx_s *ctx, uint32_t session_id, json_t* arguments);
|
||||
|
||||
@@ -1305,6 +1306,24 @@ bbl_ctrl_traffic_stop(int fd, bbl_ctx_s *ctx, uint32_t session_id __attribute__(
|
||||
return bbl_ctrl_status(fd, "ok", 200, NULL);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
bgp_ctrl_monkey_start(int fd, bbl_ctx_s *ctx __attribute__((unused)), uint32_t session_id __attribute__((unused)), json_t* arguments __attribute__((unused))) {
|
||||
if(!g_monkey) {
|
||||
LOG_NOARG(INFO, "Start monkey\n");
|
||||
}
|
||||
g_monkey = true;
|
||||
return bbl_ctrl_status(fd, "ok", 200, NULL);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
bgp_ctrl_monkey_stop(int fd, bbl_ctx_s *ctx __attribute__((unused)), uint32_t session_id __attribute__((unused)), json_t* arguments __attribute__((unused))) {
|
||||
if(g_monkey) {
|
||||
LOG_NOARG(INFO, "Stop monkey\n");
|
||||
}
|
||||
g_monkey = false;
|
||||
return bbl_ctrl_status(fd, "ok", 200, NULL);
|
||||
}
|
||||
|
||||
struct action {
|
||||
char *name;
|
||||
callback_function *fn;
|
||||
@@ -1364,6 +1383,8 @@ struct action actions[] = {
|
||||
{"bgp-teardown", bgp_ctrl_teardown},
|
||||
{"bgp-raw-update-list", bgp_ctrl_raw_update_list},
|
||||
{"bgp-raw-update", bgp_ctrl_raw_update},
|
||||
{"monkey-start", bgp_ctrl_monkey_start},
|
||||
{"monkey-stop", bgp_ctrl_monkey_stop},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ typedef struct bbl_ctx_
|
||||
uint16_t sessions_stop_rate;
|
||||
uint16_t sessions_start_delay;
|
||||
bool sessions_autostart;
|
||||
|
||||
bool monkey_autostart;
|
||||
bool iterate_outer_vlan;
|
||||
|
||||
/* Static */
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "bbl_dhcpv6.h"
|
||||
|
||||
extern volatile bool g_teardown;
|
||||
extern volatile bool g_monkey;
|
||||
|
||||
const char *
|
||||
session_state_string(uint32_t state) {
|
||||
@@ -217,7 +218,7 @@ void
|
||||
bbl_session_monkey_job(timer_s *timer) {
|
||||
bbl_session_s *session = timer->data;
|
||||
|
||||
if(g_teardown) {
|
||||
if(g_teardown || !g_monkey) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user