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_TIME_CONVERTER_HH_ 00023 # define WIFI_TIME_CONVERTER_HH_ 00024 00025 extern "C" 00026 { 00027 # include <inttypes.h> 00028 } 00029 00030 # include <wipal/tool/static_base.hh> 00031 # include <wipal/tool/microseconds.hh> 00032 00033 namespace wifi 00034 { 00035 00051 template <class Bottom = tool::bottom> 00052 struct time_converter: wp_inherit(public tool::static_base, 00053 time_converter<Bottom>) 00054 { 00056 00057 typedef wp_get_exact(Bottom, time_converter<Bottom>) exact_type; 00058 typedef tool::static_base<exact_type> super_type; 00060 00062 typedef struct timeval pcaptime_type; 00063 00065 typedef uint32_t hosttime_type; 00066 00068 typedef uint32_t mactime_type; 00069 00070 00072 time_converter(const pcaptime_type& local_pcaptime, 00073 const hosttime_type& local_hosttime, 00074 const mactime_type& local_mactime, 00075 const tool::microseconds& global_time); 00076 00078 struct time_values 00079 { 00081 time_values(); 00082 00084 time_values(const pcaptime_type& pcaptime, 00085 const hosttime_type& hosttime, 00086 const mactime_type& mactime); 00087 00089 pcaptime_type pcaptime; 00090 00092 hosttime_type hosttime; 00093 00095 mactime_type mactime; 00096 }; 00097 00099 time_values operator () (const tool::microseconds& global_time) const; 00100 00101 private: 00102 time_values local_reference_; 00103 tool::microseconds global_reference_; 00104 }; 00105 00106 } // End of namespace wifi. 00107 00108 # include "time_converter.hxx" 00109 00110 #endif // ! WIFI_TIME_CONVERTER_HH_