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