00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PCAP_OSTREAM_HH_
00023 # define PCAP_OSTREAM_HH_
00024
00025 extern "C"
00026 {
00027 # include <inttypes.h>
00028 }
00029 # include <string>
00030 # include <vector>
00031 # include <fstream>
00032 # include <cstdlib>
00033
00034 # include <boost/shared_ptr.hpp>
00035
00036 # include <wipal/pcap/pkt.hh>
00037 # include <wipal/pcap/stream.hh>
00038 # include <wipal/pcap/list.hh>
00039
00040 namespace wpl
00041 {
00042
00043 namespace pcap
00044 {
00045
00046 template <class B>
00047 struct stream;
00048
00054 struct ostream
00055 {
00056 ostream(const std::string& filename,
00057 const pkt::type type,
00058 const int32_t zone = 0,
00059 const int32_t snaplen = 0);
00060
00061 template <class B>
00062 ostream(const std::string& filename, const stream<B>& stream);
00063
00064 template <class S>
00065 ostream(const std::string& filename, const list<S>& list);
00066
00068 ostream&
00069 write(const pkt::metadata& meta, const void* bytes);
00070
00072 template <class S>
00073 ostream&
00074 operator << (const pkt::packet<S>&);
00075
00077 template <class S>
00078 ostream&
00079 operator () (const pkt::packet<S>&);
00080
00082 pcap::indexed_file<>
00083 file() const;
00084
00085
00086 private:
00087 void setup(const pkt::type type,
00088 const int32_t zone,
00089 const int32_t snaplen);
00090
00091 std::vector<std::streampos> marks_;
00092
00093 std::string filename_;
00094 unsigned size_;
00095 boost::shared_ptr<std::ofstream> output_;
00096 };
00097
00098 }
00099
00100 }
00101
00102 # include "ostream.hxx"
00103
00104 #endif // ! PCAP_STREAM_HH_