From: Maxim Mamontov Date: Sat, 19 May 2012 16:46:38 +0000 (+0300) Subject: Merge branch 'master' into full-month-stats X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/36f332ceb538480aeaed0dfa9917e983cac77389?hp=ff5b020a0b3d4c61da3425de56d80a54534d1f03 Merge branch 'master' into full-month-stats --- diff --git a/projects/stargazer/inst/freebsd/etc/stargazer/conf-available.d/mod_cap_divert.conf b/projects/stargazer/inst/freebsd/etc/stargazer/conf-available.d/mod_cap_divert.conf index ab0ddfb5..acd15e07 100644 --- a/projects/stargazer/inst/freebsd/etc/stargazer/conf-available.d/mod_cap_divert.conf +++ b/projects/stargazer/inst/freebsd/etc/stargazer/conf-available.d/mod_cap_divert.conf @@ -1,8 +1,14 @@ # Enable the traffic capture module "mod_cap_divert.so" using Divert-sockets # Port for traffic - # Parameter: required + # Parameter: optional # Value: 1 ... 65535 # Default: 15701 Port = 15701 - \ No newline at end of file + + # Disable packet forwarding + # Parameter: optional + # Value: yes, no + # Default: no + DisableForwarding = no + diff --git a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp index a949433e..5cf5358f 100644 --- a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp +++ b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp @@ -81,6 +81,7 @@ return "Divert_cap v.1.0"; DIVERT_CAP::DIVERT_CAP() : settings(), port(0), + disableForwarding(false), errorStr(), thread(), nonstop(false), @@ -250,7 +251,8 @@ if ((bytes = recvfrom (cddiv.sock, buf, BUFF_LEN, if (iface) *iface = cddiv.iface; - sendto(cddiv.sock, buf, bytes, 0, (struct sockaddr*)&divertaddr, divertaddrSize); + if (!disableForwarding) + sendto(cddiv.sock, buf, bytes, 0, (struct sockaddr*)&divertaddr, divertaddrSize); } return 0; @@ -272,11 +274,9 @@ pv.param = "Port"; pvi = std::find(settings.moduleParams.begin(), settings.moduleParams.end(), pv); if (pvi == settings.moduleParams.end()) { - port = 15701; - return 0; + p = 15701; } - -if (ParseIntInRange(pvi->value[0], 1, 65535, &p)) +else if (ParseIntInRange(pvi->value[0], 1, 65535, &p)) { errorStr = "Cannot parse parameter \'Port\': " + errorStr; printfd(__FILE__, "Cannot parse parameter 'Port'\n"); @@ -285,6 +285,22 @@ if (ParseIntInRange(pvi->value[0], 1, 65535, &p)) port = p; +bool d = false; +pv.param = "DisableForwarding"; +pvi = std::find(settings.moduleParams.begin(), settings.moduleParams.end(), pv); +if (pvi == settings.moduleParams.end()) + { + disableForwarding = false; + } +else if (ParseYesNo(pvi->value[0], &d)) + { + errorStr = "Cannot parse parameter \'DisableForwarding\': " + errorStr; + printfd(__FILE__, "Cannot parse parameter 'DisableForwarding'\n"); + return -1; + } + +disableForwarding = d; + return 0; } //----------------------------------------------------------------------------- diff --git a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h index 62a78a43..912b5a14 100644 --- a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h +++ b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h @@ -77,6 +77,7 @@ private: MODULE_SETTINGS settings; int port; + bool disableForwarding; mutable std::string errorStr; diff --git a/stglibs/Makefile b/stglibs/Makefile index 912be63d..6b9fbe40 100644 --- a/stglibs/Makefile +++ b/stglibs/Makefile @@ -7,9 +7,9 @@ include ../Makefile.conf .PHONY: all $(STG_LIBS) .PHONY: clean install uninstall includes all: $(STG_LIBS) - -$(STG_LIBS): - $(MAKE) $(MAKECMDGOALS) -C $@ + for LIB in $(STG_LIBS); do\ + $(MAKE) $(MAKECMDGOALS) -C $$LIB;\ + done includes: all