Skip to content

Commit

Permalink
add support for toggling packet checksum calculation on traffic export
Browse files Browse the repository at this point in the history
- calculation is disabled by default !
  • Loading branch information
astibal committed Oct 17, 2023
1 parent 651aa78 commit 52cf7ff
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion socle
18 changes: 17 additions & 1 deletion src/service/cfgapi/cfgapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,11 @@ bool CfgFactory::upgrade_schema(int upgrade_to_num) {
log.event(INF, "added settings.webhook.hostid");
return true;
}

else if(upgrade_to_num == 1019) {
log.event(INF, "added captures.options section");
log.event(INF, "added captures.options.calculate_checksums");
return true;
}

return false;
}
Expand Down Expand Up @@ -897,6 +901,10 @@ bool CfgFactory::load_captures() {

CfgFactory::gre_export_apply(&traflog::PcapLog::single_instance());
}
if(captures.exists("options")) {
Setting const& remote = captures["options"];
load_if_exists(remote, "calculate_checksums", socle::pcap::CONFIG::CALCULATE_CHECKSUMS);
}
}
else {
// try to load old variables
Expand Down Expand Up @@ -4996,6 +5004,14 @@ int CfgFactory::save_captures(Config& ex) const {
remote.add("tun_dst", Setting::TypeString) = CfgFactory::get()->capture_remote.tun_dst;
remote.add("tun_ttl", Setting::TypeInt) = CfgFactory::get()->capture_remote.tun_ttl;


if(not objects.exists("options"))
objects.add("options", Setting::TypeGroup);

auto& options = ex.getRoot()["captures"]["options"];
options.add("calculate_checksums", Setting::TypeBoolean) = socle::pcap::CONFIG::CALCULATE_CHECKSUMS;


return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/service/cfgapi/cfgapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class CfgFactory : public CfgFactoryBase {
public:
// Each version bump implies a config upgrade - we start on 1000
// see upgrade_schema() - control config upgrade
constexpr static inline const int SCHEMA_VERSION = 1018;
constexpr static inline const int SCHEMA_VERSION = 1019;

static inline std::atomic_bool LOAD_ERRORS = false;

Expand Down
1 change: 1 addition & 0 deletions src/service/cmd/cligen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ CONFIG_MODE_DEF(cli_conf_edit_routing, MODE_EDIT_ROUTING, "routing")
CONFIG_MODE_DEF(cli_conf_edit_captures, MODE_EDIT_CAPTURES, "captures")
CONFIG_MODE_DEF(cli_conf_edit_captures_local, MODE_EDIT_CAPTURES_LOCAL, "local")
CONFIG_MODE_DEF(cli_conf_edit_captures_remote, MODE_EDIT_CAPTURES_REMOTE, "remote")
CONFIG_MODE_DEF(cli_conf_edit_captures_options, MODE_EDIT_CAPTURES_OPTIONS, "options")

#ifdef USE_EXPERIMENT
CONFIG_MODE_DEF(cli_conf_edit_experiment, MODE_EDIT_EXPERIMENT, "experiment")
Expand Down
3 changes: 2 additions & 1 deletion src/service/cmd/cligen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,11 @@ CONFIG_MODE_DEC(cli_conf_edit_detection_signatures)
enum edit_routing { MODE_EDIT_ROUTING=0x28000000, };
CONFIG_MODE_DEC(cli_conf_edit_routing)

enum edit_captures { MODE_EDIT_CAPTURES=0x29000000, MODE_EDIT_CAPTURES_LOCAL=0x29001000, MODE_EDIT_CAPTURES_REMOTE=0x29002000 };
enum edit_captures { MODE_EDIT_CAPTURES=0x29000000, MODE_EDIT_CAPTURES_LOCAL=0x29001000, MODE_EDIT_CAPTURES_REMOTE=0x29002000, MODE_EDIT_CAPTURES_OPTIONS=0x29004000};
CONFIG_MODE_DEC(cli_conf_edit_captures)
CONFIG_MODE_DEC(cli_conf_edit_captures_local)
CONFIG_MODE_DEC(cli_conf_edit_captures_remote)
CONFIG_MODE_DEC(cli_conf_edit_captures_options)

#ifdef USE_EXPERIMENT
enum edit_experiment { MODE_EDIT_EXPERIMENT=0x30000000 };
Expand Down
6 changes: 6 additions & 0 deletions src/service/cmd/cmdserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,12 @@ void generate_callbacks() {
.cmd("set", cli_generic_set_cb)
.cap("edit", true)
.cmd("edit", cli_conf_edit_captures_remote);
register_callback( "captures.options",MODE_EDIT_CAPTURES_OPTIONS)
.cap("set", true)
.cmd("set", cli_generic_set_cb)
.cap("edit", true)
.cmd("edit", cli_conf_edit_captures_options);


#ifdef USE_EXPERIMENT
register_callback("experiment", MODE_EDIT_EXPERIMENT)
Expand Down

0 comments on commit 52cf7ff

Please sign in to comment.