]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h
Fight CLang warnings.
[stg.git] / projects / stargazer / plugins / capture / divert_freebsd / divert_cap.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 /*
19  Author : Boris Mikhailenko <stg34@stg.dp.ua>
20 */
21
22 #pragma once
23
24 #include "stg/plugin.h"
25 #include "stg/module_settings.h"
26 #include "stg/logger.h"
27
28 #include <string>
29
30 #include <pthread.h>
31
32 namespace STG
33 {
34 class Users;
35 class Tariffs;
36 struct Admins;
37 struct TraffCounter;
38 struct Settings;
39 }
40
41 //-----------------------------------------------------------------------------
42 class DIVERT_CAP : public STG::Plugin {
43 public:
44     DIVERT_CAP();
45
46     void                SetTraffcounter(STG::TraffCounter * tc) override { traffCnt = tc; }
47
48     int                 Start() override;
49     int                 Stop() override;
50     int                 Reload(const STG::ModuleSettings & /*ms*/) override { return 0; }
51     bool                IsRunning() override { return isRunning; }
52
53     void                SetSettings(const STG::ModuleSettings & s) override { settings = s; }
54     int                 ParseSettings() override;
55     const std::string & GetStrError() const override { return errorStr; }
56     std::string         GetVersion() const override;
57     uint16_t            GetStartPosition() const override { return 40; }
58     uint16_t            GetStopPosition() const override { return 40; }
59
60 private:
61     DIVERT_CAP(const DIVERT_CAP & rvalue);
62     DIVERT_CAP & operator=(const DIVERT_CAP & rvalue);
63
64     static void *       Run(void *);
65
66     int                 DivertCapOpen();
67     int                 DivertCapOpen(int n);
68     int                 DivertCapRead(char * buffer, int blen, char ** iface);
69     int                 DivertCapRead(char * buffer, int blen, char ** iface, int n);
70     int                 DivertCapClose();
71
72     STG::ModuleSettings     settings;
73
74     int                 port;
75     bool                disableForwarding;
76
77     mutable std::string errorStr;
78
79     pthread_t           thread;
80
81     bool                nonstop;
82     bool                isRunning;
83
84     STG::TraffCounter *      traffCnt;
85
86     STG::PluginLogger       logger;
87 };