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