include/wipal/wifi/frame/filter/time_adjuster.hh

00001 /*
00002  * WiPal - A library and a set of tools to manipulate wireless traces.
00003  * Copyright (C) 2007  Universite Pierre et Marie Curie - Paris 6
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00018  * MA  02110-1301  USA
00019  *
00020  * Author: Thomas Claveirole <thomas.claveirole@lip6.fr>
00021  */
00022 #ifndef WIFI_FRAME_FILTER_TIME_ADJUSTER_HH_
00023 # define WIFI_FRAME_FILTER_TIME_ADJUSTER_HH_
00024 
00025 # include <boost/optional.hpp>
00026 
00027 # include <wipal/tool/microseconds_stamp.hh>
00028 # include <wipal/pcap/frame_descriptor.hh>
00029 # include <wipal/tool/valued_iterator.hh>
00030 # include <wipal/tool/iterable.hh>
00031 # include <wipal/wifi/time_converter.hh>
00032 # include <wipal/wifi/addr_mapping.hh>
00033 
00034 # include "time_adjuster_fwd.hh"
00035 
00036 namespace tool
00037 {
00038 
00039   template <class I1, class I2, class HT, class B1, class B2>
00040   struct types< wifi::frame::filter::internals::
00041                 time_adjuster_iterator<I1, I2, HT, B1, B2> >
00042   {
00043     typedef wifi::frame::filter::time_adjuster<I1, I2, HT, B1>  iterable_type;
00044     typedef tool::microseconds_stamp<pcapxx::frame_descriptor>  value_type;
00045   };
00046 
00047   template <class I1, class I2, class HT, class B>
00048   struct types< wifi::frame::filter::time_adjuster<I1, I2, HT, B> >
00049   {
00050     typedef wifi::frame::filter::internals::
00051       time_adjuster_iterator<I1, I2, HT, B, bottom>
00052       iterator;
00053   };
00054 
00055 } // End of namespace tool.
00056 
00057 namespace wifi
00058 {
00059   namespace frame
00060   {
00061     namespace filter
00062     {
00063 
00064       namespace internals
00065       {
00066 
00067         template <class InputIterator1,
00068                   class InputIterator2,
00069                   class HeaderType,
00070                   class B,
00071                   class Bottom = tool::bottom>
00072         struct time_adjuster_iterator:
00073           tt_inherit(public tool::valued_iterator,
00074                      time_adjuster_iterator<InputIterator1, InputIterator2,
00075                                             HeaderType, B, Bottom>)
00076         {
00078 
00079           typedef tt_get_exact(Bottom, time_adjuster_iterator<InputIterator1,
00080                                                               InputIterator2,
00081                                                               HeaderType,
00082                                                               B, Bottom>)
00083                                                         exact_type;
00084           typedef tool::valued_iterator<exact_type>     super_type;
00085           typedef tt_type(value_type, exact_type)       value_type;
00086           typedef tt_type(iterable_type, exact_type)    iterable_type;
00088 
00090           time_adjuster_iterator(const iterable_type& i, bool end);
00091 
00093 
00094           bool          equal(const time_adjuster_iterator& rhs) const;
00095           void          increment();
00097 
00098         private:
00099           typedef typename InputIterator2::value_type::coefs_type coefs_type;
00100 
00101           void          update_coefs();
00102 
00103           const iterable_type*          iterable_;
00104           boost::optional<coefs_type>   coefs_;
00105 
00106           InputIterator1                next1_;
00107           InputIterator2                next2_;
00108         };
00109 
00110         template <class HeaderType>
00111         time_converter<>
00112         time_reference(const pcapxx::pkthdr&    pcap_header,
00113                        const HeaderType*        bytes,
00114                        tool::endian::endianness phy_end);
00115 
00116         template <class HeaderType>
00117         void
00118         adjust(HeaderType* bytes, size_t caplen, bool swap,
00119                const time_converter<>::time_values& time);
00120 
00121       } // End of namespace internals.
00122 
00123       template <class InputIterator1,
00124                 class InputIterator2,
00125                 class HeaderType,
00126                 class Bottom = tool::bottom>
00127       struct time_adjuster: tt_inherit(public tool::iterable,
00128                                        time_adjuster<InputIterator1,
00129                                                      InputIterator2,
00130                                                      HeaderType,
00131                                                      Bottom>)
00132       {
00133         time_adjuster(const InputIterator1&             first1,
00134                       const InputIterator1&             last1,
00135                       const InputIterator2&             first2,
00136                       const InputIterator2&             last2,
00137                       const pcapxx::frame_descriptor&   time_reference,
00138                       tool::endian::endianness          phy_end);
00139 
00140       private:
00141         time_converter<>                convert_;
00142         tool::endian::endianness        phy_end_;
00143 
00144         InputIterator1                  first1_;
00145         InputIterator1                  last1_;
00146         InputIterator2                  first2_;
00147         InputIterator2                  last2_;
00148 
00149         friend class internals::time_adjuster_iterator<InputIterator1,
00150                                                        InputIterator2,
00151                                                        HeaderType,
00152                                                        Bottom, tool::bottom>;
00153       };
00154 
00165       template <class U, class HT, template <class, class, class> class Int,
00166                 class I1, class I2, class F, class BL>
00167       void
00168       provide_time_adjuster(const I1& first1, const I1& last1,
00169                             const I2& first2, const I2& last2,
00170                             addr_mapping&               mapping,
00171                             F&                          func,
00172                             bool                        filter_prism,
00173                             tool::endian::endianness    phy_end,
00174                             const BL&                   blist);
00175 
00176     } // End of namespace wifi::frame::filter.
00177 
00178   } // End of namespace wifi::frame.
00179 
00180 } // End of namespace wifi.
00181 
00182 # include "time_adjuster.hxx"
00183 
00184 #endif // ! WIFI_FRAME_FILTER_TIME_ADJUSTER_HH_

Generated on Tue Jan 15 19:32:31 2008 for wipal by  doxygen 1.5.4