Add std_update_time option.
This commit is contained in:
17
src/config.c
17
src/config.c
@@ -23,6 +23,7 @@ void setcfgdefaults(struct config *cfg)
|
||||
cfg->updatetime = 0;
|
||||
cfg->interface = "eth0";
|
||||
cfg->nostats = 0;
|
||||
cfg->stdout_update_time = 1000;
|
||||
|
||||
for (__u16 i = 0; i < MAX_FILTERS; i++)
|
||||
{
|
||||
@@ -158,16 +159,18 @@ int readcfg(struct config *cfg)
|
||||
// Get auto update time.
|
||||
int updatetime;
|
||||
|
||||
if (!config_lookup_int(&conf, "updatetime", &updatetime))
|
||||
if (config_lookup_int(&conf, "updatetime", &updatetime) == CONFIG_TRUE)
|
||||
{
|
||||
fprintf(stderr, "Error from LibConfig when reading 'updatetime' setting - %s\n\n", config_error_text(&conf));
|
||||
|
||||
config_destroy(&conf);
|
||||
|
||||
return 1;
|
||||
cfg->updatetime = updatetime;
|
||||
}
|
||||
|
||||
cfg->updatetime = updatetime;
|
||||
// Get stdout update time.
|
||||
int stdout_update_time;
|
||||
|
||||
if (config_lookup_int(&conf, "stdout_update_time", &stdout_update_time) == CONFIG_TRUE)
|
||||
{
|
||||
cfg->stdout_update_time = stdout_update_time;
|
||||
}
|
||||
|
||||
// Get no stats.
|
||||
int nostats;
|
||||
|
||||
@@ -9,6 +9,7 @@ struct config
|
||||
char *interface;
|
||||
__u16 updatetime;
|
||||
unsigned int nostats : 1;
|
||||
int stdout_update_time;
|
||||
struct filter filters[MAX_FILTERS];
|
||||
};
|
||||
|
||||
|
||||
@@ -322,9 +322,10 @@ int main(int argc, char *argv[])
|
||||
// Check for list option.
|
||||
if (cmd.list)
|
||||
{
|
||||
fprintf(stdout, "Details:\n");
|
||||
fprintf(stdout, "Current Settings:\n");
|
||||
fprintf(stdout, "Interface Name => %s\n", cfg.interface);
|
||||
fprintf(stdout, "Update Time => %d\n", cfg.updatetime);
|
||||
fprintf(stdout, "Stdout Update Time => %d\n\n", cfg.stdout_update_time);
|
||||
|
||||
for (uint16_t i = 0; i < MAX_FILTERS; i++)
|
||||
{
|
||||
|
||||
@@ -611,7 +611,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
||||
// Before dropping, update the blacklist map.
|
||||
if (blocktime > 0)
|
||||
{
|
||||
__u64 newTime = now + (blocktime * 1000000000);
|
||||
__u64 newTime = now + (blocktime * NANO_TO_SEC);
|
||||
|
||||
if (iph6)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user