-
Notifications
You must be signed in to change notification settings - Fork 8
/
HistoricalInterface.h
executable file
·190 lines (177 loc) · 6.29 KB
/
HistoricalInterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
*
* (C) 2013-14 - ntop.org
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _HISTORICAL_INTERFACE_H_
#define _HISTORICAL_INTERFACE_H_
#include "ntop_includes.h"
class HistoricalInterface : public ParserInterface {
private:
u_int32_t num_historicals, /*< Number of historical files loaded*/
num_query_error, /*< Number of query error*/
num_open_error, /*< Number of error while opening a files*/
num_missing_file ; /*< Number of missing files*/
u_int8_t interface_id; /*< Interface index of the current data*/
time_t from_epoch; /*< From epoch of the current data*/
time_t to_epoch; /*< To Epoch of the current data*/
bool on_load; /*< Set on true when loading historical data, false otherwise*/
/**
* @brief Callback for the sqlite_exe
* @details For each flows read on the DB call @ParserInterface::parse_flows,
* in order to inject the flow into the Interface.
*
* @param data
* @param argc Number of columns in the result.
* @param argv An array of pointers to strings, one for each column.
* @param azColName An array of pointers to strings where each entry represents the name of corresponding result column.
* @return non-zero in case of error, zero otherwise.
*/
static int sqlite_callback(void *data, int argc, char **argv, char **azColName);
/**
* @brief Rest all statistic information of historical interface instance.
* @details Reset information of current data and the counter of error and loaded files.
*/
void resetStats();
public:
/**
* @brief Constructor
* @details Create a new instance and set @ref purge_idle_flows_hosts to false in order to show all the flows.
*
* @param _endpoint Interface name.
*/
HistoricalInterface(const char *_endpoint);
/**
* @brief Get interface type
* @return sqlite
*/
inline const char* get_type() { return(CONST_INTERFACE_TYPE_SQLITE); };
/**
* @brief Check if ndpi is enable for this interface
* @return True if ndpi is enable, false otherwise.
*/
inline bool is_ndpi_enabled() { return(false); };
/**
* @brief Check if the loading process running
* @return True if is running, false otherwise.
*/
inline bool is_on_load() { return(on_load); };
/**
* @brief Set current interface index
*
* @param p_id Interface index
*/
inline void setDataIntrefaceId(u_int8_t p_id) { interface_id = p_id; };
/**
* @brief Set current from epoch
* @details Epoch of first loaded files.
*
* @param p_epoch Epoch time
*/
inline void setFromEpoch(time_t p_epoch) { from_epoch = p_epoch; };
/**
* @brief Set current to epoch
* @details Epoch of last loaded files.
*
* @param p_epoch Epoch time
*/
inline void setToEpoch(time_t p_epoch) { to_epoch = p_epoch; };
/**
* @brief Get current interface index.
* @return Data interface index if set, otherwise return zero.
*/
inline u_int8_t getDataInterfaceId() { return interface_id;};
/**
* @brief Get from epoch
* @details Epoch of first loaded files.]
* @return Epoch time if set, zero otherwise.
*/
inline time_t getFromEpoch() { return from_epoch;};
/**
* @brief Get to epoch
* @details Epoch of last loaded files.
* @return Epoch time if set, zero otherwise.
*/
inline time_t getToEpoch() { return to_epoch;};
/**
* @brief Get number of open error
* @return Number of errors encountered while opening files.
*/
inline u_int32_t getOpenError() { return num_open_error;};
/**
* @brief Get number of query error
* @return Number of errors encountered during the execution of the query.
*/
inline u_int32_t getQueryError() { return num_query_error;};
/**
* @brief Get number of missing error
* @return Number of missing files.
*/
inline u_int32_t getMissingFiles() { return num_missing_file;};
/**
* @brief Get total number of file inside the interval
* @return Number of files.
*/
inline u_int32_t getNumFiles() { return num_historicals;};
/**
* @brief Load historical data
* @details Check if the file exists and then load flows from it.
*
* @param p_file_name Path to the historical data file
* @return CONST_HISTORICAL_OK in case of success, CONST_HISTORICAL_FILE_ERROR or CONST_HISTORICAL_OPEN_ERROR in case of error.
*/
int loadData(char * p_file_name);
/**
* @brief Load historical data
* @details Loop on the interval, with step of 5 minute. For each step make a correct file path and the load flows form it.
* Until an error occurs.
*
* @return CONST_HISTORICAL_OK.
*/
int loadData();
/**
* @brief Start loading historical data process
* @details Cleanup the interface, set on true @ref on_load and initialize the interval values.
*
* @param p_from_epoch Epoch time
* @param p_to_epoch Epoch time
* @param p_interface_id Index of the interface from which you want to load the data
*/
void startLoadData(time_t p_from_epoch, time_t p_to_epoch, u_int8_t p_interface_id);
/**
* @brief Get Number of dropped packets
* @return Zero
*/
inline u_int getNumDroppedPackets() { return 0; };
/**
* @brief For this interface is impossible set packet filter.
* @return False
*/
bool set_packet_filter(char *filter);
/**
* @brief Shutdown the interface
* @details Reset the stats and cleanup the interface.
*/
void shutdown();
/**
* @brief Cleanup
* @details Remove all information about flows, hosts and reset the interface stats.
*/
void cleanup();
};
#endif /* _HISTORICAL_INTERFACE_H_ */