include/wipal/wifi/frame/unique_id/helper_hooks.hxx

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_ID_HELPER_HOOKS_HXX_
00023 # define WIFI_FRAME_ID_HELPER_HOOKS_HXX_
00024 
00025 # include "helper_hooks.hh"
00026 
00027 # include <wipal/wifi/frame/frame.hh>
00028 
00029 namespace wifi
00030 {
00031 
00032   namespace frame
00033   {
00034 
00035     namespace internals
00036     {
00037 
00038       inline
00039       id_helper_hooks::id_helper_hooks():
00040         addrs_ (0),
00041         seq_ctl_ (0),
00042         timestamp_ (0)
00043       {
00044       }
00045 
00046 
00047       inline
00048       const addr*
00049       id_helper_hooks::addr_ptr(unsigned i) const
00050       {
00051         return addrs_ ? addrs_ + i : 0;
00052       }
00053 
00054       inline
00055       const uint16_t*
00056       id_helper_hooks::seq_ctl_ptr() const
00057       {
00058         return seq_ctl_;
00059       }
00060 
00061       inline
00062       const timestamp*
00063       id_helper_hooks::timestamp_ptr() const
00064       {
00065         return timestamp_;
00066       }
00067 
00068       inline
00069       void
00070       id_helper_hooks::beacon_hook(const mgt::header* h, size_t caplen)
00071       {
00072         unique_frame_hook(h, caplen);
00073       }
00074 
00075       inline
00076       void
00077       id_helper_hooks::probe_resp_hook(const mgt::header* h, size_t caplen)
00078       {
00079         if (not control_flag(3, h)) // Ignore retransmitted frames.
00080           unique_frame_hook(h, caplen);
00081       }
00082 
00083       inline
00084       void
00085       id_helper_hooks::unique_frame_hook(const mgt::header* h, size_t caplen)
00086       {
00087         if (caplen < sizeof (*h) + sizeof (*timestamp_))
00088           return;
00089 
00090         addrs_ = h->addrs;
00091         seq_ctl_ = &(h->seq_ctl);
00092         timestamp_ = reinterpret_cast<const timestamp*> (h->body);
00093       }
00094 
00095     } // End of namespace wifi::frame::internals.
00096 
00097   } // End of namespace wifi::frame.
00098 
00099 } // End of namespace wifi.
00100 
00101 #endif // ! WIFI_FRAME_ID_HELPER_HOOKS_HXX_
00102 

Generated on Wed Jan 16 16:15:14 2008 for wipal by  doxygen 1.5.4