/src/ntopng/include/TimelineExtract.h
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * (C) 2015-26 - ntop.org |
4 | | * |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | | * |
20 | | */ |
21 | | |
22 | | #ifndef _TIMELINE_EXTRACT_H_ |
23 | | #define _TIMELINE_EXTRACT_H_ |
24 | | |
25 | | #include "ntop_includes.h" |
26 | | |
27 | | class TimelineExtract { |
28 | | private: |
29 | | pthread_t extraction_thread; |
30 | | bool running; |
31 | | bool shutdown; |
32 | | int status_code; |
33 | | |
34 | | struct { |
35 | | u_int64_t packets; |
36 | | u_int64_t bytes; |
37 | | } stats; |
38 | | |
39 | | struct { |
40 | | NetworkInterface* iface; |
41 | | u_int32_t id; |
42 | | time_t from; |
43 | | time_t to; |
44 | | char* bpf_filter; |
45 | | u_int64_t max_bytes; |
46 | | const char* timeline_path; |
47 | | } extraction; |
48 | | |
49 | | #ifdef HAVE_PF_RING |
50 | | pfring* openTimeline(const char* timeline_path, time_t from, time_t to, |
51 | | const char* bpf_filter); |
52 | | pfring* openTimelineFromInterface(NetworkInterface* iface, time_t from, |
53 | | time_t to, const char* bpf_filter); |
54 | | #endif |
55 | | |
56 | | public: |
57 | | TimelineExtract(); |
58 | | ~TimelineExtract(); |
59 | 0 | inline NetworkInterface* getNetworkInterface() { return extraction.iface; }; |
60 | 0 | inline u_int32_t getID() { return extraction.id; }; |
61 | 0 | inline time_t getFrom() { return extraction.from; }; |
62 | 0 | inline time_t getTo() { return extraction.to; }; |
63 | 0 | inline const char* getFilter() { return extraction.bpf_filter; }; |
64 | 0 | inline const char* getTimelinePath() { return extraction.timeline_path; }; |
65 | 0 | inline const u_int64_t getMaxBytes() { return extraction.max_bytes; }; |
66 | 0 | inline bool isRunning() { return running; }; |
67 | | void stop(); |
68 | | /* sync */ |
69 | | bool extractToDisk(u_int32_t id, NetworkInterface* iface, time_t from, |
70 | | time_t to, const char* bpf_filter, u_int64_t max_bytes, |
71 | | const char* timeline_path); |
72 | | bool extractLive(struct mg_connection* conn, NetworkInterface* iface, |
73 | | time_t from, time_t to, const char* bpf_filter, |
74 | | const char* timeline_path); |
75 | | /* async */ |
76 | | void runExtractionJob(u_int32_t id, NetworkInterface* iface, time_t from, |
77 | | time_t to, const char* bpf_filter, u_int64_t max_bytes, |
78 | | const char* timeline_path); |
79 | | void stopExtractionJob(u_int32_t id); |
80 | | void cleanupJob(); |
81 | | void getStatus(lua_State* vm); |
82 | | }; |
83 | | |
84 | | #endif /* _TIMELINE_EXTRACT_H_ */ |