00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_FRAME_FILTER_TIME_ADJUSTER_HH_
00023 # define WIFI_FRAME_FILTER_TIME_ADJUSTER_HH_
00024
00025 # include <boost/optional.hpp>
00026
00027 # include <wipal/tool/microseconds_stamp.hh>
00028 # include <wipal/pcap/frame_descriptor.hh>
00029 # include <wipal/tool/valued_iterator.hh>
00030 # include <wipal/tool/iterable.hh>
00031 # include <wipal/wifi/time_converter.hh>
00032 # include <wipal/wifi/addr_mapping.hh>
00033
00034 # include "time_adjuster_fwd.hh"
00035
00036 namespace tool
00037 {
00038
00039 template <class I1, class I2, class HT, class B1, class B2>
00040 struct types< wifi::frame::filter::internals::
00041 time_adjuster_iterator<I1, I2, HT, B1, B2> >
00042 {
00043 typedef wifi::frame::filter::time_adjuster<I1, I2, HT, B1> iterable_type;
00044 typedef tool::microseconds_stamp< pcapxx::frame_descriptor<> >value_type;
00045 };
00046
00047 template <class I1, class I2, class HT, class B>
00048 struct types< wifi::frame::filter::time_adjuster<I1, I2, HT, B> >
00049 {
00050 typedef wifi::frame::filter::internals::
00051 time_adjuster_iterator<I1, I2, HT, B, bottom>
00052 iterator;
00053 };
00054
00055 }
00056
00057 namespace wifi
00058 {
00059 namespace frame
00060 {
00061 namespace filter
00062 {
00063
00064 namespace internals
00065 {
00066
00067 template <class InputIterator1,
00068 class InputIterator2,
00069 class HeaderType,
00070 class B,
00071 class Bottom = tool::bottom>
00072 struct time_adjuster_iterator:
00073 WP_INHERIT(public tool::valued_iterator,
00074 time_adjuster_iterator<InputIterator1, InputIterator2,
00075 HeaderType, B, Bottom>)
00076 {
00078
00079 typedef WP_GET_EXACT(Bottom, time_adjuster_iterator<InputIterator1,
00080 InputIterator2,
00081 HeaderType,
00082 B, Bottom>)
00083 exact_type;
00084 typedef tool::valued_iterator<exact_type> super_type;
00085 typedef WP_TYPE(value_type, exact_type) value_type;
00086 typedef WP_TYPE(iterable_type, exact_type) iterable_type;
00088
00090 time_adjuster_iterator(const iterable_type& i, bool end);
00091
00093
00094 bool equal(const time_adjuster_iterator& rhs) const;
00095 void increment();
00097
00098 private:
00099 typedef typename InputIterator2::value_type::coefs_type coefs_type;
00100
00101 void update_coefs();
00102
00103 const iterable_type* iterable_;
00104 boost::optional<coefs_type> coefs_;
00105
00106 InputIterator1 next1_;
00107 InputIterator2 next2_;
00108 };
00109
00110 template <class HeaderType, class D>
00111 time_converter<HeaderType>
00112 time_reference(const pcapxx::frame_descriptor<D>& f,
00113 tool::endian::endianness e);
00114
00115 template <class HeaderType>
00116 void
00117 adjust(pcapxx::pkthdr& pcap,
00118 HeaderType* h,
00119 bool swap,
00120 const typename time_converter<HeaderType>::time_values& tv);
00121
00122 }
00123
00124 template <class InputIterator1,
00125 class InputIterator2,
00126 class HeaderType,
00127 class Bottom = tool::bottom>
00128 struct time_adjuster: WP_INHERIT(public tool::iterable,
00129 time_adjuster<InputIterator1,
00130 InputIterator2,
00131 HeaderType,
00132 Bottom>)
00133 {
00134 template <class D>
00135 time_adjuster(const InputIterator1& first1,
00136 const InputIterator1& last1,
00137 const InputIterator2& first2,
00138 const InputIterator2& last2,
00139 const pcapxx::frame_descriptor<D>& time_reference,
00140 tool::endian::endianness phy_end);
00141
00142 private:
00143 time_converter<HeaderType> convert_;
00144 tool::endian::endianness phy_end_;
00145
00146 InputIterator1 first1_;
00147 InputIterator1 last1_;
00148 InputIterator2 first2_;
00149 InputIterator2 last2_;
00150
00151 friend class internals::time_adjuster_iterator<InputIterator1,
00152 InputIterator2,
00153 HeaderType,
00154 Bottom, tool::bottom>;
00155 };
00156
00166 template <class U, class HT, template <class, class, class> class Int,
00167 class I1, class I2, class F>
00168 void
00169 provide_time_adjuster(const I1& first1, const I1& last1,
00170 const I2& first2, const I2& last2,
00171 tool::opt::list& options,
00172 F& func);
00173
00174 }
00175
00176 }
00177
00178 }
00179
00180 # include "time_adjuster.hxx"
00181
00182 #endif