]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h
Fix TRAFFCOUNTER in plugins
[stg.git] / projects / stargazer / plugins / capture / ipq_linux / ipq_cap.h
1 #ifndef IPQ_CAP_H
2 #define IPQ_CAP_H
3
4 #include <string>
5
6 #include "plugin.h"
7 #include "module_settings.h"
8 #include "os_int.h"
9
10 #define BUFSIZE     (256)
11 #define PAYLOAD_LEN (96)
12
13 class USERS;
14 class TARIFFS;
15 class ADMINS;
16 class TRAFFCOUNTER;
17 class SETTINGS;
18
19 extern "C" PLUGIN * GetPlugin();
20
21 //-----------------------------------------------------------------------------
22 class IPQ_CAP :public PLUGIN {
23 public:
24     IPQ_CAP();
25     virtual ~IPQ_CAP() {}
26
27     void SetUsers(USERS *) {}
28     void SetTariffs(TARIFFS *) {}
29     void SetAdmins(ADMINS *) {}
30     void SetTraffcounter(TRAFFCOUNTER * tc) { traffCnt = tc; }
31     void SetStore(STORE *) {}
32     void SetStgSettings(const SETTINGS *) {}
33
34     int Start();
35     int Stop();
36     int Reload() { return 0; }
37     bool IsRunning() { return isRunning; }
38
39     void  SetSettings(const MODULE_SETTINGS &) {}
40     int  ParseSettings() { return 0; }
41     const std::string & GetStrError() const { return errorStr; }
42     const std::string GetVersion() const;
43     uint16_t GetStartPosition() const { return 10; }
44     uint16_t GetStopPosition() const { return 10; }
45
46 private:
47     static void * Run(void *);
48     int IPQCapOpen();
49     int IPQCapClose();
50     int IPQCapRead(void * buffer, int blen);
51
52     struct ipq_handle * ipq_h;
53     mutable std::string errorStr;
54
55     pthread_t thread;
56     bool nonstop;
57     bool isRunning;
58     int capSock;
59
60     TRAFFCOUNTER * traffCnt;
61     unsigned char buf[BUFSIZE];
62 };
63
64 #endif