include/trace-tools/wifi/frame/filter/uniquely_identifiable.hxx

00001 /*
00002  * trace-tools - 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_UNIQUELY_IDENTIFIABLE_HXX_
00023 # define WIFI_FRAME_FILTER_UNIQUELY_IDENTIFIABLE_HXX_
00024 
00025 # include <trace-tools/wifi/frame/dissector/dissector.hh>
00026 
00027 namespace wifi
00028 {
00029   namespace frame
00030   {
00031     namespace filter
00032     {
00033 
00034       namespace internals
00035       {
00036 
00037         template <class UniqueId>
00038         ui_iterator_value_type<UniqueId>::
00039         ui_iterator_value_type(const UniqueId&                  i,
00040                                const tool::microseconds&        m):
00041           UniqueId (i),
00042           microseconds_ (m)
00043         {
00044         }
00045 
00046         template <class UniqueId>
00047         const tool::microseconds&
00048         ui_iterator_value_type<UniqueId>::microseconds() const
00049         {
00050           return microseconds_;
00051         }
00052 
00053         template <class U, class I, class H, class B1, class B2>
00054         ui_iterator<U, I, H, B1, B2>::ui_iterator(iterable_type&        uif,
00055                                                   bool                  end):
00056           tool::iterator_base<exact_type> (uif, end)
00057         {
00058         }
00059 
00060         template <class U, class I, class H, class B1, class B2>
00061         void
00062         ui_iterator<U, I, H, B1, B2>::increment()
00063         {
00064           typedef typename exact_type::value_type  value_type;
00065 
00066           uniquely_identifiable<U, I, H, B1>&   iterable = *(this->i_);
00067           I&                                    next = iterable.next_;
00068           boost::optional<U>                    id;
00069 
00070           while (next != iterable.end_ and not id)
00071             {
00072               const H* h = reinterpret_cast<const H*> (next->bytes().get());
00073 
00074               iterable.mactime_.tick(h, next->pcap_header()->caplen);
00075               id = make_unique_id<U, H>(*next, *iterable.mapping_,
00076                                         iterable.
00077                                           prism_header_noise_means_error);
00078               ++next;
00079             }
00080           if (id)
00081             this->v_ =
00082               typename exact_type::value_type (id.get(), iterable.mactime_);
00083           else
00084             this->v_ = boost::none_t ();
00085         }
00086 
00087       } // End of namespace wifi::frame::filter::internals.
00088 
00089       template <class U, class I, class H, class B>
00090       uniquely_identifiable<U, I, H, B>::uniquely_identifiable(const I& begin,
00091                                                                const I& end,
00092                                                                addr_mapping&
00093                                                                  mapping):
00094         prism_header_noise_means_error (false),
00095         next_ (begin),
00096         end_ (end),
00097         mapping_ (&mapping),
00098         mactime_ ()
00099       {
00100       }
00101 
00102     } // End of namespace wifi::frame::filter.
00103 
00104   } // End of namespace wifi::frame.
00105 
00106 } // End of namespace wifi.
00107 
00108 #endif // ! WIFI_FRAME_FILTER_UNIQUELY_IDENTIFIABLE_HXX_

Generated on Wed Sep 12 16:02:47 2007 for trace-tools by  doxygen 1.5.3