]> git.stg.codes - stg.git/blob - stargazer/plugins/capture/nfqueue/nfqueue.h
Public interfaces: part 3
[stg.git] / stargazer / plugins / capture / nfqueue / nfqueue.h
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
19 */
20
21 #pragma once
22
23 #include "stg/plugin.h"
24 #include "stg/module_settings.h"
25 #include "stg/logger.h"
26
27 #include <string>
28 #include <vector>
29
30 #include <pthread.h>
31
32 namespace STG
33 {
34
35 struct Users;
36 struct Tariffs;
37 struct Admins;
38 struct TraffCounter;
39 struct Settings;
40 struct RawPacket;
41
42 }
43
44 struct nfq_handle;
45 struct nfq_q_handle;
46
47 class NFQ_CAP : public STG::Plugin {
48 public:
49     NFQ_CAP();
50
51     void                SetTraffcounter(STG::TraffCounter * tc) override { traffCnt = tc; }
52
53     int                 Start() override;
54     int                 Stop() override;
55     int                 Reload(const STG::ModuleSettings & /*ms*/) override { return 0; }
56     bool                IsRunning() override { return isRunning; }
57
58     void                SetSettings(const STG::ModuleSettings & s) override { settings = s; }
59     int                 ParseSettings() override;
60
61     const std::string & GetStrError() const override { return errorStr; }
62     std::string         GetVersion() const override;
63     uint16_t            GetStartPosition() const override { return 40; }
64     uint16_t            GetStopPosition() const override { return 40; }
65
66     void                Process(const STG::RawPacket & packet);
67
68 private:
69     NFQ_CAP(const NFQ_CAP & rvalue);
70     NFQ_CAP & operator=(const NFQ_CAP & rvalue);
71
72     static void *       Run(void *);
73
74     mutable std::string errorStr;
75
76     pthread_t           thread;
77     bool                nonstop;
78     bool                isRunning;
79     STG::ModuleSettings     settings;
80
81     size_t              queueNumber;
82
83     struct nfq_handle * nfqHandle;
84     struct nfq_q_handle * queueHandle;
85
86     STG::TraffCounter *      traffCnt;
87
88     STG::PluginLogger       logger;
89 };