00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PHY_EMPTY_HXX_
00023 # define PHY_EMPTY_HXX_
00024
00025 extern "C"
00026 {
00027 # include <sys/time.h>
00028 }
00029
00030 # include <wipal/phy/empty.hh>
00031
00032 namespace phy
00033 {
00034
00035
00036
00037
00038
00039 template <class B>
00040 typename empty_time<B>::impl_type
00041 empty_time<B>::get_impl() const
00042 {
00043 return impl_type ();
00044 }
00045
00046 template <class B>
00047 typename empty_time<B>::exact_type&
00048 empty_time<B>::increment(tool::microseconds)
00049 {
00050 return this->exact();
00051 }
00052
00053
00054
00055
00056
00057
00058 template <class B>
00059 size_t
00060 empty_header<B>::len_impl(size_t, bool) const
00061 {
00062 return 0;
00063 }
00064
00065 template <class B>
00066 typename empty_header<B>::time_type
00067 empty_header<B>::time_get_impl(bool) const
00068 {
00069 return time_type ();
00070 }
00071
00072 template <class B>
00073 void
00074 empty_header<B>::time_set_impl(const time_type&, bool)
00075 {
00076 }
00077
00078 template <class B>
00079 bool
00080 empty_header<B>::eq_time(const pcapxx::frame_descriptor& lhs,
00081 const pcapxx::frame_descriptor& rhs,
00082 tool::endian::endianness ,
00083 unsigned prec)
00084 {
00085 const pcapxx::pkthdr& lhs_pcap = *lhs.pcap_header();
00086 const pcapxx::pkthdr& rhs_pcap = *rhs.pcap_header();
00087
00088 const struct timeval* const lhs_tv = &lhs_pcap.ts;
00089 const struct timeval* const rhs_tv = &rhs_pcap.ts;
00090
00091 struct timeval dt;
00092
00093 if (timercmp(lhs_tv, rhs_tv, <))
00094 timersub(rhs_tv, lhs_tv, &dt);
00095 else
00096 timersub(lhs_tv, rhs_tv, &dt);
00097
00098 return 0 == dt.tv_sec and unsigned (dt.tv_usec) < prec;
00099 }
00100
00101 }
00102
00103 #endif // ! PHY_EMPTY_HXX_