]> git.stg.codes - stg.git/commitdiff
Merge branch 'master' into full-month-stats
authorMaxim Mamontov <faust.madf@gmail.com>
Sat, 19 May 2012 16:46:38 +0000 (19:46 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Sat, 19 May 2012 16:46:38 +0000 (19:46 +0300)
projects/stargazer/inst/freebsd/etc/stargazer/conf-available.d/mod_cap_divert.conf
projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp
projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h
stglibs/Makefile

index ab0ddfb5765a38ba27e3bed3892d5da767b6d4ff..acd15e0712975bcd61abb6ba811bebe33fe970bd 100644 (file)
@@ -1,8 +1,14 @@
 # Enable the traffic capture module "mod_cap_divert.so" using Divert-sockets
 <Module cap_divert>
    # Port for traffic
-   # Parameter: required
+   # Parameter: optional
    # Value: 1 ... 65535
    # Default: 15701
    Port = 15701
-</Module>
\ No newline at end of file
+
+   # Disable packet forwarding
+   # Parameter: optional
+   # Value: yes, no
+   # Default: no
+   DisableForwarding = no
+</Module>
index a949433e762dab509be7475f348d3d567fdb378c..5cf5358fafe2f966a8dfb8218af5f9abe56898f7 100644 (file)
@@ -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;
 }
 //-----------------------------------------------------------------------------
index 62a78a439c0430497bc69dfbb6870027c12444d1..912b5a149814db83382b2788bdd88e20534cfd5c 100644 (file)
@@ -77,6 +77,7 @@ private:
     MODULE_SETTINGS     settings;
 
     int                 port;
+    bool                disableForwarding;
 
     mutable std::string errorStr;
 
index 912be63debeb836291c7b4b6fe34904288502d56..6b9fbe4023b727919647aba2f08954a63a1b87c5 100644 (file)
@@ -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