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,
00076 const bytes_ptr& bytes,
00077 unsigned idx = 0,
00078 const PCAPDescriptor* desc = 0);
00079
00092 template <class D>
00093 frame_descriptor(const descriptor<D>& desc,
00094 std::istream& stream,
00095 unsigned idx,
00096 std::streampos* pos);
00097
00098
00099
00100
00101
00102
00103
00104 template <class OtherDescriptor>
00105 frame_descriptor(const frame_descriptor<OtherDescriptor>&);
00106
00108 unsigned id() const;
00109
00111 bool swapped() const;
00112
00114 const PCAPDescriptor*
00115 desc_ptr() const;
00116
00121 const PCAPDescriptor&
00122 desc() const;
00123
00125 const pkthdr_ptr& pcap_header() const;
00126
00128 const bytes_ptr& bytes() const;
00129
00131 std::ostream& print(std::ostream&) const;
00132
00134
00135 bool operator == (const frame_descriptor&) const;
00136 bool operator != (const frame_descriptor&) const;
00138
00140 struct shared_data
00141 {
00142 shared_data(const PCAPDescriptor* desc,
00143 unsigned id,
00144 const pkthdr_ptr& pcap_header,
00145 const bytes_ptr& bytes);
00146
00147 const PCAPDescriptor* desc;
00148 unsigned id;
00149 pkthdr_ptr pcap_header;
00150 bytes_ptr bytes;
00151 };
00152
00161 const boost::shared_ptr<shared_data>& data() const;
00162
00163 protected:
00164 boost::shared_ptr<shared_data> data_;
00165 };
00166
00168 template <class PCAPDescriptor>
00169 std::ostream&
00170 operator << (std::ostream&, const frame_descriptor<PCAPDescriptor>&);
00171
00172 }
00173
00174 # include "frame_descriptor.hxx"
00175
00176 #endif // ! PCAP_FRAME_DESCRITPOR_HH_