00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_TIME_CONVERTER_HXX_
00023 # define WIFI_TIME_CONVERTER_HXX_
00024
00025 extern "C"
00026 {
00027 # include <sys/time.h>
00028 }
00029
00030 # include "time_converter.hh"
00031
00032 namespace wpl
00033 {
00034
00035 namespace wifi
00036 {
00037
00038 template <class PHT, class Bottom>
00039 time_converter<PHT, Bottom>::
00040 time_converter(const pcap_time_type& local_pcap_time,
00041 const phy_time_type& local_phy_time,
00042 const tool::microseconds& global_time):
00043 super_type (),
00044 local_reference_ (local_pcap_time, local_phy_time),
00045 global_reference_ (global_time)
00046 {
00047 }
00048
00049 template <class PHT, class Bottom>
00050 time_converter<PHT, Bottom>::time_values::time_values()
00051 {
00052 }
00053
00054 template <class PHT, class Bottom>
00055 time_converter<PHT, Bottom>::
00056 time_values::time_values(const pcap_time_type& pcap_time,
00057 const phy_time_type& phy_time):
00058 pcap_time (pcap_time),
00059 phy_time (phy_time)
00060 {
00061 }
00062
00063 template <class PHT, class Bottom>
00064 typename time_converter<PHT, Bottom>::time_values
00065 time_converter<PHT, Bottom>::
00066 operator () (const tool::microseconds& global_time) const
00067 {
00068 const tool::microseconds dt = global_time - global_reference_;
00069 const struct timeval dt_tv = dt.get_timeval();
00070 time_values r;
00071
00072 timeradd(&local_reference_.pcap_time, &dt_tv, &r.pcap_time);
00073 r.phy_time = local_reference_.phy_time + dt;
00074
00075 return r;
00076 }
00077
00078 }
00079
00080 }
00081
00082 #endif // ! WIFI_TIME_CONVERTER_HXX_