Merge "[l2l3 stack] implements new nd state machine & nd buffering"
[samplevnf.git] / VNFs / DPPD-PROX / tools / flow_extract / streamextract.hpp
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _STREAMEXTRACT_H_
18 #define _STREAMEXTRACT_H_
19
20 #include <string>
21 #include <list>
22 #include <map>
23 #include <set>
24
25 #include "programconfig.hpp"
26 #include "bundle.hpp"
27 #include "pcapreader.hpp"
28 #include "flowtable.hpp"
29 #include "pcappkt.hpp"
30 #include "stream3.hpp"
31 #include "streamsorter.hpp"
32 #include "path.hpp"
33
34 using namespace std;
35
36 class StreamExtract {
37 public:
38         /* The size of the flow table determines the number of flows
39            that can be active at a given time. When a flow expires, it
40            is written out to a file and the memory is freed. */
41         StreamExtract(const ProgramConfig &cfg);
42         int run();
43 private:
44         int writeToPcaps(const string &sourceFilePath, const set<uint32_t> &streamIDs);
45         int writeToLua(const string& binFilePath, const Path &smallFinalBin, const string& luaFilePath, const string& orderedTemp);
46         int writeFinalBin(const string& sourceFilePath, const string& destFilePath);
47         string createStreamPcapFileName(int id);
48         vector<Bundle> createBundles(const string& streamPath);
49         set<uint32_t> getBundleStreamIDs(const vector<Bundle*>& bundleSamples);
50         FlowTable<pkt_tuple, Stream3> ft2;
51         StreamSorter streamSorter;
52         ProgramConfig cfg;
53 };
54
55 #endif /* _STREAMEXTRACT_H_ */