]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h
8423421938d7d454ce82c206875c999ab6be1ca3
[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 /*
23 $Revision: 1.6 $
24 $Date: 2009/06/23 11:32:27 $
25 */
26
27 #ifndef DIVERT_CAP_H
28 #define DIVERT_CAP_H
29
30 #include <string>
31 #include <pthread.h>
32
33 #include "base_plugin.h"
34 #include "base_settings.h"
35 #include "../../../traffcounter.h"
36
37 using namespace std;
38
39 extern "C" BASE_PLUGIN * GetPlugin();
40
41 //-----------------------------------------------------------------------------
42 class DIVERT_CAP :public BASE_PLUGIN
43 {
44 public:
45     DIVERT_CAP();
46     virtual ~DIVERT_CAP(){};
47
48     void                SetUsers(USERS *){};
49     void                SetTariffs(TARIFFS *){};
50     void                SetAdmins(ADMINS *){};
51     void                SetTraffcounter(TRAFFCOUNTER * tc);
52     void                SetStore(BASE_STORE *){};
53     void                SetStgSettings(const SETTINGS *){};
54
55     int                 Start();
56     int                 Stop();
57     int                 Reload() { return 0; };
58     bool                IsRunning();
59
60     void                SetSettings(const MODULE_SETTINGS & s);
61     int                 ParseSettings();
62     const string      & GetStrError() const;
63     const string        GetVersion() const;
64     uint16_t            GetStartPosition() const;
65     uint16_t            GetStopPosition() const;
66
67 private:
68     static void *       Run(void *);
69
70     int                 DivertCapOpen();
71     int                 DivertCapOpen(int n);
72     int                 DivertCapRead(char * buffer, int blen, char ** iface);
73     int                 DivertCapRead(char * buffer, int blen, char ** iface, int n);
74     int                 DivertCapClose();
75
76     int                 ParseIntInRange(const string & str, int min, int max, int * val);
77
78     MODULE_SETTINGS     settings;
79
80     int                 port;
81
82     mutable string      errorStr;
83
84     pthread_t           thread;
85
86     bool                nonstop;
87     bool                isRunning;
88
89     //int                 capSock;
90
91     TRAFFCOUNTER *      traffCnt;
92 };
93 //-----------------------------------------------------------------------------
94
95
96 #endif