Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow the library to enable UDP recording #269

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
allow the library to enable UDP recording
  • Loading branch information
AndreasGocht committed Jan 8, 2024
commit 52dbb174d89f4cb4d39e6ca5337fbf7c67dec878
9 changes: 9 additions & 0 deletions python/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ std::vector<NethogsPackageStats> 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_<NethogsMonitorRecord>(m, "NethogsMonitorRecord")
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/libnethogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 7 additions & 0 deletions src/libnethogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down