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 frame_count_ (0),
00047 uframe_count_ (0)
00048 {
00049 if (not end)
00050 increment();
00051 }
00052
00053 template <class U, class I, class H, class B1, class B2>
00054 bool
00055 uniquely_identifiable_iterator<U, I, H, B1, B2>::
00056 equal(const uniquely_identifiable_iterator& rhs) const
00057 {
00058 if (not rhs.value())
00059 return not this->value();
00060 return next_ == rhs.next_;
00061 }
00062
00063 template <class U, class I, class H, class B1, class B2>
00064 void
00065 uniquely_identifiable_iterator<U, I, H, B1, B2>::increment()
00066 {
00067 unique_id_factory<U> factory;
00068 boost::optional<U> id;
00069
00070 while (next_ != iterable_->end_ and not id)
00071 {
00072 mactime_.tick<H>(*next_, iterable_->phy_end_);
00073 id = factory.template build<H>(*next_, *iterable_->mapping_);
00074 ++next_;
00075 ++frame_count_;
00076 }
00077 if (id)
00078 {
00079 this->value() = value_type (mactime_.microseconds(), id.get());
00080 ++uframe_count_;
00081 }
00082 else
00083 this->value() = boost::none_t ();
00084 }
00085
00086 template <class U, class I, class H, class B1, class B2>
00087 unsigned
00088 uniquely_identifiable_iterator<U, I, H, B1, B2>::frame_count() const
00089 {
00090 return frame_count_;
00091 }
00092
00093 template <class U, class I, class H, class B1, class B2>
00094 unsigned
00095 uniquely_identifiable_iterator<U, I, H, B1, B2>::
00096 unique_frame_count() const
00097 {
00098 return uframe_count_;
00099 }
00100
00101 }
00102
00103 template <class U, class I, class H, class B>
00104 uniquely_identifiable<U, I, H, B>::
00105 uniquely_identifiable(const I& begin,
00106 const I& end,
00107 addr_mapping& mapping,
00108 tool::endian::endianness phy_end):
00109 begin_ (begin),
00110 end_ (end),
00111 mapping_ (&mapping),
00112 phy_end_ (phy_end)
00113 {
00114 }
00115
00116 template <class U, class HT, class I, class F>
00117 void
00118 for_each_uniquely_identifiable(const I& first,
00119 const I& last,
00120 addr_mapping& mapping,
00121 F& func,
00122 bool filter_prism,
00123 tool::endian::endianness phy_end)
00124 {
00125 if (filter_prism)
00126 {
00127 typedef non_noisy_prism<I> filter_type;
00128 typedef typename filter_type::iterator iterator;
00129 typedef uniquely_identifiable<U, iterator, HT> unique_type;
00130
00131 filter_type f (first, last);
00132 unique_type u (f.begin(), f.end(), mapping, phy_end);
00133
00134 u.for_each(func);
00135 }
00136 else
00137 {
00138 typedef uniquely_identifiable<U, I, HT> unique_type;
00139
00140 unique_type u (first, last, mapping, phy_end);
00141
00142 u.for_each(func);
00143 }
00144 }
00145
00146
00147 template <class U, class HT, class I, class F>
00148 void
00149 for_each_uniquely_identifiable(const I& first,
00150 const I& last,
00151 addr_mapping& mapping,
00152 const F& func,
00153 bool filter_prism,
00154 tool::endian::endianness phy_end)
00155 {
00156 if (filter_prism)
00157 {
00158 typedef non_noisy_prism<I> filter_type;
00159 typedef typename filter_type::iterator iterator;
00160 typedef uniquely_identifiable<U, iterator, HT> unique_type;
00161
00162 filter_type f (first, last);
00163 unique_type u (f.begin(), f.end(), mapping, phy_end);
00164
00165 u.for_each(func);
00166 }
00167 else
00168 {
00169 typedef uniquely_identifiable<U, I, HT> unique_type;
00170
00171 unique_type u (first, last, mapping, phy_end);
00172
00173 u.for_each(func);
00174 }
00175 }
00176
00177 }
00178
00179 }
00180
00181 }
00182
00183 #endif // ! WIFI_FRAME_FILTER_UNIQUELY_IDENTIFIABLE_HXX_