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_MERGE_HXX_
00023 # define WIFI_FRAME_FILTER_MERGE_HXX_
00024
00025 extern "C"
00026 {
00027 # include <sys/time.h>
00028 }
00029
00030 # include "merge.hh"
00031
00032 # include <wipal/wifi/frame/filter/time_adjuster.hh>
00033
00034 namespace wifi
00035 {
00036 namespace frame
00037 {
00038 namespace filter
00039 {
00040
00041 namespace internals
00042 {
00043
00044 template <class HeaderType, class FD1>
00045 equal<HeaderType, FD1>::
00046 equal(const pcapxx::frame_descriptor<FD1>& lhs,
00047 const tool::endian::endianness& phy_end):
00048 lhs_ (lhs),
00049 phy_end_ (phy_end)
00050 {
00051 }
00052
00053 template <class HeaderType, class FD1>
00054 template <class FD2>
00055 bool
00056 equal<HeaderType, FD1>::
00057 operator == (const pcapxx::frame_descriptor<FD2>& rhs) const
00058 {
00059 return HeaderType::eq_time_and_80211(lhs_, rhs, phy_end_);
00060 }
00061
00062 template <class HT, class FD1>
00063 equal<HT, FD1>
00064 make_equal(const pcapxx::frame_descriptor<FD1>& lhs,
00065 const tool::endian::endianness& phy_end)
00066 {
00067 return equal<HT, FD1> (lhs, phy_end);
00068 }
00069
00070 template <class HT, class FD1, class FD2>
00071 bool
00072 operator == (const pcapxx::frame_descriptor<FD2>& lhs,
00073 const equal<HT, FD1>& rhs)
00074 {
00075 return rhs == lhs;
00076 }
00077
00078 template <class HT, template <class, class, class, class> class Merger,
00079 class I, class F>
00080 struct provide_merge
00081 {
00082 provide_merge(const I& first2,
00083 const I& last2,
00084 tool::opt::list& options,
00085 F& func):
00086 first2_ (first2),
00087 last2_ (last2),
00088 options_ (options),
00089 func_ (func)
00090 {
00091 }
00092
00093 template <class TimeAdjuster>
00094 void
00095 operator () (const TimeAdjuster& a)
00096 {
00097 typedef tool::endian::endianness endianness;
00098
00099 const endianness& end = options_["endianness"].get<endianness>();
00100
00101 if (options_["ignore_noisy_prism"].get<bool>())
00102 {
00103 typedef non_noisy_prism<I> nnp;
00104 typedef typename nnp::const_iterator n_iterator;
00105 typedef microseconds_stamper<n_iterator, HT> us_stamper;
00106 typedef typename us_stamper::const_iterator u_iterator;
00107 typedef typename TimeAdjuster::const_iterator a_iterator;
00108 typedef
00109 Merger<HT, a_iterator, u_iterator, tool::bottom> merger;
00110
00111 nnp n (first2_, last2_);
00112 us_stamper s (n.begin(), n.end(), end);
00113 merger m (a.begin(), a.end(),
00114 s.begin(), s.end(), end);
00115
00116 func_(m);
00117 }
00118 else
00119 {
00120 typedef microseconds_stamper<I, HT> us_stamper;
00121 typedef typename us_stamper::const_iterator u_iterator;
00122 typedef typename TimeAdjuster::const_iterator a_iterator;
00123 typedef
00124 Merger<HT, a_iterator, u_iterator, tool::bottom> merger;
00125
00126 us_stamper s (first2_, last2_, end);
00127 merger m (a.begin(), a.end(),
00128 s.begin(), s.end(), end);
00129
00130 func_(m);
00131 }
00132 }
00133
00134 private:
00135 const I& first2_;
00136 const I& last2_;
00137 tool::opt::list& options_;
00138 F& func_;
00139 };
00140
00141 }
00142
00143 template <class U, class HT,
00144 template <class, class, class> class Int,
00145 template <class, class, class, class> class Merger,
00146 class I1, class I2, class F>
00147 void
00148 provide_merge(const I1& first1, const I1& last1,
00149 const I2& first2, const I2& last2,
00150 tool::opt::list& options,
00151 F& func)
00152 {
00153 internals::provide_merge<HT, Merger, I2, F> func2 (first2, last2,
00154 options,
00155 func);
00156
00157 provide_time_adjuster<U, HT, Int>(first1, last1,
00158 first2, last2,
00159 options, func2);
00160 }
00161
00162 }
00163
00164 }
00165
00166 }
00167
00168 #endif // ! WIFI_FRAME_FILTER_MERGE_HXX_