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>
00045 equal<HeaderType>::equal(const pcapxx::frame_descriptor& lhs,
00046 const tool::endian::endianness& phy_end):
00047 lhs_ (lhs),
00048 phy_end_ (phy_end)
00049 {
00050 }
00051
00052 template <class HeaderType>
00053 bool
00054 equal<HeaderType>::
00055 operator == (const pcapxx::frame_descriptor& rhs) const
00056 {
00057 return HeaderType::eq_time_and_80211(lhs_, rhs, phy_end_);
00058 }
00059
00060 template <class HT>
00061 bool
00062 operator == (const pcapxx::frame_descriptor& lhs, const equal<HT>& rhs)
00063 {
00064 return rhs == lhs;
00065 }
00066
00067 template <class HT, template <class, class, class, class> class Merger,
00068 class I, class F>
00069 struct provide_merge
00070 {
00071 provide_merge(const I& first2,
00072 const I& last2,
00073 F& func,
00074 bool filter_prism,
00075 tool::endian::endianness phy_end):
00076 first2_ (first2),
00077 last2_ (last2),
00078 func_ (func),
00079 filter_prism_ (filter_prism),
00080 phy_end_ (phy_end)
00081 {
00082 }
00083
00084 template <class TimeAdjuster>
00085 void
00086 operator () (const TimeAdjuster& a)
00087 {
00088 if (filter_prism_)
00089 {
00090 typedef non_noisy_prism<I> nnp;
00091 typedef typename nnp::const_iterator n_iterator;
00092 typedef microseconds_stamper<n_iterator, HT> us_stamper;
00093 typedef typename us_stamper::const_iterator u_iterator;
00094 typedef typename TimeAdjuster::const_iterator a_iterator;
00095 typedef
00096 Merger<HT, a_iterator, u_iterator, tool::bottom> merger;
00097
00098 nnp n (first2_, last2_);
00099 us_stamper s (n.begin(), n.end(), phy_end_);
00100 merger m (a.begin(), a.end(),
00101 s.begin(), s.end(), phy_end_);
00102
00103 func_(m);
00104 }
00105 else
00106 {
00107 typedef microseconds_stamper<I, HT> us_stamper;
00108 typedef typename us_stamper::const_iterator u_iterator;
00109 typedef typename TimeAdjuster::const_iterator a_iterator;
00110 typedef
00111 Merger<HT, a_iterator, u_iterator, tool::bottom> merger;
00112
00113 us_stamper s (first2_, last2_, phy_end_);
00114 merger m (a.begin(), a.end(),
00115 s.begin(), s.end(), phy_end_);
00116
00117 func_(m);
00118 }
00119 }
00120
00121 private:
00122 const I& first2_;
00123 const I& last2_;
00124 F& func_;
00125 bool filter_prism_;
00126 tool::endian::endianness phy_end_;
00127 };
00128
00129 }
00130
00131 template <class U, class HT,
00132 template <class, class, class> class Int,
00133 template <class, class, class, class> class Merger,
00134 class I1, class I2, class F, class BL>
00135 void
00136 provide_merge(const I1& first1, const I1& last1,
00137 const I2& first2, const I2& last2,
00138 addr_mapping& mapping,
00139 F& func,
00140 bool filter_prism,
00141 tool::endian::endianness phy_end,
00142 const BL& blist)
00143 {
00144 internals::provide_merge<HT, Merger, I1, F> func2 (first2, last2,
00145 func,
00146 filter_prism,
00147 phy_end);
00148
00149 provide_time_adjuster<U, HT, Int>(first1, last1,
00150 first2, last2,
00151 mapping, func2,
00152 filter_prism, phy_end, blist);
00153 }
00154
00155 }
00156
00157 }
00158
00159 }
00160
00161 #endif // ! WIFI_FRAME_FILTER_MERGE_HXX_