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_NON_NOISY_PRISM_HXX_
00023 # define WIFI_FRAME_FILTER_NON_NOISY_PRISM_HXX_
00024
00025 # include "non_noisy_prism.hh"
00026
00027 # include <wipal/phy/prism_header.hh>
00028
00029 namespace wifi
00030 {
00031 namespace frame
00032 {
00033 namespace filter
00034 {
00035
00036 namespace internals
00037 {
00038
00039 template <class I, class B, class Bottom>
00040 non_noisy_prism_iterator<I, B, Bottom>::
00041 non_noisy_prism_iterator(const iterable_type& i, bool end):
00042 iterable_ (&i),
00043 current_ (end ? i.end_ : i.begin_)
00044 {
00045 skip_noisy();
00046 }
00047
00048 template <class I, class B, class Bottom>
00049 bool
00050 non_noisy_prism_iterator<I, B, Bottom>::
00051 equal(const non_noisy_prism_iterator& rhs) const
00052 {
00053 return current_ == rhs.current_;
00054 }
00055
00056
00057 template <class I, class B, class Bottom>
00058 void
00059 non_noisy_prism_iterator<I, B, Bottom>::increment()
00060 {
00061 ++current_;
00062 skip_noisy();
00063 }
00064
00065 template <class I, class B, class Bottom>
00066 const typename non_noisy_prism_iterator<I, B, Bottom>::value_type&
00067 non_noisy_prism_iterator<I, B, Bottom>::get() const
00068 {
00069 return current_.get();
00070 }
00071
00072 template <class I, class B, class Bottom>
00073 typename non_noisy_prism_iterator<I, B, Bottom>::value_type&
00074 non_noisy_prism_iterator<I, B, Bottom>::get()
00075 {
00076 return current_.get();
00077 }
00078
00079 template <class I, class B, class Bottom>
00080 const typename non_noisy_prism_iterator<I, B, Bottom>::value_type*
00081 non_noisy_prism_iterator<I, B, Bottom>::get_ptr() const
00082 {
00083 return current_.get_ptr();
00084 }
00085
00086 template <class I, class B, class Bottom>
00087 typename non_noisy_prism_iterator<I, B, Bottom>::value_type*
00088 non_noisy_prism_iterator<I, B, Bottom>::get_ptr()
00089 {
00090 return current_.get_ptr();
00091 }
00092
00093 template <class I, class B, class Bottom>
00094 bool
00095 non_noisy_prism_iterator<I, B, Bottom>::noisy(const void* frame,
00096 size_t caplen)
00097 {
00098
00099
00100
00101
00102
00103
00104
00105 if (caplen < sizeof (prism::header))
00106 return true;
00107
00108 const prism::header* const h =
00109 static_cast<const prism::header*> (frame);
00110
00111 return h->noise.get(false);
00112 }
00113
00114 template <class I, class B, class Bottom>
00115 void
00116 non_noisy_prism_iterator<I, B, Bottom>::skip_noisy()
00117 {
00118 while (current_ != iterable_->end_ and
00119 noisy(current_->bytes().get(),
00120 current_->pcap_header()->caplen))
00121 ++current_;
00122 }
00123
00124 }
00125
00126
00127 template <class InputIterator, class Bottom>
00128 non_noisy_prism<InputIterator, Bottom>::
00129 non_noisy_prism(const InputIterator& begin, const InputIterator& end):
00130 begin_ (begin),
00131 end_ (end)
00132 {
00133 }
00134
00135 template <class InputIterator, class Bottom>
00136 template <class Iterable>
00137 non_noisy_prism<InputIterator, Bottom>::
00138 non_noisy_prism(const Iterable& i):
00139 begin_ (i.begin()),
00140 end_ (i.end())
00141 {
00142 }
00143
00144 }
00145
00146 }
00147
00148 }
00149
00150 #endif // ! WIFI_FRAME_FILTER_NON_NOISY_PRISM_HXX_