00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PCAP_FRAME_DESCRIPTOR_HH_
00023 # define PCAP_FRAME_DESCRIPTOR_HH_
00024
00025 extern "C"
00026 {
00027 # include <inttypes.h>
00028 }
00029 # include <iostream>
00030
00031 # include <boost/shared_ptr.hpp>
00032 # include <boost/shared_array.hpp>
00033
00034 # include <wipal/tool/static_base.hh>
00035 # include <wipal/pcap/simple_types.hh>
00036
00037 namespace pcapxx
00038 {
00039
00040
00041 template <class>
00042 class descriptor;
00043
00059 template <class PCAPDescriptor = tool::undefined_type>
00060 struct frame_descriptor
00061 {
00063 typedef boost::shared_ptr<const pkthdr> pkthdr_ptr;
00064
00066 typedef boost::shared_array<uint8_t> bytes_ptr;
00067
00075 frame_descriptor(const pkthdr_ptr& header, const bytes_ptr& bytes);
00076
00089 template <class D>
00090 frame_descriptor(const descriptor<D>& desc,
00091 std::istream& stream,
00092 unsigned idx,
00093 std::streampos* pos);
00094
00095
00096
00097
00098
00099
00100
00101 template <class OtherDescriptor>
00102 frame_descriptor(const frame_descriptor<OtherDescriptor>&);
00103
00105 unsigned id() const;
00106
00108 bool swapped() const;
00109
00111 const PCAPDescriptor*
00112 desc_ptr() const;
00113
00118 const PCAPDescriptor&
00119 desc() const;
00120
00122 const pkthdr_ptr& pcap_header() const;
00123
00125 const bytes_ptr& bytes() const;
00126
00128 std::ostream& print(std::ostream&) const;
00129
00131
00132 bool operator == (const frame_descriptor&) const;
00133 bool operator != (const frame_descriptor&) const;
00135
00137 struct shared_data
00138 {
00139 shared_data(const PCAPDescriptor* desc,
00140 unsigned id,
00141 const pkthdr_ptr& pcap_header,
00142 const bytes_ptr& bytes);
00143
00144 const PCAPDescriptor* desc;
00145 unsigned id;
00146 pkthdr_ptr pcap_header;
00147 bytes_ptr bytes;
00148 };
00149
00158 const boost::shared_ptr<shared_data>& data() const;
00159
00160 protected:
00161 boost::shared_ptr<shared_data> data_;
00162 };
00163
00165 template <class PCAPDescriptor>
00166 std::ostream&
00167 operator << (std::ostream&, const frame_descriptor<PCAPDescriptor>&);
00168
00169 }
00170
00171 # include "frame_descriptor.hxx"
00172
00173 #endif // ! PCAP_FRAME_DESCRITPOR_HH_