From 52dbb174d89f4cb4d39e6ca5337fbf7c67dec878 Mon Sep 17 00:00:00 2001 From: Andreas Gocht-Zech Date: Mon, 8 Jan 2024 22:16:39 +0100 Subject: [PATCH] allow the library to enable UDP recording --- python/bindings.cpp | 9 +++++++++ src/libnethogs.cpp | 5 +++++ src/libnethogs.h | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/python/bindings.cpp b/python/bindings.cpp index c2b215f..edf7c7a 100644 --- a/python/bindings.cpp +++ b/python/bindings.cpp @@ -84,6 +84,12 @@ std::vector nethogs_packet_stats_py() return stats_vector; } +void nethogs_enable_udp_py(bool state) +{ + nethogs_enable_udp(state); +} + + //--- python module binding PYBIND11_MODULE(nethogs, m) { py::class_(m, "NethogsMonitorRecord") @@ -117,6 +123,9 @@ PYBIND11_MODULE(nethogs, m) { m.def("nethogs_packet_stats", &nethogs_packet_stats_py, R"pbdoc( Nethogs pcap packet stats )pbdoc"); + m.def("nethogs_enable_udp", &nethogs_enable_udp_py, R"pbdoc( + Enables or disables the recording of UDP, default is False. + )pbdoc"); #ifdef VERSION diff --git a/src/libnethogs.cpp b/src/libnethogs.cpp index 81c02b6..d088090 100644 --- a/src/libnethogs.cpp +++ b/src/libnethogs.cpp @@ -355,4 +355,9 @@ void nethogs_packet_stats(NethogsPackageStats **stats, int *stats_size) i++; } *stats_size = handles.size(); +} + +void nethogs_enable_udp(bool state) +{ + catchall = state; } \ No newline at end of file diff --git a/src/libnethogs.h b/src/libnethogs.h index 26849f9..bac2eec 100644 --- a/src/libnethogs.h +++ b/src/libnethogs.h @@ -112,6 +112,13 @@ NETHOGS_DSO_VISIBLE void nethogsmonitor_breakloop(); */ NETHOGS_DSO_VISIBLE void nethogs_packet_stats(NethogsPackageStats **stats, int *stats_size); +/** + * @brief Enables or disables the UDP recording. Default is False. + * + * @param state state to set +*/ +NETHOGS_DSO_VISIBLE void nethogs_enable_udp(bool state); + #undef NETHOGS_DSO_VISIBLE #undef NETHOGS_DSO_HIDDEN