Merge "docs: Update install and release docs for DPDK migration support"
[samplevnf.git] / VNFs / DPPD-PROX / tools / flow_extract / stream3.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 _STREAM3_H_
18 #define _STREAM3_H_
19
20 #include <inttypes.h>
21 #include <vector>
22
23 #include "pcappkt.hpp"
24 #include "timestamp.hpp"
25
26 using namespace std;
27 class Allocator;
28
29 class Stream3 {
30 public:
31         PcapPkt::L4Proto getProto(void) const {return m_proto;}
32         Stream3(uint32_t id, PcapPkt::L4Proto proto);
33         Stream3() : m_id(UINT32_MAX), m_proto(PcapPkt::PROTO_UDP), m_pktCount(0), m_flushCount(0) {}
34         void addPkt(const PcapPkt& pkt);
35         void flush(ofstream *outputFile);
36         void addFromMemory(uint8_t *mem, size_t *len);
37         static uint32_t getIDFromMem(uint8_t *mem);
38         bool hasFlushablePackets() const {return !!m_flushCount;}
39         Timestamp getTimeout() const;
40         uint32_t getID() const {return m_id;}
41         void removeAllPackets();
42         void setID(const uint32_t id) {m_id = id;}
43 private:
44         void writeHeader(ofstream *outputFile) const;
45         void writePackets(ofstream *outputFile) const;
46         void clearPackets();
47
48         uint32_t m_id;
49         PcapPkt::L4Proto m_proto;
50         vector<PcapPkt *> m_pkts;
51         uint32_t m_pktCount;
52         uint32_t m_flushCount;
53 };
54
55 #endif /* _STREAM3_H_ */