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 wifi
00033 {
00034
00035 template <class PHT, class Bottom>
00036 time_converter<PHT, Bottom>::
00037 time_converter(const pcap_time_type& local_pcap_time,
00038 const phy_time_type& local_phy_time,
00039 const tool::microseconds& global_time):
00040 super_type (),
00041 local_reference_ (local_pcap_time, local_phy_time),
00042 global_reference_ (global_time)
00043 {
00044 }
00045
00046 template <class PHT, class Bottom>
00047 time_converter<PHT, Bottom>::time_values::time_values()
00048 {
00049 }
00050
00051 template <class PHT, class Bottom>
00052 time_converter<PHT, Bottom>::
00053 time_values::time_values(const pcap_time_type& pcap_time,
00054 const phy_time_type& phy_time):
00055 pcap_time (pcap_time),
00056 phy_time (phy_time)
00057 {
00058 }
00059
00060 template <class PHT, class Bottom>
00061 typename time_converter<PHT, Bottom>::time_values
00062 time_converter<PHT, Bottom>::
00063 operator () (const tool::microseconds& global_time) const
00064 {
00065 const tool::microseconds dt = global_time - global_reference_;
00066 const struct timeval dt_tv = dt.get_timeval();
00067 time_values r;
00068
00069 timeradd(&local_reference_.pcap_time, &dt_tv, &r.pcap_time);
00070 r.phy_time = local_reference_.phy_time + dt;
00071
00072 return r;
00073 }
00074
00075 }
00076
00077 #endif // ! WIFI_TIME_CONVERTER_HXX_