]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h
Version bump
[stg.git] / projects / stargazer / plugins / capture / ether_freebsd / ether_cap.h
index 6e651d35696a50d25e0d1e4f03a1ec32d7f42708..8f7e1f2fdd1693e8954047442b11ad559c9ad4fe 100644 (file)
 #ifndef ETHER_CAP_H
 #define ETHER_CAP_H
 
 #ifndef ETHER_CAP_H
 #define ETHER_CAP_H
 
-#include <string>
-#include <vector>
 #include <pthread.h>
 
 #include <pthread.h>
 
-#ifdef FREE_BSD5
-#include <inttypes.h>
-#endif
-
-#ifdef FREE_BSD
-#include <sys/inttypes.h>
-#endif
+#include <string>
+#include <vector>
 
 
-#include "base_plugin.h"
-#include "base_settings.h"
-#include "../../../traffcounter.h"
+#include "stg/os_int.h"
+#include "stg/plugin.h"
+#include "stg/module_settings.h"
 
 
-using namespace std;
+extern "C" PLUGIN * GetPlugin();
 
 
-extern "C" BASE_PLUGIN * GetPlugin();
+#define BUFF_LEN (128)
 
 
-#define BUFF_LEN    (128)
+class TRAFFCOUNTER;
 
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------
-struct BPF_DATA
-{
+struct BPF_DATA {
     BPF_DATA()
         {
         fd = 0;
     BPF_DATA()
         {
         fd = 0;
@@ -62,7 +54,6 @@ struct BPF_DATA
         bh = NULL;
         canRead = 1;
         iface = "";
         bh = NULL;
         canRead = 1;
         iface = "";
-        //memset(&polld, 0, sizeof(pollfd));
         };
 
     BPF_DATA(const BPF_DATA & bd)
         };
 
     BPF_DATA(const BPF_DATA & bd)
@@ -75,84 +66,76 @@ struct BPF_DATA
         bh = bd.bh;
         canRead = bd.canRead;
         iface = bd.iface;
         bh = bd.bh;
         canRead = bd.canRead;
         iface = bd.iface;
-        //memcpy(&polld, &bd.polld, sizeof(pollfd));
         };
 
         };
 
-int             fd;
-uint8_t *       p;
-int             r;
-int             sum;
-uint8_t         buffer[BUFF_LEN];
+int              fd;
+uint8_t *        p;
+int              r;
+int              sum;
+uint8_t          buffer[BUFF_LEN];
 struct bpf_hdr * bh;
 struct bpf_hdr * bh;
-int             canRead;
-string          iface;
-//pollfd          polld;
+int              canRead;
+std::string      iface;
 };
 //-----------------------------------------------------------------------------
 };
 //-----------------------------------------------------------------------------
-class BPF_CAP_SETTINGS
-{
+class BPF_CAP_SETTINGS {
 public:
 public:
-    virtual         ~BPF_CAP_SETTINGS(){};
-    const string&   GetStrError() const { return errorStr; }
+    virtual         ~BPF_CAP_SETTINGS() {}
+    const std::string & GetStrError() const { return errorStr; }
     int             ParseSettings(const MODULE_SETTINGS & s);
     int             ParseSettings(const MODULE_SETTINGS & s);
-    string          GetIface(unsigned int num);
+    std::string     GetIface(unsigned int num);
 
 private:
 
 private:
-    vector<string>  iface;
-    mutable string  errorStr;
+    std::vector<std::string> iface;
+    mutable std::string errorStr;
 };
 //-----------------------------------------------------------------------------
 };
 //-----------------------------------------------------------------------------
-class BPF_CAP :public BASE_PLUGIN
-{
+class BPF_CAP : public PLUGIN {
 public:
                         BPF_CAP();
 public:
                         BPF_CAP();
-    virtual             ~BPF_CAP(){};
+    virtual             ~BPF_CAP() {}
 
 
-    void                SetUsers(USERS *){};
-    void                SetTariffs(TARIFFS *){};
-    void                SetAdmins(ADMINS *){};
-    void                SetTraffcounter(TRAFFCOUNTER * tc);
-    void                SetStore(BASE_STORE *){};
-    void                SetStgSettings(const SETTINGS *){};
+    void                SetTraffcounter(TRAFFCOUNTER * tc) { traffCnt = tc; }
 
     int                 Start();
     int                 Stop();
 
     int                 Start();
     int                 Stop();
-    int                 Reload() { return 0; };
-    bool                IsRunning();
+    int                 Reload() { return 0; }
+    bool                IsRunning() { return isRunning; }
 
 
-    void                SetSettings(const MODULE_SETTINGS & s);
+    void                SetSettings(const MODULE_SETTINGS & s) { settings = s; }
     int                 ParseSettings();
 
     int                 ParseSettings();
 
-    const string      & GetStrError() const;
-    const string        GetVersion() const;
-    uint16_t            GetStartPosition() const;
-    uint16_t            GetStopPosition() const;
+    const std::string & GetStrError() const { return errorStr; }
+    const std::string   GetVersion() const;
+    uint16_t            GetStartPosition() const { return 10; }
+    uint16_t            GetStopPosition() const { return 10; }
 
 private:
 
 private:
+    BPF_CAP(const BPF_CAP & rvalue);
+    BPF_CAP & operator=(const BPF_CAP & rvalue);
+
     static void *       Run(void *);
     int                 BPFCapOpen();
     static void *       Run(void *);
     int                 BPFCapOpen();
-    //int                 BPFCapOpen(int n);
     int                 BPFCapOpen(BPF_DATA * bd);
     int                 BPFCapClose();
     int                 BPFCapRead(char * buffer, int blen, char ** iface);
     int                 BPFCapRead(char * buffer, int blen, char ** iface, BPF_DATA * bd);
 
     int                 BPFCapOpen(BPF_DATA * bd);
     int                 BPFCapClose();
     int                 BPFCapRead(char * buffer, int blen, char ** iface);
     int                 BPFCapRead(char * buffer, int blen, char ** iface, BPF_DATA * bd);
 
-    BPF_CAP_SETTINGS    capSettings;
+    BPF_CAP_SETTINGS      capSettings;
 
 
-    mutable string      errorStr;
+    mutable std::string   errorStr;
 
 
-    vector<BPF_DATA>    bpfData;
-    vector<pollfd>      polld;
+    std::vector<BPF_DATA> bpfData;
+    std::vector<pollfd>   polld;
 
 
-    pthread_t           thread;
-    bool                nonstop;
-    bool                isRunning;
-    int                 capSock;
-    MODULE_SETTINGS     settings;
+    pthread_t             thread;
+    bool                  nonstop;
+    bool                  isRunning;
+    int                   capSock;
+    MODULE_SETTINGS       settings;
 
 
-    TRAFFCOUNTER *      traffCnt;
+    TRAFFCOUNTER *        traffCnt;
 };
 //-----------------------------------------------------------------------------
 
 };
 //-----------------------------------------------------------------------------
 
-#endif //ETHER_CAP_H
-
+#endif