2 // Copyright (c) 2010-2017 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
28 #include "pcappktref.hpp"
29 #include "pcappkt.hpp"
30 #include "netsocket.hpp"
31 #include "timestamp.hpp"
32 #include "halfstream.hpp"
42 uint16_t clientHdrLen;
43 uint32_t clientContentLen;
44 uint16_t serverHdrLen;
45 uint32_t serverContentLen;
55 void toFile(ofstream *f) const;
56 int fromFile(ifstream *f);
57 size_t getStreamLen() const;
63 } __attribute__((packed));
65 Stream(uint32_t id = -1, uint32_t sizeHint = 0);
66 void addPkt(const PcapPkt &pkt);
67 void toFile(ofstream *f);
68 void toPcap(const string& outFile);
69 double getRate() const;
70 size_t actionCount() const {return m_actions.size();}
73 Header getHeader() const;
74 void actionsToFile(ofstream *f) const;
75 void clientHdrToFile(ofstream *f) const;
76 void serverHdrToFile(ofstream *f) const;
77 void contentsToFile(ofstream *f, bool isClient) const;
78 bool isClient(const PcapPkt &pkt) const;
79 size_t pktCount() const;
80 struct pkt_tuple m_pt;
81 void setTupleFromPkt(const PcapPkt &pkt);
82 void addToClient(const PcapPkt &pkt);
83 void addToServer(const PcapPkt &pkt);
84 void addAction(HalfStream *half, HalfStream::Action::Part p, bool isClientPkt);
87 vector<PcapPkt> m_pkts;
88 vector<HalfStream::Action> m_actions;
91 bool m_prevPktIsClient;
94 #endif /* _STREAM_H_ */