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 unsigned& precision,
00048 const tool::endian::endianness& phy_end,
00049 const bool& force_pcap):
00050 lhs_ (lhs),
00051 precision_ (precision),
00052 phy_end_ (phy_end),
00053 force_pcap_ (force_pcap)
00054 {
00055 }
00056
00057 template <class HeaderType, class FD1>
00058 template <class FD2>
00059 bool
00060 equal<HeaderType, FD1>::
00061 operator == (const pcapxx::frame_descriptor<FD2>& rhs) const
00062 {
00063 if (force_pcap_)
00064 return (tool::eq_timeval(lhs_.pcap_header()->ts,
00065 rhs.pcap_header()->ts,
00066 precision_)
00067 and
00068 HeaderType::eq_80211(lhs_, rhs, phy_end_));
00069 else
00070 return HeaderType::eq_time_and_80211(lhs_, rhs,
00071 precision_, phy_end_);
00072 }
00073
00074 template <class HT, class FD1>
00075 equal<HT, FD1>
00076 make_equal(const pcapxx::frame_descriptor<FD1>& lhs,
00077 const unsigned& precision,
00078 const tool::endian::endianness& phy_end,
00079 const bool& force_pcap)
00080 {
00081 return equal<HT, FD1> (lhs, precision, phy_end, force_pcap);
00082 }
00083
00084 template <class HT, class FD1, class FD2>
00085 bool
00086 operator == (const pcapxx::frame_descriptor<FD2>& lhs,
00087 const equal<HT, FD1>& rhs)
00088 {
00089 return rhs == lhs;
00090 }
00091
00092 template <class HT, template <class, class, class, class> class Merger,
00093 class I, class F>
00094 struct provide_merge
00095 {
00096 provide_merge(const I& first2,
00097 const I& last2,
00098 tool::opt::list& options,
00099 F& func):
00100 first2_ (first2),
00101 last2_ (last2),
00102 options_ (options),
00103 func_ (func)
00104 {
00105 }
00106
00107 template <class TimeAdjuster>
00108 void
00109 operator () (const TimeAdjuster& a)
00110 {
00111 typedef tool::endian::endianness endianness;
00112
00113 const unsigned& prec = options_["precision"].get<unsigned>();
00114 const endianness& end = options_["endianness"].get<endianness>();
00115 const bool pcapts = not options_["phy_tstamps"].get<bool>();
00116
00117 if (options_["ignore_noisy_prism"].get<bool>())
00118 {
00119 typedef non_noisy_prism<I> nnp;
00120 typedef typename nnp::const_iterator n_iterator;
00121 typedef microseconds_stamper<n_iterator, HT> us_stamper;
00122 typedef typename us_stamper::const_iterator u_iterator;
00123 typedef typename TimeAdjuster::const_iterator a_iterator;
00124 typedef
00125 Merger<HT, a_iterator, u_iterator, tool::bottom> merger;
00126
00127 nnp n (first2_, last2_);
00128 us_stamper s (n.begin(), n.end(), end, pcapts);
00129 merger m (a.begin(), a.end(),
00130 s.begin(), s.end(), prec, end, pcapts);
00131
00132 func_(m);
00133 }
00134 else
00135 {
00136 typedef microseconds_stamper<I, HT> us_stamper;
00137 typedef typename us_stamper::const_iterator u_iterator;
00138 typedef typename TimeAdjuster::const_iterator a_iterator;
00139 typedef
00140 Merger<HT, a_iterator, u_iterator, tool::bottom> merger;
00141
00142 us_stamper s (first2_, last2_, end, pcapts);
00143 merger m (a.begin(), a.end(),
00144 s.begin(), s.end(), prec, end, pcapts);
00145
00146 func_(m);
00147 }
00148 }
00149
00150 private:
00151 const I& first2_;
00152 const I& last2_;
00153 tool::opt::list& options_;
00154 F& func_;
00155 };
00156
00157 }
00158
00159 template <class U, class HT,
00160 template <class, class, class> class Int,
00161 template <class, class, class, class> class Merger,
00162 class I1, class I2, class F>
00163 void
00164 provide_merge(const I1& first1, const I1& last1,
00165 const I2& first2, const I2& last2,
00166 tool::opt::list& options,
00167 F& func)
00168 {
00169 internals::provide_merge<HT, Merger, I2, F> func2 (first2, last2,
00170 options,
00171 func);
00172
00173 provide_time_adjuster<U, HT, Int>(first1, last1,
00174 first2, last2,
00175 options, func2);
00176 }
00177
00178 }
00179
00180 }
00181
00182 }
00183
00184 #endif // ! WIFI_FRAME_FILTER_MERGE_HXX_