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.
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.
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
19 $Date: 2009/06/23 11:32:27 $
24 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
40 #include <sys/inttypes.h>
44 #include "module_settings.h"
45 #include "../../../traffcounter.h"
47 extern "C" PLUGIN * GetPlugin();
49 #define BUFF_LEN (128)
51 //-----------------------------------------------------------------------------
59 memset(buffer, 0, BUFF_LEN);
65 BPF_DATA(const BPF_DATA & bd)
71 memcpy(buffer, bd.buffer, BUFF_LEN);
81 uint8_t buffer[BUFF_LEN];
86 //-----------------------------------------------------------------------------
87 class BPF_CAP_SETTINGS {
89 virtual ~BPF_CAP_SETTINGS() {}
90 const std::string & GetStrError() const { return errorStr; }
91 int ParseSettings(const MODULE_SETTINGS & s);
92 std::string GetIface(unsigned int num);
95 std::vector<std::string> iface;
96 mutable std::string errorStr;
98 //-----------------------------------------------------------------------------
99 class BPF_CAP : public PLUGIN {
102 virtual ~BPF_CAP() {}
104 void SetUsers(USERS *) {}
105 void SetTariffs(TARIFFS *) {}
106 void SetAdmins(ADMINS *) {}
107 void SetTraffcounter(TRAFFCOUNTER * tc);
108 void SetStore(STORE *) {}
109 void SetStgSettings(const SETTINGS *) {}
113 int Reload() { return 0; }
116 void SetSettings(const MODULE_SETTINGS & s);
119 const std::string & GetStrError() const;
120 const std::string GetVersion() const;
121 uint16_t GetStartPosition() const;
122 uint16_t GetStopPosition() const;
125 static void * Run(void *);
127 int BPFCapOpen(BPF_DATA * bd);
129 int BPFCapRead(char * buffer, int blen, char ** iface);
130 int BPFCapRead(char * buffer, int blen, char ** iface, BPF_DATA * bd);
132 BPF_CAP_SETTINGS capSettings;
134 mutable std::string errorStr;
136 std::vector<BPF_DATA> bpfData;
137 std::vector<pollfd> polld;
143 MODULE_SETTINGS settings;
145 TRAFFCOUNTER * traffCnt;
147 //-----------------------------------------------------------------------------