Skip to content

Commit b9a6e42

Browse files
jaroslavpesekSiskaPavel
authored andcommitted
ctt - add cache-ctt
1 parent fa651a2 commit b9a6e42

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

storage/cache-ctt.cpp

Whitespace-only changes.

storage/cache-ctt.hpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#ifndef IPXP_STORAGE_CACHE_CTT_HPP
2+
#define IPXP_STORAGE_CACHE_CTT_HPP
3+
4+
#include "cache.hpp"
5+
#include "ctt-controller.hpp"
6+
7+
namespace ipxp {
8+
9+
// Extend CacheOptParser to create CacheCTTOptParser
10+
class CacheCTTOptParser : public CacheOptParser
11+
{
12+
public:
13+
std::string m_dev;
14+
15+
CacheCTTOptParser() : CacheOptParser(), m_dev("")
16+
{
17+
// Register the new option "dev=DEV for device name where is CTT running"
18+
register_option("d", "dev", "DEV", "Device name",
19+
[this](const char *arg){
20+
m_dev = arg;
21+
return true;
22+
},
23+
OptionFlags::RequiredArgument);
24+
}
25+
};
26+
27+
class NHTFlowCacheCTT : public NHTFlowCache
28+
{
29+
public:
30+
NHTFlowCacheCTT();
31+
~NHTFlowCacheCTT();
32+
33+
void init(const char *params) override;
34+
OptionsParser *get_parser() const override { return new CacheCTTOptParser(); }
35+
std::string get_name() const override { return "cache_ctt"; }
36+
37+
// override post_create method
38+
int plugins_post_create(Flow &rec, Packet &pkt) {
39+
int ret = StoragePlugin::plugins_post_create(rec, pkt);
40+
if (no_data_required(rec)) {
41+
m_ctt_controller.create_record(rec.flow_hash_ctt, rec.time_first);
42+
} else if (all_data_required(rec)) {
43+
m_ctt_controller.create_record(rec.flow_hash_ctt, rec.time_first);
44+
}
45+
46+
47+
return ret;
48+
}
49+
50+
private:
51+
std::string m_dev;
52+
CttController m_ctt_controller;
53+
};
54+
55+
}
56+
57+
#endif /* IPXP_STORAGE_CACHE_CTT_HPP */

0 commit comments

Comments
 (0)