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_UNIQUELY_IDENTIFIABLE_HXX_
00023 # define WIFI_FRAME_FILTER_UNIQUELY_IDENTIFIABLE_HXX_
00024
00025 # include <wipal/wifi/frame/dissector/dissector.hh>
00026 # include <wipal/wifi/frame/unique_id/unique_id.hh>
00027 # include <wipal/wifi/frame/filter/non_noisy_prism.hh>
00028
00029 namespace wifi
00030 {
00031 namespace frame
00032 {
00033 namespace filter
00034 {
00035
00036 namespace internals
00037 {
00038
00039 template <class U, class I, class H, class B1, class B2>
00040 uniquely_identifiable_iterator<U, I, H, B1, B2>::
00041 uniquely_identifiable_iterator(const iterable_type& uif,
00042 bool end):
00043 super_type (),
00044 iterable_ (&uif),
00045 next_ (end ? uif.end_ : uif.begin_)
00046 {
00047 if (not end)
00048 increment();
00049 }
00050
00051 template <class U, class I, class H, class B1, class B2>
00052 bool
00053 uniquely_identifiable_iterator<U, I, H, B1, B2>::
00054 equal(const uniquely_identifiable_iterator& rhs) const
00055 {
00056 if (not rhs.value())
00057 return not this->value();
00058 return next_ == rhs.next_;
00059 }
00060
00061 template <class U, class I, class H, class B1, class B2>
00062 void
00063 uniquely_identifiable_iterator<U, I, H, B1, B2>::increment()
00064 {
00065 unique_id_factory<U> factory;
00066 boost::optional<U> id;
00067
00068 while (next_ != iterable_->end_ and not id)
00069 {
00070 mactime_.tick<H>(*next_, iterable_->phy_end_);
00071 id = factory.template build<H>(*next_, *iterable_->mapping_);
00072 ++next_;
00073 }
00074 if (id)
00075 this->value() = value_type (mactime_.microseconds(), id.get());
00076 else
00077 this->value() = boost::none_t ();
00078 }
00079
00080 }
00081
00082 template <class U, class I, class H, class B>
00083 uniquely_identifiable<U, I, H, B>::
00084 uniquely_identifiable(const I& begin,
00085 const I& end,
00086 addr_mapping& mapping,
00087 tool::endian::endianness phy_end):
00088 begin_ (begin),
00089 end_ (end),
00090 mapping_ (&mapping),
00091 phy_end_ (phy_end)
00092 {
00093 }
00094
00095 template <class U, class HT, class I, class F>
00096 void
00097 for_each_uniquely_identifiable(const I& first,
00098 const I& last,
00099 addr_mapping& mapping,
00100 F& func,
00101 bool filter_prism,
00102 tool::endian::endianness phy_end)
00103 {
00104 if (filter_prism)
00105 {
00106 typedef non_noisy_prism<I> filter_type;
00107 typedef typename filter_type::iterator iterator;
00108 typedef uniquely_identifiable<U, iterator, HT> unique_type;
00109
00110 filter_type f (first, last);
00111 unique_type u (f.begin(), f.end(), mapping, phy_end);
00112
00113 u.for_each(func);
00114 }
00115 else
00116 {
00117 typedef uniquely_identifiable<U, I, HT> unique_type;
00118
00119 unique_type u (first, last, mapping, phy_end);
00120
00121 u.for_each(func);
00122 }
00123 }
00124
00125
00126 template <class U, class HT, class I, class F>
00127 void
00128 for_each_uniquely_identifiable(const I& first,
00129 const I& last,
00130 addr_mapping& mapping,
00131 const F& func,
00132 bool filter_prism,
00133 tool::endian::endianness phy_end)
00134 {
00135 if (filter_prism)
00136 {
00137 typedef non_noisy_prism<I> filter_type;
00138 typedef typename filter_type::iterator iterator;
00139 typedef uniquely_identifiable<U, iterator, HT> unique_type;
00140
00141 filter_type f (first, last);
00142 unique_type u (f.begin(), f.end(), mapping, phy_end);
00143
00144 u.for_each(func);
00145 }
00146 else
00147 {
00148 typedef uniquely_identifiable<U, I, HT> unique_type;
00149
00150 unique_type u (first, last, mapping, phy_end);
00151
00152 u.for_each(func);
00153 }
00154 }
00155
00156 }
00157
00158 }
00159
00160 }
00161
00162 #endif // ! WIFI_FRAME_FILTER_UNIQUELY_IDENTIFIABLE_HXX_