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_MICROSECONDS_STAMPER_HXX_
00023 # define WIFI_FRAME_FILTER_MICROSECONDS_STAMPER_HXX_
00024
00025 # include "microseconds_stamper.hh"
00026
00027 namespace wifi
00028 {
00029 namespace frame
00030 {
00031 namespace filter
00032 {
00033
00034 namespace internals
00035 {
00036
00037 template <class I, class HT, class B1, class B2>
00038 microseconds_stamper_iterator<I, HT, B1, B2>::
00039 microseconds_stamper_iterator(const iterable_type& i, bool end):
00040 super_type (),
00041 iterable_ (&i),
00042 next_ (end ? i.last_ : i.first_)
00043 {
00044 if (not end)
00045 increment();
00046 }
00047
00048 template <class I, class HT, class B1, class B2>
00049 bool
00050 microseconds_stamper_iterator<I, HT, B1, B2>::
00051 equal(const microseconds_stamper_iterator& rhs) const
00052 {
00053 if (not rhs.value())
00054 return not this->value();
00055
00056 const bool r (next_ == rhs.next_);
00057
00058 assert(not r or
00059 tracker_.microseconds() == rhs.tracker_.microseconds());
00060
00061 return r;
00062 }
00063
00064 template <class I, class HT, class B1, class B2>
00065 void
00066 microseconds_stamper_iterator<I, HT, B1, B2>::increment()
00067 {
00068 using tool::endian::need_swap;
00069
00070 if (next_ == iterable_->last_)
00071 {
00072 this->value() = boost::none_t ();
00073 return;
00074 }
00075
00076 const pcapxx::pkthdr* p = next_->pcap_header().get();
00077
00078 tracker_.tick(reinterpret_cast<const HT*> (next_->bytes().get()),
00079 p->caplen, need_swap(iterable_->phy_end_, p->swapped));
00080
00081 this->value() = value_type (tracker_.microseconds(), *next_);
00082 ++next_;
00083 }
00084
00085 }
00086
00087 template <class I, class HT, class B>
00088 microseconds_stamper<I, HT, B>::
00089 microseconds_stamper(const I& first,
00090 const I& last,
00091 tool::endian::endianness phy_end):
00092 first_ (first),
00093 last_ (last),
00094 phy_end_ (phy_end)
00095 {
00096 }
00097
00098 }
00099
00100 }
00101
00102 }
00103
00104 #endif // ! WIFI_FRAME_FILTER_MICROSECONDS_STAMPER_HXX_